Introduce Voyager lib and configure basic Navigation.
- Voyager is a navigation library that allows us to navigate between Composable screens. - I created basic LicenseScreen and HomeScreen.
This commit is contained in:
parent
888d29e436
commit
ce79a8fc4d
7 changed files with 67 additions and 42 deletions
|
@ -36,12 +36,13 @@ kotlin {
|
|||
implementation(libs.androidx.activity.compose)
|
||||
}
|
||||
commonMain.dependencies {
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.components.uiToolingPreview)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.ui)
|
||||
implementation(libs.voyager.navigator)
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
|
||||
}
|
||||
desktopMain.dependencies {
|
||||
|
|
|
@ -1,24 +1,17 @@
|
|||
package net.agorise.kee
|
||||
|
||||
import App
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import cafe.adriel.voyager.navigator.Navigator
|
||||
import net.agorise.kee.ui.screen.license.LicenseScreen
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
App()
|
||||
Navigator(LicenseScreen())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun AppAndroidPreview() {
|
||||
App()
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package net.agorise.kee.ui.screen.home
|
||||
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
|
||||
class HomeScreen : Screen {
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
Text("Welcome to Home Screen")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package net.agorise.kee.ui.screen.license
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import net.agorise.kee.ui.screen.home.HomeScreen
|
||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
|
||||
class LicenseScreen : Screen {
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
HomeScreenContent()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HomeScreenContent() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
Column {
|
||||
Text("Welcome to License Screen")
|
||||
Button(onClick = { navigator.replace(HomeScreen()) }) {
|
||||
Text("Accept")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun HomeScreenContentPreview() {
|
||||
HomeScreenContent()
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package net.agorise.kee
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.unit.DpSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.WindowPosition
|
||||
import androidx.compose.ui.window.application
|
||||
import androidx.compose.ui.window.rememberWindowState
|
||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
import cafe.adriel.voyager.navigator.Navigator
|
||||
import net.agorise.kee.ui.screen.license.LicenseScreen
|
||||
|
||||
fun main() = application {
|
||||
val state = rememberWindowState(
|
||||
|
@ -15,12 +15,6 @@ fun main() = application {
|
|||
position = WindowPosition(300.dp, 300.dp)
|
||||
)
|
||||
Window(title = "Kee", onCloseRequest = ::exitApplication, state = state) {
|
||||
App()
|
||||
Navigator(LicenseScreen())
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun AppAndroidPreview() {
|
||||
App()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import androidx.compose.ui.window.ComposeUIViewController
|
||||
import net.agorise.kee.App
|
||||
import cafe.adriel.voyager.navigator.Navigator
|
||||
import net.agorise.kee.ui.screen.license.LicenseScreen
|
||||
|
||||
fun MainViewController() = ComposeUIViewController { App() }
|
||||
fun MainViewController() = ComposeUIViewController { Navigator(LicenseScreen()) }
|
||||
|
|
|
@ -4,30 +4,16 @@ android-compileSdk = "34"
|
|||
android-minSdk = "24"
|
||||
android-targetSdk = "34"
|
||||
androidx-activityCompose = "1.8.2"
|
||||
androidx-appcompat = "1.6.1"
|
||||
androidx-constraintlayout = "2.1.4"
|
||||
androidx-core-ktx = "1.12.0"
|
||||
androidx-espresso-core = "3.5.1"
|
||||
androidx-material = "1.11.0"
|
||||
androidx-test-junit = "1.1.5"
|
||||
compose = "1.6.2"
|
||||
compose-plugin = "1.6.0"
|
||||
junit = "4.13.2"
|
||||
kotlin = "1.9.22"
|
||||
voyager = "1.0.0"
|
||||
|
||||
[libraries]
|
||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
||||
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" }
|
||||
androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-junit" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-espresso-core" }
|
||||
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
|
||||
androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" }
|
||||
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" }
|
||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
|
||||
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
|
||||
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
|
||||
voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
|
||||
|
||||
[plugins]
|
||||
androidApplication = { id = "com.android.application", version.ref = "agp" }
|
||||
|
|
Loading…
Reference in a new issue