Impl base structure of bottom-navigation
This commit is contained in:
@@ -39,6 +39,7 @@ dependencies {
|
||||
// Compose
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.compose.runtime)
|
||||
implementation("androidx.compose.material:material-icons-extended")
|
||||
// Navigation Compose
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
implementation(libs.androidx.navigation.common)
|
||||
|
||||
@@ -25,6 +25,9 @@ sealed interface AppRoute {
|
||||
@Serializable
|
||||
data object Progress : AppRoute
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
data object Settings : AppRoute
|
||||
|
||||
@Serializable
|
||||
data class ScheduleDetails(
|
||||
val lessonId: Long
|
||||
|
||||
@@ -4,19 +4,19 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class TopLevelDestination {
|
||||
SCHEDULE,
|
||||
NEWS,
|
||||
PROGRESS
|
||||
SCHEDULE, NEWS, PROGRESS, SETTINGS
|
||||
}
|
||||
|
||||
fun TopLevelDestination.toRoute(): AppRoute = when (this) {
|
||||
TopLevelDestination.SCHEDULE -> AppRoute.Schedule
|
||||
TopLevelDestination.NEWS -> AppRoute.News
|
||||
TopLevelDestination.PROGRESS -> AppRoute.Progress
|
||||
TopLevelDestination.SETTINGS -> AppRoute.Settings
|
||||
}
|
||||
|
||||
val TOP_LEVEL_DESTINATIONS: List<TopLevelDestination> = listOf(
|
||||
TopLevelDestination.SCHEDULE,
|
||||
TopLevelDestination.NEWS,
|
||||
TopLevelDestination.PROGRESS
|
||||
TopLevelDestination.PROGRESS,
|
||||
TopLevelDestination.SETTINGS
|
||||
)
|
||||
|
||||
@@ -27,14 +27,27 @@ android {
|
||||
sourceCompatibility = jvm
|
||||
targetCompatibility = jvm
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = jvm.toString()
|
||||
}
|
||||
kotlinOptions { jvmTarget = jvm.toString() }
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
compose = true
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtension.get()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.appcompat)
|
||||
|
||||
|
||||
// Compose UI
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.compose.runtime)
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.foundation)
|
||||
implementation(libs.compose.material3)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package ru.fincode.core.ui.components
|
||||
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
|
||||
data class BottomBarItem(
|
||||
val key: String,
|
||||
val label: String,
|
||||
val icon: Painter,
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun TsudeskBottomBar(
|
||||
items: List<BottomBarItem>,
|
||||
selectedKey: String,
|
||||
onItemClick: (BottomBarItem) -> Unit,
|
||||
) {
|
||||
NavigationBar {
|
||||
items.forEach { item ->
|
||||
NavigationBarItem(
|
||||
selected = item.key == selectedKey,
|
||||
onClick = { onItemClick(item) },
|
||||
icon = {
|
||||
Icon(
|
||||
painter = item.icon,
|
||||
contentDescription = item.label
|
||||
)
|
||||
},
|
||||
label = {
|
||||
Text(text = item.label)
|
||||
},
|
||||
alwaysShowLabel = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user