Davide Giuseppe Farella
08/30/2020, 4:15 PMScaffold(topBar = ..., bottomBar = ..., ...) {
when (currentScreen) {
...
}
}
Problem is that some screen have fab, some have search bar in topBar, which has actions, etc.
So I change that as
val content @Composable () -> Unit = {
when (currentScreen) {
...
}
}
if (currentScreen.isHomeDestination) {
Scaffold(...) { content() }
else
content()
and it was still looking nice on the UI prospective, but ugly on the code, because some screens will be wrapped in Scaffold, while some will be wrapped somewhere else ( 👆 ),
So I created a custom Scaffold and moved into my screens
@Composable
fun SearchMovie(...) {
HomeScaffold {
...
}
}
But now it looks ugly on the UI, because I open my drawer, but when I select an item it replaces the whole screen, so my drawer disappear without the animation.
What would be the best way to deal with that?drawerState.close(myAction)
Eric Martori
08/30/2020, 8:40 PMcurrentScreen
that tells you if the screen has a top bar?
Scaffold(
topBar = { AppBar(currentScreen) }.takeIf(currentScreen.hasTopBar)
) { /*body*/ }
Davide Giuseppe Farella
08/31/2020, 6:49 PMProblem is that some screen have fab, some have search bar in topBar, which has actions, etc.
Eric Martori
08/31/2020, 7:59 PMinterface Screen {
val topBar: @Composable (() -> Unit)?
val bottomBar: @Composable (() -> Unit)?
val fab: @Composable (() -> Unit)?
val body: @Composable (InnerPadding) -> Unit
}
and implement your scaffold like this:
Scaffold(
topBar = currentScreen.topBar,
bottomBar = currentScreen.bottomBar,
floatingActionButton = currentScreen.fab
) {
currentScreen.body(it)
}
Take in mind this are just some ideas I am not experienced with Compose yetDavide Giuseppe Farella
09/01/2020, 3:45 PMTimo Drick
09/02/2020, 9:36 AM