Closed iNoles closed 4 years ago
shouldShowUp
is interesting because normally in a shared toolbar you can use it with
val newKeys = stateChange.getNewKeys()
upButton.showIf { newKeys.size > 1 }
Which is especially possible if you're using the general pattern of .setStateChanger(SimpleStateChanger(this))
to delegate over to the DefaultFragmentStateChanger.
As for title
though, the general idea is that you can extend DefaultFragmentKey
and add any new custom properties that must be shared across all of your keys.
abstract class FragmentKey: DefaultFragmentKey() {
abstract val title: String?
}
Then
class MyFragmentKey: FragmentKey() {
override val title: String? = "MyFragment"
}
You can of course prefer a String resource ID instead of a String, you can make it a fun
that gets a context, etc. it's configurable to your needs.
Did that help?
Sorry, I didn't have a time to test it. :(
Same idea as https://github.com/Zhuinden/simple-stack/blob/master/tutorials/tutorial-sample/src/main/java/com/zhuinden/simplestacktutorials/steps/step_3/Step3Screen.kt#L5 except you extend from DefaultFragmentKey instead.
Any luck?
Yeah, it does work.
Is there is a way to have title and shouldShowUp on DefaultFragmentKey? Is there is better way other than the DefaultFragmentKey?