diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..f795f5a
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,6 @@
+[*.{kt,kts}]
+ktlint_function_naming_ignore_when_annotated_with = Composable
+ktlint_standard_multiline-expression-wrapping = disabled
+ktlint_standard_string-template-indent = disabled
+ktlint_standard_annotation = disabled = disabled
+ktlint_code_style = intellij_idea
\ No newline at end of file
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index be9f7cc..cc334c6 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -11,20 +11,24 @@ jobs:
publish:
name: Publish release build
runs-on: ubuntu-latest
+ timeout-minutes: 15
steps:
- name: Check out code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure JDK 17
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v4
+
- name: Decrypt secrets
run: scripts/decrypt-secrets.sh "${{ secrets.SECRETS_PASSPHRASE }}"
diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml
index f9047a4..7c8b197 100644
--- a/.github/workflows/publish-snapshot.yml
+++ b/.github/workflows/publish-snapshot.yml
@@ -11,17 +11,20 @@ jobs:
timeout-minutes: 10
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure JDK 17
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v4
+
- name: Decrypt secrets
run: scripts/decrypt-secrets.sh "${{ secrets.SECRETS_PASSPHRASE }}"
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index cc2d2f0..666538d 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -14,32 +14,26 @@ jobs:
timeout-minutes: 10
steps:
- - uses: actions/checkout@v2
-
- - uses: gradle/wrapper-validation-action@v1
+ - uses: actions/checkout@v4
- name: Configure JDK 17
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- - name: Set Up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: 2.7
- bundler-cache: true
-
- - name: Danger Checks
- run: |
- ./gradlew dependencyUpdates -DoutputDir=build/danger
- bundle exec danger
- env:
- DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v4
- name: Run tests
run: ./gradlew testDebugUnitTest
+ - name: Publish Test Report
+ uses: mikepenz/action-junit-report@v5
+ if: success() || failure()
+ with:
+ report_paths: '**/build/test-results/**/TEST-*.xml'
+
- name: Run static analysis
run: ./gradlew ktlintCheck detekt
diff --git a/.gitignore b/.gitignore
index 454a446..03480f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,8 @@ signing.gpg
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/deploymentTargetDropDown.xml
+.idea/deploymentTargetSelector.xml
+.idea/inspectionProfiles/Project_Default.xml
gradle.xml
*.iml
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 0000000..11b79c2
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 2842237..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index fdf8d99..6d0ee1c 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/migrations.xml b/.idea/migrations.xml
new file mode 100644
index 0000000..f8051a6
--- /dev/null
+++ b/.idea/migrations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..16660f1
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e20f6c9..6f9e3f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,18 @@
### Changes
+# 1.0.0
+
+### Changes
+
+- Updated Kotlin to `2.0.0`
+- Switched to version catalogs for dependency management.
+- Updated to Jetpack Compose BoM `2024.11.00`
+- Accompanist navigation got replaced with AndroidX library.
+
+Migration:
+- Replace `rememberAnimatedNavController()` with `rememberNavController()`
+
# 0.3.4
### Changes
diff --git a/README.md b/README.md
index f06bca1..2903d87 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ repositories {
}
dependencies {
- implementation "com.adamkobus:compose-navigation:0.3.0"
+ implementation "com.adamkobus:compose-navigation:1.0.0"
}
```
@@ -34,7 +34,7 @@ repositories {
}
dependencies {
- implementation "com.adamkobus:compose-navigation:0.3.0-SNAPSHOT"
+ implementation "com.adamkobus:compose-navigation:1.0.0-SNAPSHOT"
}
```
diff --git a/build.gradle b/build.gradle
index b368e4c..8ec33f6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,60 +1,18 @@
-import com.adamkobus.compose.navigation.Lib
-
-apply plugin: "io.github.gradle-nexus.publish-plugin"
-apply plugin: "com.github.ben-manes.versions"
-
-buildscript {
- ext {
- // https://github.com/JLLeitschuh/ktlint-gradle/releases
- ktlintPluginVersion = "11.5.0"
-
- // https://github.com/detekt/detekt/releases
- detektPluginVersion = "1.21.0"
-
- // https://github.com/ben-manes/gradle-versions-plugin/releases
- versionsPluginVersion = "0.47.0"
-
- // https://github.com/gradle-nexus/publish-plugin/releases
- publishPluginVersion = "1.3.0"
-
- // https://developer.android.com/studio/releases/gradle-plugin
- androidBuildtoolsPluginVersion = '8.0.2'
- }
-
- repositories {
- google()
- mavenCentral()
- gradlePluginPortal()
- }
-
- dependencies {
- classpath "com.android.tools.build:gradle:$androidBuildtoolsPluginVersion"
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${Lib.KOTLIN_VERSION}"
- classpath "com.google.dagger:hilt-android-gradle-plugin:${Lib.HILT_VERSION}"
- classpath "org.jlleitschuh.gradle:ktlint-gradle:$ktlintPluginVersion"
- classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektPluginVersion"
- classpath "com.github.ben-manes:gradle-versions-plugin:$versionsPluginVersion"
- classpath "io.github.gradle-nexus:publish-plugin:$publishPluginVersion"
- classpath "org.jetbrains.dokka:dokka-gradle-plugin:${Lib.DOKKA_VERSION}"
- }
- rootProject.ext
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
-
-allprojects {
- tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
- kotlinOptions {
- freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
- }
- }
+plugins {
+ alias(libs.plugins.android.application) apply false
+ alias(libs.plugins.android.library) apply false
+ alias(libs.plugins.kotlin.android) apply false
+ alias(libs.plugins.kotlin.compose) apply false
+ alias(libs.plugins.hilt) apply false
+ alias(libs.plugins.dokka) apply false
+ alias(libs.plugins.detekt) apply false
+ alias(libs.plugins.ktlint) apply false
+ alias(libs.plugins.kotlin.ksp) apply false
+ alias(libs.plugins.nexus.publish)
}
apply from: "gradle/utils.gradle"
apply from: "gradle/version.gradle"
-apply from: "gradle/dependency-updates.gradle"
apply from: "gradle/android-setup.gradle"
apply from: "gradle/publishing-root.gradle"
apply from: "gradle/dokka-config.gradle"
diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/buildSrc/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
\ No newline at end of file
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
deleted file mode 100644
index f155244..0000000
--- a/buildSrc/build.gradle.kts
+++ /dev/null
@@ -1,7 +0,0 @@
-repositories {
- mavenCentral()
-}
-
-plugins {
- `kotlin-dsl`
-}
\ No newline at end of file
diff --git a/buildSrc/build/libs/buildSrc.jar b/buildSrc/build/libs/buildSrc.jar
new file mode 100644
index 0000000..26e681c
Binary files /dev/null and b/buildSrc/build/libs/buildSrc.jar differ
diff --git a/buildSrc/build/tmp/jar/MANIFEST.MF b/buildSrc/build/tmp/jar/MANIFEST.MF
new file mode 100644
index 0000000..59499bc
--- /dev/null
+++ b/buildSrc/build/tmp/jar/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/composenav/build.gradle b/composenav/build.gradle
index 33705c8..c45330e 100644
--- a/composenav/build.gradle
+++ b/composenav/build.gradle
@@ -1,36 +1,32 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'org.jetbrains.dokka'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.dokka)
+ alias(libs.plugins.kotlin.compose)
}
android {
- namespace 'com.adamkobus.compose.navigation'
+ namespace "com.adamkobus.compose.navigation"
}
dependencies {
- implementation Lib.AndroidX.Core
- implementation Lib.AndroidX.Appcompat
- implementation Lib.Kotlin.Coroutines
- implementation Lib.Google.Material
- implementation Lib.AdamKobus.LifecycleAwareViewModel
+ implementation libs.androidx.core
+ implementation libs.androidx.appcompat
+ implementation libs.androidx.composenavigation
+ implementation libs.kotlin.coroutines
// compose
- implementation Lib.Compose.Ui
- implementation Lib.Compose.Activity
- implementation Lib.Compose.Material
- implementation Lib.Compose.ToolingPreview
- debugImplementation Lib.Compose.UiTooling
+ implementation platform(libs.compose.bom)
+ implementation libs.compose.ui
+ implementation libs.compose.tooling.preview
+ debugImplementation libs.compose.tooling.ui
- implementation Lib.Accompanist.NavigationAnimation
+ implementation libs.ak.lifecycle.vm
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
- testImplementation Lib.Test.CoroutinesTest
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
+ testImplementation libs.test.coroutines
}
ext {
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavHost.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavHost.kt
index e98da23..3163764 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavHost.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavHost.kt
@@ -4,6 +4,7 @@ import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.ExperimentalAnimationApi
+import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
@@ -14,16 +15,16 @@ import androidx.compose.ui.Modifier
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
+import androidx.navigation.compose.NavHost
import com.adamkobus.compose.navigation.destination.NavGraph
import com.adamkobus.compose.navigation.model.NavGraphNamesExtractor
import com.adamkobus.compose.navigation.ui.NavComposable
-import com.google.accompanist.navigation.animation.AnimatedNavHost
/***
- * Configures nested [AnimatedNavHost]
+ * Configures nested [NavHost]
*
* @param startGraph This graph's [NavGraph.startDestination] will be the first navigation displayed to the user.
- * @see [AnimatedNavHost]
+ * @see [NavHost]
*/
@Suppress("LongParameterList")
@ExperimentalAnimationApi
@@ -40,21 +41,24 @@ fun ComposeNavHost(
{ fadeOut(animationSpec = tween(DEFAULT_ANIM_DURATION_MS)) },
popEnterTransition: (AnimatedContentTransitionScope.() -> EnterTransition) = enterTransition,
popExitTransition: (AnimatedContentTransitionScope.() -> ExitTransition) = exitTransition,
- builder: NavGraphBuilder.() -> Unit
+ sizeTransform: (AnimatedContentTransitionScope.() -> SizeTransform?)? = null,
+ builder: NavGraphBuilder.() -> Unit,
) {
val graphRoutes = remember { NavGraphNamesExtractor.extractGraphNames(controller, startGraph.serializedRoute, builder) }
NavComposable(navController = controller, navigationId = navigationId, observedGraphs = graphRoutes)
- AnimatedNavHost(
+ val route: String? = null
+ NavHost(
navController = controller,
startDestination = startGraph.serializedRoute,
modifier = modifier,
- route = null,
contentAlignment = contentAlignment,
+ route = route,
enterTransition = enterTransition,
exitTransition = exitTransition,
popEnterTransition = popEnterTransition,
popExitTransition = popExitTransition,
- builder = builder
+ sizeTransform = sizeTransform,
+ builder = builder,
)
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavigation.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavigation.kt
index 9b25a62..15fb12b 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavigation.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/ComposeNavigation.kt
@@ -36,7 +36,6 @@ import kotlinx.coroutines.Dispatchers
* - Current [NavLogger] via [ComposeNavigation.getLogger]
*/
object ComposeNavigation {
-
private const val DEFAULT_RESERVED_NAMES_ENABLED = true
private const val DEFAULT_NAVIGATION_PROCESSING_TIMEOUT_MS = 1000L
@@ -113,7 +112,9 @@ object ComposeNavigation {
*
* @see [NavLogLevel]
*/
- fun setLogLevel(@NavLogLevel level: Int): ComposeNavigation {
+ fun setLogLevel(
+ @NavLogLevel level: Int,
+ ): ComposeNavigation {
this.logLevel = level
navLogger.setLogLevel(level)
return this
@@ -227,12 +228,12 @@ object ComposeNavigation {
internal fun getNavGatekeeper(): NavGatekeeper = navGatekeeper
internal fun getIoDispatcher(): CoroutineDispatcher = ioDispatcher
+
internal fun getMainDispatcher(): CoroutineDispatcher = mainDispatcher
internal fun getKnownDestinationsSource() = knownDestinationsSource
- internal fun getNavDelegate(navigationId: NavigationId): NavDelegate =
- navigationProcessor.getDispatcher(navigationId = navigationId)
+ internal fun getNavDelegate(navigationId: NavigationId): NavDelegate = navigationProcessor.getDispatcher(navigationId = navigationId)
private fun createNavigationProcessor(): NavigationProcessor =
NavigationProcessor(
@@ -242,9 +243,8 @@ object ComposeNavigation {
timeoutProvider = provider { getNavigationProcessingTimeout() },
loggerProvider = provider { getLogger() },
navIntentResolver = navIntentResolvingManager,
- navGatekeeper = navGatekeeper
+ navGatekeeper = navGatekeeper,
)
- internal fun getNavProcessor(): NavigationProcessor =
- navigationProcessor
+ internal fun getNavProcessor(): NavigationProcessor = navigationProcessor
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/NavActionVerifier.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/NavActionVerifier.kt
index bedb3b0..316d6f0 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/NavActionVerifier.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/NavActionVerifier.kt
@@ -9,7 +9,6 @@ import com.adamkobus.compose.navigation.destination.NavState
* As an example, it could be used to prevent duplicate nav action if user clicks list item twice.
*/
interface NavActionVerifier {
-
/**
* @param navState Represents the state of the back stack at the moment of performing this check
* @param action Action that was produced via [NavigationConsumer.offer]
@@ -20,5 +19,8 @@ interface NavActionVerifier {
* @see [NavState]
* @see [NavAction]
*/
- fun isNavActionAllowed(navState: NavState, action: NavAction): VerifyResult
+ fun isNavActionAllowed(
+ navState: NavState,
+ action: NavAction,
+ ): VerifyResult
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/NavIntentResolver.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/NavIntentResolver.kt
index 7e0e983..b7e1cfe 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/NavIntentResolver.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/NavIntentResolver.kt
@@ -28,5 +28,8 @@ interface NavIntentResolver {
*
* - [ResolveResult.None] - should be returned when the implementation of [NavIntentResolver] doesn't recognize provided [intent]
*/
- suspend fun resolve(intent: NavIntent, navState: NavState): ResolveResult
+ suspend fun resolve(
+ intent: NavIntent,
+ navState: NavState,
+ ): ResolveResult
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/NavigationId.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/NavigationId.kt
index 73d9a81..070b24d 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/NavigationId.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/NavigationId.kt
@@ -12,7 +12,7 @@ import com.adamkobus.compose.navigation.ui.NavComposable
* @param id value of this field will be used to identify [ComposeNavHost] or [NavComposable]
*/
data class NavigationId(
- val id: String
+ val id: String,
) {
/**
* Returns string representation of [NavigationId]
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/TabBarIntentResolver.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/TabBarIntentResolver.kt
index 030e3fe..78bae4b 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/TabBarIntentResolver.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/TabBarIntentResolver.kt
@@ -44,12 +44,14 @@ open class TabBarIntentResolver(
private val tabsMapping: Map,
private val tabsRootGraph: NavGraph,
private val popToTabHostIntent: NavIntent? = null,
- private val tabStateSavingBehaviour: TabStateSavingBehaviour = SAVE_START_DESTINATION
+ private val tabStateSavingBehaviour: TabStateSavingBehaviour = SAVE_START_DESTINATION,
) : NavIntentResolver {
-
private val allGraphs = tabsMapping.values.toSet()
- override suspend fun resolve(intent: NavIntent, navState: NavState): ResolveResult {
+ override suspend fun resolve(
+ intent: NavIntent,
+ navState: NavState,
+ ): ResolveResult {
if (intent == popToTabHostIntent) {
return handlePopIntent(navState)
}
@@ -58,7 +60,10 @@ open class TabBarIntentResolver(
} ?: ResolveResult.None
}
- private fun resolveInternal(intent: NavIntent, navState: NavState): NavAction? {
+ private fun resolveInternal(
+ intent: NavIntent,
+ navState: NavState,
+ ): NavAction? {
val mappedGraph = tabsMapping[intent.name] ?: return null
intent.origin?.let {
if (!navState.isCurrent(it)) return null
@@ -77,48 +82,53 @@ open class TabBarIntentResolver(
// we're already at the destination that clicking this tab would take us to
if (currentDest == graphStartDestination) return null
- val navOptions = if (currentDest.graph !in allGraphs) {
- intent.popOptions?.copy(launchSingleTop = true)
- } else {
- navActionOptions {
- popUpTo(graphStartDestination)
- launchSingleTop = true
+ val navOptions =
+ if (currentDest.graph !in allGraphs) {
+ intent.popOptions?.copy(launchSingleTop = true)
+ } else {
+ navActionOptions {
+ popUpTo(graphStartDestination)
+ launchSingleTop = true
+ }
}
- }
// Current destination doesn't belong to tab host and intent didn't provide nav options
if (navOptions == null) return null
// tab item's starting destination is already in back stack and we can pop back to it
if (navState.isInBackStack(graphStartDestination)) {
- return currentDest goTo graphStartDestination withOptions navActionOptions {
- popUpTo(graphStartDestination)
- launchSingleTop = true
- }
+ return currentDest goTo graphStartDestination withOptions
+ navActionOptions {
+ popUpTo(graphStartDestination)
+ launchSingleTop = true
+ }
}
// we know we're in tab host based on the back stack, but the graph of different tab is being displayed
// in such situation we will pop to the root of the tab host and save state based on [tabStateSavingBehaviour]
- return currentDest goTo mappedGraph withOptions navActionOptions {
- popUpTo(tabsRootGraph) {
- saveState = tabStateSavingBehaviour == SAVE_ALL ||
- (
- tabStateSavingBehaviour == SAVE_START_DESTINATION &&
- currentDest == currentDest.graph.startDestination()
- )
+ return currentDest goTo mappedGraph withOptions
+ navActionOptions {
+ popUpTo(tabsRootGraph) {
+ saveState = tabStateSavingBehaviour == SAVE_ALL ||
+ (
+ tabStateSavingBehaviour == SAVE_START_DESTINATION &&
+ currentDest == currentDest.graph.startDestination()
+ )
+ }
+ restoreState = true
+ launchSingleTop = true
}
- restoreState = true
- launchSingleTop = true
- }
}
private fun handlePopIntent(navState: NavState): ResolveResult {
val controllerState = navState.find(tabsRootGraph) ?: return ResolveResult.None
val currentDest = controllerState.currentDestination ?: return ResolveResult.None
controllerState.backStack.findLast { it.destination.graph in allGraphs }?.let {
- val ret = currentDest.destination goTo it.destination withOptions navActionOptions {
- popUpTo(it.destination)
- launchSingleTop = true
- }
+ val ret =
+ currentDest.destination goTo it.destination withOptions
+ navActionOptions {
+ popUpTo(it.destination)
+ launchSingleTop = true
+ }
return ret.asResult()
} ?: return ResolveResult.None
}
@@ -144,5 +154,5 @@ enum class TabStateSavingBehaviour {
/**
* The state of the tabs will always be preserved when switching between them.
*/
- SAVE_ALL
+ SAVE_ALL,
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/VerifyResult.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/VerifyResult.kt
index 5a21ceb..edbbc56 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/VerifyResult.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/VerifyResult.kt
@@ -15,5 +15,5 @@ enum class VerifyResult {
/**
* [NavAction] has been discarded by a verifier and it will no longer be processed.
*/
- Discard
+ Discard,
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavAction.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavAction.kt
index 4ae53d4..d6d4385 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavAction.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavAction.kt
@@ -11,9 +11,8 @@ import com.adamkobus.compose.navigation.intent.ResolveResult
*/
abstract class NavAction(
val fromDestination: INavDestination,
- val toDestination: INavDestination
+ val toDestination: INavDestination,
) {
-
/**
* Compares other [NavAction] by [fromDestination] and [toDestination] fields
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavActionWrapper.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavActionWrapper.kt
index 38bca25..3cfd439 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavActionWrapper.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavActionWrapper.kt
@@ -10,9 +10,8 @@ import com.adamkobus.compose.navigation.NavigationConsumer
* @param action actual action that will be processed when offered to [NavigationConsumer]
*/
open class NavActionWrapper(
- val action: NavAction
+ val action: NavAction,
) {
-
/**
* Compares other [NavActionWrapper] by [action] field
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavOptions.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavOptions.kt
index e4213ba..78cea31 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavOptions.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavOptions.kt
@@ -19,7 +19,7 @@ data class NavOptions internal constructor(
val launchSingleTop: Boolean,
val restoreState: Boolean,
val popOptions: PopOptions?,
- val anim: AnimBuilder?
+ val anim: AnimBuilder?,
) {
/**
* [NavOptions] were introduced for internal use by Compose Navigation library.
@@ -60,9 +60,8 @@ data class NavOptionsBuilder internal constructor(
var launchSingleTop: Boolean = false,
var restoreState: Boolean = false,
private var popOptions: PopOptions? = null,
- private var animBuilder: AnimBuilder? = null
+ private var animBuilder: AnimBuilder? = null,
) {
-
/**
* Creates [PopOptions]
*
@@ -82,7 +81,10 @@ data class NavOptionsBuilder internal constructor(
*
* @see [androidx.navigation.NavOptionsBuilder.popUpTo]
*/
- fun popUpTo(destination: NavDestination, init: PopOptionsBuilder.() -> Unit) {
+ fun popUpTo(
+ destination: NavDestination,
+ init: PopOptionsBuilder.() -> Unit,
+ ) {
this.popOptions = PopOptionsBuilder(destination).apply(init).build()
}
@@ -116,7 +118,7 @@ data class NavOptionsBuilder internal constructor(
launchSingleTop = launchSingleTop,
restoreState = restoreState,
popOptions = popOptions,
- anim = animBuilder
+ anim = animBuilder,
)
}
@@ -136,7 +138,7 @@ data class NavOptionsBuilder internal constructor(
data class PopOptions internal constructor(
val destination: NavDestination,
val saveState: Boolean,
- val inclusive: Boolean
+ val inclusive: Boolean,
)
/**
@@ -160,13 +162,13 @@ data class PopOptions internal constructor(
data class PopOptionsBuilder internal constructor(
var destination: NavDestination,
var saveState: Boolean = false,
- var inclusive: Boolean = false
+ var inclusive: Boolean = false,
) {
internal fun build(): PopOptions =
PopOptions(
destination = destination,
saveState = saveState,
- inclusive = inclusive
+ inclusive = inclusive,
)
}
@@ -178,5 +180,4 @@ data class PopOptionsBuilder internal constructor(
* @see NavOptions
* @see NavOptionsBuilder
*/
-fun navActionOptions(init: NavOptionsBuilder.() -> Unit): NavOptions =
- NavOptionsBuilder().apply(init).build()
+fun navActionOptions(init: NavOptionsBuilder.() -> Unit): NavOptions = NavOptionsBuilder().apply(init).build()
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigateAction.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigateAction.kt
index c38d32e..f7f73a9 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigateAction.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigateAction.kt
@@ -15,9 +15,8 @@ class NavigateAction(
private val fromNavDestination: NavDestination,
private val toNavDestination: NavDestination,
private val params: List = emptyList(),
- private val options: NavOptions? = null
+ private val options: NavOptions? = null,
) : NavAction(fromDestination = fromNavDestination, toDestination = toNavDestination) {
-
/**
* This constructor allows you to copy other [NavigateAction]
*/
@@ -25,7 +24,7 @@ class NavigateAction(
navAction.fromNavDestination,
navAction.toNavDestination,
navAction.params,
- navAction.options
+ navAction.options,
)
/**
@@ -61,7 +60,7 @@ class NavigateAction(
fromNavDestination,
toNavDestination,
params = this.params + param,
- options = options
+ options = options,
)
/**
@@ -74,7 +73,7 @@ class NavigateAction(
fromNavDestination,
toNavDestination,
params,
- options = param
+ options = param,
)
/**
@@ -87,7 +86,7 @@ class NavigateAction(
fromNavDestination,
toNavDestination,
params,
- options = navActionOptions(init)
+ options = navActionOptions(init),
)
override fun navigate(controller: NavHostController): Boolean {
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigationResult.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigationResult.kt
index 3fff0b1..052f750 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigationResult.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/action/NavigationResult.kt
@@ -15,7 +15,6 @@ sealed class NavigationResult {
* Indicates that navigation action was executed.
*/
object Accepted : NavigationResult() {
-
/**
* Returns a formatted String representation of [Accepted]
*/
@@ -64,7 +63,6 @@ sealed class DiscardReason {
* @param verifier [NavActionVerifier] that discarded a [NavAction]
*/
class RejectedByVerifier(val verifier: NavActionVerifier) : DiscardReason() {
-
/**
* Compares other [RejectedByVerifier] based on [verifier] field
*/
@@ -89,7 +87,6 @@ sealed class DiscardReason {
* Indicates that [NavIntent] could not be mapped to actual action
*/
object NotMapped : DiscardReason() {
-
/**
* Returns a formatted String representation of [NotMapped]
*/
@@ -100,7 +97,6 @@ sealed class DiscardReason {
* Action could not be delivered because of invalid state
*/
object NotDelivered : DiscardReason() {
-
/**
* Returns a formatted String representation of [NotDelivered]
*/
@@ -114,7 +110,6 @@ sealed class DiscardReason {
* This might be removed in future once the solution is proven tobe stable.
*/
object Timeout : DiscardReason() {
-
/**
* Returns a formatted String representation of [Timeout]
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopAction.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopAction.kt
index 3cbb872..e54178f 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopAction.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopAction.kt
@@ -10,9 +10,8 @@ import com.adamkobus.compose.navigation.destination.PopDestination
*/
class PopAction(
fromDestination: NavDestination,
- toDestination: PopDestination = GlobalGraph.Back
+ toDestination: PopDestination = GlobalGraph.Back,
) : NavAction(fromDestination = fromDestination, toDestination = toDestination) {
-
/**
* Calls [NavHostController.popBackStack]
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopUpToAction.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopUpToAction.kt
index e570dbc..814bee1 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopUpToAction.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/action/PopUpToAction.kt
@@ -15,9 +15,8 @@ class PopUpToAction(
fromDestination: INavDestination,
toDestination: INavDestination,
private val inclusive: Boolean = false,
- private val saveState: Boolean = false
+ private val saveState: Boolean = false,
) : NavAction(fromDestination, toDestination) {
-
/**
* Calls [NavHostController.popBackStack]
*
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/DialogDestination.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/DialogDestination.kt
index 0b7b6cd..04089c0 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/DialogDestination.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/DialogDestination.kt
@@ -8,9 +8,8 @@ package com.adamkobus.compose.navigation.destination
*/
open class DialogDestination(
override val graph: NavGraph,
- override val route: NavRoute
+ override val route: NavRoute,
) : NavDestination {
-
/**
* @return formatted String representation of [DialogDestination]
*/
@@ -39,7 +38,7 @@ internal fun dialogDestination(
graph: NavGraph,
pathName: String,
reservedNameCheck: Boolean = true,
- init: NavRoute.Builder.() -> Unit = {}
+ init: NavRoute.Builder.() -> Unit = {},
): DialogDestination {
val route = navRoute(graphName = graph.name, path = pathName, reservedNamesCheck = reservedNameCheck, init)
return DialogDestination(graph, route)
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/GlobalGraph.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/GlobalGraph.kt
index 0fa8267..c2038c6 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/GlobalGraph.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/GlobalGraph.kt
@@ -8,7 +8,6 @@ import com.adamkobus.compose.navigation.action.NavigateAction
* It might be a bad idea though as it increases chance for your [NavActionVerifier]s to not work properly.
*/
object GlobalGraph : NavGraph(name = "__global__", reservedNameCheck = false) {
-
/**
* Start destination of [GlobalGraph]. Please keep in mind that navigating to GlobalGraph should be avoided
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/INavDestination.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/INavDestination.kt
index 9a09e1c..00aae40 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/INavDestination.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/INavDestination.kt
@@ -4,7 +4,6 @@ package com.adamkobus.compose.navigation.destination
* Base type for all of the destinations.
*/
interface INavDestination {
-
/**
* Graph that this destination belongs to
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavDestination.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavDestination.kt
index 8f592e5..16ae948 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavDestination.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavDestination.kt
@@ -11,19 +11,16 @@ import com.adamkobus.compose.navigation.intent.navIntent
* Represents a destination that can be added to back stack
*/
interface NavDestination : INavDestination {
-
/**
* Creates [PopDestination] with this [NavDestination] destination's [graph]
*/
- fun popDestination(): PopDestination =
- popDestination(this.graph)
+ fun popDestination(): PopDestination = popDestination(this.graph)
/**
* Creates [PopAction] that uses this [NavDestination] as a source destination
* and uses this destination's graph in target [PopDestination]
*/
- fun pop(): PopAction =
- PopAction(this, popDestination())
+ fun pop(): PopAction = PopAction(this, popDestination())
/**
* Creates [PopAction] that originates from this [NavDestination] and targets [other].
@@ -40,8 +37,11 @@ interface NavDestination : INavDestination {
* @param saveState if true then popped destinations' state will be saved and it will be possible to restore it later
* by navigating to any of them with [NavOptions.restoreState] set to true
*/
- fun popUpTo(destination: NavDestination, inclusive: Boolean = false, saveState: Boolean = false): PopUpToAction =
- PopUpToAction(this, destination, inclusive = inclusive, saveState = saveState)
+ fun popUpTo(
+ destination: NavDestination,
+ inclusive: Boolean = false,
+ saveState: Boolean = false,
+ ): PopUpToAction = PopUpToAction(this, destination, inclusive = inclusive, saveState = saveState)
/**
* Creates [NavigateAction] that originates from this [NavDestination] and targets [other].
@@ -53,6 +53,5 @@ interface NavDestination : INavDestination {
/**
* Creates new [NavIntent]. It will be initialized with provided name and this destination as [NavIntent.origin]
*/
- fun navIntent(name: String): NavIntent =
- navIntent(name, this)
+ fun navIntent(name: String): NavIntent = navIntent(name, this)
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavGraph.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavGraph.kt
index 05285ed..95855f2 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavGraph.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavGraph.kt
@@ -9,9 +9,8 @@ package com.adamkobus.compose.navigation.destination
*/
abstract class NavGraph internal constructor(
val name: String,
- private val reservedNameCheck: Boolean = true
+ private val reservedNameCheck: Boolean = true,
) : NavDestination {
-
/**
* @param name It is used to identify this graph. All destinations created in this graph will also be prefixed by the graph's name.
*/
@@ -35,14 +34,18 @@ abstract class NavGraph internal constructor(
/**
* Creates new type-safe builder for [ScreenDestination]. It will be initialized with this graph and provided [name]
*/
- fun screenDestination(name: String, init: NavRoute.Builder.() -> Unit = {}): ScreenDestination =
- screenDestination(this, pathName = name, reservedNameCheck = reservedNameCheck, init = init)
+ fun screenDestination(
+ name: String,
+ init: NavRoute.Builder.() -> Unit = {},
+ ): ScreenDestination = screenDestination(this, pathName = name, reservedNameCheck = reservedNameCheck, init = init)
/**
* Creates new type-safe builder for [DialogDestination]. It will be initialized with this graph and provided [name]
*/
- fun dialogDestination(pathName: String, init: NavRoute.Builder.() -> Unit = {}): DialogDestination =
- dialogDestination(this, pathName = pathName, reservedNameCheck = reservedNameCheck, init = init)
+ fun dialogDestination(
+ pathName: String,
+ init: NavRoute.Builder.() -> Unit = {},
+ ): DialogDestination = dialogDestination(this, pathName = pathName, reservedNameCheck = reservedNameCheck, init = init)
/**
* In case of [NavGraph], [graph] always points to itself
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoute.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoute.kt
index 106ab60..f09505a 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoute.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoute.kt
@@ -6,18 +6,18 @@ package com.adamkobus.compose.navigation.destination
* @param parts Initial parts
*/
data class NavRoute constructor(
- private val parts: List
+ private val parts: List,
) {
-
private val paramsCount: Int by lazy { parts.count { it is NavRoutePart.Param } }
/**
* Returns the names of all of the params present in this route.
*/
val paramNames: List
- get() = parts.mapNotNull { part ->
- part as? NavRoutePart.Param
- }.map { it.paramName }
+ get() =
+ parts.mapNotNull { part ->
+ part as? NavRoutePart.Param
+ }.map { it.paramName }
/**
* @return route definition that can be later used with TODO refer class from Jetpack navigation
@@ -39,8 +39,8 @@ data class NavRoute constructor(
* @throws [IllegalArgumentException] if number of provided params doesn't match the expected params count.
*/
fun buildPath(params: List): String {
- if (params.size != paramsCount) {
- throw IllegalArgumentException("Wrong number of params, expected $paramsCount but got ${params.size} | $params")
+ require(params.size == paramsCount) {
+ "Wrong number of params, expected $paramsCount but got ${params.size} | $params"
}
var currentParamIndex = 0
return parts.joinToString(separator = PART_SEPARATOR) {
@@ -55,10 +55,12 @@ data class NavRoute constructor(
/**
* Starts building a new route using builder that is populated with [NavRoutePart]s from the [NavRoute] on which [next] was invoked.
*/
- fun next(init: Builder.() -> Unit = {}): NavRoute =
- next(reservedNamesCheck = true, init)
+ fun next(init: Builder.() -> Unit = {}): NavRoute = next(reservedNamesCheck = true, init)
- internal fun next(reservedNamesCheck: Boolean = true, init: Builder.() -> Unit = {}): NavRoute {
+ internal fun next(
+ reservedNamesCheck: Boolean = true,
+ init: Builder.() -> Unit = {},
+ ): NavRoute {
val builder = Builder(parts, reservedNamesCheck = reservedNamesCheck)
builder.init()
return builder.build()
@@ -96,7 +98,7 @@ data class NavRoute constructor(
internal constructor(graphName: String, pathName: String, reservedNamesCheck: Boolean) : this(
emptyList(),
- reservedNamesCheck = reservedNamesCheck
+ reservedNamesCheck = reservedNamesCheck,
) {
graphName(graphName)
path(pathName)
@@ -125,8 +127,8 @@ data class NavRoute constructor(
}
private fun ensureNameNotEmpty(name: String) {
- if (name.isEmpty()) {
- throw IllegalArgumentException("Name must not be empty")
+ require(name.isNotEmpty()) {
+ "Name must not be empty"
}
}
@@ -155,13 +157,15 @@ data class NavRoute constructor(
*
* @param graphName Name of the graph the builder will be initialized with
*/
-fun navRoute(graphName: String, init: NavRoute.Builder.() -> Unit = {}): NavRoute =
- navRoute(graphName = graphName, reservedNamesCheck = true, init = init)
+fun navRoute(
+ graphName: String,
+ init: NavRoute.Builder.() -> Unit = {},
+): NavRoute = navRoute(graphName = graphName, reservedNamesCheck = true, init = init)
internal fun navRoute(
graphName: String,
reservedNamesCheck: Boolean = true,
- init: NavRoute.Builder.() -> Unit = {}
+ init: NavRoute.Builder.() -> Unit = {},
): NavRoute {
val builder = NavRoute.Builder(graphName = graphName, reservedNamesCheck = reservedNamesCheck)
builder.init()
@@ -174,14 +178,17 @@ internal fun navRoute(
* @param graphName Name of the graph the builder will be initialized with
* @param path Path to initialize the builder with
*/
-fun navRoute(graphName: String, path: String, init: NavRoute.Builder.() -> Unit = {}): NavRoute =
- navRoute(graphName = graphName, path = path, reservedNamesCheck = true, init = init)
+fun navRoute(
+ graphName: String,
+ path: String,
+ init: NavRoute.Builder.() -> Unit = {},
+): NavRoute = navRoute(graphName = graphName, path = path, reservedNamesCheck = true, init = init)
internal fun navRoute(
graphName: String,
path: String,
reservedNamesCheck: Boolean = true,
- init: NavRoute.Builder.() -> Unit = {}
+ init: NavRoute.Builder.() -> Unit = {},
): NavRoute {
val builder = NavRoute.Builder(graphName = graphName, pathName = path, reservedNamesCheck = reservedNamesCheck)
builder.init()
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoutePart.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoutePart.kt
index f103672..0362713 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoutePart.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavRoutePart.kt
@@ -6,14 +6,12 @@ import com.adamkobus.compose.navigation.ComposeNavigation
* Used to declare apart of [ScreenDestination]'s route..
*/
sealed class NavRoutePart {
-
/**
* Declares a path of the route that contains name of a [NavGraph]
*
* @param name Name of a [NavGraph]
*/
class GraphName internal constructor(val name: String, reservedNamesCheck: Boolean = true) : NavRoutePart() {
-
/**
* @param name Name of a [NavGraph]
*/
@@ -51,7 +49,6 @@ sealed class NavRoutePart {
* @param name will become part of the final route without any modification
*/
class Path internal constructor(val name: String, reservedNamesCheck: Boolean) : NavRoutePart() {
-
/**
* @param name will become part of the final route without any modification
*/
@@ -89,7 +86,6 @@ sealed class NavRoutePart {
* @param paramName name by which this param can be later obtained from [NavStackEntry]
*/
class Param internal constructor(val paramName: String, reservedNamesCheck: Boolean) : NavRoutePart() {
-
/**
* @param paramName name by which this param can be later obtained from [NavStackEntry]
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavStackEntry.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavStackEntry.kt
index c7601cc..fc0fe6c 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavStackEntry.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavStackEntry.kt
@@ -15,7 +15,7 @@ import com.adamkobus.compose.navigation.error.NavArgumentMissingError
*/
data class NavStackEntry(
val destination: NavDestination,
- val arguments: Map
+ val arguments: Map,
) {
/**
* Returns a String representation of [NavStackEntry]
@@ -47,7 +47,7 @@ data class NavStackEntry(
return stringValue.toInt()
} catch (e: NumberFormatException) {
throw NavArgumentFormatInvalidError(
- "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Int"
+ "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Int",
)
}
}
@@ -65,7 +65,7 @@ data class NavStackEntry(
return stringValue.toLong()
} catch (e: NumberFormatException) {
throw NavArgumentFormatInvalidError(
- "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Long"
+ "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Long",
)
}
}
@@ -83,7 +83,7 @@ data class NavStackEntry(
return stringValue.toFloat()
} catch (e: NumberFormatException) {
throw NavArgumentFormatInvalidError(
- "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Float"
+ "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Float",
)
}
}
@@ -101,7 +101,7 @@ data class NavStackEntry(
return stringValue.toDouble()
} catch (e: NumberFormatException) {
throw NavArgumentFormatInvalidError(
- "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Double"
+ "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Double",
)
}
}
@@ -118,7 +118,7 @@ data class NavStackEntry(
"true" -> true
"false" -> false
else -> throw NavArgumentFormatInvalidError(
- "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Boolean"
+ "Value '$stringValue' of argument '$key' in destination '${this.destination}' could not be parsed to Boolean",
)
}
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavState.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavState.kt
index eb6a49f..9df3d9f 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavState.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/NavState.kt
@@ -8,7 +8,7 @@ import com.adamkobus.compose.navigation.NavigationId
* @param controllersState Each [NavControllerState] represents the back stack state of tracked NavHost.
*/
data class NavState(
- val controllersState: List
+ val controllersState: List,
) {
/**
* Checks if provided destination is currently in back stack of any of the tracked controllers
@@ -51,7 +51,7 @@ data class NavState(
data class NavControllerState(
val navId: NavigationId,
val currentDestination: NavStackEntry?,
- val backStack: List
+ val backStack: List,
) {
/**
* Checks if provided destination is currently in back stack
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/PopDestination.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/PopDestination.kt
index 94a54b7..a08ddd0 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/PopDestination.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/PopDestination.kt
@@ -7,9 +7,8 @@ import com.adamkobus.compose.navigation.action.PopAction
*/
data class PopDestination(
override val graph: NavGraph,
- override val route: NavRoute = navRoute(graph.name, path = "__back__", reservedNamesCheck = false)
+ override val route: NavRoute = navRoute(graph.name, path = "__back__", reservedNamesCheck = false),
) : INavDestination {
-
/**
* @return formatted string representation of [PopDestination]
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/ScreenDestination.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/ScreenDestination.kt
index 0e3e7c4..961fb44 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/ScreenDestination.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/ScreenDestination.kt
@@ -8,9 +8,8 @@ package com.adamkobus.compose.navigation.destination
*/
open class ScreenDestination(
override val graph: NavGraph,
- override val route: NavRoute
+ override val route: NavRoute,
) : NavDestination {
-
/**
* Creates a new [ScreenDestination] with a route that is a continuation of this destination's [route]
*/
@@ -49,7 +48,7 @@ internal fun screenDestination(
graph: NavGraph,
pathName: String,
reservedNameCheck: Boolean = true,
- init: NavRoute.Builder.() -> Unit = {}
+ init: NavRoute.Builder.() -> Unit = {},
): ScreenDestination {
val route = navRoute(graphName = graph.name, path = pathName, reservedNamesCheck = reservedNameCheck, init)
return ScreenDestination(graph, route)
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownDestination.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownDestination.kt
index 13724bc..8fd9e98 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownDestination.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownDestination.kt
@@ -8,7 +8,7 @@ import com.adamkobus.compose.navigation.NavigationStateSource
* @param path Raw path string that was encountered by [NavigationStateSource]
*/
data class UnknownDestination internal constructor(
- val path: String
+ val path: String,
) : NavDestination {
/**
* Fixed value - [UnknownGraph]
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownGraph.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownGraph.kt
index 3e9e2c3..6715285 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownGraph.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/destination/UnknownGraph.kt
@@ -6,7 +6,6 @@ import com.adamkobus.compose.navigation.NavigationStateSource
* Any destination that is not recognized by [NavigationStateSource] is assigned to this graph.
*/
object UnknownGraph : NavGraph("__unknown__", reservedNameCheck = false) {
-
/**
* [UnknownGraph] has fixed startDestination with the same name as the name of the graph.
*/
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/ext/NavGraphBuilderExt.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/ext/NavGraphBuilderExt.kt
index 7f55b88..969e471 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/ext/NavGraphBuilderExt.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/ext/NavGraphBuilderExt.kt
@@ -12,7 +12,9 @@ import androidx.navigation.NamedNavArgument
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavDeepLink
import androidx.navigation.NavGraphBuilder
+import androidx.navigation.compose.composable
import androidx.navigation.compose.dialog
+import androidx.navigation.compose.navigation
import com.adamkobus.compose.navigation.ComposeNavigation
import com.adamkobus.compose.navigation.destination.DialogDestination
import com.adamkobus.compose.navigation.destination.NavGraph
@@ -20,8 +22,6 @@ import com.adamkobus.compose.navigation.destination.NavStackEntry
import com.adamkobus.compose.navigation.destination.ScreenDestination
import com.adamkobus.compose.navigation.model.toNavStackEntry
import com.adamkobus.compose.navigation.ui.LocalNavDestination
-import com.google.accompanist.navigation.animation.composable
-import com.google.accompanist.navigation.animation.navigation
/**
* @see [navigation]
@@ -34,7 +34,7 @@ fun NavGraphBuilder.composableNavigation(
exitTransition: (AnimatedContentTransitionScope.() -> ExitTransition?)? = null,
popEnterTransition: (AnimatedContentTransitionScope.() -> EnterTransition?)? = enterTransition,
popExitTransition: (AnimatedContentTransitionScope.() -> ExitTransition?)? = exitTransition,
- builder: NavGraphBuilder.() -> Unit
+ builder: NavGraphBuilder.() -> Unit,
) {
ComposeNavigation.getKnownDestinationsSource().addToKnownDestinations(graph)
@@ -45,7 +45,7 @@ fun NavGraphBuilder.composableNavigation(
exitTransition = exitTransition,
popEnterTransition = popEnterTransition,
popExitTransition = popExitTransition,
- builder = builder
+ builder = builder,
)
}
@@ -62,7 +62,7 @@ fun NavGraphBuilder.composableDestination(
exitTransition: (AnimatedContentTransitionScope.() -> ExitTransition?)? = null,
popEnterTransition: (AnimatedContentTransitionScope.() -> EnterTransition?)? = enterTransition,
popExitTransition: (AnimatedContentTransitionScope.() -> ExitTransition?)? = exitTransition,
- content: @Composable AnimatedVisibilityScope.(NavStackEntry) -> Unit
+ content: @Composable AnimatedVisibilityScope.(NavStackEntry) -> Unit,
) {
ComposeNavigation.getKnownDestinationsSource().addToKnownDestinations(destination)
@@ -78,7 +78,7 @@ fun NavGraphBuilder.composableDestination(
CompositionLocalProvider(LocalNavDestination provides destination) {
content(backStackEntry.toNavStackEntry())
}
- }
+ },
)
}
@@ -90,7 +90,7 @@ fun NavGraphBuilder.composableDialog(
arguments: List = emptyList(),
deepLinks: List = emptyList(),
dialogProperties: DialogProperties = DialogProperties(),
- content: @Composable (NavStackEntry) -> Unit
+ content: @Composable (NavStackEntry) -> Unit,
) {
ComposeNavigation.getKnownDestinationsSource().addToKnownDestinations(destination)
@@ -103,6 +103,6 @@ fun NavGraphBuilder.composableDialog(
CompositionLocalProvider(LocalNavDestination provides destination) {
content(backStackEntry.toNavStackEntry())
}
- }
+ },
)
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntent.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntent.kt
index ecb1ce5..91c180b 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntent.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntent.kt
@@ -26,7 +26,7 @@ data class NavIntent(
val origin: NavDestination? = null,
val popOptions: NavOptions? = null,
val navigationId: NavigationId? = null,
- private val arguments: MutableMap = mutableMapOf()
+ private val arguments: MutableMap = mutableMapOf(),
) {
/**
* Creates a copy of [NavIntent] with [pair] added to its arguments
@@ -36,13 +36,18 @@ data class NavIntent(
/**
* Creates a copy of [NavIntent] with [pair] added to its arguments
*/
- operator fun plus(pair: Pair): NavIntent = copy(
- arguments = arguments.toMutableMap().also {
- it[pair.first] = pair.second
- }
- )
+ operator fun plus(pair: Pair): NavIntent =
+ copy(
+ arguments =
+ arguments.toMutableMap().also {
+ it[pair.first] = pair.second
+ },
+ )
- fun addArgument(key: String, value: Any) {
+ fun addArgument(
+ key: String,
+ value: Any,
+ ) {
arguments[key] = value
}
@@ -100,7 +105,7 @@ data class NavIntent(
internal fun navIntent(
name: String,
sourceDestination: NavDestination,
- reservedNameCheck: Boolean = true
+ reservedNameCheck: Boolean = true,
): NavIntent {
if (reservedNameCheck) {
ComposeNavigation.getReservedNamesHandler().checkIntentName(name)
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentHistory.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentHistory.kt
index e60d7e0..6e60114 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentHistory.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentHistory.kt
@@ -26,11 +26,11 @@ internal class NavIntentHistory(startingIntent: NavIntent) {
fun popNode(intent: NavIntent) {
if (nodes.last() == intent) {
- nodes.removeLast()
+ nodes.removeAt(nodes.lastIndex)
} else {
throw IllegalStateException(
"Last node is different from the one that should be removed. " +
- "Current last: ${nodes.last()} | node to remove $intent"
+ "Current last: ${nodes.last()} | node to remove $intent",
)
}
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManager.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManager.kt
index 32c16f5..ec11f2f 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManager.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManager.kt
@@ -5,14 +5,16 @@ import com.adamkobus.compose.navigation.action.NavAction
import com.adamkobus.compose.navigation.destination.NavState
internal class NavIntentResolvingManager {
-
private val resolvers = mutableListOf()
fun register(resolvers: Collection) {
this.resolvers.addAll(resolvers)
}
- suspend fun resolve(intent: NavIntent, navState: NavState): NavAction? {
+ suspend fun resolve(
+ intent: NavIntent,
+ navState: NavState,
+ ): NavAction? {
val history = NavIntentHistory(intent)
val result = getNextResult(intent, navState, history)
return if (result is ResolveResult.Action) {
@@ -22,7 +24,11 @@ internal class NavIntentResolvingManager {
}
}
- private suspend fun getNextResult(intent: NavIntent, navState: NavState, history: NavIntentHistory): ResolveResult {
+ private suspend fun getNextResult(
+ intent: NavIntent,
+ navState: NavState,
+ history: NavIntentHistory,
+ ): ResolveResult {
resolvers.forEach {
val resolverResult = it.resolve(intent, navState)
if (resolverResult is ResolveResult.Action) {
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/ResolveResult.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/ResolveResult.kt
index c058e06..35eef38 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/intent/ResolveResult.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/intent/ResolveResult.kt
@@ -7,7 +7,6 @@ import com.adamkobus.compose.navigation.action.NavAction
* Produced as a result of [NavIntent] processing by [NavIntentResolver]s
*/
sealed class ResolveResult {
-
/**
* Indicates that [NavIntent] was resolved to the [action]
*
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLogger.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLogger.kt
index 7d68e85..72e18e1 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLogger.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLogger.kt
@@ -9,7 +9,6 @@ import com.adamkobus.compose.navigation.ComposeNavigation
* You can provide your own implementation via [ComposeNavigation.setLogger]
*/
interface NavLogger {
-
/**
* Used to log details about navigation actions processing, i.e. when processing of the new actions has started and finished
*/
@@ -18,7 +17,10 @@ interface NavLogger {
/**
* Used to log details about navigation actions processing, i.e. when processing of the new actions has started and finished
*/
- fun v(error: Throwable, message: String)
+ fun v(
+ error: Throwable,
+ message: String,
+ )
/**
* Used to log current destination changes
@@ -28,7 +30,10 @@ interface NavLogger {
/**
* Used to log current destination changes
*/
- fun d(error: Throwable, message: String)
+ fun d(
+ error: Throwable,
+ message: String,
+ )
/**
* Used to log warnings, i.e. about intents or actions that were discarded
@@ -38,7 +43,10 @@ interface NavLogger {
/**
* Used to log warnings, i.e. about intents or actions that were discarded
*/
- fun w(error: Throwable, message: String)
+ fun w(
+ error: Throwable,
+ message: String,
+ )
/**
* Used to log unexpected errors
@@ -48,7 +56,10 @@ interface NavLogger {
/**
* Used to log unexpected errors
*/
- fun e(error: Throwable, message: String)
+ fun e(
+ error: Throwable,
+ message: String,
+ )
/**
* When set, then logger should log only the messages with matching or higher importance than [level].
@@ -57,7 +68,9 @@ interface NavLogger {
* @see [android.util.Log]
* @see [NavLogLevel]
*/
- fun setLogLevel(@NavLogLevel level: Int)
+ fun setLogLevel(
+ @NavLogLevel level: Int,
+ )
companion object {
/**
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLoggerImpl.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLoggerImpl.kt
index d7af31a..33e3cad 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLoggerImpl.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/logger/NavLoggerImpl.kt
@@ -4,7 +4,6 @@ import android.util.Log
import com.adamkobus.compose.navigation.ComposeNavigation
internal object NavLoggerImpl : NavLogger {
-
private const val TAG = "Navigation"
private var logLevel: Int = ComposeNavigation.DEFAULT_LOG_LEVEL
@@ -15,7 +14,10 @@ internal object NavLoggerImpl : NavLogger {
}
}
- override fun v(error: Throwable, message: String) {
+ override fun v(
+ error: Throwable,
+ message: String,
+ ) {
if (canLog(Log.VERBOSE)) {
Log.v(TAG, message, error)
}
@@ -27,7 +29,10 @@ internal object NavLoggerImpl : NavLogger {
}
}
- override fun d(error: Throwable, message: String) {
+ override fun d(
+ error: Throwable,
+ message: String,
+ ) {
if (canLog(Log.DEBUG)) {
Log.d(TAG, message, error)
}
@@ -39,7 +44,10 @@ internal object NavLoggerImpl : NavLogger {
}
}
- override fun w(error: Throwable, message: String) {
+ override fun w(
+ error: Throwable,
+ message: String,
+ ) {
if (canLog(Log.WARN)) {
Log.w(TAG, message, error)
}
@@ -51,7 +59,10 @@ internal object NavLoggerImpl : NavLogger {
}
}
- override fun e(error: Throwable, message: String) {
+ override fun e(
+ error: Throwable,
+ message: String,
+ ) {
if (canLog(Log.ERROR)) {
Log.e(TAG, message, error)
}
@@ -61,5 +72,7 @@ internal object NavLoggerImpl : NavLogger {
logLevel = level
}
- private fun canLog(@NavLogLevel level: Int) = level >= logLevel
+ private fun canLog(
+ @NavLogLevel level: Int,
+ ) = level >= logLevel
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ActionConsumer.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ActionConsumer.kt
index 158cb38..e5b495a 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ActionConsumer.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ActionConsumer.kt
@@ -2,5 +2,6 @@ package com.adamkobus.compose.navigation.model
internal interface ActionConsumer {
val supportedGraphsRoutes: List
+
suspend fun awaitUntilReady()
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/KnownDestinationsSource.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/KnownDestinationsSource.kt
index c673ef6..4720028 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/KnownDestinationsSource.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/KnownDestinationsSource.kt
@@ -9,7 +9,6 @@ import com.adamkobus.compose.navigation.destination.NavStackEntry
import com.adamkobus.compose.navigation.destination.UnknownDestination
internal class KnownDestinationsSource {
-
private val knownDestinations = mutableMapOf()
internal fun addToKnownDestinations(destination: INavDestination) {
@@ -20,7 +19,10 @@ internal class KnownDestinationsSource {
}
}
- private fun addKnownDestination(route: String, destination: NavDestination) {
+ private fun addKnownDestination(
+ route: String,
+ destination: NavDestination,
+ ) {
synchronized(knownDestinations) {
knownDestinations.putIfAbsent(route, destination)
}
@@ -38,16 +40,19 @@ internal class KnownDestinationsSource {
}
internal fun NavBackStackEntry.toNavStackEntry(
- knownDestinationsSource: KnownDestinationsSource = ComposeNavigation.getKnownDestinationsSource()
+ knownDestinationsSource: KnownDestinationsSource = ComposeNavigation.getKnownDestinationsSource(),
): NavStackEntry {
val destination = knownDestinationsSource.resolveNavBackStackEntryToDestination(this)
return NavStackEntry(
destination = destination,
- arguments = buildArguments(destination, this.arguments)
+ arguments = buildArguments(destination, this.arguments),
)
}
-private fun buildArguments(destination: NavDestination, arguments: Bundle?): Map =
+private fun buildArguments(
+ destination: NavDestination,
+ arguments: Bundle?,
+): Map =
destination.route.paramNames.associateWith {
arguments?.getString(it)!!
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavDelegate.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavDelegate.kt
index 60aa68f..49abc63 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavDelegate.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavDelegate.kt
@@ -6,8 +6,19 @@ import kotlinx.coroutines.flow.Flow
internal interface NavDelegate {
fun onActionCompletedWithoutBackStackUpdate(actionConsumer: ActionConsumer)
- fun onBackStackEntryUpdated(actionConsumer: ActionConsumer, entry: NavBackStackEntry?, backQueue: List)
- fun register(actionConsumer: ActionConsumer, supportedGraphsRoutes: List): Flow
+
+ fun onBackStackEntryUpdated(
+ actionConsumer: ActionConsumer,
+ entry: NavBackStackEntry?,
+ backQueue: List,
+ )
+
+ fun register(
+ actionConsumer: ActionConsumer,
+ supportedGraphsRoutes: List,
+ ): Flow
+
fun unregister(actionConsumer: ActionConsumer)
+
fun onBackStackCleared(actionConsumer: ActionConsumer)
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGatekeeper.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGatekeeper.kt
index 531c2e5..b5735c6 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGatekeeper.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGatekeeper.kt
@@ -6,14 +6,17 @@ import com.adamkobus.compose.navigation.action.NavAction
import com.adamkobus.compose.navigation.destination.NavState
internal class NavGatekeeper(
- private val initialVerifiers: Set = emptySet()
+ private val initialVerifiers: Set = emptySet(),
) {
+ private val verifiers =
+ mutableListOf().apply {
+ addAll(initialVerifiers)
+ }
- private val verifiers = mutableListOf().apply {
- addAll(initialVerifiers)
- }
-
- fun isNavActionAllowed(navState: NavState, action: NavAction): NavActionVerifier? {
+ fun isNavActionAllowed(
+ navState: NavState,
+ action: NavAction,
+ ): NavActionVerifier? {
synchronized(verifiers) {
verifiers.forEach {
if (it.isNavActionAllowed(navState, action) == VerifyResult.Discard) {
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGraphNamesExtractor.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGraphNamesExtractor.kt
index 8782035..2dfe00c 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGraphNamesExtractor.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavGraphNamesExtractor.kt
@@ -7,8 +7,11 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
internal object NavGraphNamesExtractor {
-
- fun extractGraphNames(controller: NavHostController, startRoute: String, init: NavGraphBuilder.() -> Unit): List {
+ fun extractGraphNames(
+ controller: NavHostController,
+ startRoute: String,
+ init: NavGraphBuilder.() -> Unit,
+ ): List {
val navGraphBuilder = NavGraphBuilder(controller.navigatorProvider, startRoute, null)
val nodes = navGraphBuilder.apply(init).build().nodes
val graphNames = mutableListOf()
@@ -16,7 +19,10 @@ internal object NavGraphNamesExtractor {
return graphNames
}
- private fun addGraphNames(nodes: SparseArrayCompat, graphNames: MutableList) {
+ private fun addGraphNames(
+ nodes: SparseArrayCompat,
+ graphNames: MutableList,
+ ) {
for (i in 0 until nodes.size()) {
val node = nodes.get(nodes.keyAt(i))
node?.route
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavStateManager.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavStateManager.kt
index a2d0db5..9ff3b7b 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavStateManager.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavStateManager.kt
@@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.StateFlow
* It depends on NavComposable to work properly.
*/
internal class NavStateManager : NavigationStateSource {
-
private val _navState = MutableStateFlow(NavState(emptyList()))
override val navState: NavState
get() = _navState.value
@@ -25,15 +24,20 @@ internal class NavStateManager : NavigationStateSource {
private val logger: NavLogger
get() = ComposeNavigation.getLogger()
- internal fun onBackStackUpdated(navigationId: NavigationId, entry: NavBackStackEntry?, backQueue: List) {
- val backStack = backQueue.mapNotNull {
- if (it.destination.id == 0 && it.destination.route == null) {
- // this is the app's root graph that is not part of the navigation tree
- null
- } else {
- it.toNavStackEntry()
+ internal fun onBackStackUpdated(
+ navigationId: NavigationId,
+ entry: NavBackStackEntry?,
+ backQueue: List,
+ ) {
+ val backStack =
+ backQueue.mapNotNull {
+ if (it.destination.id == 0 && it.destination.route == null) {
+ // this is the app's root graph that is not part of the navigation tree
+ null
+ } else {
+ it.toNavStackEntry()
+ }
}
- }
updateCurrentDestination(NavControllerState(navigationId, entry?.toNavStackEntry(), backStack))
}
@@ -45,15 +49,16 @@ internal class NavStateManager : NavigationStateSource {
}
logger.d("[${controllerState.navId}] Current destination changed to $controllerState")
if (existing != null) {
- _navState.value = NavState(
- _navState.value.controllersState.map {
- if (it.navId == controllerState.navId) {
- controllerState
- } else {
- it
- }
- }
- )
+ _navState.value =
+ NavState(
+ _navState.value.controllersState.map {
+ if (it.navId == controllerState.navId) {
+ controllerState
+ } else {
+ it
+ }
+ },
+ )
} else {
_navState.value = NavState(_navState.value.controllersState + controllerState)
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationConsumerImpl.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationConsumerImpl.kt
index 6f02a0e..1ad8a7f 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationConsumerImpl.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationConsumerImpl.kt
@@ -9,7 +9,6 @@ import com.adamkobus.compose.navigation.intent.NavIntent
import kotlinx.coroutines.CompletableDeferred
internal class NavigationConsumerImpl : NavigationConsumer {
-
private val navProcessor
get() = ComposeNavigation.getNavProcessor()
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationProcessor.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationProcessor.kt
index bc72f2f..70b3f21 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationProcessor.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/NavigationProcessor.kt
@@ -27,7 +27,7 @@ internal class NavigationProcessor(
private val navIntentResolver: NavIntentResolvingManager,
private val navGatekeeper: NavGatekeeper,
private val loggerProvider: Provider,
- private val timeoutProvider: Provider
+ private val timeoutProvider: Provider,
) {
private val navState: NavState
get() = stateManager.navState
@@ -52,36 +52,44 @@ internal class NavigationProcessor(
fun getDispatcher(navigationId: NavigationId): PendingActionDispatcher {
synchronized(dispatchers) {
return dispatchers.find { it.navigationId == navigationId } ?: run {
- val dispatcher = PendingActionDispatcher(
- navigationId = navigationId,
- loggerProvider = loggerProvider,
- timeoutProvider = timeoutProvider,
- mainDispatcher = mainDispatcher,
- stateManager = stateManager
- )
+ val dispatcher =
+ PendingActionDispatcher(
+ navigationId = navigationId,
+ loggerProvider = loggerProvider,
+ timeoutProvider = timeoutProvider,
+ mainDispatcher = mainDispatcher,
+ stateManager = stateManager,
+ )
dispatchers.add(dispatcher)
dispatcher
}
}
}
- fun postNavAction(navAction: NavAction, onTaskCompleted: CompletableDeferred? = null) {
+ fun postNavAction(
+ navAction: NavAction,
+ onTaskCompleted: CompletableDeferred? = null,
+ ) {
scope.launch {
actionBuffer.emit(ProcessorTask.Action(navAction, onTaskCompleted))
}
}
- fun postNavIntent(intent: NavIntent, onTaskCompleted: CompletableDeferred? = null) {
+ fun postNavIntent(
+ intent: NavIntent,
+ onTaskCompleted: CompletableDeferred? = null,
+ ) {
scope.launch {
actionBuffer.emit(ProcessorTask.Intent(intent, onTaskCompleted))
}
}
private suspend fun processTask(task: ProcessorTask) {
- val result = when (task) {
- is ProcessorTask.Action -> processAction(task.navAction)
- is ProcessorTask.Intent -> processIntent(task.navIntent)
- }
+ val result =
+ when (task) {
+ is ProcessorTask.Action -> processAction(task.navAction)
+ is ProcessorTask.Intent -> processIntent(task.navIntent)
+ }
task.onTaskCompleted?.complete(result)
}
@@ -109,9 +117,10 @@ internal class NavigationProcessor(
return NavigationResult.Discarded(DiscardReason.NotDelivered)
}
- val readyDispatchers = dispatchers.filter {
- it.awaitUntilReady()
- }
+ val readyDispatchers =
+ dispatchers.filter {
+ it.awaitUntilReady()
+ }
val rejectingVerifier = navGatekeeper.isNavActionAllowed(navState, action)
if (rejectingVerifier != null) {
@@ -119,9 +128,10 @@ internal class NavigationProcessor(
return NavigationResult.Discarded(DiscardReason.RejectedByVerifier(rejectingVerifier))
}
- val suitableDispatchers = readyDispatchers.filter {
- isDispatcherSuitableForAction(it, action)
- }
+ val suitableDispatchers =
+ readyDispatchers.filter {
+ isDispatcherSuitableForAction(it, action)
+ }
if (suitableDispatchers.isEmpty()) {
logger.v("$logPrefix There is no NavHost suitable for action: $action")
@@ -133,24 +143,25 @@ internal class NavigationProcessor(
suitableDispatchers.map {
Pair(it, it.dispatchAction(action))
}.forEach { (dispatcher, deferredResult) ->
- val mappedResult = when (deferredResult.await()) {
- DispatchResult.Success -> {
- logger.v("$logPrefix Action $action accepted by dispatcher $dispatcher")
- NavigationResult.Accepted
- }
- DispatchResult.Timeout -> {
- logger.e("$logPrefix Timeout when trying to deliver action $action to $dispatcher")
- NavigationResult.Discarded(DiscardReason.Timeout)
- }
- DispatchResult.NotDelivered -> {
- logger.w("$logPrefix Failed to deliver action $action to $dispatcher")
- NavigationResult.Discarded(DiscardReason.NotDelivered)
+ val mappedResult =
+ when (deferredResult.await()) {
+ DispatchResult.Success -> {
+ logger.v("$logPrefix Action $action accepted by dispatcher $dispatcher")
+ NavigationResult.Accepted
+ }
+ DispatchResult.Timeout -> {
+ logger.e("$logPrefix Timeout when trying to deliver action $action to $dispatcher")
+ NavigationResult.Discarded(DiscardReason.Timeout)
+ }
+ DispatchResult.NotDelivered -> {
+ logger.w("$logPrefix Failed to deliver action $action to $dispatcher")
+ NavigationResult.Discarded(DiscardReason.NotDelivered)
+ }
+ DispatchResult.WrongNavHost -> {
+ logger.v("$logPrefix Action cannot be processed by nav host $dispatcher: $action")
+ NavigationResult.Discarded(DiscardReason.NotDelivered)
+ }
}
- DispatchResult.WrongNavHost -> {
- logger.v("$logPrefix Action cannot be processed by nav host $dispatcher: $action")
- NavigationResult.Discarded(DiscardReason.NotDelivered)
- }
- }
if (result !is NavigationResult.Accepted) {
result = mappedResult
}
@@ -158,7 +169,10 @@ internal class NavigationProcessor(
return result
}
- private suspend fun isDispatcherSuitableForAction(dispatcher: PendingActionDispatcher, action: NavAction): Boolean {
+ private suspend fun isDispatcherSuitableForAction(
+ dispatcher: PendingActionDispatcher,
+ action: NavAction,
+ ): Boolean {
val supportedGraphs = dispatcher.getSupportedGraphRoutes() ?: return false
return if (action is NavigateAction || action is PopUpToAction) {
action.toDestination.graph.serializedRoute in supportedGraphs
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/PendingActionDispatcher.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/PendingActionDispatcher.kt
index ad80cbf..c6f49ce 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/PendingActionDispatcher.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/PendingActionDispatcher.kt
@@ -20,7 +20,7 @@ internal class PendingActionDispatcher(
private val mainDispatcher: CoroutineDispatcher,
private val loggerProvider: Provider,
private val timeoutProvider: Provider,
- private val stateManager: NavStateManager
+ private val stateManager: NavStateManager,
) : NavDelegate {
private val actionDispatchTimeoutMs: Long
get() = timeoutProvider.provide()
@@ -36,7 +36,7 @@ internal class PendingActionDispatcher(
override fun onBackStackEntryUpdated(
actionConsumer: ActionConsumer,
entry: NavBackStackEntry?,
- backQueue: List
+ backQueue: List,
) {
if (actionConsumer == consumer?.owner) {
stateManager.onBackStackUpdated(navigationId, entry, backQueue)
@@ -57,18 +57,22 @@ internal class PendingActionDispatcher(
}
}
- override fun register(actionConsumer: ActionConsumer, supportedGraphsRoutes: List): Flow {
+ override fun register(
+ actionConsumer: ActionConsumer,
+ supportedGraphsRoutes: List,
+ ): Flow {
consumer?.let {
unregister(it.owner)
}
logger.v("$logPrefix Registering action consumer: $actionConsumer")
val flow = MutableSharedFlow()
- consumer = PendingActionConsumer(
- actionConsumer,
- flow,
- CoroutineScope(this.mainDispatcher + SupervisorJob()),
- supportedGraphsRoutes
- )
+ consumer =
+ PendingActionConsumer(
+ actionConsumer,
+ flow,
+ CoroutineScope(this.mainDispatcher + SupervisorJob()),
+ supportedGraphsRoutes,
+ )
return flow
}
@@ -110,24 +114,28 @@ internal class PendingActionDispatcher(
complete(DispatchResult.WrongNavHost)
}
- suspend fun getSupportedGraphRoutes(): List? =
- getReadyConsumer()?.supportedGraphsRoutes
+ suspend fun getSupportedGraphRoutes(): List? = getReadyConsumer()?.supportedGraphsRoutes
- private suspend fun dispatchToConsumer(action: NavAction, consumer: PendingActionConsumer): CompletableDeferred {
+ private suspend fun dispatchToConsumer(
+ action: NavAction,
+ consumer: PendingActionConsumer,
+ ): CompletableDeferred {
val ret = CompletableDeferred()
onActionPerformed = ret
var job: Job? = null
- job = consumer.scope.launch {
- timeoutJob = consumer.scope.launch {
- delay(actionDispatchTimeoutMs)
- job?.cancel()
- if (ret == onActionPerformed) {
- completeAction(DispatchResult.Timeout)
- }
+ job =
+ consumer.scope.launch {
+ timeoutJob =
+ consumer.scope.launch {
+ delay(actionDispatchTimeoutMs)
+ job?.cancel()
+ if (ret == onActionPerformed) {
+ completeAction(DispatchResult.Timeout)
+ }
+ }
+ consumer.owner.awaitUntilReady()
+ consumer.consumerFlow.emit(action)
}
- consumer.owner.awaitUntilReady()
- consumer.consumerFlow.emit(action)
- }
return ret
}
@@ -147,7 +155,7 @@ private data class PendingActionConsumer(
val owner: ActionConsumer,
val consumerFlow: MutableSharedFlow,
val scope: CoroutineScope,
- val supportedGraphsRoutes: List
+ val supportedGraphsRoutes: List,
) {
override fun toString(): String {
return owner.toString()
@@ -158,5 +166,5 @@ internal enum class DispatchResult {
WrongNavHost,
NotDelivered,
Timeout,
- Success
+ Success,
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorInitializedState.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorInitializedState.kt
index 9369693..0b3e6e1 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorInitializedState.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorInitializedState.kt
@@ -3,7 +3,6 @@ package com.adamkobus.compose.navigation.model
import kotlinx.coroutines.CompletableDeferred
internal class ProcessorInitializedState {
-
private var state: State = State.Unregistered
private var initializedDeferred: CompletableDeferred = CompletableDeferred()
@@ -33,6 +32,6 @@ internal class ProcessorInitializedState {
private enum class State {
Registered,
- Unregistered
+ Unregistered,
}
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorTask.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorTask.kt
index c2ec700..81b3945 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorTask.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ProcessorTask.kt
@@ -6,7 +6,6 @@ import com.adamkobus.compose.navigation.intent.NavIntent
import kotlinx.coroutines.CompletableDeferred
internal sealed class ProcessorTask(val onTaskCompleted: CompletableDeferred?) {
-
class Action(val navAction: NavAction, onTaskCompleted: CompletableDeferred?) : ProcessorTask(onTaskCompleted) {
override fun equals(other: Any?): Boolean {
return other is Action && other.navAction == navAction
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ReservedNamesHandler.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ReservedNamesHandler.kt
index 0772d30..8b26464 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/model/ReservedNamesHandler.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/model/ReservedNamesHandler.kt
@@ -3,14 +3,13 @@ package com.adamkobus.compose.navigation.model
import com.adamkobus.compose.navigation.error.ReservedNameError
internal class ReservedNamesHandler {
-
internal var enabled = true
fun checkGraphName(graphName: String) {
if (enabled && graphName.startsWith(RESERVED_NAME_PREFIX)) {
throw ReservedNameError(
"Graph names starting with $RESERVED_NAME_PREFIX are reserved " +
- "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()"
+ "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()",
)
}
}
@@ -19,7 +18,7 @@ internal class ReservedNamesHandler {
if (enabled && pathName.startsWith(RESERVED_NAME_PREFIX)) {
throw ReservedNameError(
"Path names starting with $RESERVED_NAME_PREFIX are reserved " +
- "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()"
+ "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()",
)
}
}
@@ -28,7 +27,7 @@ internal class ReservedNamesHandler {
if (enabled && paramName.startsWith(RESERVED_NAME_PREFIX)) {
throw ReservedNameError(
"Param names starting with $RESERVED_NAME_PREFIX are reserved " +
- "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()"
+ "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()",
)
}
}
@@ -37,7 +36,7 @@ internal class ReservedNamesHandler {
if (enabled && name.startsWith(RESERVED_NAME_PREFIX)) {
throw ReservedNameError(
"Intent names starting with $RESERVED_NAME_PREFIX are reserved " +
- "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()"
+ "for internal usage. You can disable this with ComposeNavigation.disableRestrictedNamesCheck()",
)
}
}
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposable.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposable.kt
index 43b6dd8..05f2de1 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposable.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposable.kt
@@ -1,5 +1,6 @@
package com.adamkobus.compose.navigation.ui
+import android.annotation.SuppressLint
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.State
@@ -20,7 +21,7 @@ import com.adamkobus.compose.navigation.NavigationId
fun NavComposable(
navController: NavHostController,
observedGraphs: List = emptyList(),
- navigationId: NavigationId
+ navigationId: NavigationId,
) {
val vm: NavComposableVM = viewModel(key = navController.toString())
vm.viewParam.bind(NavComposableParam(navigationId = navigationId, graphs = observedGraphs))
@@ -31,18 +32,19 @@ fun NavComposable(
@Composable
private fun NavComposableInner(
navController: NavHostController,
- vm: NavComposableVM
+ vm: NavComposableVM,
) {
val backStackState = navController.currentBackStackEntryAsState()
CurrentBackStackEntryUpdater(navController, vm, backStackState)
PendingActionProcessor(navController, vm)
}
+@SuppressLint("RestrictedApi")
@Composable
private fun CurrentBackStackEntryUpdater(
navController: NavHostController,
vm: NavComposableVM,
- backStackState: State
+ backStackState: State,
) {
val currentBackStackEntry = backStackState.value
val queue = navController.currentBackStack.collectAsState().value
@@ -54,7 +56,10 @@ private fun CurrentBackStackEntryUpdater(
}
@Composable
-private fun PendingActionProcessor(navController: NavHostController, vm: NavComposableVM) {
+private fun PendingActionProcessor(
+ navController: NavHostController,
+ vm: NavComposableVM,
+) {
val pendingAction = vm.pendingActionState.value
LaunchedEffect(key1 = pendingAction) {
if (pendingAction is PendingActionState.Present) {
@@ -66,5 +71,5 @@ private fun PendingActionProcessor(navController: NavHostController, vm: NavComp
private data class BackStackEntryUpdateState(
val currentBackStackEntry: NavBackStackEntry?,
- val queue: List
+ val queue: List,
)
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableState.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableState.kt
index 7df737e..ffdb256 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableState.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableState.kt
@@ -3,5 +3,5 @@ package com.adamkobus.compose.navigation.ui
import androidx.compose.runtime.State
internal data class NavComposableState(
- val isInitialized: State
+ val isInitialized: State,
)
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableVM.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableVM.kt
index f8ea758..f2557b1 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableVM.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/NavComposableVM.kt
@@ -18,7 +18,6 @@ import kotlinx.coroutines.launch
@OptIn(ExperimentalCoroutinesApi::class)
internal class NavComposableVM : ViewModel(), ActionConsumer {
-
val viewParam = ViewParam()
private val logger: NavLogger
@@ -74,7 +73,10 @@ internal class NavComposableVM : ViewModel(), ActionConsumer {
pendingActionState.value = PendingActionState.Missing
}
- fun processBackStackEntry(entry: NavBackStackEntry?, backQueue: List) {
+ fun processBackStackEntry(
+ entry: NavBackStackEntry?,
+ backQueue: List,
+ ) {
navDelegate?.onBackStackEntryUpdated(this@NavComposableVM, entry, backQueue)
if (entry != null) {
loadingCompletable?.let {
@@ -94,5 +96,5 @@ internal class NavComposableVM : ViewModel(), ActionConsumer {
internal data class NavComposableParam(
val navigationId: NavigationId,
- val graphs: List
+ val graphs: List,
)
diff --git a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/PendingActionState.kt b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/PendingActionState.kt
index 8c15ab2..b46cc2f 100644
--- a/composenav/src/main/java/com/adamkobus/compose/navigation/ui/PendingActionState.kt
+++ b/composenav/src/main/java/com/adamkobus/compose/navigation/ui/PendingActionState.kt
@@ -4,7 +4,6 @@ import com.adamkobus.compose.navigation.action.NavAction
import kotlinx.coroutines.CompletableDeferred
internal sealed class PendingActionState {
-
object Missing : PendingActionState()
class Present(val action: NavAction, private val completable: CompletableDeferred) : PendingActionState() {
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/ComposeNavigationTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/ComposeNavigationTest.kt
index 6806ad3..e815a8d 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/ComposeNavigationTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/ComposeNavigationTest.kt
@@ -5,7 +5,6 @@ import org.junit.After
import org.junit.Test
class ComposeNavigationTest {
-
@After
fun cleanUp() {
ComposeNavigation.reset()
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/action/NavigateActionTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/action/NavigateActionTest.kt
index 549989c..b1d7ad4 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/action/NavigateActionTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/action/NavigateActionTest.kt
@@ -11,7 +11,6 @@ import org.junit.Before
import org.junit.Test
class NavigateActionTest {
-
private val controller: NavHostController = mockk()
private val fromDestination: NavDestination = mockk()
private val toDestination: NavDestination = mockk()
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/GlobalGraphTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/GlobalGraphTest.kt
index 6a7c314..5585168 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/GlobalGraphTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/GlobalGraphTest.kt
@@ -4,7 +4,6 @@ import org.junit.Assert.assertEquals
import org.junit.Test
class GlobalGraphTest {
-
@Test
fun `WHEN startDestination THEN proper destination is returned`() {
assertEquals("__global__/__root__", GlobalGraph.startDestination().route.buildRoute())
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRoutePartTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRoutePartTest.kt
index 1b9ccd6..0f1e562 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRoutePartTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRoutePartTest.kt
@@ -5,7 +5,6 @@ import junit.framework.TestCase.assertEquals
import org.junit.Test
class NavRoutePartTest {
-
@Test(expected = ReservedNameError::class)
fun `GIVEN reserved graph name WHEN GraphName THEN ReservedNameError is thrown`() {
NavRoutePart.GraphName("__reserved")
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRouteTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRouteTest.kt
index d9b694d..6bc6361 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRouteTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavRouteTest.kt
@@ -5,7 +5,6 @@ import org.junit.Assert.assertEquals
import org.junit.Test
class NavRouteTest {
-
@Test
fun `GIVEN route defined WHEN buildRoute THEN proper route is returned`() {
// given
@@ -21,11 +20,12 @@ class NavRouteTest {
@Test
fun `GIVEN route with params defined WHEN buildRoute THEN proper route is returned`() {
// given
- val testSubject = navRoute("testGraph", "testPath") {
- param("param1")
- path("foobar")
- param("secondParam")
- }
+ val testSubject =
+ navRoute("testGraph", "testPath") {
+ param("param1")
+ path("foobar")
+ param("secondParam")
+ }
// when
val obtained = testSubject.buildRoute()
@@ -37,9 +37,10 @@ class NavRouteTest {
@Test
fun `GIVEN route defined WHEN next THEN properly initialized route builder is returned`() {
// given
- val testSubject = navRoute("testGraph", "testPath").next {
- param("param")
- }
+ val testSubject =
+ navRoute("testGraph", "testPath").next {
+ param("param")
+ }
// when
val obtained = testSubject.buildRoute()
@@ -63,11 +64,12 @@ class NavRouteTest {
@Test
fun `GIVEN route with params WHEN buildPath THEN proper path is returned`() {
// given
- val testSubject = navRoute("testGraph", "testPath") {
- param("param1")
- path("foobar")
- param("secondParam")
- }
+ val testSubject =
+ navRoute("testGraph", "testPath") {
+ param("param1")
+ path("foobar")
+ param("secondParam")
+ }
// when
val obtained = testSubject.buildPath("aaa", "bbb")
@@ -79,11 +81,12 @@ class NavRouteTest {
@Test(expected = IllegalArgumentException::class)
fun `GIVEN providing too few params WHEN buildPath THEN IllegalArgumentException is thrown`() {
// given
- val testSubject = navRoute("testGraph", "testPath") {
- param("param1")
- path("foobar")
- param("secondParam")
- }
+ val testSubject =
+ navRoute("testGraph", "testPath") {
+ param("param1")
+ path("foobar")
+ param("secondParam")
+ }
// when
testSubject.buildPath("aaa")
@@ -92,11 +95,12 @@ class NavRouteTest {
@Test(expected = IllegalArgumentException::class)
fun `GIVEN providing too many params WHEN buildPath THEN IllegalArgumentException is thrown`() {
// given
- val testSubject = navRoute("testGraph", "testPath") {
- param("param1")
- path("foobar")
- param("secondParam")
- }
+ val testSubject =
+ navRoute("testGraph", "testPath") {
+ param("param1")
+ path("foobar")
+ param("secondParam")
+ }
// when
testSubject.buildPath("aaa", "bbb", "ccc")
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavStackEntryTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavStackEntryTest.kt
index 9dddaa9..ba72524 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavStackEntryTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/NavStackEntryTest.kt
@@ -10,16 +10,16 @@ import org.junit.Before
import org.junit.Test
class NavStackEntryTest {
-
private val destination: NavDestination = mockk()
- private val arguments = mutableMapOf(
- "intArg" to "10",
- "longArg" to "100000000",
- "stringArg" to "asdf",
- "floatArg" to "0.5",
- "doubleArg" to "0.123",
- "booleanArg" to "true"
- )
+ private val arguments =
+ mutableMapOf(
+ "intArg" to "10",
+ "longArg" to "100000000",
+ "stringArg" to "asdf",
+ "floatArg" to "0.5",
+ "doubleArg" to "0.123",
+ "booleanArg" to "true",
+ )
private val testSubject = NavStackEntry(destination, arguments)
@@ -40,9 +40,10 @@ class NavStackEntryTest {
@Test
fun `GIVEN String argument is missing WHEN getString THEN NavArgumentMissingError is thrown`() {
// when
- val error = assertThrows(NavArgumentMissingError::class.java) {
- testSubject.getString("missing")
- }
+ val error =
+ assertThrows(NavArgumentMissingError::class.java) {
+ testSubject.getString("missing")
+ }
// then
assertEquals("Destination 'destinationString' did not receive value for argument with key 'missing'", error.message)
@@ -60,9 +61,10 @@ class NavStackEntryTest {
@Test
fun `GIVEN Long argument is missing WHEN getLong THEN NavArgumentMissingError is thrown`() {
// when
- val error = assertThrows(NavArgumentMissingError::class.java) {
- testSubject.getLong("missing")
- }
+ val error =
+ assertThrows(NavArgumentMissingError::class.java) {
+ testSubject.getLong("missing")
+ }
// then
assertEquals("Destination 'destinationString' did not receive value for argument with key 'missing'", error.message)
@@ -71,14 +73,15 @@ class NavStackEntryTest {
@Test
fun `GIVEN Reading non-numeric argument WHEN getLong THEN NavArgumentFormatInvalidError is thrown`() {
// when
- val error = assertThrows(NavArgumentFormatInvalidError::class.java) {
- testSubject.getLong("stringArg")
- }
+ val error =
+ assertThrows(NavArgumentFormatInvalidError::class.java) {
+ testSubject.getLong("stringArg")
+ }
// then
assertEquals(
"Value 'asdf' of argument 'stringArg' in destination 'destinationString' could not be parsed to Long",
- error.message
+ error.message,
)
}
@@ -94,9 +97,10 @@ class NavStackEntryTest {
@Test
fun `GIVEN Int argument is missing WHEN getInt THEN NavArgumentMissingError is thrown`() {
// when
- val error = assertThrows(NavArgumentMissingError::class.java) {
- testSubject.getInt("missing")
- }
+ val error =
+ assertThrows(NavArgumentMissingError::class.java) {
+ testSubject.getInt("missing")
+ }
// then
assertEquals("Destination 'destinationString' did not receive value for argument with key 'missing'", error.message)
@@ -105,14 +109,15 @@ class NavStackEntryTest {
@Test
fun `GIVEN Reading non-numeric argument WHEN getInt THEN NavArgumentFormatInvalidError is thrown`() {
// when
- val error = assertThrows(NavArgumentFormatInvalidError::class.java) {
- testSubject.getInt("stringArg")
- }
+ val error =
+ assertThrows(NavArgumentFormatInvalidError::class.java) {
+ testSubject.getInt("stringArg")
+ }
// then
assertEquals(
"Value 'asdf' of argument 'stringArg' in destination 'destinationString' could not be parsed to Int",
- error.message
+ error.message,
)
}
@@ -128,9 +133,10 @@ class NavStackEntryTest {
@Test
fun `GIVEN Float argument is missing WHEN getFloat THEN NavArgumentMissingError is thrown`() {
// when
- val error = assertThrows(NavArgumentMissingError::class.java) {
- testSubject.getFloat("missing")
- }
+ val error =
+ assertThrows(NavArgumentMissingError::class.java) {
+ testSubject.getFloat("missing")
+ }
// then
assertEquals("Destination 'destinationString' did not receive value for argument with key 'missing'", error.message)
@@ -139,14 +145,15 @@ class NavStackEntryTest {
@Test
fun `GIVEN Reading non-numeric argument WHEN getFloat THEN NavArgumentFormatInvalidError is thrown`() {
// when
- val error = assertThrows(NavArgumentFormatInvalidError::class.java) {
- testSubject.getFloat("stringArg")
- }
+ val error =
+ assertThrows(NavArgumentFormatInvalidError::class.java) {
+ testSubject.getFloat("stringArg")
+ }
// then
assertEquals(
"Value 'asdf' of argument 'stringArg' in destination 'destinationString' could not be parsed to Float",
- error.message
+ error.message,
)
}
@@ -162,9 +169,10 @@ class NavStackEntryTest {
@Test
fun `GIVEN Double argument is missing WHEN getDouble THEN NavArgumentMissingError is thrown`() {
// when
- val error = assertThrows(NavArgumentMissingError::class.java) {
- testSubject.getDouble("missing")
- }
+ val error =
+ assertThrows(NavArgumentMissingError::class.java) {
+ testSubject.getDouble("missing")
+ }
// then
assertEquals("Destination 'destinationString' did not receive value for argument with key 'missing'", error.message)
@@ -173,14 +181,15 @@ class NavStackEntryTest {
@Test
fun `GIVEN Reading non-numeric argument WHEN getDouble THEN NavArgumentFormatInvalidError is thrown`() {
// when
- val error = assertThrows(NavArgumentFormatInvalidError::class.java) {
- testSubject.getDouble("stringArg")
- }
+ val error =
+ assertThrows(NavArgumentFormatInvalidError::class.java) {
+ testSubject.getDouble("stringArg")
+ }
// then
assertEquals(
"Value 'asdf' of argument 'stringArg' in destination 'destinationString' could not be parsed to Double",
- error.message
+ error.message,
)
}
@@ -196,9 +205,10 @@ class NavStackEntryTest {
@Test
fun `GIVEN Boolean argument is missing WHEN getDouble THEN NavArgumentMissingError is thrown`() {
// when
- val error = assertThrows(NavArgumentMissingError::class.java) {
- testSubject.getBoolean("missing")
- }
+ val error =
+ assertThrows(NavArgumentMissingError::class.java) {
+ testSubject.getBoolean("missing")
+ }
// then
assertEquals("Destination 'destinationString' did not receive value for argument with key 'missing'", error.message)
@@ -207,14 +217,15 @@ class NavStackEntryTest {
@Test
fun `GIVEN Reading non-boolean argument WHEN getDouble THEN NavArgumentFormatInvalidError is thrown`() {
// when
- val error = assertThrows(NavArgumentFormatInvalidError::class.java) {
- testSubject.getBoolean("stringArg")
- }
+ val error =
+ assertThrows(NavArgumentFormatInvalidError::class.java) {
+ testSubject.getBoolean("stringArg")
+ }
// then
assertEquals(
"Value 'asdf' of argument 'stringArg' in destination 'destinationString' could not be parsed to Boolean",
- error.message
+ error.message,
)
}
}
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/ScreenDestinationTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/ScreenDestinationTest.kt
index b486a79..6ffab67 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/destination/ScreenDestinationTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/destination/ScreenDestinationTest.kt
@@ -6,7 +6,6 @@ import junit.framework.TestCase.assertEquals
import org.junit.Test
class ScreenDestinationTest {
-
private val graph: NavGraph = mockk()
@Test
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentHistoryTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentHistoryTest.kt
index aaa57e5..66b47da 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentHistoryTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentHistoryTest.kt
@@ -6,15 +6,15 @@ import org.junit.Assert.assertThrows
import org.junit.Test
class NavIntentHistoryTest {
-
private val testSubject = NavIntentHistory(INITIAL_ACTION)
@Test
fun `GIVEN only single node preset WHEN adding intent with same name THEN NavIntentCycleDetectedError thrown`() {
// when
- val error = assertThrows(NavIntentCycleDetectedError::class.java) {
- testSubject.addNode(NavIntent("initial"))
- }
+ val error =
+ assertThrows(NavIntentCycleDetectedError::class.java) {
+ testSubject.addNode(NavIntent("initial"))
+ }
// then
assertEquals("initial -> initial", error.message)
@@ -23,11 +23,12 @@ class NavIntentHistoryTest {
@Test
fun `GIVEN multiple nodes preset WHEN adding node creates cycle THEN NavIntentCycleDetectedError thrown`() {
// when
- val error = assertThrows(NavIntentCycleDetectedError::class.java) {
- testSubject.addNode(NavIntent("second"))
- testSubject.addNode(NavIntent("third"))
- testSubject.addNode(NavIntent("second"))
- }
+ val error =
+ assertThrows(NavIntentCycleDetectedError::class.java) {
+ testSubject.addNode(NavIntent("second"))
+ testSubject.addNode(NavIntent("third"))
+ testSubject.addNode(NavIntent("second"))
+ }
// then
assertEquals("initial -> second -> third -> second", error.message)
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManagerTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManagerTest.kt
index 5933cd2..f866acc 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManagerTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentResolvingManagerTest.kt
@@ -17,7 +17,6 @@ import org.junit.Test
@OptIn(ExperimentalCoroutinesApi::class)
class NavIntentResolvingManagerTest {
-
private val actionProducingResolver: NavIntentResolver = mockk()
private val intentProducingResolver: NavIntentResolver = mockk()
private val cycleProducingResolver: NavIntentResolver = mockk()
@@ -38,29 +37,31 @@ class NavIntentResolvingManagerTest {
}
}
coEvery { intentProducingResolver.resolve(capture(slot), any()) } coAnswers {
- val mapped = if (slot.captured == firstIntent) {
- secondIntent
- } else if (slot.captured == secondIntent) {
- thirdIntent
- } else if (slot.captured == thirdIntent) {
- actionProducingIntent
- } else {
- null
- }
+ val mapped =
+ if (slot.captured == firstIntent) {
+ secondIntent
+ } else if (slot.captured == secondIntent) {
+ thirdIntent
+ } else if (slot.captured == thirdIntent) {
+ actionProducingIntent
+ } else {
+ null
+ }
mapped?.let {
ResolveResult.Intent(it)
} ?: ResolveResult.None
}
coEvery { cycleProducingResolver.resolve(capture(slot), any()) } coAnswers {
- val mapped = if (slot.captured == firstIntent) {
- secondIntent
- } else if (slot.captured == secondIntent) {
- thirdIntent
- } else if (slot.captured == thirdIntent) {
- firstIntent
- } else {
- null
- }
+ val mapped =
+ if (slot.captured == firstIntent) {
+ secondIntent
+ } else if (slot.captured == secondIntent) {
+ thirdIntent
+ } else if (slot.captured == thirdIntent) {
+ firstIntent
+ } else {
+ null
+ }
mapped?.let {
ResolveResult.Intent(it)
} ?: ResolveResult.None
@@ -68,79 +69,86 @@ class NavIntentResolvingManagerTest {
}
@Test
- fun `GIVEN only one resolver registered WHEN resolve intent that directly produces action THEN action is returned`() = runTest {
- // given
- testSubject.register(listOf(actionProducingResolver))
+ fun `GIVEN only one resolver registered WHEN resolve intent that directly produces action THEN action is returned`() =
+ runTest {
+ // given
+ testSubject.register(listOf(actionProducingResolver))
- // when
- val obtained = testSubject.resolve(actionProducingIntent, navState)
+ // when
+ val obtained = testSubject.resolve(actionProducingIntent, navState)
- // then
- assertEquals(producedAction, obtained)
- }
+ // then
+ assertEquals(producedAction, obtained)
+ }
@Test
- fun `GIVEN multiple resolvers registered WHEN resolve intent that directly produces action THEN action is returned`() = runTest {
- // given
- testSubject.register(listOf(intentProducingResolver, actionProducingResolver))
+ fun `GIVEN multiple resolvers registered WHEN resolve intent that directly produces action THEN action is returned`() =
+ runTest {
+ // given
+ testSubject.register(listOf(intentProducingResolver, actionProducingResolver))
- // when
- val obtained = testSubject.resolve(actionProducingIntent, navState)
+ // when
+ val obtained = testSubject.resolve(actionProducingIntent, navState)
- // then
- assertEquals(producedAction, obtained)
- }
+ // then
+ assertEquals(producedAction, obtained)
+ }
@Test
- fun `GIVEN unknown intent WHEN resolve THEN null is returned`() = runTest {
- // given
- testSubject.register(listOf(intentProducingResolver, actionProducingResolver))
+ fun `GIVEN unknown intent WHEN resolve THEN null is returned`() =
+ runTest {
+ // given
+ testSubject.register(listOf(intentProducingResolver, actionProducingResolver))
- // when
- val obtained = testSubject.resolve(unknownIntent, navState)
+ // when
+ val obtained = testSubject.resolve(unknownIntent, navState)
- // then
- assertNull(obtained)
- }
+ // then
+ assertNull(obtained)
+ }
@Test
- fun `GIVEN finding actions requires multiple resolves WHEN resolve THEN action is returned`() = runTest {
- // given
- testSubject.register(listOf(intentProducingResolver, actionProducingResolver))
+ fun `GIVEN finding actions requires multiple resolves WHEN resolve THEN action is returned`() =
+ runTest {
+ // given
+ testSubject.register(listOf(intentProducingResolver, actionProducingResolver))
- // when
- val obtained = testSubject.resolve(firstIntent, navState)
+ // when
+ val obtained = testSubject.resolve(firstIntent, navState)
- // then
- assertEquals(producedAction, obtained)
- }
+ // then
+ assertEquals(producedAction, obtained)
+ }
@Test(expected = NavIntentCycleDetectedError::class)
- fun `GIVEN resolver produces cycle WHEN resolve THEN NavIntentCycleDetectedError thrown`() = runTest {
- // given
- testSubject.register(listOf(cycleProducingResolver))
+ fun `GIVEN resolver produces cycle WHEN resolve THEN NavIntentCycleDetectedError thrown`() =
+ runTest {
+ // given
+ testSubject.register(listOf(cycleProducingResolver))
- // when
- testSubject.resolve(firstIntent, navState)
- }
+ // when
+ testSubject.resolve(firstIntent, navState)
+ }
@Test(expected = NavIntentMappingTooDeepError::class)
- fun `GIVEN too many mappings required WHEN resolve THEN NavIntentMappingTooDeepError thrown`() = runTest {
- // given
- val firstIntent = createChain(51)
+ fun `GIVEN too many mappings required WHEN resolve THEN NavIntentMappingTooDeepError thrown`() =
+ runTest {
+ // given
+ val firstIntent = createChain(51)
- // when
- testSubject.resolve(firstIntent, navState)
- }
+ // when
+ testSubject.resolve(firstIntent, navState)
+ }
@Test
- fun `GIVEN mappings number just at the depth limit WHEN resolve THEN no error`() = runTest {
- // given
- val firstIntent = createChain(50)
+ fun `GIVEN mappings number just at the depth limit WHEN resolve THEN no error`() =
+ runTest {
+ // given
+ val firstIntent = createChain(50)
- // when
- testSubject.resolve(firstIntent, navState)
- }
+ // when
+ testSubject.resolve(firstIntent, navState)
+ }
private fun createChain(depth: Int): NavIntent {
val firstIntent = NavIntent("0")
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentTest.kt
index d3c2b04..69bc4ab 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/intent/NavIntentTest.kt
@@ -4,7 +4,6 @@ import junit.framework.TestCase.assertEquals
import org.junit.Test
class NavIntentTest {
-
@Test
fun `GIVEN nav intent has argument WHEN get THEN argument value is returned`() {
// given
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/model/NavGatekeeperTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/model/NavGatekeeperTest.kt
index 9b7882b..330caba 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/model/NavGatekeeperTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/model/NavGatekeeperTest.kt
@@ -11,7 +11,6 @@ import junit.framework.TestCase.assertNull
import org.junit.Test
class NavGatekeeperTest {
-
@Test
fun `GIVEN at least one verifier returns false WHEN isNavActionAllowed THEN returns false`() {
// given
diff --git a/composenav/src/test/java/com/adamkobus/compose/navigation/model/ReservedNamesHandlerTest.kt b/composenav/src/test/java/com/adamkobus/compose/navigation/model/ReservedNamesHandlerTest.kt
index 7abe508..f624a24 100644
--- a/composenav/src/test/java/com/adamkobus/compose/navigation/model/ReservedNamesHandlerTest.kt
+++ b/composenav/src/test/java/com/adamkobus/compose/navigation/model/ReservedNamesHandlerTest.kt
@@ -5,7 +5,6 @@ import junit.framework.TestCase.assertTrue
import org.junit.Test
class ReservedNamesHandlerTest {
-
private val testSubject = ReservedNamesHandler()
@Test
diff --git a/demo-common-ui/build.gradle b/demo-common-ui/build.gradle
index fd02d04..427b5c3 100644
--- a/demo-common-ui/build.gradle
+++ b/demo-common-ui/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -15,24 +14,27 @@ dependencies {
api project(':demo-core')
api project(':composenav')
- api Lib.AndroidX.Core
- api Lib.AndroidX.Appcompat
- api Lib.Kotlin.Coroutines
- api Lib.AdamKobus.LifecycleAwareViewModel
+ api libs.androidx.core
+ api libs.androidx.appcompat
+
+ api libs.kotlin.coroutines
+ api libs.ak.lifecycle.vm
// hilt
- implementation Lib.Google.Hilt
- api Lib.Google.HiltNavigationCompose
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// compose
- api Lib.Compose.Ui
- api Lib.Compose.Activity
- api Lib.Compose.Material
- api Lib.Compose.ToolingPreview
- debugApi Lib.Compose.UiTooling
+ api platform(libs.compose.bom)
+ api libs.compose.ui
+ api libs.compose.activity
+ api libs.compose.material
+ api libs.compose.material3
+ api libs.compose.tooling.preview
+ api libs.compose.hilt
+ debugApi libs.compose.tooling.ui
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/DemoAppBackground.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/DemoAppBackground.kt
index 8c5772b..212c730 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/DemoAppBackground.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/DemoAppBackground.kt
@@ -5,9 +5,9 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.LocalContentColor
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.contentColorFor
+import androidx.compose.material3.LocalContentColor
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
@@ -17,16 +17,17 @@ import com.adamkobus.compose.navigation.demo.ui.appbar.AppBarHeight
@Composable
fun DemoAppBackground(
usesTopBar: Boolean = false,
- content: @Composable BoxScope.() -> Unit
+ content: @Composable BoxScope.() -> Unit,
) {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .background(MaterialTheme.colors.background)
- .padding(top = if (usesTopBar) AppBarHeight else 0.dp)
+ .background(MaterialTheme.colorScheme.background)
+ .padding(top = if (usesTopBar) AppBarHeight else 0.dp),
) {
CompositionLocalProvider(
- LocalContentColor provides contentColorFor(backgroundColor = MaterialTheme.colors.background)
+ LocalContentColor provides contentColorFor(backgroundColor = MaterialTheme.colorScheme.background),
) {
content()
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/Paddings.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/Paddings.kt
index 7104586..9386e4e 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/Paddings.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/Paddings.kt
@@ -8,10 +8,11 @@ object Paddings {
val CardPadding = 14.dp
val TabHostSpacing = 64.dp
- val ScreenWithTabHostInsets = PaddingValues(
- top = Screen,
- start = Screen,
- end = Screen,
- bottom = TabHostSpacing
- )
+ val ScreenWithTabHostInsets =
+ PaddingValues(
+ top = Screen,
+ start = Screen,
+ end = Screen,
+ bottom = TabHostSpacing,
+ )
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/PreviewComponent.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/PreviewComponent.kt
index 7902db0..1804a30 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/PreviewComponent.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/PreviewComponent.kt
@@ -1,13 +1,13 @@
package com.adamkobus.compose.navigation.demo.ui
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Surface
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.adamkobus.compose.navigation.demo.ui.theme.DemoTheme
@Composable
fun PreviewComponent(content: @Composable () -> Unit) {
DemoTheme {
- Surface(color = MaterialTheme.colors.background, content = content)
+ Surface(color = MaterialTheme.colorScheme.background, content = content)
}
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBar.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBar.kt
index 3208c93..a084542 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBar.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBar.kt
@@ -17,15 +17,14 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.AppBarDefaults
import androidx.compose.material.ContentAlpha
-import androidx.compose.material.Icon
-import androidx.compose.material.IconButton
import androidx.compose.material.LocalContentAlpha
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.ProvideTextStyle
-import androidx.compose.material.Surface
-import androidx.compose.material.Text
-import androidx.compose.material.contentColorFor
-import androidx.compose.material.primarySurface
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.ProvideTextStyle
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
@@ -48,30 +47,31 @@ fun AnimatedAppBar() {
@Composable
private fun AnimatedAppBarContent(
appBarState: AnimatedAppBarState,
- backgroundColor: Color = MaterialTheme.colors.primarySurface,
+ backgroundColor: Color = MaterialTheme.colorScheme.primaryContainer,
contentColor: Color = contentColorFor(backgroundColor),
elevation: Dp = AppBarDefaults.TopAppBarElevation,
contentPadding: PaddingValues = AppBarDefaults.ContentPadding,
shape: Shape = RectangleShape,
- height: Dp = AppBarHeight
+ height: Dp = AppBarHeight,
) {
val targetBackground = animateColorAsState(targetValue = if (appBarState.isAnyContentAvailable) backgroundColor else Color.Transparent)
val targetElevation = animateDpAsState(targetValue = if (appBarState.isAnyContentAvailable) elevation else 0.dp)
Surface(
color = targetBackground.value,
contentColor = contentColor,
- elevation = targetElevation.value,
+ shadowElevation = targetElevation.value,
shape = shape,
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
- .height(height)
+ .height(height),
) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Box(
Modifier
.fillMaxSize()
.padding(contentPadding),
- contentAlignment = Alignment.CenterStart
+ contentAlignment = Alignment.CenterStart,
) {
AnimatedAppBarInnerContent(appBarState)
}
@@ -84,14 +84,15 @@ private fun AnimatedAppBarInnerContent(appBarState: AnimatedAppBarState) {
val titlePosition = animateDpAsState(targetValue = if (appBarState.iconState != null) TitleIconOffset else TitleNoIconOffset)
Box(
modifier = Modifier.fillMaxHeight(),
- contentAlignment = Alignment.CenterStart
+ contentAlignment = Alignment.CenterStart,
) {
IconContent(appBarState.iconState)
Row(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
.padding(start = titlePosition.value),
- verticalAlignment = Alignment.CenterVertically
+ verticalAlignment = Alignment.CenterVertically,
) {
Box(modifier = Modifier.weight(1f)) {
TitleContent(appBarState.titleState)
@@ -103,9 +104,9 @@ private fun AnimatedAppBarInnerContent(appBarState: AnimatedAppBarState) {
@Composable
private fun TitleContent(titleState: AppBarTitleState?) {
- ProvideTextStyle(value = MaterialTheme.typography.h6) {
+ ProvideTextStyle(value = MaterialTheme.typography.titleMedium) {
CompositionLocalProvider(
- LocalContentAlpha provides ContentAlpha.high
+ LocalContentAlpha provides ContentAlpha.high,
) {
Crossfade(targetState = titleState?.getText() ?: "", modifier = Modifier.fillMaxWidth()) { text ->
Text(text = text, modifier = Modifier.fillMaxWidth())
@@ -127,7 +128,7 @@ private fun IconContent(iconState: AppBarIconState?) {
} else {
Row(TitleIconModifier, verticalAlignment = Alignment.CenterVertically) {
CompositionLocalProvider(
- LocalContentAlpha provides ContentAlpha.high
+ LocalContentAlpha provides ContentAlpha.high,
) {
AnimatedAppBarIcon(iconStateInner, onClick = onClickWrapper)
}
@@ -138,12 +139,15 @@ private fun IconContent(iconState: AppBarIconState?) {
@OptIn(ExperimentalAnimationApi::class)
@Composable
-private fun ActionButtons(actionsList: List, clickable: Boolean) {
+private fun ActionButtons(
+ actionsList: List,
+ clickable: Boolean,
+) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Row(
modifier = Modifier.fillMaxHeight(),
horizontalArrangement = Arrangement.End,
- verticalAlignment = Alignment.CenterVertically
+ verticalAlignment = Alignment.CenterVertically,
) {
actionsList.forEachIndexed { index, item ->
val onClickWrapper = {
@@ -160,14 +164,20 @@ private fun ActionButtons(actionsList: List, clickable: Boole
}
@Composable
-fun ActionButtonContent(item: AppBarActionState, onClick: () -> Unit) {
+fun ActionButtonContent(
+ item: AppBarActionState,
+ onClick: () -> Unit,
+) {
IconButton(onClick = onClick) {
Icon(imageVector = item.icon, contentDescription = stringResource(id = item.contentDescriptionResId))
}
}
@Composable
-private fun AnimatedAppBarIcon(iconState: AppBarIconState, onClick: () -> Unit) {
+private fun AnimatedAppBarIcon(
+ iconState: AppBarIconState,
+ onClick: () -> Unit,
+) {
IconButton(onClick = onClick) {
Icon(iconState.icon, iconState.contentDescriptionResId?.let { stringResource(id = it) })
}
@@ -177,12 +187,14 @@ val AppBarHeight = 56.dp
private val AppBarHorizontalPadding = 4.dp
-private val TitleInsetWithoutIcon = Modifier
- .width(16.dp - AppBarHorizontalPadding)
+private val TitleInsetWithoutIcon =
+ Modifier
+ .width(16.dp - AppBarHorizontalPadding)
-private val TitleIconModifier = Modifier
- .fillMaxHeight()
- .width(72.dp - AppBarHorizontalPadding)
+private val TitleIconModifier =
+ Modifier
+ .fillMaxHeight()
+ .width(72.dp - AppBarHorizontalPadding)
private val TitleNoIconOffset = 12.dp
private val TitleIconOffset = 68.dp
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarDefaults.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarDefaults.kt
index fac1a87..cf55834 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarDefaults.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarDefaults.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.demo.ui.appbar
object AnimatedAppBarDefaults {
- const val DefaultStyle = 0
+ const val DEFAULT_STYLE = 0
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarState.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarState.kt
index 4191ae2..c460de8 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarState.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarState.kt
@@ -2,28 +2,28 @@ package com.adamkobus.compose.navigation.demo.ui.appbar
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.ArrowBack
+import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Settings
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
-import com.adamkobus.compose.navigation.demo.ui.appbar.AnimatedAppBarDefaults.DefaultStyle
+import com.adamkobus.compose.navigation.demo.ui.appbar.AnimatedAppBarDefaults.DEFAULT_STYLE
import com.adamkobus.compose.navigation.demo.ui.common.R
data class AnimatedAppBarState(
val titleState: AppBarTitleState? = null,
val iconState: AppBarIconState? = null,
val actionsState: List = emptyList(),
- val searchState: AppBarSearchState = AppBarSearchState()
+ val searchState: AppBarSearchState = AppBarSearchState(),
) {
val isAnyContentAvailable: Boolean
get() = titleState != null || iconState != null || actionsState.isNotEmpty() || searchState.isSearchEnabled
}
data class AppBarTitleState(
- val style: Int = DefaultStyle,
+ val style: Int = DEFAULT_STYLE,
@StringRes private val titleResId: Int? = null,
- private val title: String? = null
+ private val title: String? = null,
) {
override fun equals(other: Any?): Boolean {
return other is AppBarTitleState && other.style == style && other.titleResId == titleResId && other.title == title
@@ -46,7 +46,7 @@ class AppBarIconState(
@StringRes val contentDescriptionResId: Int?,
val onClick: (() -> Unit) = {},
val iconId: Int = nextIconId,
- val style: Int = AnimatedAppBarDefaults.DefaultStyle
+ val style: Int = AnimatedAppBarDefaults.DEFAULT_STYLE,
) {
override fun equals(other: Any?): Boolean {
return other is AppBarIconState && other.iconId == iconId
@@ -65,7 +65,11 @@ class AppBarIconState(
}
fun back(onClick: () -> Unit): AppBarIconState =
- AppBarIconState(icon = Icons.Filled.ArrowBack, onClick = onClick, contentDescriptionResId = R.string.accessibility_back)
+ AppBarIconState(
+ icon = Icons.AutoMirrored.Filled.ArrowBack,
+ onClick = onClick,
+ contentDescriptionResId = R.string.accessibility_back,
+ )
}
}
@@ -73,9 +77,8 @@ class AppBarActionState(
val actionId: Int = nextActionId,
val icon: ImageVector,
@StringRes val contentDescriptionResId: Int,
- val onClick: (() -> Unit)
+ val onClick: (() -> Unit),
) {
-
override fun equals(other: Any?): Boolean {
return other is AppBarActionState && other.actionId == actionId
}
@@ -100,5 +103,5 @@ class AppBarActionState(
data class AppBarSearchState(
val isSearchEnabled: Boolean = false,
val currentText: String = "",
- val onQueryChanged: ((String) -> Unit)? = null
+ val onQueryChanged: ((String) -> Unit)? = null,
)
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarVM.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarVM.kt
index 2ea199d..a349725 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarVM.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/appbar/AnimatedAppBarVM.kt
@@ -6,7 +6,7 @@ import javax.inject.Inject
@HiltViewModel
class AnimatedAppBarVM @Inject constructor(
- appBarStateSource: AppBarStateSource
+ appBarStateSource: AppBarStateSource,
) : ViewModel() {
val appBarState = appBarStateSource.appBarState
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModule.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModule.kt
index 45b1d33..f17abdf 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModule.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModule.kt
@@ -10,7 +10,6 @@ import dagger.hilt.components.SingletonComponent
@InstallIn(SingletonComponent::class)
@Module(includes = [NavModuleInternalBinds::class])
object NavModule {
-
@Provides
fun provideNavigationStateSource(): NavigationStateSource = ComposeNavigation.getNavigationStateSource()
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModuleInternalBinds.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModuleInternalBinds.kt
index adea43d..d0b6d8d 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModuleInternalBinds.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/NavModuleInternalBinds.kt
@@ -11,7 +11,6 @@ import dagger.multibindings.IntoSet
@InstallIn(SingletonComponent::class)
@Module
internal interface NavModuleInternalBinds {
-
@Binds
@IntoSet
fun providesStubNavGraphApplier(impl: StubNavGraphApplier): NavGraphApplier
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/UiModule.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/UiModule.kt
index b564a71..dbd6951 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/UiModule.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/di/UiModule.kt
@@ -11,7 +11,6 @@ import dagger.multibindings.IntoSet
@InstallIn(SingletonComponent::class)
@Module
interface UiModule {
-
@Binds
@IntoSet
fun bindsAppBarOverlayProvider(impl: AppBarOverlayProvider): OverlayProvider
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/ext/LifecycleEventExt.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/ext/LifecycleEventExt.kt
index f9e6edc..155218a 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/ext/LifecycleEventExt.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/ext/LifecycleEventExt.kt
@@ -2,7 +2,10 @@ package com.adamkobus.compose.navigation.demo.ui.ext
import androidx.lifecycle.Lifecycle
-fun Lifecycle.Event.onStartStop(onStart: () -> Unit, onStop: () -> Unit) {
+fun Lifecycle.Event.onStartStop(
+ onStart: () -> Unit,
+ onStop: () -> Unit,
+) {
if (this == Lifecycle.Event.ON_START) {
onStart()
} else if (this == Lifecycle.Event.ON_STOP) {
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/loading/LoadingScreen.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/loading/LoadingScreen.kt
index 48a1511..b6a16f4 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/loading/LoadingScreen.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/loading/LoadingScreen.kt
@@ -2,7 +2,7 @@ package com.adamkobus.compose.navigation.demo.ui.loading
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.material.CircularProgressIndicator
+import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/Actions.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/Actions.kt
index 3db647e..a0ffe72 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/Actions.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/Actions.kt
@@ -6,10 +6,11 @@ import com.adamkobus.compose.navigation.action.navActionOptions
sealed class FromSplash(action: NavAction) : NavActionWrapper(action) {
object ToWelcome : FromSplash(
- AppGraph.SplashScreen goTo OnBoardingGraph withOptions navActionOptions {
- popUpTo(AppRootGraph)
- launchSingleTop = true
- }
+ AppGraph.SplashScreen goTo OnBoardingGraph withOptions
+ navActionOptions {
+ popUpTo(AppRootGraph)
+ launchSingleTop = true
+ },
)
}
@@ -19,22 +20,24 @@ sealed class FromWelcome(action: NavAction) : NavActionWrapper(action) {
.setNavOptions {
popUpTo(AppRootGraph)
launchSingleTop = true
- }
+ },
)
object ToDogsList : FromWelcome(
- OnBoardingGraph.WelcomeScreen goTo DogsBrowserGraph withOptions navActionOptions {
- popUpTo(AppRootGraph)
- launchSingleTop = true
- }
+ OnBoardingGraph.WelcomeScreen goTo DogsBrowserGraph withOptions
+ navActionOptions {
+ popUpTo(AppRootGraph)
+ launchSingleTop = true
+ },
)
}
sealed class FromCatsList(action: NavAction) : NavActionWrapper(action) {
class ToCatDetails(catId: Int) : FromCatsList(
- CatsBrowserGraph.CatsList goTo CatsBrowserGraph.CatDetails arg catId withOptions navActionOptions {
- popUpTo(CatsBrowserGraph.CatsList)
- }
+ CatsBrowserGraph.CatsList goTo CatsBrowserGraph.CatDetails arg catId withOptions
+ navActionOptions {
+ popUpTo(CatsBrowserGraph.CatsList)
+ },
)
object ToSettings : FromCatsList(CatsBrowserGraph.CatsList goTo SettingsGraph)
@@ -46,12 +49,15 @@ sealed class FromCatDetails(action: NavAction) : NavActionWrapper(action) {
sealed class FromDogsList(action: NavAction) : NavActionWrapper(action) {
class ToDogDetails(dogId: Int) : FromDogsList(DogsBrowserGraph.DogsList goTo DogsBrowserGraph.DogDetails arg dogId)
+
object ToSettings : FromDogsList(DogsBrowserGraph.DogsList goTo SettingsGraph)
}
sealed class FromDogDetails(action: NavAction) : NavActionWrapper(action) {
object Back : FromDogDetails(DogsBrowserGraph.DogDetails.pop())
+
object ToDemoDialog : FromDogDetails(DogsBrowserGraph.DogDetails goTo DogsBrowserGraph.DemoDialog)
+
class ToGallery(dogId: Int) : FromDogDetails(DogsBrowserGraph.DogDetails goTo DogsBrowserGraph.DogGallery arg dogId)
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/ApplyNavGraphsTask.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/ApplyNavGraphsTask.kt
index 99884f1..06d790a 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/ApplyNavGraphsTask.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/ApplyNavGraphsTask.kt
@@ -5,7 +5,7 @@ import androidx.navigation.NavGraphBuilder
import javax.inject.Inject
class ApplyNavGraphsTask @Inject constructor(
- private val graphs: Set<@JvmSuppressWildcards NavGraphApplier>
+ private val graphs: Set<@JvmSuppressWildcards NavGraphApplier>,
) {
@OptIn(ExperimentalAnimationApi::class)
fun apply(builder: NavGraphBuilder) {
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/CatsBrowserGraph.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/CatsBrowserGraph.kt
index 76ea0f2..c126107 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/CatsBrowserGraph.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/CatsBrowserGraph.kt
@@ -10,9 +10,10 @@ object CatsBrowserGraph : NavGraph("cats") {
override fun startDestination(): ScreenDestination = CatsList
val CatsList = screenDestination("catsList")
- val CatDetails = CatsList.next {
- param(PARAM_CAT_ID)
- }
+ val CatDetails =
+ CatsList.next {
+ param(PARAM_CAT_ID)
+ }
}
fun NavStackEntry.catId() = getInt(CatsBrowserGraph.PARAM_CAT_ID)
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/DogsBrowserGraph.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/DogsBrowserGraph.kt
index c2df379..8f0d707 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/DogsBrowserGraph.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/nav/DogsBrowserGraph.kt
@@ -10,13 +10,15 @@ object DogsBrowserGraph : NavGraph("dogs") {
override fun startDestination(): ScreenDestination = DogsList
val DogsList = screenDestination("dogsList")
- val DogDetails = DogsList.next {
- param(PARAM_DOG_ID)
- }
+ val DogDetails =
+ DogsList.next {
+ param(PARAM_DOG_ID)
+ }
val DemoDialog = dialogDestination("demoDialog")
- val DogGallery = DogDetails.next {
- path("gallery")
- }
+ val DogGallery =
+ DogDetails.next {
+ path("gallery")
+ }
}
fun NavStackEntry.dogId() = getInt(DogsBrowserGraph.PARAM_DOG_ID)
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppBarOverlayProvider.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppBarOverlayProvider.kt
index 7788f78..bce785c 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppBarOverlayProvider.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppBarOverlayProvider.kt
@@ -7,9 +7,10 @@ import javax.inject.Inject
class AppBarOverlayProvider @Inject constructor() : OverlayProvider {
@Composable
- override fun provideOverlay(): @Composable BoxScope.() -> Unit = {
- AnimatedAppBar()
- }
+ override fun provideOverlay(): @Composable BoxScope.() -> Unit =
+ {
+ AnimatedAppBar()
+ }
override val priority: Int
get() = PRIORITY
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppOverlays.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppOverlays.kt
index daa24cc..40fde1b 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppOverlays.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/overlay/AppOverlays.kt
@@ -3,7 +3,7 @@ package com.adamkobus.compose.navigation.demo.ui.overlay
import javax.inject.Inject
class AppOverlays @Inject constructor(
- private val providersSet: Set<@JvmSuppressWildcards OverlayProvider>
+ private val providersSet: Set<@JvmSuppressWildcards OverlayProvider>,
) {
val providers: List
get() = providersSet.sortedBy { it.priority }
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/DemoTheme.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/DemoTheme.kt
index 92560c4..c56a00f 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/DemoTheme.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/DemoTheme.kt
@@ -2,8 +2,8 @@
package com.adamkobus.compose.navigation.demo.ui.theme
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.lightColors
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
@@ -13,21 +13,22 @@ private val Primary = Color(0xFF35B6B6)
private val PrimaryVariant = Color(0xFF5CD1D1)
private val Background = Color(0xFFEEEEEE)
-private val DemoPalette = lightColors(
- primary = Primary,
- primaryVariant = PrimaryVariant,
- onPrimary = Color.Black,
- secondary = Teal200,
- surface = Color.White,
- background = Background
-)
+private val DemoPalette =
+ lightColorScheme(
+ primary = Primary,
+ primaryContainer = PrimaryVariant,
+ onPrimary = Color.Black,
+ secondary = Teal200,
+ surface = Color.White,
+ background = Background,
+ )
@Composable
fun DemoTheme(content: @Composable () -> Unit) {
MaterialTheme(
- colors = DemoPalette,
+ colorScheme = DemoPalette,
typography = Typography,
shapes = Shapes,
- content = content
+ content = content,
)
}
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Shape.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Shape.kt
index b305b42..f266ebd 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Shape.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Shape.kt
@@ -1,11 +1,12 @@
package com.adamkobus.compose.navigation.demo.ui.theme
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.Shapes
+import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp
-internal val Shapes = Shapes(
- small = RoundedCornerShape(4.dp),
- medium = RoundedCornerShape(4.dp),
- large = RoundedCornerShape(0.dp)
-)
+internal val Shapes =
+ Shapes(
+ small = RoundedCornerShape(4.dp),
+ medium = RoundedCornerShape(4.dp),
+ large = RoundedCornerShape(0.dp),
+ )
diff --git a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Type.kt b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Type.kt
index 8c2a957..73e0f2f 100644
--- a/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Type.kt
+++ b/demo-common-ui/src/main/java/com/adamkobus/compose/navigation/demo/ui/theme/Type.kt
@@ -1,20 +1,23 @@
package com.adamkobus.compose.navigation.demo.ui.theme
-import androidx.compose.material.Typography
+import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
-internal val Typography = Typography(
- body1 = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 16.sp
- ),
- h2 = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.SemiBold,
- fontSize = 24.sp
+internal val Typography =
+ Typography(
+ bodyLarge =
+ TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp,
+ ),
+ titleMedium =
+ TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.SemiBold,
+ fontSize = 24.sp,
+ ),
)
-)
diff --git a/demo-core/build.gradle b/demo-core/build.gradle
index 1f1454b..88e35ba 100644
--- a/demo-core/build.gradle
+++ b/demo-core/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -12,16 +11,18 @@ android {
}
dependencies {
- api Lib.AndroidX.Core
- api Lib.AndroidX.Appcompat
- api Lib.Kotlin.Coroutines
+ api libs.androidx.core
+ api libs.androidx.appcompat
+ api libs.kotlin.coroutines
// hilt
- implementation Lib.Google.Hilt
- api Lib.Google.HiltNavigationCompose
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
+
+ // compose
+ api libs.compose.hilt
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
diff --git a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/CatInfo.kt b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/CatInfo.kt
index 5af1f87..575bfd9 100644
--- a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/CatInfo.kt
+++ b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/CatInfo.kt
@@ -2,5 +2,5 @@ package com.adamkobus.compose.navigation.democore.data
data class CatInfo(
val id: Int,
- val name: String
+ val name: String,
)
diff --git a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/DogInfo.kt b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/DogInfo.kt
index 495e137..fb3bc82 100644
--- a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/DogInfo.kt
+++ b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/data/DogInfo.kt
@@ -2,5 +2,5 @@ package com.adamkobus.compose.navigation.democore.data
data class DogInfo(
val id: Int,
- val name: String
+ val name: String,
)
diff --git a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/CatsSource.kt b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/CatsSource.kt
index 12c7c4e..03ce2af 100644
--- a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/CatsSource.kt
+++ b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/CatsSource.kt
@@ -19,15 +19,14 @@ class CatsSource @Inject constructor() {
suspend fun getCat(id: Int): CatInfo {
delay(MOCK_DELAY)
- if (Random.nextBoolean()) {
- return data.value.find { it.id == id } ?: throw IllegalArgumentException("Cat with id $id does not exist")
- } else {
- throw IllegalArgumentException("Failed to load cat info for id $id")
+ val isSuccess = Random.nextBoolean()
+ require(isSuccess) {
+ "Failed to load cat info for id $id"
}
+ return data.value.find { it.id == id } ?: throw IllegalArgumentException("Cat with id $id does not exist")
}
- private fun createData() =
- generateSequence(0) { it + 1 }.take(MOCKED_DATA_SIZE).map { CatInfo(it, "Cat $it") }.toList()
+ private fun createData() = generateSequence(0) { it + 1 }.take(MOCKED_DATA_SIZE).map { CatInfo(it, "Cat $it") }.toList()
companion object {
private const val MOCK_DELAY = 500L
diff --git a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/DogsSource.kt b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/DogsSource.kt
index 855d2b6..9cfe471 100644
--- a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/DogsSource.kt
+++ b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/model/DogsSource.kt
@@ -21,8 +21,7 @@ class DogsSource @Inject constructor() {
return data.value.find { it.id == id } ?: throw IllegalArgumentException("Dog with id $id does not exist")
}
- private fun createData() =
- generateSequence(0) { it + 1 }.take(MOCKED_DATA_SIZE).map { DogInfo(it, "Dog $it") }.toList()
+ private fun createData() = generateSequence(0) { it + 1 }.take(MOCKED_DATA_SIZE).map { DogInfo(it, "Dog $it") }.toList()
companion object {
private const val MOCK_DELAY = 500L
diff --git a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/util/AsyncData.kt b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/util/AsyncData.kt
index 08139b9..da9c586 100644
--- a/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/util/AsyncData.kt
+++ b/demo-core/src/main/java/com/adamkobus/compose/navigation/democore/util/AsyncData.kt
@@ -2,6 +2,8 @@ package com.adamkobus.compose.navigation.democore.util
sealed class AsyncData {
class Loading : AsyncData()
+
class Present(val data: T) : AsyncData()
+
class Missing(val error: E? = null) : AsyncData()
}
diff --git a/demo-devmenu/build.gradle b/demo-devmenu/build.gradle
index d49faf3..7ca1c99 100644
--- a/demo-devmenu/build.gradle
+++ b/demo-devmenu/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -14,14 +13,11 @@ android {
dependencies {
implementation project(':demo-common-ui')
- // compose
- implementation Lib.Accompanist.NavigationAnimation
-
// hilt
- implementation Lib.Google.Hilt
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/di/DevMenuModuleInternalBinds.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/di/DevMenuModuleInternalBinds.kt
index 45963ab..494c28f 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/di/DevMenuModuleInternalBinds.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/di/DevMenuModuleInternalBinds.kt
@@ -14,7 +14,6 @@ import dagger.multibindings.IntoSet
@InstallIn(SingletonComponent::class)
@Module
internal interface DevMenuModuleInternalBinds {
-
@Binds
@IntoSet
fun bindsDevMenuNavIntentResolver(impl: DevMenuNavIntentResolver): NavIntentResolver
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuNavIntentResolver.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuNavIntentResolver.kt
index 716e0b6..2d02f34 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuNavIntentResolver.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuNavIntentResolver.kt
@@ -9,14 +9,20 @@ import com.adamkobus.compose.navigation.intent.ResolveResult
import javax.inject.Inject
internal class DevMenuNavIntentResolver @Inject constructor() : NavIntentResolver {
- override suspend fun resolve(intent: NavIntent, navState: NavState): ResolveResult =
+ override suspend fun resolve(
+ intent: NavIntent,
+ navState: NavState,
+ ): ResolveResult =
when (intent.name) {
DemoIntents.OPEN_DEV_MENU -> openDevMenu(intent, navState)
DemoIntents.CLOSE_DEV_MENU -> closeDevMenu(navState)
else -> ResolveResult.None
}
- private fun openDevMenu(intent: NavIntent, navState: NavState): ResolveResult {
+ private fun openDevMenu(
+ intent: NavIntent,
+ navState: NavState,
+ ): ResolveResult {
if (navState.isInBackStack(DevMenuRootGraph)) return ResolveResult.None
return intent.navigationId?.let {
@@ -24,9 +30,11 @@ internal class DevMenuNavIntentResolver @Inject constructor() : NavIntentResolve
}?.takeIf {
!it.isInBackStack(DevMenuRootGraph)
}?.currentDestination?.destination?.let {
- val action = it goTo DevMenuRootGraph withOptions navActionOptions {
- launchSingleTop = true
- }
+ val action =
+ it goTo DevMenuRootGraph withOptions
+ navActionOptions {
+ launchSingleTop = true
+ }
return action.asResult()
} ?: ResolveResult.None
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuRootGraph.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuRootGraph.kt
index db2cf31..52dfb0b 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuRootGraph.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/DevMenuRootGraph.kt
@@ -8,7 +8,6 @@ import com.adamkobus.compose.navigation.ext.composableDestination
import com.adamkobus.compose.navigation.ext.composableNavigation
internal object DevMenuRootGraph : NavGraph("devMenuRoot") {
-
override fun startDestination() = Root
val Root = screenDestination("root")
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuInfoGraph.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuInfoGraph.kt
index 60266a6..77c2424 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuInfoGraph.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuInfoGraph.kt
@@ -8,7 +8,6 @@ import com.adamkobus.compose.navigation.ext.composableDestination
import com.adamkobus.compose.navigation.ext.composableNavigation
internal object DevMenuInfoGraph : NavGraph("devMenuInfo") {
-
override fun startDestination() = Home
val Home = screenDestination("home")
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuSettingsGraph.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuSettingsGraph.kt
index f362ddd..a368d0d 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuSettingsGraph.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuSettingsGraph.kt
@@ -8,7 +8,6 @@ import com.adamkobus.compose.navigation.ext.composableDestination
import com.adamkobus.compose.navigation.ext.composableNavigation
internal object DevMenuSettingsGraph : NavGraph("devMenuSettings") {
-
override fun startDestination() = Home
val Home = screenDestination("home")
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuTabHostIntentResolver.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuTabHostIntentResolver.kt
index 79159c3..bb34d10 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuTabHostIntentResolver.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/nav/tabhost/DevMenuTabHostIntentResolver.kt
@@ -6,10 +6,11 @@ import com.adamkobus.compose.navigation.demo.devmenu.nav.DevMenuGraph
import javax.inject.Inject
internal class DevMenuTabHostIntentResolver @Inject constructor() : TabBarIntentResolver(
- tabsMapping = mapOf(
+ tabsMapping =
+ mapOf(
DevMenuTabHostIntents.OpenInfo.name to DevMenuInfoGraph,
- DevMenuTabHostIntents.OpenSettings.name to DevMenuSettingsGraph
+ DevMenuTabHostIntents.OpenSettings.name to DevMenuSettingsGraph,
),
tabStateSavingBehaviour = TabStateSavingBehaviour.SAVE_ALL,
- tabsRootGraph = DevMenuGraph
+ tabsRootGraph = DevMenuGraph,
)
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/theme/DevMenuTheme.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/theme/DevMenuTheme.kt
index 0630f2b..06fe833 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/theme/DevMenuTheme.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/theme/DevMenuTheme.kt
@@ -1,10 +1,10 @@
package com.adamkobus.compose.navigation.demo.devmenu.theme
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Shapes
-import androidx.compose.material.Typography
-import androidx.compose.material.darkColors
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Shapes
+import androidx.compose.material3.Typography
+import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
@@ -13,43 +13,48 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-private val DevMenuColors = darkColors(
- primary = Color.DarkGray,
- primaryVariant = Color.DarkGray,
- onPrimary = Color.White,
- secondary = Color.DarkGray,
- onSecondary = Color.White,
- surface = Color.DarkGray,
- onSurface = Color.White,
- background = Color.DarkGray,
- onBackground = Color.White
-)
+private val DevMenuColors =
+ darkColorScheme(
+ primary = Color.DarkGray,
+ primaryContainer = Color.DarkGray,
+ onPrimary = Color.White,
+ secondary = Color.DarkGray,
+ onSecondary = Color.White,
+ surface = Color.DarkGray,
+ onSurface = Color.White,
+ background = Color.DarkGray,
+ onBackground = Color.White,
+ )
-private val Shapes = Shapes(
- small = RoundedCornerShape(4.dp),
- medium = RoundedCornerShape(4.dp),
- large = RoundedCornerShape(0.dp)
-)
+private val Shapes =
+ Shapes(
+ small = RoundedCornerShape(4.dp),
+ medium = RoundedCornerShape(4.dp),
+ large = RoundedCornerShape(0.dp),
+ )
-private val Typography = Typography(
- body1 = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 16.sp
- ),
- h2 = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.SemiBold,
- fontSize = 24.sp
+private val Typography =
+ Typography(
+ bodyLarge =
+ TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp,
+ ),
+ titleMedium =
+ TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.SemiBold,
+ fontSize = 24.sp,
+ ),
)
-)
@Composable
internal fun DevMenuTheme(content: @Composable () -> Unit) {
MaterialTheme(
- colors = DevMenuColors,
+ colorScheme = DevMenuColors,
typography = Typography,
shapes = Shapes,
- content = content
+ content = content,
)
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/DevMenuPaddings.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/DevMenuPaddings.kt
index 17ba502..9f2feab 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/DevMenuPaddings.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/DevMenuPaddings.kt
@@ -7,10 +7,11 @@ internal object DevMenuPaddings {
val Screen = 16.dp
val TabHostSpacing = 64.dp
- val InsetsWithTabHost = PaddingValues(
- start = Screen,
- end = Screen,
- top = Screen,
- bottom = TabHostSpacing
- )
+ val InsetsWithTabHost =
+ PaddingValues(
+ start = Screen,
+ end = Screen,
+ top = Screen,
+ bottom = TabHostSpacing,
+ )
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/info/home/InfoHome.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/info/home/InfoHome.kt
index 441cb4d..bd30ac5 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/info/home/InfoHome.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/info/home/InfoHome.kt
@@ -2,7 +2,7 @@ package com.adamkobus.compose.navigation.demo.devmenu.ui.info.home
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Text
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.adamkobus.compose.navigation.demo.devmenu.ui.DevMenuPaddings
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRoot.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRoot.kt
index 89b0900..9b545ec 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRoot.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRoot.kt
@@ -8,6 +8,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
+import androidx.navigation.compose.rememberNavController
import com.adamkobus.compose.navigation.ComposeNavHost
import com.adamkobus.compose.navigation.demo.devmenu.nav.DevMenuGraph
import com.adamkobus.compose.navigation.demo.devmenu.nav.DevMenuNavId
@@ -16,14 +17,13 @@ import com.adamkobus.compose.navigation.demo.devmenu.theme.DevMenuTheme
import com.adamkobus.compose.navigation.demo.devmenu.ui.tabhost.DevMenuTabHost
import com.adamkobus.compose.navigation.demo.ui.DemoAppBackground
import com.adamkobus.compose.navigation.demo.ui.LifecycleAwareComponent
-import com.google.accompanist.navigation.animation.rememberAnimatedNavController
@OptIn(ExperimentalAnimationApi::class)
@Composable
internal fun DevMenuRoot() {
val vm: DevMenuRootVM = hiltViewModel()
LifecycleAwareComponent(observer = vm)
- val controller = rememberAnimatedNavController()
+ val controller = rememberNavController()
DevMenuRootContent(controller = controller)
BackHandler(onBack = vm.interactions.onBackPressed)
}
@@ -36,14 +36,15 @@ private fun DevMenuRootContent(controller: NavHostController) {
ComposeNavHost(
startGraph = DevMenuGraph,
controller = controller,
- navigationId = DevMenuNavId
+ navigationId = DevMenuNavId,
) {
devMenuGraph()
}
DevMenuTabHost(
- modifier = Modifier
+ modifier =
+ Modifier
.align(Alignment.BottomCenter)
- .fillMaxWidth()
+ .fillMaxWidth(),
)
}
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootInteractions.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootInteractions.kt
index 4fe1116..8f88929 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootInteractions.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.demo.devmenu.ui.root
internal data class DevMenuRootInteractions(
- val onBackPressed: () -> Unit
+ val onBackPressed: () -> Unit,
)
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootVM.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootVM.kt
index 5e43507..4fa6885 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootVM.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/root/DevMenuRootVM.kt
@@ -12,14 +12,14 @@ import javax.inject.Inject
@HiltViewModel
internal class DevMenuRootVM @Inject constructor(
private val appBarStateSource: AppBarStateSource,
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = DevMenuRootInteractions(
- onBackPressed = {
- navigationConsumer.offer(NavIntent(DemoIntents.CLOSE_DEV_MENU))
- }
- )
+ val interactions =
+ DevMenuRootInteractions(
+ onBackPressed = {
+ navigationConsumer.offer(NavIntent(DemoIntents.CLOSE_DEV_MENU))
+ },
+ )
init {
runOnStart {
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHome.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHome.kt
index 324a1c9..5cc9c3b 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHome.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHome.kt
@@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@@ -21,19 +21,18 @@ internal fun SettingsHome() {
}
@Composable
-private fun SettingsHomeContent(
- interactions: SettingsHomeInteractions = SettingsHomeInteractions.STUB
-) {
+private fun SettingsHomeContent(interactions: SettingsHomeInteractions = SettingsHomeInteractions.STUB) {
DemoAppBackground {
Column(modifier = Modifier.padding(DevMenuPaddings.InsetsWithTabHost)) {
Text(
- text = "Button below will invoke intent that will be translated into action that has " +
- "different source and target nav controllers, but action will still succeed"
+ text =
+ "Button below will invoke intent that will be translated into action that has " +
+ "different source and target nav controllers, but action will still succeed",
)
Spacer(modifier = Modifier.height(60.dp))
Button(
onClick = interactions.onRestartAppClicked,
- modifier = Modifier.fillMaxWidth()
+ modifier = Modifier.fillMaxWidth(),
) {
Text(text = "Restart app")
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeInteractions.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeInteractions.kt
index 98369d4..590aeaf 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeInteractions.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeInteractions.kt
@@ -1,11 +1,12 @@
package com.adamkobus.compose.navigation.demo.devmenu.ui.settings.home
internal data class SettingsHomeInteractions(
- val onRestartAppClicked: () -> Unit
+ val onRestartAppClicked: () -> Unit,
) {
companion object {
- val STUB = SettingsHomeInteractions(
- onRestartAppClicked = {}
- )
+ val STUB =
+ SettingsHomeInteractions(
+ onRestartAppClicked = {},
+ )
}
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeVM.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeVM.kt
index 478237d..ecc78f6 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeVM.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/settings/home/SettingsHomeVM.kt
@@ -9,12 +9,12 @@ import javax.inject.Inject
@HiltViewModel
internal class SettingsHomeVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = SettingsHomeInteractions(
- onRestartAppClicked = {
- navigationConsumer.offer(DemoIntents.restartApp(origin = DevMenuSettingsGraph.Home))
- }
- )
+ val interactions =
+ SettingsHomeInteractions(
+ onRestartAppClicked = {
+ navigationConsumer.offer(DemoIntents.restartApp(origin = DevMenuSettingsGraph.Home))
+ },
+ )
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabData.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabData.kt
index 7a4db43..b21085e 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabData.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabData.kt
@@ -5,10 +5,8 @@ import androidx.annotation.StringRes
internal data class DevMenuTabData(
val index: Int,
-
@DrawableRes
val iconResId: Int,
-
@StringRes
- val titleResId: Int
+ val titleResId: Int,
)
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHost.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHost.kt
index f0884a3..718d2ec 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHost.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHost.kt
@@ -3,10 +3,10 @@ package com.adamkobus.compose.navigation.demo.devmenu.ui.tabhost
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.material.Icon
-import androidx.compose.material.LeadingIconTab
-import androidx.compose.material.TabRow
-import androidx.compose.material.Text
+import androidx.compose.material3.Icon
+import androidx.compose.material3.LeadingIconTab
+import androidx.compose.material3.TabRow
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
@@ -29,7 +29,7 @@ internal fun DevMenuTabHost(modifier: Modifier) {
private fun DevMenuTabHostContent(
modifier: Modifier,
state: DevMenuTabHostState = DevMenuTabHostState.stub(),
- interactions: DevMenuTabHostInteractions = DevMenuTabHostInteractions.STUB
+ interactions: DevMenuTabHostInteractions = DevMenuTabHostInteractions.STUB,
) {
Box(modifier = modifier) {
Crossfade(targetState = state.isVisible.value) { renderedIsVisible ->
@@ -47,19 +47,22 @@ private fun EmptyTabHost() {
}
@Composable
-private fun TabHost(state: DevMenuTabHostState, onTabSelected: (DevMenuTabData) -> Unit) {
+private fun TabHost(
+ state: DevMenuTabHostState,
+ onTabSelected: (DevMenuTabData) -> Unit,
+) {
val selectedIndex = state.selectedIndex.value
val items = state.tabs.value
val scope = rememberCoroutineScope()
TabRow(
- selectedTabIndex = selectedIndex
+ selectedTabIndex = selectedIndex,
) {
items.forEachIndexed { index, tab ->
LeadingIconTab(
icon = {
Icon(
painter = painterResource(id = tab.iconResId),
- contentDescription = null
+ contentDescription = null,
)
},
text = {
@@ -70,7 +73,7 @@ private fun TabHost(state: DevMenuTabHostState, onTabSelected: (DevMenuTabData)
scope.launch {
onTabSelected(tab)
}
- }
+ },
)
}
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostInteractions.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostInteractions.kt
index 980a590..a4c4ef0 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostInteractions.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostInteractions.kt
@@ -1,11 +1,12 @@
package com.adamkobus.compose.navigation.demo.devmenu.ui.tabhost
internal data class DevMenuTabHostInteractions(
- val onTabSelected: (DevMenuTabData) -> Unit
+ val onTabSelected: (DevMenuTabData) -> Unit,
) {
companion object {
- val STUB = DevMenuTabHostInteractions(
- onTabSelected = {}
- )
+ val STUB =
+ DevMenuTabHostInteractions(
+ onTabSelected = {},
+ )
}
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostState.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostState.kt
index 3bc163e..5ddf99a 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostState.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostState.kt
@@ -6,20 +6,21 @@ import androidx.compose.runtime.mutableStateOf
internal data class DevMenuTabHostState(
val isVisible: State,
val tabs: State>,
- val selectedIndex: State
+ val selectedIndex: State,
) {
companion object {
fun stub(
isVisible: Boolean = true,
- tabs: List = listOf(
- DevMenuTabs.Info,
- DevMenuTabs.Settings
- ),
- selectedIndex: Int = 0
+ tabs: List =
+ listOf(
+ DevMenuTabs.Info,
+ DevMenuTabs.Settings,
+ ),
+ selectedIndex: Int = 0,
) = DevMenuTabHostState(
isVisible = mutableStateOf(isVisible),
tabs = mutableStateOf(tabs),
- selectedIndex = mutableStateOf(selectedIndex)
+ selectedIndex = mutableStateOf(selectedIndex),
)
}
}
diff --git a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostVM.kt b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostVM.kt
index a4fd3b4..838e6d2 100644
--- a/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostVM.kt
+++ b/demo-devmenu/src/main/java/com/adamkobus/compose/navigation/demo/devmenu/ui/tabhost/DevMenuTabHostVM.kt
@@ -15,28 +15,30 @@ import javax.inject.Inject
@HiltViewModel
internal class DevMenuTabHostVM @Inject constructor(
private val navigationStateSource: NavigationStateSource,
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
private val isVisible = mutableStateOf(false)
private val selectedIndex = mutableStateOf(0)
- private val tabs = mutableStateOf(
- listOf(
- DevMenuTabs.Info,
- DevMenuTabs.Settings
+ private val tabs =
+ mutableStateOf(
+ listOf(
+ DevMenuTabs.Info,
+ DevMenuTabs.Settings,
+ ),
+ )
+ val state =
+ DevMenuTabHostState(
+ tabs = tabs,
+ isVisible = isVisible,
+ selectedIndex = selectedIndex,
)
- )
- val state = DevMenuTabHostState(
- tabs = tabs,
- isVisible = isVisible,
- selectedIndex = selectedIndex
- )
- val interactions = DevMenuTabHostInteractions(
- onTabSelected = {
- processTabSelection(it)
- }
- )
+ val interactions =
+ DevMenuTabHostInteractions(
+ onTabSelected = {
+ processTabSelection(it)
+ },
+ )
init {
runOnStart {
diff --git a/demo-ui-cats-browser/build.gradle b/demo-ui-cats-browser/build.gradle
index 642b254..d9e99e3 100644
--- a/demo-ui-cats-browser/build.gradle
+++ b/demo-ui-cats-browser/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -15,10 +14,10 @@ dependencies {
implementation project(':demo-common-ui')
// hilt
- implementation Lib.Google.Hilt
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
diff --git a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreen.kt b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreen.kt
index 42c1f52..96b9040 100644
--- a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreen.kt
+++ b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreen.kt
@@ -6,8 +6,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -46,13 +46,14 @@ private fun CatDetailsScreenContent(screenState: CatDetailsScreenState) {
@Composable
private fun CatDetails(catInfo: CatInfo) {
Column(modifier = Modifier.padding(Paddings.Screen)) {
- Text(text = catInfo.name, style = MaterialTheme.typography.h2)
+ Text(text = catInfo.name, style = MaterialTheme.typography.titleMedium)
Spacer(modifier = Modifier.height(24.dp))
val currentDestination = LocalNavDestination.current
val isCatDetails = currentDestination == CatsBrowserGraph.CatDetails
Text(
- text = "Current destination: $currentDestination\n" +
- "isCatDetailsDestination: $isCatDetails"
+ text =
+ "Current destination: $currentDestination\n" +
+ "isCatDetailsDestination: $isCatDetails",
)
}
}
@@ -60,10 +61,11 @@ private fun CatDetails(catInfo: CatInfo) {
@Composable
private fun CatError() {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .padding(Paddings.Screen)
+ .padding(Paddings.Screen),
) {
- Text(text = stringResource(id = R.string.cat_details_error), style = MaterialTheme.typography.h2, color = Color.Red)
+ Text(text = stringResource(id = R.string.cat_details_error), style = MaterialTheme.typography.titleMedium, color = Color.Red)
}
}
diff --git a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenState.kt b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenState.kt
index c28fccd..031b1b8 100644
--- a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenState.kt
+++ b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenState.kt
@@ -5,5 +5,5 @@ import com.adamkobus.compose.navigation.democore.data.CatInfo
import com.adamkobus.compose.navigation.democore.util.AsyncData
data class CatDetailsScreenState(
- val catInfo: State>
+ val catInfo: State>,
)
diff --git a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenVM.kt b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenVM.kt
index a16fe3b..b75f319 100644
--- a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenVM.kt
+++ b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catdetails/CatDetailsScreenVM.kt
@@ -22,20 +22,21 @@ import javax.inject.Inject
class CatDetailsScreenVM @Inject constructor(
private val catsSource: CatsSource,
private val navigationConsumer: NavigationConsumer,
- private val appBarStateSource: AppBarStateSource
+ private val appBarStateSource: AppBarStateSource,
) : LifecycleAwareViewModel() {
-
val catIdParam = ViewParam()
private val catInfo = mutableStateOf>(AsyncData.Loading())
- val screenState = CatDetailsScreenState(
- catInfo = catInfo
- )
+ val screenState =
+ CatDetailsScreenState(
+ catInfo = catInfo,
+ )
- private val appBarState = AnimatedAppBarState(
- titleState = AppBarTitleState(titleResId = R.string.cat_details_title),
- iconState = AppBarIconState.back { onBackPressed() }
- )
+ private val appBarState =
+ AnimatedAppBarState(
+ titleState = AppBarTitleState(titleResId = R.string.cat_details_title),
+ iconState = AppBarIconState.back { onBackPressed() },
+ )
private fun onBackPressed() {
navigationConsumer.offer(CatsBrowserGraph.CatDetails.pop())
diff --git a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListInteractions.kt b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListInteractions.kt
index da4964b..9d1c224 100644
--- a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListInteractions.kt
+++ b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListInteractions.kt
@@ -3,5 +3,5 @@ package com.adamkobus.compose.navigation.demo.ui.catslist
import com.adamkobus.compose.navigation.democore.data.CatInfo
data class CatsListInteractions(
- val onCatListItemSelected: (CatInfo) -> Unit = {}
+ val onCatListItemSelected: (CatInfo) -> Unit = {},
)
diff --git a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreen.kt b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreen.kt
index 70b0c9f..fb3501e 100644
--- a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreen.kt
+++ b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreen.kt
@@ -8,8 +8,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
-import androidx.compose.material.Card
-import androidx.compose.material.Text
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@@ -32,7 +33,7 @@ fun CatsListScreen() {
@Composable
private fun CatsListScreenContent(
state: CatsListScreenState,
- interactions: CatsListInteractions
+ interactions: CatsListInteractions,
) {
when (state.isLoading.value) {
true -> LoadingScreen()
@@ -43,13 +44,13 @@ private fun CatsListScreenContent(
@Composable
private fun CatsListContent(
state: CatsListScreenState,
- onCatListItemSelected: (CatInfo) -> Unit
+ onCatListItemSelected: (CatInfo) -> Unit,
) {
val data = state.catsList.value
LazyColumn(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(10.dp),
- contentPadding = Paddings.ScreenWithTabHostInsets
+ contentPadding = Paddings.ScreenWithTabHostInsets,
) {
items(data, key = { it.id }) { catInfo ->
CatListItem(catInfo = catInfo, onCatListItemSelected)
@@ -58,14 +59,18 @@ private fun CatsListContent(
}
@Composable
-private fun CatListItem(catInfo: CatInfo, onCatListItemSelected: (CatInfo) -> Unit) {
+private fun CatListItem(
+ catInfo: CatInfo,
+ onCatListItemSelected: (CatInfo) -> Unit,
+) {
Card(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
.clickable {
onCatListItemSelected(catInfo)
},
- elevation = 4.dp
+ elevation = CardDefaults.elevatedCardElevation(),
) {
Column(modifier = Modifier.padding(Paddings.CardPadding)) {
Text(text = catInfo.name)
diff --git a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenState.kt b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenState.kt
index e3ed205..a0bd287 100644
--- a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenState.kt
+++ b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenState.kt
@@ -5,5 +5,5 @@ import com.adamkobus.compose.navigation.democore.data.CatInfo
data class CatsListScreenState(
val isLoading: State,
- val catsList: State>
+ val catsList: State>,
)
diff --git a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenVM.kt b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenVM.kt
index b0389bd..dfe72f8 100644
--- a/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenVM.kt
+++ b/demo-ui-cats-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/catslist/CatsListScreenVM.kt
@@ -20,31 +20,34 @@ import javax.inject.Inject
class CatsListScreenVM @Inject constructor(
private val navigationConsumer: NavigationConsumer,
private val appBarStateSource: AppBarStateSource,
- private val catsSource: CatsSource
+ private val catsSource: CatsSource,
) : LifecycleAwareViewModel() {
-
private val isLoading = mutableStateOf(true)
private val catsList = mutableStateOf>(emptyList())
- val screenState = CatsListScreenState(
- isLoading = isLoading,
- catsList = catsList
- )
+ val screenState =
+ CatsListScreenState(
+ isLoading = isLoading,
+ catsList = catsList,
+ )
- val interactions = CatsListInteractions(
- onCatListItemSelected = {
- navigationConsumer.offer(FromCatsList.ToCatDetails(it.id))
- }
- )
+ val interactions =
+ CatsListInteractions(
+ onCatListItemSelected = {
+ navigationConsumer.offer(FromCatsList.ToCatDetails(it.id))
+ },
+ )
- private val settingsAction = AppBarActionState.settings {
- viewModelScope.launch {
- navigationConsumer.offer(FromCatsList.ToSettings)
+ private val settingsAction =
+ AppBarActionState.settings {
+ viewModelScope.launch {
+ navigationConsumer.offer(FromCatsList.ToSettings)
+ }
}
- }
- private val appBarState = AnimatedAppBarState(
- titleState = AppBarTitleState(titleResId = R.string.cats_list_title),
- actionsState = listOf(settingsAction)
- )
+ private val appBarState =
+ AnimatedAppBarState(
+ titleState = AppBarTitleState(titleResId = R.string.cats_list_title),
+ actionsState = listOf(settingsAction),
+ )
init {
runOnStart {
diff --git a/demo-ui-dogs-browser/build.gradle b/demo-ui-dogs-browser/build.gradle
index c394161..208bd71 100644
--- a/demo-ui-dogs-browser/build.gradle
+++ b/demo-ui-dogs-browser/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -15,10 +14,10 @@ dependencies {
implementation project(':demo-common-ui')
// hilt
- implementation Lib.Google.Hilt
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialog.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialog.kt
index 79c3f79..da8df42 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialog.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialog.kt
@@ -7,9 +7,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
-import androidx.compose.material.Button
-import androidx.compose.material.Card
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Card
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -31,7 +31,7 @@ fun DemoDialog() {
private fun DemoDialogContent(onCancelClicked: () -> Unit) {
Box(
modifier = Modifier.padding(vertical = Paddings.Screen),
- contentAlignment = Alignment.Center
+ contentAlignment = Alignment.Center,
) {
Card(modifier = Modifier.widthIn(0.dp, 350.dp)) {
DialogCardContent(onCancelClicked)
@@ -42,9 +42,10 @@ private fun DemoDialogContent(onCancelClicked: () -> Unit) {
@Composable
private fun DialogCardContent(onCancelClicked: () -> Unit) {
Column(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
- .padding(Paddings.Screen)
+ .padding(Paddings.Screen),
) {
Text(text = stringResource(id = R.string.demo_dialog_text))
Spacer(modifier = Modifier.height(24.dp))
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogInteractions.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogInteractions.kt
index 64f7c05..88c952a 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogInteractions.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.demo.ui.demodialog
data class DemoDialogInteractions(
- val onCancelClicked: () -> Unit = {}
+ val onCancelClicked: () -> Unit = {},
)
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogVM.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogVM.kt
index e4be3b9..2f2ab94 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogVM.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/demodialog/DemoDialogVM.kt
@@ -10,14 +10,14 @@ import javax.inject.Inject
@HiltViewModel
class DemoDialogVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : ViewModel() {
-
- val interactions = DemoDialogInteractions(
- onCancelClicked = {
- viewModelScope.launch {
- navigationConsumer.offer(FromDemoDialog.Dismiss)
- }
- }
- )
+ val interactions =
+ DemoDialogInteractions(
+ onCancelClicked = {
+ viewModelScope.launch {
+ navigationConsumer.offer(FromDemoDialog.Dismiss)
+ }
+ },
+ )
}
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreen.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreen.kt
index 5c1a403..2f58b02 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreen.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreen.kt
@@ -7,9 +7,9 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -35,7 +35,7 @@ fun DogDetailsScreen(dogId: Int) {
@Composable
private fun DogDetailsScreenContent(
screenState: DogDetailsScreenState,
- interactions: DogDetailsScreenInteractions
+ interactions: DogDetailsScreenInteractions,
) {
DemoAppBackground(usesTopBar = true) {
when (val dogInfo = screenState.dogInfo.value) {
@@ -47,9 +47,12 @@ private fun DogDetailsScreenContent(
}
@Composable
-private fun DogDetails(dogInfo: DogInfo, interactions: DogDetailsScreenInteractions) {
+private fun DogDetails(
+ dogInfo: DogInfo,
+ interactions: DogDetailsScreenInteractions,
+) {
Column(modifier = Modifier.padding(Paddings.Screen)) {
- Text(text = dogInfo.name, style = MaterialTheme.typography.h2)
+ Text(text = dogInfo.name, style = MaterialTheme.typography.titleMedium)
Spacer(modifier = Modifier.height(60.dp))
Button(onClick = interactions.onOpenDialogClicked, modifier = Modifier.fillMaxWidth()) {
Text(text = stringResource(id = R.string.dog_details_open_dialog_button))
@@ -64,10 +67,11 @@ private fun DogDetails(dogInfo: DogInfo, interactions: DogDetailsScreenInteracti
@Composable
private fun DogError() {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .padding(Paddings.Screen)
+ .padding(Paddings.Screen),
) {
- Text(text = stringResource(id = R.string.dog_details_error), style = MaterialTheme.typography.h2, color = Color.Red)
+ Text(text = stringResource(id = R.string.dog_details_error), style = MaterialTheme.typography.titleMedium, color = Color.Red)
}
}
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenInteractions.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenInteractions.kt
index 4b7998c..1231740 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenInteractions.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenInteractions.kt
@@ -2,5 +2,5 @@ package com.adamkobus.compose.navigation.demo.ui.dogdetails
data class DogDetailsScreenInteractions(
val onOpenDialogClicked: () -> Unit = {},
- val onOpenGalleryClicked: () -> Unit = {}
+ val onOpenGalleryClicked: () -> Unit = {},
)
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenState.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenState.kt
index 7c0e469..9d1b335 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenState.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenState.kt
@@ -5,5 +5,5 @@ import com.adamkobus.compose.navigation.democore.data.DogInfo
import com.adamkobus.compose.navigation.democore.util.AsyncData
data class DogDetailsScreenState(
- val dogInfo: State>
+ val dogInfo: State>,
)
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenVM.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenVM.kt
index 8ac7985..426fafc 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenVM.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogdetails/DogDetailsScreenVM.kt
@@ -24,34 +24,36 @@ import javax.inject.Inject
class DogDetailsScreenVM @Inject constructor(
private val dogsSource: DogsSource,
private val appBarStateSource: AppBarStateSource,
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
val dogIdParam = ViewParam()
private val dogInfo = mutableStateOf>(AsyncData.Loading())
- val screenState = DogDetailsScreenState(
- dogInfo = dogInfo
- )
+ val screenState =
+ DogDetailsScreenState(
+ dogInfo = dogInfo,
+ )
- val interactions = DogDetailsScreenInteractions(
- onOpenDialogClicked = {
- viewModelScope.launch {
- navigationConsumer.offer(FromDogDetails.ToDemoDialog)
- }
- },
- onOpenGalleryClicked = {
- viewModelScope.launch {
- val id = dogIdParam.observe().first()
- navigationConsumer.offer(FromDogDetails.ToGallery(id))
- }
- }
- )
+ val interactions =
+ DogDetailsScreenInteractions(
+ onOpenDialogClicked = {
+ viewModelScope.launch {
+ navigationConsumer.offer(FromDogDetails.ToDemoDialog)
+ }
+ },
+ onOpenGalleryClicked = {
+ viewModelScope.launch {
+ val id = dogIdParam.observe().first()
+ navigationConsumer.offer(FromDogDetails.ToGallery(id))
+ }
+ },
+ )
- private val appBarState = AnimatedAppBarState(
- titleState = AppBarTitleState(titleResId = R.string.dog_details_title),
- iconState = AppBarIconState.back { onBackPressed() }
- )
+ private val appBarState =
+ AnimatedAppBarState(
+ titleState = AppBarTitleState(titleResId = R.string.dog_details_title),
+ iconState = AppBarIconState.back { onBackPressed() },
+ )
private fun onBackPressed() {
navigationConsumer.offer(DogsBrowserGraph.DogDetails.pop())
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreen.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreen.kt
index eb417ce..e3fd13d 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreen.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreen.kt
@@ -3,8 +3,8 @@ package com.adamkobus.compose.navigation.demo.ui.doggallery
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -33,9 +33,10 @@ private fun DogGalleryScreenContent(interactions: DogGalleryScreenInteractions)
@Composable
fun InnerContent(interactions: DogGalleryScreenInteractions) {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .padding(Paddings.ScreenWithTabHostInsets)
+ .padding(Paddings.ScreenWithTabHostInsets),
) {
Button(onClick = interactions.onBackToListClicked, modifier = Modifier.align(Alignment.BottomCenter)) {
Text(text = stringResource(id = R.string.dog_gallery_back_to_list_button))
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenInteractions.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenInteractions.kt
index 3e97817..f07d4c2 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenInteractions.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.demo.ui.doggallery
data class DogGalleryScreenInteractions(
- val onBackToListClicked: () -> Unit
+ val onBackToListClicked: () -> Unit,
)
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenVM.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenVM.kt
index 4338044..8d93c80 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenVM.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/doggallery/DogGalleryScreenVM.kt
@@ -18,21 +18,22 @@ import javax.inject.Inject
@HiltViewModel
class DogGalleryScreenVM @Inject constructor(
private val navigationConsumer: NavigationConsumer,
- private val topBarState: AppBarStateSource
+ private val topBarState: AppBarStateSource,
) : LifecycleAwareViewModel() {
-
val dogId = ViewParam()
- private val appBarState = AnimatedAppBarState(
- titleState = AppBarTitleState(titleResId = R.string.dog_gallery_title),
- iconState = AppBarIconState.back { onBackPressed() }
- )
+ private val appBarState =
+ AnimatedAppBarState(
+ titleState = AppBarTitleState(titleResId = R.string.dog_gallery_title),
+ iconState = AppBarIconState.back { onBackPressed() },
+ )
- val interactions = DogGalleryScreenInteractions(
- onBackToListClicked = {
- navigationConsumer.offer(FromDogsGallery.ToList)
- }
- )
+ val interactions =
+ DogGalleryScreenInteractions(
+ onBackToListClicked = {
+ navigationConsumer.offer(FromDogsGallery.ToList)
+ },
+ )
init {
runOnStart {
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListInteractions.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListInteractions.kt
index dda19f5..7ba9fe6 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListInteractions.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListInteractions.kt
@@ -3,5 +3,5 @@ package com.adamkobus.compose.navigation.demo.ui.dogslist
import com.adamkobus.compose.navigation.democore.data.DogInfo
data class DogsListInteractions(
- val onDogsItemSelected: (DogInfo) -> Unit = {}
+ val onDogsItemSelected: (DogInfo) -> Unit = {},
)
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreen.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreen.kt
index 04a93f3..257d9a4 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreen.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreen.kt
@@ -8,8 +8,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
-import androidx.compose.material.Card
-import androidx.compose.material.Text
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@@ -33,7 +34,7 @@ fun DogsListScreen() {
@Composable
private fun DogsListScreenContent(
state: DogsListScreenState,
- interactions: DogsListInteractions
+ interactions: DogsListInteractions,
) {
when (state.isLoading.value) {
true -> LoadingScreen()
@@ -42,12 +43,15 @@ private fun DogsListScreenContent(
}
@Composable
-private fun DogsListContent(state: DogsListScreenState, onDogsItemSelected: (DogInfo) -> Unit) {
+private fun DogsListContent(
+ state: DogsListScreenState,
+ onDogsItemSelected: (DogInfo) -> Unit,
+) {
val data = state.dogsList.value
LazyColumn(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(10.dp),
- contentPadding = Paddings.ScreenWithTabHostInsets
+ contentPadding = Paddings.ScreenWithTabHostInsets,
) {
items(data, key = { it.id }) { dogInfo ->
DogListItem(dogInfo = dogInfo, onDogsItemSelected)
@@ -56,14 +60,18 @@ private fun DogsListContent(state: DogsListScreenState, onDogsItemSelected: (Dog
}
@Composable
-private fun DogListItem(dogInfo: DogInfo, onDogsItemSelected: (DogInfo) -> Unit) {
+private fun DogListItem(
+ dogInfo: DogInfo,
+ onDogsItemSelected: (DogInfo) -> Unit,
+) {
Card(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
.clickable {
onDogsItemSelected(dogInfo)
},
- elevation = Elevation.AppBar
+ elevation = CardDefaults.elevatedCardElevation(Elevation.AppBar),
) {
Column(modifier = Modifier.padding(Paddings.CardPadding)) {
Text(text = dogInfo.name)
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenState.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenState.kt
index 4c40fff..010c563 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenState.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenState.kt
@@ -5,5 +5,5 @@ import com.adamkobus.compose.navigation.democore.data.DogInfo
data class DogsListScreenState(
val isLoading: State,
- val dogsList: State>
+ val dogsList: State>,
)
diff --git a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenVM.kt b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenVM.kt
index df9fc78..5efb787 100644
--- a/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenVM.kt
+++ b/demo-ui-dogs-browser/src/main/java/com/adamkobus/compose/navigation/demo/ui/dogslist/DogsListScreenVM.kt
@@ -20,34 +20,37 @@ import javax.inject.Inject
class DogsListScreenVM @Inject constructor(
private val navigationConsumer: NavigationConsumer,
private val appBarStateSource: AppBarStateSource,
- private val dogsSource: DogsSource
+ private val dogsSource: DogsSource,
) : LifecycleAwareViewModel() {
-
private val isLoading = mutableStateOf(true)
private val dogsList = mutableStateOf>(emptyList())
- val screenState = DogsListScreenState(
- isLoading = isLoading,
- dogsList = dogsList
- )
+ val screenState =
+ DogsListScreenState(
+ isLoading = isLoading,
+ dogsList = dogsList,
+ )
+
+ val interactions =
+ DogsListInteractions(
+ onDogsItemSelected = {
+ viewModelScope.launch {
+ navigationConsumer.offer(FromDogsList.ToDogDetails(it.id))
+ }
+ },
+ )
- val interactions = DogsListInteractions(
- onDogsItemSelected = {
+ private val settingsAction =
+ AppBarActionState.settings {
viewModelScope.launch {
- navigationConsumer.offer(FromDogsList.ToDogDetails(it.id))
+ navigationConsumer.offer(FromDogsList.ToSettings)
}
}
- )
-
- private val settingsAction = AppBarActionState.settings {
- viewModelScope.launch {
- navigationConsumer.offer(FromDogsList.ToSettings)
- }
- }
- private val appBarState = AnimatedAppBarState(
- titleState = AppBarTitleState(titleResId = R.string.dogs_list_title),
- actionsState = listOf(settingsAction)
- )
+ private val appBarState =
+ AnimatedAppBarState(
+ titleState = AppBarTitleState(titleResId = R.string.dogs_list_title),
+ actionsState = listOf(settingsAction),
+ )
init {
runOnStart {
diff --git a/demo-ui-on-boarding/build.gradle b/demo-ui-on-boarding/build.gradle
index 2f81219..e02a81d 100644
--- a/demo-ui-on-boarding/build.gradle
+++ b/demo-ui-on-boarding/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -15,10 +14,10 @@ dependencies {
implementation project(':demo-common-ui')
// hilt
- implementation Lib.Google.Hilt
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
diff --git a/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreen.kt b/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreen.kt
index a8215f4..49bf8fe 100644
--- a/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreen.kt
+++ b/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreen.kt
@@ -7,9 +7,9 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -33,17 +33,18 @@ fun WelcomeScreen() {
fun WelcomeScreenContent(interactions: WelcomeScreenInteractions) {
DemoAppBackground {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.padding(Paddings.Screen)
.fillMaxSize(),
- contentAlignment = Alignment.Center
+ contentAlignment = Alignment.Center,
) {
Column {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.welcome_hi),
textAlign = TextAlign.Center,
- style = MaterialTheme.typography.h2
+ style = MaterialTheme.typography.titleMedium,
)
Spacer(modifier = Modifier.height(90.dp))
WelcomeScreenButton(stringResource(id = R.string.welcome_button_cats), onClick = interactions.onCatsSelected)
@@ -55,7 +56,10 @@ fun WelcomeScreenContent(interactions: WelcomeScreenInteractions) {
}
@Composable
-private fun WelcomeScreenButton(text: String, onClick: () -> Unit) {
+private fun WelcomeScreenButton(
+ text: String,
+ onClick: () -> Unit,
+) {
Button(modifier = Modifier.fillMaxWidth(), onClick = onClick) {
Text(text = text)
}
diff --git a/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenInteractions.kt b/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenInteractions.kt
index 10d79cd..9b1a6e9 100644
--- a/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenInteractions.kt
+++ b/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenInteractions.kt
@@ -2,5 +2,5 @@ package com.adamkobus.compose.navigation.demo.ui.welcome
data class WelcomeScreenInteractions(
val onDogsSelected: () -> Unit = {},
- val onCatsSelected: () -> Unit = {}
+ val onCatsSelected: () -> Unit = {},
)
diff --git a/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenVM.kt b/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenVM.kt
index ee413c6..c8d076b 100644
--- a/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenVM.kt
+++ b/demo-ui-on-boarding/src/main/java/com/adamkobus/compose/navigation/demo/ui/welcome/WelcomeScreenVM.kt
@@ -11,17 +11,17 @@ import javax.inject.Inject
@HiltViewModel
class WelcomeScreenVM @Inject constructor(
private val navigationConsumer: NavigationConsumer,
- private val appBarStateSource: AppBarStateSource
+ private val appBarStateSource: AppBarStateSource,
) : LifecycleAwareViewModel() {
-
- val interactions = WelcomeScreenInteractions(
- onDogsSelected = {
- navigationConsumer.offer(FromWelcome.ToDogsList)
- },
- onCatsSelected = {
- navigationConsumer.offer(FromWelcome.ToCatsList)
- }
- )
+ val interactions =
+ WelcomeScreenInteractions(
+ onDogsSelected = {
+ navigationConsumer.offer(FromWelcome.ToDogsList)
+ },
+ onCatsSelected = {
+ navigationConsumer.offer(FromWelcome.ToCatsList)
+ },
+ )
private val appBatState = AnimatedAppBarState()
diff --git a/demo-ui-settings/build.gradle b/demo-ui-settings/build.gradle
index 2f38baa..03a318b 100644
--- a/demo-ui-settings/build.gradle
+++ b/demo-ui-settings/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.library'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -15,10 +14,10 @@ dependencies {
implementation project(':demo-common-ui')
// hilt
- implementation Lib.Google.Hilt
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
diff --git a/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/HomeScreenVM.kt b/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/HomeScreenVM.kt
index b20f69b..22995e3 100644
--- a/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/HomeScreenVM.kt
+++ b/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/HomeScreenVM.kt
@@ -14,13 +14,13 @@ import javax.inject.Inject
@HiltViewModel
internal class HomeScreenVM @Inject constructor(
private val navigationConsumer: NavigationConsumer,
- private val appBarStateSource: AppBarStateSource
+ private val appBarStateSource: AppBarStateSource,
) : LifecycleAwareViewModel() {
-
- private val appBarState = AnimatedAppBarState(
- titleState = AppBarTitleState(titleResId = R.string.settings_title),
- iconState = AppBarIconState.back { onBackClicked() }
- )
+ private val appBarState =
+ AnimatedAppBarState(
+ titleState = AppBarTitleState(titleResId = R.string.settings_title),
+ iconState = AppBarIconState.back { onBackClicked() },
+ )
init {
runOnStart {
diff --git a/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/SettingsHomeScreen.kt b/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/SettingsHomeScreen.kt
index 7e15a9e..8e437d0 100644
--- a/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/SettingsHomeScreen.kt
+++ b/demo-ui-settings/src/main/java/com/adamkobus/compose/navigation/demo/settings/ui/home/SettingsHomeScreen.kt
@@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@@ -29,11 +29,12 @@ internal fun SettingsHomeScreen() {
@Composable
fun HomeScreenContent() {
Column(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .padding(Paddings.Screen)
+ .padding(Paddings.Screen),
) {
- Text(text = stringResource(id = R.string.settings_title), style = MaterialTheme.typography.h5)
+ Text(text = stringResource(id = R.string.settings_title), style = MaterialTheme.typography.titleSmall)
Spacer(modifier = Modifier.height(30.dp))
Text(text = stringResource(id = R.string.settings_dev_menu_info))
}
diff --git a/demo/build.gradle b/demo/build.gradle
index 6ddb6f0..e97acc8 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.application'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -25,16 +24,13 @@ dependencies {
debugImplementation project(':demo-devmenu')
- implementation Lib.Google.Material
+ implementation libs.compose.material3
// hilt
- implementation Lib.Google.Hilt
- kapt Lib.Google.HiltCompiler
-
- // compose
- implementation Lib.Accompanist.NavigationAnimation
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// testing
- testImplementation Lib.Test.JUnit
- testImplementation Lib.Test.Mockk
+ testImplementation libs.test.junit
+ testImplementation libs.test.mockk
}
\ No newline at end of file
diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml
index 84b31ec..e5bbe53 100644
--- a/demo/src/main/AndroidManifest.xml
+++ b/demo/src/main/AndroidManifest.xml
@@ -13,7 +13,7 @@
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
- android:theme="@style/Theme.ComposeNavigation.NoActionBar">
+ android:theme="@style/Theme.ComposeNavigation">
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/app/DemoApp.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/app/DemoApp.kt
index e51f35f..1c2b31c 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/app/DemoApp.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/app/DemoApp.kt
@@ -10,7 +10,6 @@ import javax.inject.Inject
@HiltAndroidApp
class DemoApp : Application() {
-
@Inject
lateinit var intentResolvers: Set<@JvmSuppressWildcards NavIntentResolver>
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/AppModuleBinds.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/AppModuleBinds.kt
index de5fca1..14c8b99 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/AppModuleBinds.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/AppModuleBinds.kt
@@ -17,7 +17,6 @@ import dagger.multibindings.IntoSet
@InstallIn(SingletonComponent::class)
@Module
interface AppModuleBinds {
-
@Binds
@IntoSet
fun bindsAppNavActionVerifier(impl: AppNavActionVerifier): NavActionVerifier
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/NavigationModule.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/NavigationModule.kt
index 39713a9..a9b029a 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/NavigationModule.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/di/NavigationModule.kt
@@ -10,7 +10,6 @@ import dagger.hilt.components.SingletonComponent
@InstallIn(SingletonComponent::class)
@Module
object NavigationModule {
-
@Provides
fun providesNavigationConsumer(): NavigationConsumer = ComposeNavigation.getNavigationConsumer()
}
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/AppNavActionVerifier.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/AppNavActionVerifier.kt
index b7927f1..d553705 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/AppNavActionVerifier.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/AppNavActionVerifier.kt
@@ -7,7 +7,10 @@ import com.adamkobus.compose.navigation.destination.GlobalGraph
import com.adamkobus.compose.navigation.destination.NavState
object AppNavActionVerifier : NavActionVerifier {
- override fun isNavActionAllowed(navState: NavState, action: NavAction): VerifyResult {
+ override fun isNavActionAllowed(
+ navState: NavState,
+ action: NavAction,
+ ): VerifyResult {
if (action.fromDestination.graph == GlobalGraph) return VerifyResult.Allow
return if (navState.isCurrent(action.fromDestination)) {
VerifyResult.Allow
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/RestartAppNavIntentResolver.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/RestartAppNavIntentResolver.kt
index 6e10414..814ff01 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/RestartAppNavIntentResolver.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/RestartAppNavIntentResolver.kt
@@ -10,11 +10,15 @@ import com.adamkobus.compose.navigation.intent.ResolveResult
import javax.inject.Inject
class RestartAppNavIntentResolver @Inject constructor() : NavIntentResolver {
- override suspend fun resolve(intent: NavIntent, navState: NavState): ResolveResult =
+ override suspend fun resolve(
+ intent: NavIntent,
+ navState: NavState,
+ ): ResolveResult =
intent.takeIf { it.name == DemoIntents.RESTART_APP }?.origin?.let {
- val action = it.goTo(AppGraph.SplashScreen).setNavOptions {
- popUpTo(AppRootGraph)
- }
+ val action =
+ it.goTo(AppGraph.SplashScreen).setNavOptions {
+ popUpTo(AppRootGraph)
+ }
action.asResult()
} ?: ResolveResult.None
}
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/tabhost/DemoTabBarIntentResolver.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/tabhost/DemoTabBarIntentResolver.kt
index 848f56d..bea0fe6 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/tabhost/DemoTabBarIntentResolver.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/nav/tabhost/DemoTabBarIntentResolver.kt
@@ -11,8 +11,8 @@ import javax.inject.Inject
class DemoTabBarIntentResolver @Inject constructor() : TabBarIntentResolver(
mapOf(
DemoIntents.OpenDogsBrowser.name to DogsBrowserGraph,
- DemoIntents.OpenCatsBrowser.name to CatsBrowserGraph
+ DemoIntents.OpenCatsBrowser.name to CatsBrowserGraph,
),
AppRootGraph,
- tabStateSavingBehaviour = TabStateSavingBehaviour.SAVE_START_DESTINATION
+ tabStateSavingBehaviour = TabStateSavingBehaviour.SAVE_START_DESTINATION,
)
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/DevMenuLauncherOverlayProvider.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/DevMenuLauncherOverlayProvider.kt
index 665c3d8..86c07de 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/DevMenuLauncherOverlayProvider.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/DevMenuLauncherOverlayProvider.kt
@@ -18,11 +18,11 @@ import com.adamkobus.compose.navigation.intent.NavIntent
import javax.inject.Inject
class DevMenuLauncherOverlayProvider @Inject constructor() : OverlayProvider {
-
@Composable
- override fun provideOverlay(): @Composable BoxScope.() -> Unit = {
- Launcher()
- }
+ override fun provideOverlay(): @Composable BoxScope.() -> Unit =
+ {
+ Launcher()
+ }
override val priority: Int
get() = PRIORITY
@@ -35,7 +35,8 @@ class DevMenuLauncherOverlayProvider @Inject constructor() : OverlayProvider {
@Composable
private fun BoxScope.Launcher() {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.height(56.dp)
.fillMaxWidth(LAUNCHER_WIDTH_FACTOR)
.align(Alignment.TopCenter)
@@ -45,9 +46,9 @@ private fun BoxScope.Launcher() {
ComposeNavigation
.getNavigationConsumer()
.offer(NavIntent(DemoIntents.OPEN_DEV_MENU, navigationId = DemoNavigationId))
- }
+ },
)
- }
+ },
)
}
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRoot.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRoot.kt
index a1539c2..af56ded 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRoot.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRoot.kt
@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
+import androidx.navigation.compose.rememberNavController
import com.adamkobus.compose.navigation.ComposeNavHost
import com.adamkobus.compose.navigation.demo.nav.appGraph
import com.adamkobus.compose.navigation.demo.nav.onBoardingGraph
@@ -16,19 +17,18 @@ import com.adamkobus.compose.navigation.demo.ui.nav.AppRootGraph
import com.adamkobus.compose.navigation.demo.ui.nav.DemoNavigationId
import com.adamkobus.compose.navigation.demo.ui.overlay.AppOverlays
import com.adamkobus.compose.navigation.ext.composableNavigation
-import com.google.accompanist.navigation.animation.rememberAnimatedNavController
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun DemoAppRoot() {
val vm = hiltViewModel()
- val controller = rememberAnimatedNavController()
+ val controller = rememberNavController()
Box(modifier = Modifier.fillMaxSize()) {
ComposeNavHost(
startGraph = AppRootGraph,
controller = controller,
navigationId = DemoNavigationId,
- modifier = Modifier.fillMaxSize()
+ modifier = Modifier.fillMaxSize(),
) {
composableNavigation(AppRootGraph) {
appGraph()
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRootVM.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRootVM.kt
index dee7697..29905ab 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRootVM.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/app/DemoAppRootVM.kt
@@ -9,5 +9,5 @@ import javax.inject.Inject
@HiltViewModel
class DemoAppRootVM @Inject constructor(
val overlays: AppOverlays,
- val applyNavGraphsTask: ApplyNavGraphsTask
+ val applyNavGraphsTask: ApplyNavGraphsTask,
) : ViewModel()
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/splash/SplashScreenVM.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/splash/SplashScreenVM.kt
index e359e45..a588a2f 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/splash/SplashScreenVM.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/splash/SplashScreenVM.kt
@@ -15,9 +15,8 @@ import javax.inject.Inject
@HiltViewModel
class SplashScreenVM @Inject constructor(
private val navigationConsumer: NavigationConsumer,
- private val appBarStateSource: AppBarStateSource
+ private val appBarStateSource: AppBarStateSource,
) : LifecycleAwareViewModel() {
-
private val appBarState = AnimatedAppBarState()
init {
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabData.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabData.kt
index 1521ad2..0655221 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabData.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabData.kt
@@ -7,7 +7,6 @@ data class DemoTabData(
val index: Int,
@DrawableRes
val iconResId: Int,
-
@StringRes
- val titleResId: Int
+ val titleResId: Int,
)
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsInteractions.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsInteractions.kt
index f86759b..736c46b 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsInteractions.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.demo.ui.tabhost
data class DemoTabsInteractions(
- val onTabSelected: (DemoTabData) -> Unit
+ val onTabSelected: (DemoTabData) -> Unit,
)
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigation.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigation.kt
index 4a10df5..61175b2 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigation.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigation.kt
@@ -3,10 +3,10 @@ package com.adamkobus.compose.navigation.demo.ui.tabhost
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.material.Icon
-import androidx.compose.material.LeadingIconTab
-import androidx.compose.material.TabRow
-import androidx.compose.material.Text
+import androidx.compose.material3.Icon
+import androidx.compose.material3.LeadingIconTab
+import androidx.compose.material3.TabRow
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
@@ -25,7 +25,7 @@ fun DemoTabsNavigation(modifier: Modifier = Modifier) {
DemoTabsNavigationContent(
state,
interactions = interactions,
- modifier = modifier
+ modifier = modifier,
)
}
@@ -33,7 +33,7 @@ fun DemoTabsNavigation(modifier: Modifier = Modifier) {
private fun DemoTabsNavigationContent(
state: DemoTabsNavigationState,
interactions: DemoTabsInteractions,
- modifier: Modifier = Modifier
+ modifier: Modifier = Modifier,
) {
Box(modifier = modifier) {
Crossfade(targetState = state.tabHostType.value) { renderedState ->
@@ -51,17 +51,20 @@ fun EmptyTabHost() {
}
@Composable
-fun AnimalsTabHost(state: AnimalsTabHostState, onTabSelected: (DemoTabData) -> Unit) {
+fun AnimalsTabHost(
+ state: AnimalsTabHostState,
+ onTabSelected: (DemoTabData) -> Unit,
+) {
val scope = rememberCoroutineScope()
TabRow(
- selectedTabIndex = state.selectedIndex
+ selectedTabIndex = state.selectedIndex,
) {
state.items.forEachIndexed { index, tab ->
LeadingIconTab(
icon = {
Icon(
painter = painterResource(id = tab.iconResId),
- contentDescription = null
+ contentDescription = null,
)
},
text = {
@@ -72,7 +75,7 @@ fun AnimalsTabHost(state: AnimalsTabHostState, onTabSelected: (DemoTabData) -> U
scope.launch {
onTabSelected(tab)
}
- }
+ },
)
}
}
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationOverlayProvider.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationOverlayProvider.kt
index f2250c1..efe9168 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationOverlayProvider.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationOverlayProvider.kt
@@ -8,11 +8,11 @@ import com.adamkobus.compose.navigation.demo.ui.overlay.OverlayProvider
import javax.inject.Inject
class DemoTabsNavigationOverlayProvider @Inject constructor() : OverlayProvider {
-
@Composable
- override fun provideOverlay(): @Composable BoxScope.() -> Unit = {
- DemoTabsNavigation(modifier = Modifier.align(Alignment.BottomCenter))
- }
+ override fun provideOverlay(): @Composable BoxScope.() -> Unit =
+ {
+ DemoTabsNavigation(modifier = Modifier.align(Alignment.BottomCenter))
+ }
override val priority: Int = PRIORITY
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationState.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationState.kt
index a21117c..cf470dd 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationState.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationState.kt
@@ -4,15 +4,15 @@ import androidx.compose.runtime.State
data class DemoTabsNavigationState(
val tabHostType: State,
- val animalsTabHostState: State
+ val animalsTabHostState: State,
)
data class AnimalsTabHostState(
val items: List,
- val selectedIndex: Int
+ val selectedIndex: Int,
)
enum class TabHostType {
NONE,
- ANIMALS
+ ANIMALS,
}
diff --git a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationVM.kt b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationVM.kt
index 08278df..f8e181f 100644
--- a/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationVM.kt
+++ b/demo/src/main/java/com/adamkobus/compose/navigation/demo/ui/tabhost/DemoTabsNavigationVM.kt
@@ -17,32 +17,35 @@ import javax.inject.Inject
@HiltViewModel
class DemoTabsNavigationVM @Inject constructor(
private val navigationStateSource: NavigationStateSource,
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
private val currentTabHostType = mutableStateOf(TabHostType.NONE)
- private val animalsTabHostState = mutableStateOf(
- AnimalsTabHostState(
- items = listOf(
- DemoTabs.Dogs,
- DemoTabs.Cats
- ).sortedBy { it.index },
- selectedIndex = 0
+ private val animalsTabHostState =
+ mutableStateOf(
+ AnimalsTabHostState(
+ items =
+ listOf(
+ DemoTabs.Dogs,
+ DemoTabs.Cats,
+ ).sortedBy { it.index },
+ selectedIndex = 0,
+ ),
)
- )
- val screenState = DemoTabsNavigationState(
- tabHostType = currentTabHostType,
- animalsTabHostState = animalsTabHostState
- )
+ val screenState =
+ DemoTabsNavigationState(
+ tabHostType = currentTabHostType,
+ animalsTabHostState = animalsTabHostState,
+ )
- val interactions = DemoTabsInteractions(
- onTabSelected = {
- viewModelScope.launch {
- processTabSelection(it)
- }
- }
- )
+ val interactions =
+ DemoTabsInteractions(
+ onTabSelected = {
+ viewModelScope.launch {
+ processTabSelection(it)
+ }
+ },
+ )
init {
runOnStart {
@@ -86,11 +89,12 @@ class DemoTabsNavigationVM @Inject constructor(
companion object {
private val CATS_DESTINATIONS = listOf(CatsBrowserGraph.CatsList, CatsBrowserGraph.CatDetails)
- private val DOGS_DESTINATIONS = listOf(
- DogsBrowserGraph.DogDetails,
- DogsBrowserGraph.DogsList,
- DogsBrowserGraph.DemoDialog,
- DogsBrowserGraph.DogGallery
- )
+ private val DOGS_DESTINATIONS =
+ listOf(
+ DogsBrowserGraph.DogDetails,
+ DogsBrowserGraph.DogsList,
+ DogsBrowserGraph.DemoDialog,
+ DogsBrowserGraph.DogGallery,
+ )
}
}
diff --git a/demo/src/main/res/values/themes.xml b/demo/src/main/res/values/themes.xml
index 148d817..a66c519 100644
--- a/demo/src/main/res/values/themes.xml
+++ b/demo/src/main/res/values/themes.xml
@@ -1,25 +1,4 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
diff --git a/detekt/config/custom.yml b/detekt/config/custom.yml
index bb7c5d1..67d4a08 100644
--- a/detekt/config/custom.yml
+++ b/detekt/config/custom.yml
@@ -16,7 +16,7 @@ style:
ReturnCount:
active: true
max: 3
- excludedFunctions: 'equals'
+ excludedFunctions: ['equals']
excludeLabeled: false
excludeReturnFromLambda: true
excludeGuardClauses: false
diff --git a/detekt/config/default.yml b/detekt/config/default.yml
index 6f3a520..3e738fc 100644
--- a/detekt/config/default.yml
+++ b/detekt/config/default.yml
@@ -2,14 +2,15 @@ build:
maxIssues: 0
excludeCorrectable: false
weights:
- # complexity: 2
- # LongParameterList: 1
- # style: 1
- # comments: 1
+ # complexity: 2
+ # LongParameterList: 1
+ # style: 1
+ # comments: 1
config:
validation: true
warningsAsErrors: false
+ checkExhaustiveness: false
# when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]'
excludes: ''
@@ -33,11 +34,11 @@ processors:
console-reports:
active: true
exclude:
- - 'ProjectStatisticsReport'
- - 'ComplexityReport'
- - 'NotificationReport'
- - 'FindingsReport'
- - 'FileBasedFindingsReport'
+ - 'ProjectStatisticsReport'
+ - 'ComplexityReport'
+ - 'NotificationReport'
+ - 'FindingsReport'
+ - 'FileBasedFindingsReport'
# - 'LiteFindingsReport'
output-reports:
@@ -47,6 +48,7 @@ output-reports:
# - 'XmlOutputReport'
# - 'HtmlOutputReport'
# - 'MdOutputReport'
+ # - 'SarifOutputReport'
comments:
active: true
@@ -65,7 +67,7 @@ comments:
endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)'
KDocReferencesNonPublicProperty:
active: false
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
OutdatedDocumentation:
active: false
matchTypeParameters: true
@@ -73,20 +75,26 @@ comments:
allowParamOnConstructorProperties: false
UndocumentedPublicClass:
active: false
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
searchInNestedClass: true
searchInInnerClass: true
searchInInnerObject: true
searchInInnerInterface: true
+ searchInProtectedClass: false
UndocumentedPublicFunction:
active: false
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
+ searchProtectedFunction: false
UndocumentedPublicProperty:
active: false
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
+ searchProtectedProperty: false
complexity:
active: true
+ CognitiveComplexMethod:
+ active: false
+ threshold: 15
ComplexCondition:
active: true
threshold: 4
@@ -95,7 +103,8 @@ complexity:
threshold: 10
includeStaticDeclarations: false
includePrivateDeclarations: false
- ComplexMethod:
+ ignoreOverloaded: false
+ CyclomaticComplexMethod:
active: true
threshold: 15
ignoreSingleWhenExpression: false
@@ -150,14 +159,14 @@ complexity:
active: false
StringLiteralDuplication:
active: false
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
threshold: 3
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
TooManyFunctions:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInInterfaces: 11
@@ -166,6 +175,7 @@ complexity:
ignoreDeprecated: false
ignorePrivate: false
ignoreOverridden: false
+ ignoreAnnotatedFunctions: []
coroutines:
active: true
@@ -181,6 +191,8 @@ coroutines:
active: true
SleepInsteadOfDelay:
active: true
+ SuspendFunSwallowedCancellation:
+ active: false
SuspendFunWithCoroutineScopeReceiver:
active: false
SuspendFunWithFlowReturnType:
@@ -232,7 +244,7 @@ exceptions:
- 'toString'
InstanceOfCheckForException:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
NotImplementedDeclaration:
active: false
ObjectExtendsThrowable:
@@ -258,7 +270,7 @@ exceptions:
active: false
ThrowingExceptionsWithoutMessageOrCause:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
exceptions:
- 'ArrayIndexOutOfBoundsException'
- 'Exception'
@@ -273,7 +285,7 @@ exceptions:
active: true
TooGenericExceptionCaught:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
exceptionNames:
- 'ArrayIndexOutOfBoundsException'
- 'Error'
@@ -297,7 +309,6 @@ naming:
BooleanPropertyNaming:
active: false
allowedPattern: '^(is|has|are)'
- ignoreOverridden: true
ClassNaming:
active: true
classPattern: '[A-Z][a-zA-Z0-9]*'
@@ -306,7 +317,6 @@ naming:
parameterPattern: '[a-z][A-Za-z0-9]*'
privateParameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
- ignoreOverridden: true
EnumNaming:
active: true
enumEntryPattern: '[A-Z][_a-zA-Z0-9]*'
@@ -321,15 +331,13 @@ naming:
minimumFunctionNameLength: 3
FunctionNaming:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '[a-z][a-zA-Z0-9]*'
excludeClassPattern: '$^'
- ignoreOverridden: true
FunctionParameterNaming:
active: true
parameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
- ignoreOverridden: true
InvalidPackageDeclaration:
active: true
rootPackage: ''
@@ -371,7 +379,6 @@ naming:
variablePattern: '[a-z][A-Za-z0-9]*'
privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
- ignoreOverridden: true
performance:
active: true
@@ -382,10 +389,12 @@ performance:
threshold: 3
ForEachOnRange:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
SpreadOperator:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
+ UnnecessaryPartOfBinaryExpression:
+ active: false
UnnecessaryTemporaryInstantiation:
active: true
@@ -395,6 +404,8 @@ potential-bugs:
active: true
forbiddenTypePatterns:
- 'kotlin.String'
+ CastNullableToNonNullableType:
+ active: false
CastToNullableType:
active: false
Deprecation:
@@ -412,10 +423,9 @@ potential-bugs:
- 'java.util.HashSet'
- 'java.util.LinkedHashMap'
- 'java.util.HashMap'
- DuplicateCaseInWhenExpression:
- active: true
ElseCaseInsteadOfExhaustiveWhen:
active: false
+ ignoredSubjectTypes: []
EqualsAlwaysReturnsTrueOrFalse:
active: true
EqualsWithHashCodeExist:
@@ -428,12 +438,19 @@ potential-bugs:
active: true
IgnoredReturnValue:
active: true
- restrictToAnnotatedMethods: true
+ restrictToConfig: true
returnValueAnnotations:
+ - 'CheckResult'
- '*.CheckResult'
+ - 'CheckReturnValue'
- '*.CheckReturnValue'
ignoreReturnValueAnnotations:
+ - 'CanIgnoreReturnValue'
- '*.CanIgnoreReturnValue'
+ returnValueTypes:
+ - 'kotlin.sequences.Sequence'
+ - 'kotlinx.coroutines.flow.*Flow'
+ - 'java.util.stream.*Stream'
ignoreFunctionCall: []
ImplicitDefaultLocale:
active: true
@@ -448,24 +465,23 @@ potential-bugs:
active: true
LateinitUsage:
active: false
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
ignoreOnClassesPattern: ''
MapGetWithNotNullAssertionOperator:
active: true
MissingPackageDeclaration:
active: false
excludes: ['**/*.kts']
- MissingWhenCase:
- active: true
- allowElseExpression: true
NullCheckOnMutableProperty:
active: false
NullableToStringCall:
active: false
- RedundantElseInWhen:
- active: true
+ PropertyUsedBeforeDeclaration:
+ active: false
UnconditionalJumpStatementInLoop:
active: false
+ UnnecessaryNotNullCheck:
+ active: false
UnnecessaryNotNullOperator:
active: true
UnnecessarySafeCall:
@@ -476,7 +492,7 @@ potential-bugs:
active: true
UnsafeCallOnNullableType:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
UnsafeCast:
active: true
UnusedUnaryOperator:
@@ -488,6 +504,16 @@ potential-bugs:
style:
active: true
+ AlsoCouldBeApply:
+ active: false
+ BracesOnIfStatements:
+ active: false
+ singleLine: 'never'
+ multiLine: 'always'
+ BracesOnWhenStatements:
+ active: false
+ singleLine: 'necessary'
+ multiLine: 'consistent'
CanBeNonNullable:
active: false
CascadingCallWrapping:
@@ -499,12 +525,24 @@ style:
active: false
DataClassContainsFunctions:
active: false
- conversionFunctionPrefix: 'to'
+ conversionFunctionPrefix:
+ - 'to'
+ allowOperators: false
DataClassShouldBeImmutable:
active: false
DestructuringDeclarationWithTooManyEntries:
active: true
maxDestructuringEntries: 3
+ DoubleNegativeLambda:
+ active: false
+ negativeFunctions:
+ - reason: 'Use `takeIf` instead.'
+ value: 'takeUnless'
+ - reason: 'Use `all` instead.'
+ value: 'none'
+ negativeFunctionNameParts:
+ - 'not'
+ - 'non'
EqualsNullCall:
active: true
EqualsOnSignatureLine:
@@ -516,14 +554,33 @@ style:
ExpressionBodySyntax:
active: false
includeLineWrapping: false
+ ForbiddenAnnotation:
+ active: false
+ annotations:
+ - reason: 'it is a java annotation. Use `Suppress` instead.'
+ value: 'java.lang.SuppressWarnings'
+ - reason: 'it is a java annotation. Use `kotlin.Deprecated` instead.'
+ value: 'java.lang.Deprecated'
+ - reason: 'it is a java annotation. Use `kotlin.annotation.MustBeDocumented` instead.'
+ value: 'java.lang.annotation.Documented'
+ - reason: 'it is a java annotation. Use `kotlin.annotation.Target` instead.'
+ value: 'java.lang.annotation.Target'
+ - reason: 'it is a java annotation. Use `kotlin.annotation.Retention` instead.'
+ value: 'java.lang.annotation.Retention'
+ - reason: 'it is a java annotation. Use `kotlin.annotation.Repeatable` instead.'
+ value: 'java.lang.annotation.Repeatable'
+ - reason: 'Kotlin does not support @Inherited annotation, see https://youtrack.jetbrains.com/issue/KT-22265'
+ value: 'java.lang.annotation.Inherited'
ForbiddenComment:
active: true
- values:
- - 'FIXME:'
- - 'STOPSHIP:'
- - 'TODO:'
+ comments:
+ - reason: 'Forbidden FIXME todo marker in comment, please fix the problem.'
+ value: 'FIXME:'
+ - reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.'
+ value: 'STOPSHIP:'
+ - reason: 'Forbidden TODO todo marker in comment, please do the changes.'
+ value: 'TODO:'
allowedPatterns: ''
- customMessage: ''
ForbiddenImport:
active: false
imports: []
@@ -531,14 +588,10 @@ style:
ForbiddenMethodCall:
active: false
methods:
- - 'kotlin.io.print'
- - 'kotlin.io.println'
- ForbiddenPublicDataClass:
- active: true
- excludes: ['**']
- ignorePackages:
- - '*.internal'
- - '*.internal.*'
+ - reason: 'print does not allow you to configure the output stream. Use a logger instead.'
+ value: 'kotlin.io.print'
+ - reason: 'println does not allow you to configure the output stream. Use a logger instead.'
+ value: 'kotlin.io.println'
ForbiddenSuppress:
active: false
rules: []
@@ -550,19 +603,13 @@ style:
active: true
ignoreOverridableFunction: true
ignoreActualFunction: true
- excludedFunctions: ''
- LibraryCodeMustSpecifyReturnType:
- active: true
- excludes: ['**']
- LibraryEntitiesShouldNotBePublic:
- active: true
- excludes: ['**']
+ excludedFunctions: []
LoopWithTooManyJumpStatements:
active: true
maxJumpCount: 1
MagicNumber:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts']
+ excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts']
ignoreNumbers:
- '-1'
- '0'
@@ -578,8 +625,6 @@ style:
ignoreEnums: false
ignoreRanges: false
ignoreExtensionFunctions: true
- MandatoryBracesIfStatements:
- active: false
MandatoryBracesLoops:
active: false
MaxChainedCallsOnSameLine:
@@ -591,12 +636,19 @@ style:
excludePackageStatements: true
excludeImportStatements: true
excludeCommentStatements: false
+ excludeRawStrings: true
MayBeConst:
active: true
ModifierOrder:
active: true
MultilineLambdaItParameter:
active: false
+ MultilineRawStringIndentation:
+ active: false
+ indentSize: 4
+ trimmingMethods:
+ - 'trimIndent'
+ - 'trimMargin'
NestedClassesVisibility:
active: true
NewLineAtEndOfFile:
@@ -611,8 +663,6 @@ style:
active: true
OptionalUnit:
active: false
- OptionalWhenBraces:
- active: false
PreferToOverPairSyntax:
active: false
ProtectedMemberInFinalClass:
@@ -626,7 +676,8 @@ style:
ReturnCount:
active: true
max: 2
- excludedFunctions: 'equals'
+ excludedFunctions:
+ - 'equals'
excludeLabeled: false
excludeReturnFromLambda: true
excludeGuardClauses: false
@@ -636,12 +687,21 @@ style:
active: true
SpacingBetweenPackageAndImports:
active: false
+ StringShouldBeRawString:
+ active: false
+ maxEscapedCharacterCount: 2
+ ignoredCharacters: []
ThrowsCount:
active: true
max: 2
excludeGuardClauses: false
TrailingWhitespace:
active: false
+ TrimMultilineRawString:
+ active: false
+ trimmingMethods:
+ - 'trimIndent'
+ - 'trimMargin'
UnderscoresInNumericLiterals:
active: false
acceptableLength: 4
@@ -654,6 +714,8 @@ style:
active: true
UnnecessaryBackticks:
active: false
+ UnnecessaryBracesAroundTrailingLambda:
+ active: false
UnnecessaryFilter:
active: true
UnnecessaryInheritance:
@@ -664,15 +726,22 @@ style:
active: false
UnnecessaryParentheses:
active: false
+ allowForUnclearPrecedence: false
UntilInsteadOfRangeTo:
active: false
UnusedImports:
active: false
+ UnusedParameter:
+ active: true
+ allowedNames: 'ignored|expected'
UnusedPrivateClass:
active: true
UnusedPrivateMember:
active: true
- allowedNames: '(_|ignored|expected|serialVersionUID)'
+ allowedNames: ''
+ UnusedPrivateProperty:
+ active: true
+ allowedNames: '_|ignored|expected|serialVersionUID'
UseAnyOrNoneInsteadOfFind:
active: true
UseArrayLiteralsInAnnotations:
@@ -690,14 +759,19 @@ style:
active: false
UseIfInsteadOfWhen:
active: false
+ ignoreWhenContainingVariableDeclaration: false
UseIsNullOrEmpty:
active: true
+ UseLet:
+ active: false
UseOrEmpty:
active: true
UseRequire:
active: true
UseRequireNotNull:
active: true
+ UseSumOfInsteadOfFlatMapSize:
+ active: false
UselessCallOnNotNull:
active: true
UtilityClassWithPublicConstructor:
@@ -707,6 +781,5 @@ style:
ignoreLateinitVar: false
WildcardImport:
active: true
- excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludeImports:
- 'java.util.*'
diff --git a/docs/tutorial/02_first_graph.md b/docs/tutorial/02_first_graph.md
index f6a6645..51c3d66 100644
--- a/docs/tutorial/02_first_graph.md
+++ b/docs/tutorial/02_first_graph.md
@@ -7,8 +7,8 @@ We will start by creating a `WelcomeScreen` composable and its `ViewModel` in `.
> `.ui.welcome.WelcomeScreen.kt`
```kotlin
import androidx.compose.foundation.layout.*
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
diff --git a/docs/tutorial/03_navigation_basics.md b/docs/tutorial/03_navigation_basics.md
index c988d4c..e34389e 100644
--- a/docs/tutorial/03_navigation_basics.md
+++ b/docs/tutorial/03_navigation_basics.md
@@ -10,9 +10,9 @@ Let's start by declaring two addictional screens:
> `.ui.image.ImageScreen.kt`:
```kotlin
import androidx.compose.foundation.layout.*
-import androidx.compose.material.*
-import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.ThumbUp
+import androidx.compose.material3.*
+import androidx.compose.material3.icons.Icons
+import androidx.compose.material3.icons.filled.ThumbUp
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -37,8 +37,8 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
-import androidx.compose.material.Card
-import androidx.compose.material.Text
+import androidx.compose.material3.Card
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
diff --git a/docs/tutorial/05_using_navigation_arguments.md b/docs/tutorial/05_using_navigation_arguments.md
index fefde4f..2397885 100644
--- a/docs/tutorial/05_using_navigation_arguments.md
+++ b/docs/tutorial/05_using_navigation_arguments.md
@@ -12,7 +12,7 @@ Let's start by creating new screen in `.ui.detail` package:
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.*
+import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
diff --git a/docs/tutorial/06_back_navigation.md b/docs/tutorial/06_back_navigation.md
index 4ccc353..88b842b 100644
--- a/docs/tutorial/06_back_navigation.md
+++ b/docs/tutorial/06_back_navigation.md
@@ -9,10 +9,10 @@ on `Detail` destination when the button is clicked:
> `.ui.detailscreen.DetailScreen.kt`
```kotlin
// added imports
-import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.ArrowBack
-import androidx.compose.material.Icon
-import androidx.compose.material.IconButton
+import androidx.compose.material3.icons.Icons
+import androidx.compose.material3.icons.filled.ArrowBack
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.ViewModel
import com.adamkobus.compose.navigation.NavigationConsumer
diff --git a/docs/tutorial/07_displaying_dialog.md b/docs/tutorial/07_displaying_dialog.md
index 4d88374..b7414d4 100644
--- a/docs/tutorial/07_displaying_dialog.md
+++ b/docs/tutorial/07_displaying_dialog.md
@@ -6,7 +6,7 @@ First let's define a dialog in `DetailScreen.kt`:
> `.ui.detail.DetailScreen.kt`
```kotlin
-import androidx.compose.material.Card
+import androidx.compose.material3.Card
@Composable
fun DetailScreenDialog(itemId: Int) {
diff --git a/gradle/android-setup.gradle b/gradle/android-setup.gradle
index 0927c98..2771ccf 100644
--- a/gradle/android-setup.gradle
+++ b/gradle/android-setup.gradle
@@ -1,5 +1,3 @@
-import com.adamkobus.compose.navigation.Lib
-
def commitIndex = "git rev-list HEAD --count".execute().text.trim()
def versionSuffix = rootProject.properties.getOrDefault("versionSuffix", "")
@@ -24,11 +22,11 @@ subprojects { subproject ->
def configureAndroidProject(Project androidProject, boolean isApplication) {
androidProject.android {
- compileSdkVersion 33
+ compileSdkVersion 35
defaultConfig {
minSdkVersion 26
- targetSdkVersion 33
+ targetSdkVersion 35
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
if (isApplication) {
@@ -65,9 +63,6 @@ def configureAndroidProject(Project androidProject, boolean isApplication) {
buildFeatures {
compose true
}
- composeOptions {
- kotlinCompilerExtensionVersion Lib.COMPOSE_COMPILER_VERSION
- }
packagingOptions {
resources {
diff --git a/gradle/dependency-updates.gradle b/gradle/dependency-updates.gradle
deleted file mode 100644
index 91303d8..0000000
--- a/gradle/dependency-updates.gradle
+++ /dev/null
@@ -1,13 +0,0 @@
-def isNonStable = { String version ->
- def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
- def regex = /^[0-9,.v-]+(-r)?$/
- return !stableKeyword && !(version ==~ regex)
-}
-
-tasks.named("dependencyUpdates").configure {
- rejectVersionIf {
- isNonStable(it.candidate.version)
- }
-
- gradleReleaseChannel = "current"
-}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 0000000..54f4c48
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,53 @@
+[versions]
+agp = "8.7.2"
+kotlin = "2.0.0"
+coreKtx = "1.15.0"
+dokka = "1.8.10"
+accompanist = "0.34.0"
+hilt = "2.52"
+ktlint = "0.49.1"
+kotlin-coroutines = "1.7.3"
+
+[libraries]
+# compose
+compose-bom = { module = "androidx.compose:compose-bom", version = "2024.11.00" }
+compose-ui = { module = "androidx.compose.ui:ui" }
+compose-material = { module = "androidx.compose.material:material" }
+compose-material3 = { module = "androidx.compose.material3:material3" }
+compose-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
+compose-tooling-ui = { module = "androidx.compose.ui:ui-tooling" }
+compose-activity = { module = "androidx.activity:activity-compose", version = "1.9.3" }
+compose-vm-lifecycle = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version = "2.8.7" }
+compose-hilt = { module = "androidx.hilt:hilt-navigation-compose", version = "1.2.0" }
+
+# androidx
+androidx-core = { module = "androidx.core:core-ktx", version = "1.15.0" }
+androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.0" }
+androidx-composenavigation = { module = "androidx.navigation:navigation-compose", version = "2.8.4" }
+
+# kotlin
+kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlin-coroutines" }
+
+# personal libraries
+ak-lifecycle-vm = { module = "com.adamkobus:lifecycle-observer-viewmodel-ktx", version = "1.0.2" }
+
+# hilt
+google-hilt-core = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
+google-hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
+
+# tests
+test-junit = { module = "junit:junit", version = "4.13.2" }
+test-mockk = { module = "io.mockk:mockk", version = "1.13.5" }
+test-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlin-coroutines" }
+
+[plugins]
+android-application = { id = "com.android.application", version.ref = "agp" }
+android-library = { id = "com.android.library", version.ref = "agp" }
+kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
+kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
+kotlin-ksp = { id = "com.google.devtools.ksp", version = "2.0.0-1.0.22" }
+nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
+dokka = { id = "org.jetbrains.dokka", version = "2.0.0-Beta" }
+detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.23.7" }
+hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
+ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.1.2" }
diff --git a/gradle/version.gradle b/gradle/version.gradle
index db3136e..37e4656 100644
--- a/gradle/version.gradle
+++ b/gradle/version.gradle
@@ -1,4 +1,4 @@
-def VERSION_BASE = "0.3.4"
+def VERSION_BASE = "1.0.0"
rootProject.readParam("mavenSnapshot", true)
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e708b1c..2c35211 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index fe73d9b..09523c0 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
-#Wed May 24 18:20:29 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 4f906e0..f5feea6 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
#
-# Copyright 2015 the original author or authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,69 +15,104 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -87,9 +122,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,88 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=`expr $i + 1`
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 107acd3..9d21a21 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -13,8 +13,10 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
-@if "%DEBUG%" == "" @echo off
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +27,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
+if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
+if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/poc-multiple-nav-hosts/build.gradle b/poc-multiple-nav-hosts/build.gradle
index 254df3a..2bc2ba8 100644
--- a/poc-multiple-nav-hosts/build.gradle
+++ b/poc-multiple-nav-hosts/build.gradle
@@ -1,10 +1,9 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.application'
- id 'kotlin-android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
+ alias(libs.plugins.kotlin.compose)
}
android {
@@ -17,21 +16,21 @@ android {
dependencies {
implementation project(':composenav')
- implementation Lib.AndroidX.Core
- implementation Lib.AndroidX.Appcompat
- implementation Lib.Kotlin.Coroutines
- implementation Lib.AdamKobus.LifecycleAwareViewModel
+ implementation libs.androidx.core
+ implementation libs.androidx.appcompat
+ implementation libs.kotlin.coroutines
+ implementation libs.ak.lifecycle.vm
// hilt
- implementation Lib.Google.Hilt
- implementation Lib.Google.HiltNavigationCompose
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// compose
- implementation Lib.Compose.Ui
- implementation Lib.Compose.Activity
- implementation Lib.Compose.Material
- implementation Lib.Compose.ToolingPreview
- debugImplementation Lib.Compose.UiTooling
- implementation Lib.Accompanist.NavigationAnimation
-}
\ No newline at end of file
+ implementation platform(libs.compose.bom)
+ implementation libs.compose.ui
+ implementation libs.compose.activity
+ implementation libs.compose.material3
+ implementation libs.compose.tooling.preview
+ implementation libs.compose.hilt
+ debugImplementation libs.compose.tooling.ui
+}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/PocApplication.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/PocApplication.kt
index d6f3cce..dcf2071 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/PocApplication.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/PocApplication.kt
@@ -20,7 +20,10 @@ class PocApplication : Application() {
}
private object PocNavActionVerifier : NavActionVerifier {
- override fun isNavActionAllowed(navState: NavState, action: NavAction): VerifyResult {
+ override fun isNavActionAllowed(
+ navState: NavState,
+ action: NavAction,
+ ): VerifyResult {
if (action.fromDestination.graph == GlobalGraph) return VerifyResult.Allow
return if (navState.isCurrent(action.fromDestination)) {
VerifyResult.Allow
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/di/PocModule.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/di/PocModule.kt
index 31b2003..897ef9e 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/di/PocModule.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/di/PocModule.kt
@@ -10,7 +10,6 @@ import dagger.hilt.components.SingletonComponent
@InstallIn(SingletonComponent::class)
@Module
object PocModule {
-
@Provides
fun providesNavigationConsumer(): NavigationConsumer {
return ComposeNavigation.getNavigationConsumer()
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenGraph.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenGraph.kt
index 6c38f9a..eae35bb 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenGraph.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenGraph.kt
@@ -12,7 +12,6 @@ import com.adamkobus.compose.navigation.poc.multinavhost.green.ui.home.GreenHome
import com.adamkobus.compose.navigation.poc.multinavhost.green.ui.next.GreenNextScreen
object GreenGraph : NavGraph("greenGraph") {
-
override fun startDestination(): NavDestination = Home
val Home = screenDestination("home")
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenNavHost.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenNavHost.kt
index 1afdf3a..3e571a5 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenNavHost.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/nav/GreenNavHost.kt
@@ -10,13 +10,16 @@ import com.adamkobus.compose.navigation.poc.multinavhost.ui.theme.GreenTheme
@OptIn(ExperimentalAnimationApi::class)
@Composable
-fun GreenNavHost(controller: NavHostController, modifier: Modifier = Modifier) {
+fun GreenNavHost(
+ controller: NavHostController,
+ modifier: Modifier = Modifier,
+) {
GreenTheme {
ComposeNavHost(
startGraph = GreenGraph,
controller = controller,
navigationId = GreenNavId,
- modifier = modifier
+ modifier = modifier,
) {
greenGraph()
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialog.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialog.kt
index 6c60adf..bd63277 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialog.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialog.kt
@@ -4,10 +4,11 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Card
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -23,10 +24,8 @@ fun GreenDialog() {
}
@Composable
-private fun GreenDialogContent(
- interactions: GreenDialogInteractions
-) {
- Card(backgroundColor = MaterialTheme.colors.background) {
+private fun GreenDialogContent(interactions: GreenDialogInteractions) {
+ Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.background)) {
Column(modifier = Modifier.padding(Paddings.Screen), horizontalAlignment = Alignment.CenterHorizontally) {
Text(text = "Green dialog")
Spacer(modifier = Modifier.height(45.dp))
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogInteractions.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogInteractions.kt
index 8dde1c1..91f94fb 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogInteractions.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.poc.multinavhost.green.ui.dialog
data class GreenDialogInteractions(
- val onDismissClicked: () -> Unit
+ val onDismissClicked: () -> Unit,
)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogVM.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogVM.kt
index 87b756b..8771b9d 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogVM.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/dialog/GreenDialogVM.kt
@@ -8,12 +8,12 @@ import javax.inject.Inject
@HiltViewModel
class GreenDialogVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = GreenDialogInteractions(
- onDismissClicked = {
- navigationConsumer.offer(GreenGraph.Dialog.pop())
- }
- )
+ val interactions =
+ GreenDialogInteractions(
+ onDismissClicked = {
+ navigationConsumer.offer(GreenGraph.Dialog.pop())
+ },
+ )
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreen.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreen.kt
index 7e08126..43f4b37 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreen.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreen.kt
@@ -2,8 +2,8 @@ package com.adamkobus.compose.navigation.poc.multinavhost.green.ui.home
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
@@ -19,7 +19,7 @@ fun GreenHomeScreen() {
@Composable
private fun GreenHomeScreenContent(interactions: GreenHomeScreenInteractions) {
ScreenBackground(
- modifier = Modifier.padding(Paddings.Screen)
+ modifier = Modifier.padding(Paddings.Screen),
) {
Button(onClick = interactions.onNextClicked, modifier = Modifier.fillMaxWidth()) {
Text(text = "Go to the next screen")
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenInteractions.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenInteractions.kt
index 6069a88..066ce3c 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenInteractions.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.poc.multinavhost.green.ui.home
data class GreenHomeScreenInteractions(
- val onNextClicked: () -> Unit
+ val onNextClicked: () -> Unit,
)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenVM.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenVM.kt
index e5a0f9b..fa553a5 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenVM.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/home/GreenHomeScreenVM.kt
@@ -8,12 +8,12 @@ import javax.inject.Inject
@HiltViewModel
class GreenHomeScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = GreenHomeScreenInteractions(
- onNextClicked = {
- navigationConsumer.offer(GreenGraph.Home goTo GreenGraph.Next)
- }
- )
+ val interactions =
+ GreenHomeScreenInteractions(
+ onNextClicked = {
+ navigationConsumer.offer(GreenGraph.Home goTo GreenGraph.Next)
+ },
+ )
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreen.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreen.kt
index 7d33feb..554313e 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreen.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreen.kt
@@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@@ -25,8 +25,9 @@ private fun GreenNextScreenContent(interactions: GreenNextScreenInteractions) {
ScreenBackground(modifier = Modifier.padding(Paddings.Screen)) {
Column {
Text(
- text = "Try changing the screen orientation between Portrait and Landscape. " +
- "Back stack state should be preserved between configuration changes by Jetpack's Navigation"
+ text =
+ "Try changing the screen orientation between Portrait and Landscape. " +
+ "Back stack state should be preserved between configuration changes by Jetpack's Navigation",
)
Spacer(modifier = Modifier.height(45.dp))
Button(onClick = interactions.onOpenDialogClicked, modifier = Modifier.fillMaxWidth()) {
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenInteractions.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenInteractions.kt
index 7b9e827..4b84c81 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenInteractions.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.poc.multinavhost.green.ui.next
data class GreenNextScreenInteractions(
- val onOpenDialogClicked: () -> Unit
+ val onOpenDialogClicked: () -> Unit,
)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenVM.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenVM.kt
index 481307c..553cbb8 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenVM.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/green/ui/next/GreenNextScreenVM.kt
@@ -8,12 +8,12 @@ import javax.inject.Inject
@HiltViewModel
class GreenNextScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = GreenNextScreenInteractions(
- onOpenDialogClicked = {
- navigationConsumer.offer(GreenGraph.Next goTo GreenGraph.Dialog)
- }
- )
+ val interactions =
+ GreenNextScreenInteractions(
+ onOpenDialogClicked = {
+ navigationConsumer.offer(GreenGraph.Next goTo GreenGraph.Dialog)
+ },
+ )
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/nav/MainNavHost.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/nav/MainNavHost.kt
index d77ba4a..b48b999 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/nav/MainNavHost.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/nav/MainNavHost.kt
@@ -2,18 +2,18 @@ package com.adamkobus.compose.navigation.poc.multinavhost.main.nav
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
+import androidx.navigation.compose.rememberNavController
import com.adamkobus.compose.navigation.ComposeNavHost
import com.adamkobus.compose.navigation.NavigationId
-import com.google.accompanist.navigation.animation.rememberAnimatedNavController
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun MainNavHost() {
- val controller = rememberAnimatedNavController()
+ val controller = rememberNavController()
ComposeNavHost(
startGraph = PocGraph,
controller = controller,
- navigationId = MainNavId
+ navigationId = MainNavId,
) {
pocGraph()
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/demo/DemoScreen.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/demo/DemoScreen.kt
index 503d271..62d79ea 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/demo/DemoScreen.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/demo/DemoScreen.kt
@@ -11,10 +11,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.navigation.NavHostController
+import androidx.navigation.compose.rememberNavController
import com.adamkobus.compose.navigation.poc.multinavhost.green.nav.GreenNavHost
import com.adamkobus.compose.navigation.poc.multinavhost.ui.common.ScreenBackground
import com.adamkobus.compose.navigation.poc.multinavhost.yellow.nav.YellowNavHost
-import com.google.accompanist.navigation.animation.rememberAnimatedNavController
@Composable
fun DemoScreen() {
@@ -26,8 +26,8 @@ fun DemoScreen() {
private fun DemoScreenContent() {
ScreenBackground {
val configuration = LocalConfiguration.current
- val greenController = rememberAnimatedNavController()
- val yellowController = rememberAnimatedNavController()
+ val greenController = rememberNavController()
+ val yellowController = rememberNavController()
when (configuration.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> LandscapeContent(greenController, yellowController)
else -> PortraitContent(greenController, yellowController)
@@ -37,37 +37,47 @@ private fun DemoScreenContent() {
@OptIn(ExperimentalAnimationApi::class)
@Composable
-private fun PortraitContent(greenController: NavHostController, yellowController: NavHostController) {
+private fun PortraitContent(
+ greenController: NavHostController,
+ yellowController: NavHostController,
+) {
Column(modifier = Modifier.fillMaxSize()) {
GreenScreen(
greenController,
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
- .weight(1f)
+ .weight(1f),
)
YellowScreen(
yellowController,
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
- .weight(1f)
+ .weight(1f),
)
}
}
@Composable
-private fun LandscapeContent(greenController: NavHostController, yellowController: NavHostController) {
+private fun LandscapeContent(
+ greenController: NavHostController,
+ yellowController: NavHostController,
+) {
Row(modifier = Modifier.fillMaxSize()) {
GreenScreen(
greenController,
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxHeight()
- .weight(1f)
+ .weight(1f),
)
YellowScreen(
yellowController,
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxHeight()
- .weight(1f)
+ .weight(1f),
)
}
}
@@ -76,7 +86,7 @@ private fun LandscapeContent(greenController: NavHostController, yellowControlle
@Composable
private fun GreenScreen(
controller: NavHostController,
- modifier: Modifier = Modifier
+ modifier: Modifier = Modifier,
) {
GreenNavHost(controller = controller, modifier = modifier)
}
@@ -85,7 +95,7 @@ private fun GreenScreen(
@Composable
private fun YellowScreen(
controller: NavHostController,
- modifier: Modifier = Modifier
+ modifier: Modifier = Modifier,
) {
YellowNavHost(controller = controller, modifier = modifier)
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreen.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreen.kt
index 62de2bf..894eab5 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreen.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreen.kt
@@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@@ -28,15 +28,17 @@ fun HomeScreen() {
fun HomeScreenContent(interactions: HomeScreenInteractions) {
ScreenBackground {
Column(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
- .padding(Paddings.Screen)
+ .padding(Paddings.Screen),
) {
Text(
text = stringResource(id = R.string.home_screen_description),
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth(),
- textAlign = TextAlign.Center
+ textAlign = TextAlign.Center,
)
Spacer(modifier = Modifier.height(45.dp))
Button(onClick = interactions.onContinueClicked, modifier = Modifier.fillMaxWidth()) {
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenInteractions.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenInteractions.kt
index d104e2f..0fdefe2 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenInteractions.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.poc.multinavhost.main.ui.home
data class HomeScreenInteractions(
- val onContinueClicked: () -> Unit
+ val onContinueClicked: () -> Unit,
)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenVM.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenVM.kt
index bce6ac2..812c23c 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenVM.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/main/ui/home/HomeScreenVM.kt
@@ -8,11 +8,12 @@ import javax.inject.Inject
@HiltViewModel
class HomeScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
- val interactions = HomeScreenInteractions(
- onContinueClicked = {
- navigationConsumer.offer(PocGraph.Home goTo PocGraph.Demo)
- }
- )
+ val interactions =
+ HomeScreenInteractions(
+ onContinueClicked = {
+ navigationConsumer.offer(PocGraph.Home goTo PocGraph.Demo)
+ },
+ )
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/common/ScreenBackground.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/common/ScreenBackground.kt
index 15b0cfc..5adb789 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/common/ScreenBackground.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/common/ScreenBackground.kt
@@ -4,20 +4,21 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.material.MaterialTheme
+import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@Composable
fun ScreenBackground(
modifier: Modifier = Modifier,
- content: @Composable BoxScope.() -> Unit
+ content: @Composable BoxScope.() -> Unit,
) {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .background(MaterialTheme.colors.background)
- .then(modifier)
+ .background(MaterialTheme.colorScheme.background)
+ .then(modifier),
) {
content()
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Shape.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Shape.kt
index 545c714..beb1129 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Shape.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Shape.kt
@@ -1,11 +1,12 @@
package com.adamkobus.compose.navigation.poc.multinavhost.ui.theme
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.Shapes
+import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp
-val Shapes = Shapes(
- small = RoundedCornerShape(4.dp),
- medium = RoundedCornerShape(4.dp),
- large = RoundedCornerShape(0.dp)
-)
+val Shapes =
+ Shapes(
+ small = RoundedCornerShape(4.dp),
+ medium = RoundedCornerShape(4.dp),
+ large = RoundedCornerShape(0.dp),
+ )
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Theme.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Theme.kt
index 286bb4e..65e7f55 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Theme.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Theme.kt
@@ -2,22 +2,22 @@
package com.adamkobus.compose.navigation.poc.multinavhost.ui.theme
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.lightColors
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
-private val MainColorPalette = lightColors(
- primary = Purple500,
- primaryVariant = Purple700,
- secondary = Teal200,
- background = Color.White,
- surface = Color.White,
- onPrimary = Color.White,
- onSecondary = Color.Black,
- onBackground = Color.Black,
- onSurface = Color.Black
-)
+private val MainColorPalette =
+ lightColorScheme(
+ primary = Purple500,
+ secondary = Teal200,
+ background = Color.White,
+ surface = Color.White,
+ onPrimary = Color.White,
+ onSecondary = Color.Black,
+ onBackground = Color.Black,
+ onSurface = Color.Black,
+ )
private val YellowColorPalette = MainColorPalette.copy(background = Color(0xFFFFFBC2))
private val GreenColorPalette = MainColorPalette.copy(background = Color(0xFFC2FFC7))
@@ -25,29 +25,29 @@ private val GreenColorPalette = MainColorPalette.copy(background = Color(0xFFC2F
@Composable
fun ComposeNavigationTheme(content: @Composable () -> Unit) {
MaterialTheme(
- colors = MainColorPalette,
+ colorScheme = MainColorPalette,
typography = Typography,
shapes = Shapes,
- content = content
+ content = content,
)
}
@Composable
fun YellowTheme(content: @Composable () -> Unit) {
MaterialTheme(
- colors = YellowColorPalette,
+ colorScheme = YellowColorPalette,
typography = Typography,
shapes = Shapes,
- content = content
+ content = content,
)
}
@Composable
fun GreenTheme(content: @Composable () -> Unit) {
MaterialTheme(
- colors = GreenColorPalette,
+ colorScheme = GreenColorPalette,
typography = Typography,
shapes = Shapes,
- content = content
+ content = content,
)
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Type.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Type.kt
index 99918bb..1de390a 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Type.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/ui/theme/Type.kt
@@ -1,28 +1,18 @@
package com.adamkobus.compose.navigation.poc.multinavhost.ui.theme
-import androidx.compose.material.Typography
+import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
-val Typography = Typography(
- body1 = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 16.sp
+val Typography =
+ Typography(
+ bodyLarge =
+ TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp,
+ ),
)
- /* Other default text styles to override
- button = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.W500,
- fontSize = 14.sp
- ),
- caption = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 12.sp
- )
- */
-)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowGraph.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowGraph.kt
index c1aebaf..71f228a 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowGraph.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowGraph.kt
@@ -12,7 +12,6 @@ import com.adamkobus.compose.navigation.poc.multinavhost.yellow.ui.home.YellowHo
import com.adamkobus.compose.navigation.poc.multinavhost.yellow.ui.next.YellowNextScreen
object YellowGraph : NavGraph("yellowGraph") {
-
override fun startDestination(): NavDestination = Home
val Home = screenDestination("home")
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowNavHost.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowNavHost.kt
index c4101cc..0fe52ee 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowNavHost.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/nav/YellowNavHost.kt
@@ -10,13 +10,16 @@ import com.adamkobus.compose.navigation.poc.multinavhost.ui.theme.YellowTheme
@OptIn(ExperimentalAnimationApi::class)
@Composable
-fun YellowNavHost(controller: NavHostController, modifier: Modifier = Modifier) {
+fun YellowNavHost(
+ controller: NavHostController,
+ modifier: Modifier = Modifier,
+) {
YellowTheme {
ComposeNavHost(
startGraph = YellowGraph,
controller = controller,
navigationId = YellowNavId,
- modifier = modifier
+ modifier = modifier,
) {
yellowGraph()
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialog.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialog.kt
index 7c80428..bc11ee0 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialog.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialog.kt
@@ -4,10 +4,11 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Card
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -23,10 +24,8 @@ fun YellowDialog() {
}
@Composable
-private fun YellowDialogContent(
- interactions: YellowDialogInteractions
-) {
- Card(backgroundColor = MaterialTheme.colors.background) {
+private fun YellowDialogContent(interactions: YellowDialogInteractions) {
+ Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.background)) {
Column(modifier = Modifier.padding(Paddings.Screen), horizontalAlignment = Alignment.CenterHorizontally) {
Text(text = "Yellow dialog")
Spacer(modifier = Modifier.height(45.dp))
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogInteractions.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogInteractions.kt
index 8321fbd..ced48dd 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogInteractions.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.poc.multinavhost.yellow.ui.dialog
data class YellowDialogInteractions(
- val onDismissClicked: () -> Unit
+ val onDismissClicked: () -> Unit,
)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogVM.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogVM.kt
index ff4d869..0606366 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogVM.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/dialog/YellowDialogVM.kt
@@ -8,12 +8,12 @@ import javax.inject.Inject
@HiltViewModel
class YellowDialogVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = YellowDialogInteractions(
- onDismissClicked = {
- navigationConsumer.offer(YellowGraph.Dialog.pop())
- }
- )
+ val interactions =
+ YellowDialogInteractions(
+ onDismissClicked = {
+ navigationConsumer.offer(YellowGraph.Dialog.pop())
+ },
+ )
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreen.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreen.kt
index 40f716a..9ac17f9 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreen.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreen.kt
@@ -2,8 +2,8 @@ package com.adamkobus.compose.navigation.poc.multinavhost.yellow.ui.home
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
@@ -17,11 +17,9 @@ fun YellowHomeScreen() {
}
@Composable
-private fun YellowHomeScreenContent(
- interactions: YellowHomeScreenInteractions
-) {
+private fun YellowHomeScreenContent(interactions: YellowHomeScreenInteractions) {
ScreenBackground(
- modifier = Modifier.padding(Paddings.Screen)
+ modifier = Modifier.padding(Paddings.Screen),
) {
Button(onClick = interactions.onNextClicked, modifier = Modifier.fillMaxWidth()) {
Text(text = "Go to the next screen")
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenInteractions.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenInteractions.kt
index d200b5d..f440869 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenInteractions.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.poc.multinavhost.yellow.ui.home
data class YellowHomeScreenInteractions(
- val onNextClicked: () -> Unit
+ val onNextClicked: () -> Unit,
)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenVM.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenVM.kt
index dbdb08e..20ef25a 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenVM.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/home/YellowHomeScreenVM.kt
@@ -8,12 +8,12 @@ import javax.inject.Inject
@HiltViewModel
class YellowHomeScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = YellowHomeScreenInteractions(
- onNextClicked = {
- navigationConsumer.offer(YellowGraph.Home goTo YellowGraph.Next)
- }
- )
+ val interactions =
+ YellowHomeScreenInteractions(
+ onNextClicked = {
+ navigationConsumer.offer(YellowGraph.Home goTo YellowGraph.Next)
+ },
+ )
}
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreen.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreen.kt
index 4a01b80..650862b 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreen.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreen.kt
@@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenInteractions.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenInteractions.kt
index 3a53243..1d4e2be 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenInteractions.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenInteractions.kt
@@ -1,5 +1,5 @@
package com.adamkobus.compose.navigation.poc.multinavhost.yellow.ui.next
data class YellowNextScreenInteractions(
- val onOpenDialogClicked: () -> Unit
+ val onOpenDialogClicked: () -> Unit,
)
diff --git a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenVM.kt b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenVM.kt
index 3b25ef1..4d6893e 100644
--- a/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenVM.kt
+++ b/poc-multiple-nav-hosts/src/main/java/com/adamkobus/compose/navigation/poc/multinavhost/yellow/ui/next/YellowNextScreenVM.kt
@@ -8,12 +8,12 @@ import javax.inject.Inject
@HiltViewModel
class YellowNextScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : LifecycleAwareViewModel() {
-
- val interactions = YellowNextScreenInteractions(
- onOpenDialogClicked = {
- navigationConsumer.offer(YellowGraph.Next goTo YellowGraph.Dialog)
- }
- )
+ val interactions =
+ YellowNextScreenInteractions(
+ onOpenDialogClicked = {
+ navigationConsumer.offer(YellowGraph.Next goTo YellowGraph.Dialog)
+ },
+ )
}
diff --git a/settings.gradle b/settings.gradle
index 7a30bd9..d44dace 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,3 +1,17 @@
+pluginManagement {
+ repositories {
+ google {
+ content {
+ includeGroupByRegex("com\\.android.*")
+ includeGroupByRegex("com\\.google.*")
+ includeGroupByRegex("androidx.*")
+ }
+ }
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
@@ -5,6 +19,7 @@ dependencyResolutionManagement {
mavenCentral()
}
}
+
rootProject.name = "Compose Navigation"
include ':composenav'
include ':demo'
diff --git a/tutorial/build.gradle b/tutorial/build.gradle
index 603d6ed..0051449 100644
--- a/tutorial/build.gradle
+++ b/tutorial/build.gradle
@@ -1,39 +1,36 @@
-import com.adamkobus.compose.navigation.Lib
-
plugins {
- id 'com.android.application'
- id 'org.jetbrains.kotlin.android'
- id 'kotlin-kapt'
- id 'dagger.hilt.android.plugin'
+ alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.compose)
+ alias(libs.plugins.kotlin.ksp)
+ alias(libs.plugins.hilt)
}
android {
buildFeatures {
compose true
}
- composeOptions {
- kotlinCompilerExtensionVersion Lib.COMPOSE_COMPILER_VERSION
- }
namespace 'com.adamkobus.compose.navigation.tutorial'
}
dependencies {
implementation project(':composenav')
- implementation Lib.AndroidX.Core
- implementation Lib.AndroidX.Appcompat
- implementation Lib.Kotlin.Coroutines
+ implementation libs.androidx.core
+ implementation libs.androidx.appcompat
+ implementation libs.kotlin.coroutines
+ implementation libs.ak.lifecycle.vm
// hilt
- implementation Lib.Google.Hilt
- implementation Lib.Google.HiltNavigationCompose
- kapt Lib.Google.HiltCompiler
+ implementation libs.google.hilt.core
+ ksp libs.google.hilt.compiler
// compose
- implementation Lib.Compose.Ui
- implementation Lib.Compose.Activity
- implementation Lib.Compose.Material
- implementation Lib.Compose.ToolingPreview
- debugImplementation Lib.Compose.UiTooling
- implementation Lib.Accompanist.NavigationAnimation
+ implementation platform(libs.compose.bom)
+ implementation libs.compose.ui
+ implementation libs.compose.activity
+ implementation libs.compose.material3
+ implementation libs.compose.tooling.preview
+ implementation libs.compose.hilt
+ debugImplementation libs.compose.tooling.ui
}
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/MainActivity.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/MainActivity.kt
index 2f70257..5e10f57 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/MainActivity.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/MainActivity.kt
@@ -6,12 +6,12 @@ import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
+import androidx.navigation.compose.rememberNavController
import com.adamkobus.compose.navigation.ComposeNavHost
import com.adamkobus.compose.navigation.NavigationId
import com.adamkobus.compose.navigation.tutorial.nav.TutorialGraph
import com.adamkobus.compose.navigation.tutorial.nav.tutorialGraph
import com.adamkobus.compose.navigation.tutorial.ui.theme.ComposeNavigationTutorialTheme
-import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import dagger.hilt.android.AndroidEntryPoint
@OptIn(ExperimentalAnimationApi::class)
@@ -21,12 +21,12 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
ComposeNavigationTutorialTheme {
- val controller = rememberAnimatedNavController()
+ val controller = rememberNavController()
ComposeNavHost(
startGraph = TutorialGraph,
controller = controller,
navigationId = NavigationId.DEFAULT,
- modifier = Modifier.fillMaxSize()
+ modifier = Modifier.fillMaxSize(),
) {
tutorialGraph()
}
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/NavigationModule.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/NavigationModule.kt
index e9ee69d..9592b1e 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/NavigationModule.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/NavigationModule.kt
@@ -10,7 +10,6 @@ import dagger.hilt.components.SingletonComponent
@InstallIn(SingletonComponent::class)
@Module
object NavigationModule {
-
@Provides
fun providesNavigationConsumer(): NavigationConsumer = ComposeNavigation.getNavigationConsumer()
}
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/OpenRandomItemIntentResolver.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/OpenRandomItemIntentResolver.kt
index 0c21185..084f6d8 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/OpenRandomItemIntentResolver.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/OpenRandomItemIntentResolver.kt
@@ -9,7 +9,10 @@ import kotlin.random.Random
object OpenRandomItemIntentResolver : NavIntentResolver {
private val random = Random.Default
- override suspend fun resolve(intent: NavIntent, navState: NavState): ResolveResult =
+ override suspend fun resolve(
+ intent: NavIntent,
+ navState: NavState,
+ ): ResolveResult =
intent.origin?.takeIf {
intent.name == TutorialIntents.OPEN_RANDOM_ITEM_INTENT
}?.let { origin ->
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialGraph.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialGraph.kt
index 18ae895..fba1b65 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialGraph.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialGraph.kt
@@ -22,13 +22,15 @@ object TutorialGraph : NavGraph("tutorialGraph") {
val Image = screenDestination("image")
val List = screenDestination("list")
- val Detail = List.next {
- param(PARAM_ITEM_ID)
- }
+ val Detail =
+ List.next {
+ param(PARAM_ITEM_ID)
+ }
- val DetailDialog = Detail.next {
- path("dialog")
- }.asDialog()
+ val DetailDialog =
+ Detail.next {
+ path("dialog")
+ }.asDialog()
}
fun NavStackEntry.getItemId() = getInt(TutorialGraph.PARAM_ITEM_ID)
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialIntents.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialIntents.kt
index f58d42d..20424b8 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialIntents.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialIntents.kt
@@ -4,9 +4,7 @@ import com.adamkobus.compose.navigation.destination.NavDestination
import com.adamkobus.compose.navigation.intent.NavIntent
object TutorialIntents {
-
const val OPEN_RANDOM_ITEM_INTENT = "openRandomItem"
- fun openRandomItem(origin: NavDestination) =
- NavIntent(name = OPEN_RANDOM_ITEM_INTENT, origin = origin)
+ fun openRandomItem(origin: NavDestination) = NavIntent(name = OPEN_RANDOM_ITEM_INTENT, origin = origin)
}
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialNavActionVerifier.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialNavActionVerifier.kt
index 8d34b0f..a50a2f5 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialNavActionVerifier.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/nav/TutorialNavActionVerifier.kt
@@ -7,7 +7,10 @@ import com.adamkobus.compose.navigation.destination.GlobalGraph
import com.adamkobus.compose.navigation.destination.NavState
object TutorialNavActionVerifier : NavActionVerifier {
- override fun isNavActionAllowed(navState: NavState, action: NavAction): VerifyResult {
+ override fun isNavActionAllowed(
+ navState: NavState,
+ action: NavAction,
+ ): VerifyResult {
if (action.fromDestination.graph == GlobalGraph) return VerifyResult.Allow
return if (navState.isCurrent(action.fromDestination)) {
VerifyResult.Allow
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/detail/DetailScreen.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/detail/DetailScreen.kt
index 8a7def8..95983f0 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/detail/DetailScreen.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/detail/DetailScreen.kt
@@ -3,13 +3,13 @@ package com.adamkobus.compose.navigation.tutorial.ui.detail
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Card
-import androidx.compose.material.Icon
-import androidx.compose.material.IconButton
-import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.ArrowBack
+import androidx.compose.material.icons.automirrored.filled.ArrowBack
+import androidx.compose.material3.Button
+import androidx.compose.material3.Card
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -28,17 +28,18 @@ import javax.inject.Inject
fun DetailScreen(itemId: Int) {
val vm: DetailScreenVM = hiltViewModel()
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .padding(16.dp)
+ .padding(16.dp),
) {
IconButton(onClick = vm.interactions.onBackClicked) {
- Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = null)
+ Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null)
}
Text(text = "Opened item with id $itemId", modifier = Modifier.align(Alignment.Center))
Button(
onClick = { vm.interactions.onOpenDialogClicked(itemId) },
- modifier = Modifier.align(Alignment.BottomCenter)
+ modifier = Modifier.align(Alignment.BottomCenter),
) {
Text(text = "Open a dialog")
}
@@ -47,25 +48,26 @@ fun DetailScreen(itemId: Int) {
@HiltViewModel
class DetailScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : ViewModel() {
- val interactions = DetailScreenInteractions(
- onBackClicked = {
- viewModelScope.launch {
- navigationConsumer.offer(TutorialGraph.Detail.pop())
- }
- },
- onOpenDialogClicked = { itemId ->
- viewModelScope.launch {
- navigationConsumer.offer(TutorialNavActions.fromDetailToDialog(itemId))
- }
- }
- )
+ val interactions =
+ DetailScreenInteractions(
+ onBackClicked = {
+ viewModelScope.launch {
+ navigationConsumer.offer(TutorialGraph.Detail.pop())
+ }
+ },
+ onOpenDialogClicked = { itemId ->
+ viewModelScope.launch {
+ navigationConsumer.offer(TutorialNavActions.fromDetailToDialog(itemId))
+ }
+ },
+ )
}
data class DetailScreenInteractions(
val onBackClicked: () -> Unit,
- val onOpenDialogClicked: (Int) -> Unit
+ val onOpenDialogClicked: (Int) -> Unit,
)
@Composable
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/image/ImageScreen.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/image/ImageScreen.kt
index 342ff60..45c563c 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/image/ImageScreen.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/image/ImageScreen.kt
@@ -9,11 +9,11 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
-import androidx.compose.material.Button
-import androidx.compose.material.Icon
-import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ThumbUp
+import androidx.compose.material3.Button
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -29,23 +29,25 @@ import kotlinx.coroutines.launch
@Composable
fun ImageScreen() {
Box(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxSize()
- .padding(16.dp)
+ .padding(16.dp),
) {
Icon(
imageVector = Icons.Filled.ThumbUp,
contentDescription = "app icon",
- modifier = Modifier.align(Alignment.Center)
+ modifier = Modifier.align(Alignment.Center),
)
val scope = rememberCoroutineScope()
val textEntries = remember { mutableStateOf(emptyList()) }
LazyColumn(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
.fillMaxHeight(0.45f),
- verticalArrangement = Arrangement.spacedBy(10.dp)
+ verticalArrangement = Arrangement.spacedBy(10.dp),
) {
items(textEntries.value) { item ->
Text(text = item)
@@ -60,7 +62,7 @@ fun ImageScreen() {
textEntries.value += "Result $result in ${elapsed}ms"
}
},
- modifier = Modifier.align(Alignment.BottomCenter)
+ modifier = Modifier.align(Alignment.BottomCenter),
) {
Text(text = "Open a dialog")
}
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/list/ListScreen.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/list/ListScreen.kt
index 294955b..c072c22 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/list/ListScreen.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/list/ListScreen.kt
@@ -10,8 +10,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
-import androidx.compose.material.Card
-import androidx.compose.material.Text
+import androidx.compose.material3.Card
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
@@ -29,7 +29,7 @@ fun ListScreen() {
LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(16.dp),
- verticalArrangement = Arrangement.spacedBy(10.dp)
+ verticalArrangement = Arrangement.spacedBy(10.dp),
) {
items(vm.listContent.value, key = { it.id }) { itemData ->
ListElement(itemData, vm.interactions.onItemSelected)
@@ -38,11 +38,15 @@ fun ListScreen() {
}
@Composable
-private fun ListElement(data: ListItemData, onItemClicked: (ListItemData) -> Unit) {
+private fun ListElement(
+ data: ListItemData,
+ onItemClicked: (ListItemData) -> Unit,
+) {
Card(
- modifier = Modifier
+ modifier =
+ Modifier
.fillMaxWidth()
- .clickable { onItemClicked(data) }
+ .clickable { onItemClicked(data) },
) {
Text(text = data.title, modifier = Modifier.padding(14.dp))
}
@@ -50,24 +54,26 @@ private fun ListElement(data: ListItemData, onItemClicked: (ListItemData) -> Uni
@HiltViewModel
class ListScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : ViewModel() {
- val listContent = mutableStateOf(
- // will generate 50 list elements numbered from 1 to 50
- generateSequence(1) { it + 1 }.take(50).map { ListItemData(it, "List item #$it") }.toList()
- )
- val interactions = ListScreenInteractions(
- onItemSelected = {
- navigationConsumer.offer(TutorialNavActions.fromListToDetail(it.id))
- }
- )
+ val listContent =
+ mutableStateOf(
+ // will generate 50 list elements numbered from 1 to 50
+ generateSequence(1) { it + 1 }.take(50).map { ListItemData(it, "List item #$it") }.toList(),
+ )
+ val interactions =
+ ListScreenInteractions(
+ onItemSelected = {
+ navigationConsumer.offer(TutorialNavActions.fromListToDetail(it.id))
+ },
+ )
}
data class ListScreenInteractions(
- val onItemSelected: (ListItemData) -> Unit
+ val onItemSelected: (ListItemData) -> Unit,
)
data class ListItemData(
val id: Int,
- val title: String
+ val title: String,
)
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Shape.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Shape.kt
index 0adf19b..3166e11 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Shape.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Shape.kt
@@ -1,11 +1,12 @@
package com.adamkobus.compose.navigation.tutorial.ui.theme
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.Shapes
+import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp
-val Shapes = Shapes(
- small = RoundedCornerShape(4.dp),
- medium = RoundedCornerShape(4.dp),
- large = RoundedCornerShape(0.dp)
-)
+val Shapes =
+ Shapes(
+ small = RoundedCornerShape(4.dp),
+ medium = RoundedCornerShape(4.dp),
+ large = RoundedCornerShape(0.dp),
+ )
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Theme.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Theme.kt
index 2688ecb..e0daff1 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Theme.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Theme.kt
@@ -1,44 +1,39 @@
package com.adamkobus.compose.navigation.tutorial.ui.theme
import androidx.compose.foundation.isSystemInDarkTheme
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.darkColors
-import androidx.compose.material.lightColors
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
-private val DarkColorPalette = darkColors(
- primary = Purple200,
- primaryVariant = Purple700,
- secondary = Teal200
-)
-
-private val LightColorPalette = lightColors(
- primary = Purple500,
- primaryVariant = Purple700,
- secondary = Teal200
+private val DarkColorPalette =
+ darkColorScheme(
+ primary = Purple200,
+ secondary = Teal200,
+ )
- /* Other default colors to override
- background = Color.White,
- surface = Color.White,
- onPrimary = Color.White,
- onSecondary = Color.Black,
- onBackground = Color.Black,
- onSurface = Color.Black,
- */
-)
+private val LightColorPalette =
+ lightColorScheme(
+ primary = Purple500,
+ secondary = Teal200,
+ )
@Composable
-fun ComposeNavigationTutorialTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
- val colors = if (darkTheme) {
- DarkColorPalette
- } else {
- LightColorPalette
- }
+fun ComposeNavigationTutorialTheme(
+ darkTheme: Boolean = isSystemInDarkTheme(),
+ content: @Composable () -> Unit,
+) {
+ val colors =
+ if (darkTheme) {
+ DarkColorPalette
+ } else {
+ LightColorPalette
+ }
MaterialTheme(
- colors = colors,
+ colorScheme = colors,
typography = Typography,
shapes = Shapes,
- content = content
+ content = content,
)
}
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Type.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Type.kt
index ad3994f..c19d322 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Type.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/theme/Type.kt
@@ -1,28 +1,18 @@
package com.adamkobus.compose.navigation.tutorial.ui.theme
-import androidx.compose.material.Typography
+import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
-val Typography = Typography(
- body1 = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 16.sp
+val Typography =
+ Typography(
+ bodyLarge =
+ TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp,
+ ),
)
- /* Other default text styles to override
- button = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.W500,
- fontSize = 14.sp
- ),
- caption = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 12.sp
- )
- */
-)
diff --git a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/welcome/WelcomeScreen.kt b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/welcome/WelcomeScreen.kt
index e03873f..4fd7296 100644
--- a/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/welcome/WelcomeScreen.kt
+++ b/tutorial/src/main/java/com/adamkobus/compose/navigation/tutorial/ui/welcome/WelcomeScreen.kt
@@ -6,8 +6,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.material.Button
-import androidx.compose.material.Text
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
@@ -33,7 +33,7 @@ fun WelcomeScreen() {
private fun WelcomeScreenContent(interactions: WelcomeScreenInteractions = WelcomeScreenInteractions.STUB) {
Column(
modifier = Modifier.padding(16.dp),
- verticalArrangement = Arrangement.Center
+ verticalArrangement = Arrangement.Center,
) {
Button(onClick = interactions.onShowImageClicked, modifier = Modifier.fillMaxWidth()) {
Text(text = "Show me an image!")
@@ -57,37 +57,39 @@ private fun WelcomeScreenPreview() {
@HiltViewModel
class WelcomeScreenVM @Inject constructor(
- private val navigationConsumer: NavigationConsumer
+ private val navigationConsumer: NavigationConsumer,
) : ViewModel() {
- val interactions = WelcomeScreenInteractions(
- onShowImageClicked = {
- viewModelScope.launch {
- navigationConsumer.offer(TutorialNavActions.FromWelcomeToImage)
- }
- },
- onShowListClicked = {
- viewModelScope.launch {
- navigationConsumer.offer(TutorialNavActions.FromWelcomeToList)
- }
- },
- onOpenRandomItemClicked = {
- viewModelScope.launch {
- navigationConsumer.offer(TutorialIntents.openRandomItem(TutorialGraph.Welcome))
- }
- }
- )
+ val interactions =
+ WelcomeScreenInteractions(
+ onShowImageClicked = {
+ viewModelScope.launch {
+ navigationConsumer.offer(TutorialNavActions.FromWelcomeToImage)
+ }
+ },
+ onShowListClicked = {
+ viewModelScope.launch {
+ navigationConsumer.offer(TutorialNavActions.FromWelcomeToList)
+ }
+ },
+ onOpenRandomItemClicked = {
+ viewModelScope.launch {
+ navigationConsumer.offer(TutorialIntents.openRandomItem(TutorialGraph.Welcome))
+ }
+ },
+ )
}
data class WelcomeScreenInteractions(
val onShowImageClicked: () -> Unit,
val onShowListClicked: () -> Unit,
- val onOpenRandomItemClicked: () -> Unit
+ val onOpenRandomItemClicked: () -> Unit,
) {
companion object {
- val STUB = WelcomeScreenInteractions(
- onShowImageClicked = {},
- onShowListClicked = {},
- onOpenRandomItemClicked = {}
- )
+ val STUB =
+ WelcomeScreenInteractions(
+ onShowImageClicked = {},
+ onShowListClicked = {},
+ onOpenRandomItemClicked = {},
+ )
}
}
diff --git a/tutorial/src/main/res/values/themes.xml b/tutorial/src/main/res/values/themes.xml
index ca304cd..4f5fc49 100644
--- a/tutorial/src/main/res/values/themes.xml
+++ b/tutorial/src/main/res/values/themes.xml
@@ -1,7 +1,6 @@
-
-
\ No newline at end of file
+