basic bottom navbar setup
This commit is contained in:
parent
8ae7995a96
commit
a627a8b279
13 changed files with 226 additions and 6 deletions
3
DBTApp/.idea/deploymentTargetSelector.xml
generated
3
DBTApp/.idea/deploymentTargetSelector.xml
generated
|
|
@ -5,6 +5,9 @@
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
|
<SelectionState runConfigName="BottomNavigationBar">
|
||||||
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
</SelectionState>
|
||||||
</selectionStates>
|
</selectionStates>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
1
DBTApp/.idea/gradle.xml
generated
1
DBTApp/.idea/gradle.xml
generated
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
|
|
||||||
61
DBTApp/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
61
DBTApp/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewParameterProviderOnFirstParameter" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
12
DBTApp/.idea/material_theme_project_new.xml
generated
Normal file
12
DBTApp/.idea/material_theme_project_new.xml
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MaterialThemeProjectNewConfig">
|
||||||
|
<option name="metadata">
|
||||||
|
<MTProjectMetadataState>
|
||||||
|
<option name="migrated" value="true" />
|
||||||
|
<option name="pristineConfig" value="false" />
|
||||||
|
<option name="userId" value="191b448e:196c8d670cb:-7ffe" />
|
||||||
|
</MTProjectMetadataState>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
1
DBTApp/.idea/misc.xml
generated
1
DBTApp/.idea/misc.xml
generated
|
|
@ -1,4 +1,3 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@ dependencies {
|
||||||
// Optional - Integration with activities
|
// Optional - Integration with activities
|
||||||
implementation(libs.androidx.activity.compose)
|
implementation(libs.androidx.activity.compose)
|
||||||
|
|
||||||
|
//Compose navigation
|
||||||
|
implementation(libs.androidx.navigation.compose)
|
||||||
|
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
implementation(libs.androidx.appcompat)
|
implementation(libs.androidx.appcompat)
|
||||||
implementation(libs.material)
|
implementation(libs.material)
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,7 @@ class MainActivity : ComponentActivity(){
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContent {
|
setContent {
|
||||||
NavigationBar()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
|
||||||
@Composable
|
|
||||||
fun NavigationBar() {
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package de.cdaut.dbtapp.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.NavigationBar
|
||||||
|
import androidx.compose.material3.NavigationBarItem
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import de.cdaut.dbtapp.navigation.BottomNavigationItem
|
||||||
|
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
private fun BottomNavigationBar() {
|
||||||
|
var navigationSelectedItem by remember {
|
||||||
|
mutableIntStateOf(
|
||||||
|
BottomNavigationItem().bottomNavigationItems()
|
||||||
|
.find { item -> item.label == "Home" }!!.idx
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val navController = rememberNavController()
|
||||||
|
|
||||||
|
Scaffold(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
bottomBar = {
|
||||||
|
NavigationBar {
|
||||||
|
BottomNavigationItem().bottomNavigationItems().sortedBy { item -> item.idx }
|
||||||
|
.forEachIndexed { index, item ->
|
||||||
|
NavigationBarItem(
|
||||||
|
selected = index == navigationSelectedItem,
|
||||||
|
label = {
|
||||||
|
if (index == navigationSelectedItem) {
|
||||||
|
Text(item.label)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon = {
|
||||||
|
Icon(
|
||||||
|
item.icon,
|
||||||
|
contentDescription = item.label
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
navigationSelectedItem = index
|
||||||
|
navController.navigate(item.route) {
|
||||||
|
popUpTo(navController.graph.findStartDestination().id)
|
||||||
|
launchSingleTop = true
|
||||||
|
restoreState = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) { paddingVals ->
|
||||||
|
Text("Test $paddingVals")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package de.cdaut.dbtapp.navigation
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.MenuBook
|
||||||
|
import androidx.compose.material.icons.filled.CalendarToday
|
||||||
|
import androidx.compose.material.icons.filled.Checklist
|
||||||
|
import androidx.compose.material.icons.filled.Home
|
||||||
|
import androidx.compose.material.icons.filled.MenuBook
|
||||||
|
import androidx.compose.material.icons.outlined.Star
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import de.cdaut.dbtapp.R
|
||||||
|
import de.cdaut.dbtapp.navigation.BottomNavigationItem
|
||||||
|
|
||||||
|
data class BottomNavigationItem(
|
||||||
|
val label: String = "",
|
||||||
|
val icon: ImageVector = Icons.Filled.Home,
|
||||||
|
val route: String = "",
|
||||||
|
val idx: Int = 0
|
||||||
|
) {
|
||||||
|
fun bottomNavigationItems(): List<BottomNavigationItem> {
|
||||||
|
return listOf(
|
||||||
|
BottomNavigationItem(
|
||||||
|
label = Resources.getSystem().getString(R.string.label_tracking),
|
||||||
|
icon = Icons.Filled.CalendarToday,
|
||||||
|
route = Screens.Tracking.route,
|
||||||
|
idx = 0
|
||||||
|
),
|
||||||
|
BottomNavigationItem(
|
||||||
|
label = Resources.getSystem().getString(R.string.label_skillslist),
|
||||||
|
icon = Icons.AutoMirrored.Filled.MenuBook,
|
||||||
|
route = Screens.Skillslist.route,
|
||||||
|
idx = 1
|
||||||
|
),
|
||||||
|
BottomNavigationItem(
|
||||||
|
label = Resources.getSystem().getString(R.string.label_home),
|
||||||
|
icon = Icons.Filled.Home,
|
||||||
|
route = Screens.Home.route,
|
||||||
|
idx = 2
|
||||||
|
),
|
||||||
|
BottomNavigationItem(
|
||||||
|
label = Resources.getSystem().getString(R.string.label_favourites),
|
||||||
|
icon = Icons.Outlined.Star,
|
||||||
|
route = Screens.Favourites.route,
|
||||||
|
idx = 3
|
||||||
|
),
|
||||||
|
BottomNavigationItem(
|
||||||
|
label = Resources.getSystem().getString(R.string.label_skillschains),
|
||||||
|
icon = Icons.Filled.Checklist,
|
||||||
|
route = Screens.Skillschains.route,
|
||||||
|
idx = 4
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package de.cdaut.dbtapp.navigation
|
||||||
|
|
||||||
|
sealed class Screens(val route: String) {
|
||||||
|
object Home : Screens("home_route")
|
||||||
|
object Tracking : Screens("tracking_route")
|
||||||
|
object Skillslist : Screens("skillslist_route")
|
||||||
|
object Favourites : Screens("favourites_route")
|
||||||
|
object Skillschains : Screens("skillschains_route")
|
||||||
|
}
|
||||||
9
DBTApp/app/src/main/res/values-de/strings.xml
Normal file
9
DBTApp/app/src/main/res/values-de/strings.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">DBTApp</string>
|
||||||
|
<string name="label_home">Home</string>
|
||||||
|
<string name="label_skillslist">Skills</string>
|
||||||
|
<string name="label_tracking">Tracking</string>
|
||||||
|
<string name="label_favourites">Favoriten</string>
|
||||||
|
<string name="label_skillschains">Skillsketten</string>
|
||||||
|
</resources>
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">DBTApp</string>
|
<string name="app_name">DBTApp</string>
|
||||||
|
<string name="label_home">Home</string>
|
||||||
|
<string name="label_skillslist">Skillslist</string>
|
||||||
|
<string name="label_tracking">Tracking</string>
|
||||||
|
<string name="label_favourites">Favourites</string>
|
||||||
|
<string name="label_skillschains">Skills Chains</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -8,6 +8,7 @@ junitVersion = "1.2.1"
|
||||||
espressoCore = "3.6.1"
|
espressoCore = "3.6.1"
|
||||||
appcompat = "1.7.0"
|
appcompat = "1.7.0"
|
||||||
material = "1.12.0"
|
material = "1.12.0"
|
||||||
|
navigationCompose = "2.7.0-rc01"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
|
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
|
||||||
|
|
@ -16,6 +17,7 @@ androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref =
|
||||||
androidx-material-icons-core = { module = "androidx.compose.material:material-icons-core" }
|
androidx-material-icons-core = { module = "androidx.compose.material:material-icons-core" }
|
||||||
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }
|
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }
|
||||||
androidx-material3 = { module = "androidx.compose.material3:material3" }
|
androidx-material3 = { module = "androidx.compose.material3:material3" }
|
||||||
|
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
|
||||||
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
|
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
|
||||||
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
|
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
|
||||||
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
|
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue