Stijndcl
07/18/2024, 7:20 PMDestinationsNavHost
inside of that shared composable like the sample app does here: https://github.com/raamcosta/compose-destinations/blob/main/sample/src/main/java/com/ramcosta/destinations/sample/SampleApp.kt#L30
CommonScaffold {
DestinationsNavHost(...)
}
However, my scaffold is only shared for a handful of screens, not every screen in the app. Is there any support for this type of behaviour?
An idea I had was to do something like this (half pseudo-code to get the idea across)
RootComposable {
if (onRouteWithCommonScaffold) {
CommonScaffold {
DestinationsNavHost(...)
}
} else {
DestinationsNavHost(...)
}
}
Is this the right way to implement this? Is there any harm in conditionally defining the DestinationsNavHost
in two separate places like this, or can the library handle that?Ian Lake
07/18/2024, 7:44 PMStijndcl
07/18/2024, 7:53 PMStylianos Gakis
07/18/2024, 7:57 PMStijndcl
07/18/2024, 7:58 PMStijndcl
07/18/2024, 8:43 PMAnimatedContentScope
to our screens in this case? The basic usage docs from Android suggest this@AnimatedContent
(which could be a dependency passed to the NavHost), but the navigation docs specifically use this@composable
for this. Do we have to go with the second case and manually define all our routes using composable {}
, or can we make the library inject this scope for us as well?Stylianos Gakis
07/18/2024, 8:44 PMStijndcl
07/18/2024, 8:44 PMStylianos Gakis
07/18/2024, 8:47 PMval LocalNavAnimatedVisibilityScope = compositionLocalOf<AnimatedVisibilityScope?> { null }
val LocalSharedTransitionScope = compositionLocalOf<SharedTransitionScope?> { null }
Stijndcl
07/18/2024, 9:23 PMcomposable {}
call so I can't use it. ^^ Thanks for the info, will try to piece something together.
Considering this is a fairly common use case now I think it might not hurt to add it to the docs under that Common use cases
section, or just having a docs page that talks about how to integrate shared element transitions with the libStijndcl
07/18/2024, 10:09 PMStylianos Gakis
07/18/2024, 11:50 PMColumn {
MyTopAppBar()
ScreenContent(Modifier.weight(1f, true))
}
Instead to make this simple for yourself.
And inside that custom MyTopAppBar use the same ID for the shared element. And make sure your screens call that same composable.
Yes it would be interesting to see your screen recording. The shared elements apis are still not stable, so using the latest alpha is your best bet with them, but or course that sometimes may come with bugs. I can't tell from the info I got so far if what you're experiencing is a bug or a misconfigurationStijndcl
07/19/2024, 10:32 AMStijndcl
07/19/2024, 10:45 AMStylianos Gakis
07/19/2024, 10:45 AMStijndcl
07/19/2024, 10:48 AMStijndcl
07/19/2024, 10:48 AMStijndcl
07/19/2024, 10:51 AMcolors =
to the topbarStylianos Gakis
07/19/2024, 10:57 AMwindowInsets = WindowInsets(0.dp),
the same exact thing happens?
Also how is the text defined?
Also, try without using the material3 TopAppBar, just do a Box() { Text() }
instead to see if that also behaves weirdly.
I still feel like the text is jumping up exactly the height of the status bar so insets are to blame here, but I am not 100% sure of how m3 topappbar internally lays out stuffStijndcl
07/19/2024, 10:59 AMStijndcl
07/19/2024, 11:01 AMStylianos Gakis
07/19/2024, 11:04 AMStijndcl
07/19/2024, 11:07 AMStylianos Gakis
07/19/2024, 11:08 AMStijndcl
07/19/2024, 11:10 AMStijndcl
07/19/2024, 11:13 AMStijndcl
07/19/2024, 11:14 AMStylianos Gakis
07/19/2024, 11:15 AMStijndcl
07/19/2024, 11:16 AMStijndcl
07/19/2024, 11:32 AMStijndcl
07/19/2024, 11:32 AMStylianos Gakis
07/19/2024, 11:37 AMStijndcl
07/19/2024, 11:39 AMStylianos Gakis
07/19/2024, 11:46 AMSurface(color = YourTheme.colorScheme.background) {
NavHost(...)
}
So that if this happens you still see your color scheme's background behind everything.
And each screen you got should also use that same background color so that there's no distinction between the twoStijndcl
07/19/2024, 11:48 AMStijndcl
07/19/2024, 11:53 AMStylianos Gakis
07/19/2024, 11:57 AMStijndcl
07/19/2024, 12:00 PMWhere such a suggestion would fit
There's a Common Use cases section where I feel like it would fit. Either scaffolds/topbars specifically or just integration with shared element transitions. I'd argue it is a common use case if the question is so common 😄
Stylianos Gakis
07/19/2024, 12:05 PMStijndcl
07/19/2024, 12:09 PMStylianos Gakis
07/19/2024, 12:13 PMStijndcl
07/19/2024, 12:14 PMStylianos Gakis
07/19/2024, 12:18 PMStijndcl
07/19/2024, 12:22 PMthis@composable
but that returns an animated visibility scope when using DestinationsStijndcl
07/19/2024, 12:22 PMStylianos Gakis
07/19/2024, 12:26 PMsealed interface AnimatedContentScope : AnimatedVisibilityScope
contentscope seems to be a visibilityscope itself. I am not sure why it is exposed this way in compose-destinations and if there's any particular reason about it to be honest 🤷Stijndcl
07/19/2024, 1:01 PMStijndcl
07/19/2024, 1:02 PMStylianos Gakis
07/19/2024, 1:12 PMStylianos Gakis
07/19/2024, 1:14 PMStijndcl
07/19/2024, 1:18 PMscreen1
is the start route of the graph, only when it isn'tStylianos Gakis
07/19/2024, 1:21 PMStijndcl
07/19/2024, 1:22 PMStijndcl
07/19/2024, 1:37 PMstart=true
from HomeScreen to Screen1 the issue is solved. Adding a sharedBounds() to the text changes nothing.
(also for some reason Slack keeps changing the language of my text snippet to C++ even though I've set it to Kotlin so excuse the highlighting being broken)Stylianos Gakis
07/19/2024, 1:45 PMText(
text = "HomeScreen is the start",
modifier = Modifier.sharedBounds(sharedTransitionScope.rememberSharedContentState(key = "text"))
)
on your wrapper text changes nothing you say right?
I can't think of something else for this either. There may be a bug too tbf in the current animation version you may be using atm.
Also yeah I am out of my depth regarding what start = true
might be doing. I still find it hard to think that it's the culprit, but as I said I've never used this so I'd rather not make any more assumptions here.Stijndcl
07/19/2024, 1:47 PMstart = true
just changes the value in RootGraph.startRoute, which is passed to the navhost. I also don't think it's the culprit, but rather that there might be a bug when an item has to get created on app launch Vs at a later stage or something.Stijndcl
07/19/2024, 1:50 PMStylianos Gakis
07/19/2024, 2:10 PMStijndcl
07/19/2024, 2:11 PMStijndcl
07/19/2024, 4:01 PM