Skip to content

Commit

Permalink
Dependency updates - no longer using accompanist
Browse files Browse the repository at this point in the history
  • Loading branch information
raamcosta committed Mar 11, 2024
1 parent 275544d commit 96d0729
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion compose-destinations-animations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ dependencies {

api(project(mapOf("path" to ":compose-destinations")))

api(libs.accompanist.material)
api(libs.compose.material.navigation)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

package com.ramcosta.composedestinations.animations

import androidx.compose.animation.*
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.ramcosta.composedestinations.animations.defaults.*
import com.ramcosta.composedestinations.animations.defaults.NestedNavGraphDefaultAnimations
import com.ramcosta.composedestinations.animations.defaults.RootNavGraphDefaultAnimations
import com.ramcosta.composedestinations.annotation.InternalDestinationsApi
import com.ramcosta.composedestinations.manualcomposablecalls.ManualComposableCalls
import com.ramcosta.composedestinations.navigation.DependenciesContainerBuilder
import com.ramcosta.composedestinations.rememberNavHostEngine
import com.ramcosta.composedestinations.spec.*
import com.ramcosta.composedestinations.spec.DestinationSpec
import com.ramcosta.composedestinations.spec.NavGraphSpec
import com.ramcosta.composedestinations.spec.NavHostEngine
import com.ramcosta.composedestinations.spec.addComposable
import com.ramcosta.composedestinations.spec.additionalAddComposable

/**
* Remembers and returns an instance of a [NavHostEngine]
Expand All @@ -29,7 +33,6 @@ import com.ramcosta.composedestinations.spec.*
* that specific nested navigation graph. Return null for all nested nav graphs, you don't wish
* to override animations for.
*/
@ExperimentalMaterialNavigationApi
@ExperimentalAnimationApi
@Composable
fun rememberAnimatedNavHostEngine(
Expand All @@ -46,7 +49,6 @@ fun rememberAnimatedNavHostEngine(
)
}

@ExperimentalMaterialNavigationApi
private val lambda: (
NavGraphBuilder,
DestinationSpec<*>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.ramcosta.composedestinations.animations.utils

import androidx.compose.material.navigation.bottomSheet
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.navigation.NavGraphBuilder
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.navigation.material.bottomSheet
import com.ramcosta.composedestinations.animations.scope.BottomSheetNavGraphBuilderDestinationScopeImpl
import com.ramcosta.composedestinations.scope.BottomSheetNavGraphBuilderDestinationScope
import com.ramcosta.composedestinations.spec.DestinationSpec
Expand All @@ -28,7 +27,6 @@ import com.ramcosta.composedestinations.spec.DestinationStyleBottomSheet
* }
* ```
*/
@ExperimentalMaterialNavigationApi
fun <T> NavGraphBuilder.bottomSheetComposable(
destination: DestinationSpec<T>,
content: @Composable BottomSheetNavGraphBuilderDestinationScope<T>.() -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package com.ramcosta.composedestinations.spec

import android.annotation.SuppressLint
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material.navigation.bottomSheet
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.navigation.material.bottomSheet
import com.ramcosta.composedestinations.animations.scope.BottomSheetDestinationScopeImpl
import com.ramcosta.composedestinations.manualcomposablecalls.DestinationLambda
import com.ramcosta.composedestinations.manualcomposablecalls.ManualComposableCalls
Expand Down Expand Up @@ -38,7 +37,6 @@ import com.ramcosta.composedestinations.navigation.DependenciesContainerBuilder
*/
object DestinationStyleBottomSheet : DestinationStyle

@ExperimentalMaterialNavigationApi
internal fun <T> NavGraphBuilder.addComposable(
destination: DestinationSpec<T>,
navController: NavHostController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ramcosta.composedestinations
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand All @@ -15,6 +16,7 @@ import androidx.navigation.Navigator
import androidx.navigation.compose.navigation
import com.ramcosta.composedestinations.animations.defaults.DestinationEnterTransition
import com.ramcosta.composedestinations.animations.defaults.DestinationExitTransition
import com.ramcosta.composedestinations.animations.defaults.DestinationSizeTransform
import com.ramcosta.composedestinations.animations.defaults.NestedNavGraphDefaultAnimations
import com.ramcosta.composedestinations.animations.defaults.RootNavGraphDefaultAnimations
import com.ramcosta.composedestinations.manualcomposablecalls.ManualComposableCalls
Expand All @@ -23,7 +25,7 @@ import com.ramcosta.composedestinations.spec.DestinationSpec
import com.ramcosta.composedestinations.spec.NavGraphSpec
import com.ramcosta.composedestinations.spec.NavHostEngine
import com.ramcosta.composedestinations.spec.Route
import com.ramcosta.composedestinations.spec.addActivityDestination
import com.ramcosta.composedestinations.spec.addDestination

/**
* Returns the default [NavHostEngine] to be used with [DestinationsNavHost]
Expand Down Expand Up @@ -86,6 +88,7 @@ internal class DefaultNavHostEngine(
exitTransition = exitTransition.toAccompanist(),
popEnterTransition = popEnterTransition.toAccompanist(),
popExitTransition = popExitTransition.toAccompanist(),
sizeTransform = sizeTransform?.toAccompanist(),
builder = builder
)
}
Expand All @@ -103,6 +106,7 @@ internal class DefaultNavHostEngine(
exitTransition = transitions.exitTransition?.toAccompanist(),
popEnterTransition = transitions.popEnterTransition?.toAccompanist(),
popExitTransition = transitions.popExitTransition?.toAccompanist(),
sizeTransform = transitions.sizeTransform?.toAccompanist(),
builder = builder
)
} else {
Expand All @@ -120,7 +124,7 @@ internal class DefaultNavHostEngine(
dependenciesContainerBuilder: @Composable DependenciesContainerBuilder<*>.() -> Unit,
manualComposableCalls: ManualComposableCalls,
) = with(destination.style) {
addActivityDestination(this@composable, destination, navController, dependenciesContainerBuilder, manualComposableCalls)
addDestination(this@composable, destination, navController, dependenciesContainerBuilder, manualComposableCalls)
}

private fun DestinationEnterTransition.toAccompanist(): (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) {
Expand All @@ -130,4 +134,8 @@ internal class DefaultNavHostEngine(
private fun DestinationExitTransition.toAccompanist(): (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) {
return { exit() }
}

private fun DestinationSizeTransform.toAccompanist(): (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?) {
return { sizeTransform() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface NavGraphDefaultAnimationParams {
val exitTransition: DestinationExitTransition?
val popEnterTransition: DestinationEnterTransition?
val popExitTransition: DestinationExitTransition?
val sizeTransform: DestinationSizeTransform?
}

/**
Expand All @@ -23,6 +24,7 @@ class RootNavGraphDefaultAnimations(
override val exitTransition: DestinationExitTransition = DestinationExitTransition { ExitTransition.None },
override val popEnterTransition: DestinationEnterTransition = enterTransition,
override val popExitTransition: DestinationExitTransition = exitTransition,
override val sizeTransform: DestinationSizeTransform? = null
): NavGraphDefaultAnimationParams {
companion object {
val ACCOMPANIST_FADING by lazy {
Expand All @@ -46,6 +48,7 @@ class NestedNavGraphDefaultAnimations(
override val exitTransition: DestinationExitTransition? = null,
override val popEnterTransition: DestinationEnterTransition? = enterTransition,
override val popExitTransition: DestinationExitTransition? = exitTransition,
override val sizeTransform: DestinationSizeTransform? = null
) : NavGraphDefaultAnimationParams {
companion object {
val ACCOMPANIST_FADING by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ramcosta.composedestinations.animations.defaults
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.navigation.NavBackStackEntry

fun interface DestinationEnterTransition {
Expand All @@ -12,3 +13,7 @@ fun interface DestinationEnterTransition {
fun interface DestinationExitTransition {
fun AnimatedContentTransitionScope<NavBackStackEntry>.exit() : ExitTransition
}

fun interface DestinationSizeTransform {
fun AnimatedContentTransitionScope<NavBackStackEntry>.sizeTransform() : SizeTransform?
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.navigation.NavHostController
import androidx.navigation.activity
import androidx.navigation.compose.composable
import androidx.navigation.compose.dialog
import com.ramcosta.composedestinations.animations.defaults.DestinationSizeTransform
import com.ramcosta.composedestinations.annotation.InternalDestinationsApi
import com.ramcosta.composedestinations.manualcomposablecalls.DestinationLambda
import com.ramcosta.composedestinations.manualcomposablecalls.ManualComposableCalls
Expand Down Expand Up @@ -81,6 +82,8 @@ interface DestinationStyle {
return exitTransition()
}

val sizeTransform: DestinationSizeTransform? get() = null

/**
* Can be used to force no animations for certain destinations, if you've overridden
* the default animation with `defaultAnimationParams`.
Expand Down Expand Up @@ -141,7 +144,7 @@ internal typealias AddComposable<T> = (NavGraphBuilder, DestinationSpec<T>, NavH
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
var additionalAddComposable : AddComposable<*>? = null

internal fun <T> DestinationStyle.addActivityDestination(
internal fun <T> DestinationStyle.addDestination(
navGraphBuilder: NavGraphBuilder,
destination: DestinationSpec<T>,
navController: NavHostController,
Expand Down Expand Up @@ -190,14 +193,17 @@ internal fun <T> DestinationStyle.addActivityDestination(
}
}
is DestinationStyle.Animated -> {
navGraphBuilder.composable(
navGraphBuilder.composable(
route = destination.route,
arguments = destination.arguments,
deepLinks = destination.deepLinks,
enterTransition = { enterTransition() },
exitTransition = { exitTransition() },
popEnterTransition = { popEnterTransition() },
popExitTransition = { popExitTransition() }
popExitTransition = { popExitTransition() },
sizeTransform = sizeTransform?.let { transform ->
{ with(transform) { sizeTransform() } }
}
) { navBackStackEntry ->
@SuppressLint("RestrictedApi")
@Suppress("UNCHECKED_CAST")
Expand Down
12 changes: 5 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ ksp = "1.9.22-1.0.17"

junit = "4.13.2"

compose = "1.7.0-alpha03"
composeMaterial = "1.7.0-alpha03"
composeCompiler = "1.5.9"
composeNavigation = "2.8.0-alpha03"
accompanist = "0.35.0-alpha"
compose = "1.7.0-alpha04"
composeMaterial = "1.7.0-alpha04"
composeCompiler = "1.5.10"
composeNavigation = "2.8.0-alpha04"

ktxSerialization = "1.6.3"
mockk = "1.13.9"
Expand Down Expand Up @@ -53,11 +52,10 @@ androidx-activityCompose = { module = "androidx.activity:activity-compose", vers
# Compose
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-material = { module = "androidx.compose.material:material", version.ref = "composeMaterial" }
compose-material-navigation = { module = "androidx.compose.material:material-navigation", version.ref = "composeMaterial" }
compose-navigation = { module = "androidx.navigation:navigation-compose", version.ref = "composeNavigation" }
compose-viewModel = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "composeViewModel" }

accompanist-material = { module = "com.google.accompanist:accompanist-navigation-material", version.ref = "accompanist" }

# Ksp
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.navigation
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.animations.rememberAnimatedNavHostEngine
import com.ramcosta.composedestinations.animations.utils.bottomSheetComposable
Expand All @@ -34,7 +33,7 @@ import com.ramcosta.samples.playground.ui.screens.settings.SettingsScreen
import com.ramcosta.samples.playground.ui.screens.settings.SettingsViewModel
import com.ramcosta.samples.playground.ui.screens.settings.ThemeSettings

@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialNavigationApi::class)
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun AppNavigation(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -98,7 +97,6 @@ private fun ManualComposableCallsBuilder.greetingScreen(

// region ------- Without using DestinationsNavHost example -------
@Suppress("UNUSED")
@ExperimentalMaterialNavigationApi
@ExperimentalAnimationApi
@Composable
fun SampleAppAnimatedNavHostExample(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Scaffold
import androidx.compose.material.ScaffoldState
import androidx.compose.material.navigation.ModalBottomSheetLayout
import androidx.compose.material.navigation.rememberBottomSheetNavigator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.unit.dp
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavHostController
import androidx.navigation.plusAssign
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.navigation.material.ModalBottomSheetLayout
import com.google.accompanist.navigation.material.rememberBottomSheetNavigator
import com.ramcosta.composedestinations.utils.route
import com.ramcosta.samples.playground.ui.screens.*
import com.ramcosta.samples.playground.ui.screens.destinations.Destination

@OptIn(ExperimentalMaterialNavigationApi::class)
@SuppressLint("RestrictedApi")
@Composable
fun PlaygroundScaffold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.animations.rememberAnimatedNavHostEngine
import com.ramcosta.composedestinations.navigation.navigate
Expand All @@ -19,7 +18,7 @@ import com.ramcosta.destinations.sample.ui.composables.BottomBar
import com.ramcosta.destinations.sample.ui.composables.SampleScaffold
import com.ramcosta.destinations.sample.ui.composables.TopBar

@OptIn(ExperimentalMaterialNavigationApi::class, ExperimentalAnimationApi::class)
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun SampleApp() {
val engine = rememberAnimatedNavHostEngine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ import android.annotation.SuppressLint
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Scaffold
import androidx.compose.material.navigation.ModalBottomSheetLayout
import androidx.compose.material.navigation.rememberBottomSheetNavigator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.unit.dp
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavHostController
import androidx.navigation.plusAssign
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.google.accompanist.navigation.material.ModalBottomSheetLayout
import com.google.accompanist.navigation.material.rememberBottomSheetNavigator
import com.ramcosta.composedestinations.spec.Route
import com.ramcosta.destinations.sample.appCurrentDestinationAsState
import com.ramcosta.destinations.sample.destinations.Destination
import com.ramcosta.destinations.sample.startAppDestination

@OptIn(ExperimentalMaterialNavigationApi::class)
@SuppressLint("RestrictedApi")
@Composable
fun SampleScaffold(
Expand Down

0 comments on commit 96d0729

Please sign in to comment.