Like <@U5F0UDF35>, I'm deeply diving into `nav3` a...
# compose
g
Like @galex, I'm deeply diving into
nav3
and I have a question regarding the scene strategy. Do we have a way for the composables to be aware of the strategy ? Meaning I have a composable that is marked as a detail pane, and I want to modify a bit the ui when that composable is displayed within the scene (vs when it's displayed full screen, not as a detail pane)
👀 1
i
Scenes can certainly provide that information, but there is nothing built into the library for that. See the example in https://github.com/android/nav3-recipes/pull/152
g
yeah saw that, we should definitely have a boolean that let the composable know if within a scene or not (not only for the back button) I was going that direction but having the info from the scene is def way better
Copy code
fun PaneScaffoldDirective.isWithinScene(partitionCount: Int) =
    this.maxHorizontalPartitions >= partitionCount
Copy code
val windowAdaptiveInfo = currentWindowAdaptiveInfo()
val directive = calculatePaneScaffoldDirective(windowAdaptiveInfo)
val withinScene = directive.isWithinScene(2)
i
Being in a particular Scene isn't any guarantee of anything, which is why the Scene needs to be involved
g
yeah
So going with creating my own scene, thanks @Ian Lake!
s
Out of curiosity, is there a way for the Scene to propagate this information down without composition locals?
g
@Stylianos Gakis Yeah that could be nice to have that info from the scene strategy we have with
Copy code
val listDetailStrategy = rememberListDetailSceneStrategy<NavKey>()
for now I'm just doing like Don, but instead of mentioning the back button, i'm just telling about the scene
Copy code
val LocalWithinScene = compositionLocalOf{ false }
👍 1
a
I wonder if it would be useful to have a
LocalScene: CompositionLocal<Scene<T>>
where you could pull out information about a
Scene
(assuming the scene supports it)
👍 3
Out of curiosity, is there a way for the Scene to propagate this information down without composition locals?
It'd be hard, to do it explicitly you'd need to have a way to pass through an extra argument while keeping type-safety through all of the wrapping. A
CompositionLocal
is probably a simpler cross-cutting mechanism, especially if it is a piece of information that may or may not be available
👍 2
106 Views