<@UHAJKUSTU> probably basic Decompose question but...
# confetti
j
@Arkadii Ivanov probably basic Decompose question but was looking to add back button to settings screen and not sure how that can be hooked up given way
DefaultSettingsComponent
is created....normally component would be part of tree of components with root one having navigation stack so
navigation.pop()
for example can be passed down to child components.
a
Yeah, not possible with the current setup, since
DefaultSettingsComponent
is singleton, not tied to an activity. I don't remember all the details currently, but it might be possible to move it inside the root component (using
childContext
), and expose it from there.
Oh, it's not in the common code, but specific to the Android app. In this case (since it's not possible to have two root component contexts in an activity), I would try creating both components in the following way (in the main activity).
Copy code
val appComponent =
            handleDeepLink { uri ->
                val initialConferenceId = uri?.extractConferenceIdOrNull()
                val rootComponentContext = defaultComponentContext(discardSavedState = initialConferenceId != null)

                val appComponent = DefaultAppComponent(
                    componentContext = rootComponentContext.childContext("app"),
                    initialConferenceId = initialConferenceId,
                    ...
                )

                val settingsComponent = DefaultSettingsComponent(
                    componentContext = rootComponentContext.childContext("settings"),
                    ...
                )

                appComponent to settingsComponent
            } ?: return
j
Cool, will try that out, thanks
👍 1
Should it be possible to access navigation using that setup?
a
Should be possible, yes.
j
not sure if it's best way but moved things around a bit and seems to work now https://github.com/joreilly/Confetti/pull/1366
a
Can you explain what's changed in the app?
I don't see any changes in
DefaultSettingsComponent
, so I'm not sure why did you need to change its scope. You only handle the back button in the UI. So perhaps, you could just pass
SettingsComponent
via DI instead of using
by inject
in
DefaultConferenceComponent
.
Or maybe, in this particular case you could create and host
SettingsComponent
in the root component.
j
Hmm, yeah, could probably be cleaner.....I'll take another look at how things are plumbed when I get a chance
👍 1