Using now Scaffold instead of implemented app layout by ourselves
This commit is contained in:
parent
ae95673856
commit
3046188db9
|
@ -35,11 +35,12 @@ fun App() {
|
|||
val colors = MaterialTheme.colors.copy(primary = Colors.Primary, primaryVariant = Colors.PrimaryDark, onPrimary = Color.White,
|
||||
secondary = Colors.Accent, secondaryVariant = Colors.Accent, onSecondary = Color.White)
|
||||
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
|
||||
// the same values as in BottomBar, but LocalContentColor.current and LocalContentAlpha.current have a different value there
|
||||
val snackbarTextColor = MaterialTheme.colors.onPrimary.copy(alpha = 0.74f) // 0.74f = ContentAlpha.HighContrastContentAlpha.medium
|
||||
|
||||
// we want to place the FAB half size into the BottomBar so we have to add some top padding to it
|
||||
val fabPositionAdjustment = 44.dp // FabSpacing = 16.dp + FAB height (= 56.dp) / 2
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
coroutineScope.launch {
|
||||
|
@ -49,46 +50,43 @@ fun App() {
|
|||
|
||||
MaterialTheme(colors = colors, typography = typography) {
|
||||
SideMenu {
|
||||
Box {
|
||||
Column(
|
||||
Modifier.background(color = Colors.Zinc100).fillMaxWidth()
|
||||
) {
|
||||
Column(Modifier.fillMaxWidth().weight(1f), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
TransactionsList(DI.uiState)
|
||||
Scaffold(
|
||||
bottomBar = { BottomBar() },
|
||||
backgroundColor = Colors.Zinc100,
|
||||
floatingActionButton = {
|
||||
FloatingActionButton(
|
||||
shape = CircleShape,
|
||||
modifier = Modifier.offset(x = 4.dp, y = fabPositionAdjustment),
|
||||
onClick = { DI.uiState.showAddAccountDialog.value = true }
|
||||
) {
|
||||
Icon(Icons.Filled.Add, contentDescription = "Add a bank account")
|
||||
}
|
||||
},
|
||||
snackbarHost = { snackbarHostState ->
|
||||
StateHandler(DI.uiState, snackbarHostState)
|
||||
|
||||
SnackbarHost(
|
||||
hostState = snackbarHostState
|
||||
) { data ->
|
||||
Snackbar(
|
||||
modifier = Modifier.padding(bottom = 18.dp).padding(12.dp),
|
||||
modifier = Modifier.offset(y = fabPositionAdjustment - 4.dp).padding(horizontal = 12.dp),
|
||||
action = { if (data.actionLabel == null) null else {
|
||||
TextButton(
|
||||
onClick = { data.performAction() },
|
||||
content = { Text(data.actionLabel!!, color = Colors.CodinuxSecondaryColor) }
|
||||
)
|
||||
}
|
||||
TextButton(
|
||||
onClick = { data.performAction() },
|
||||
content = { Text(data.actionLabel!!, color = Colors.CodinuxSecondaryColor) }
|
||||
)
|
||||
}
|
||||
},
|
||||
content = { Text(data.message, color = snackbarTextColor) },
|
||||
backgroundColor = Colors.Primary
|
||||
)
|
||||
}
|
||||
|
||||
BottomBar()
|
||||
}
|
||||
|
||||
Row(Modifier.align(Alignment.BottomEnd)) {
|
||||
FloatingActionButton(
|
||||
shape = CircleShape,
|
||||
modifier = Modifier.offset((-12).dp, (-26).dp),
|
||||
onClick = { DI.uiState.showAddAccountDialog.value = true }
|
||||
) {
|
||||
Icon(Icons.Filled.Add, contentDescription = "Add a bank account")
|
||||
}
|
||||
) { insets ->
|
||||
Column(Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
TransactionsList(DI.uiState)
|
||||
}
|
||||
}
|
||||
|
||||
StateHandler(DI.uiState, snackbarHostState)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue