MainView: Add support for SnackBar

This commit is contained in:
Davide Depau committed 2024-10-30 23:17:32 +01:00
1 parent b45eb912de
commit 42987f476d
1 file changed
+15 -4
@@ -2,8 +2,9 @@ package eu.depau.etchdroid.ui.composables
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
@@ -14,7 +15,11 @@ import eu.depau.etchdroid.ui.theme.EtchDroidTheme
@Composable
fun MainView(viewModel: IThemeViewModel<*>, content: @Composable () -> Unit) {
fun MainView(
viewModel: IThemeViewModel<*>,
snackbarHost: @Composable () -> Unit = {},
content: @Composable () -> Unit
) {
val uiState by viewModel.state.collectAsState()
val darkMode by viewModel.darkMode
@@ -25,8 +30,14 @@ fun MainView(viewModel: IThemeViewModel<*>, content: @Composable () -> Unit) {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Box(Modifier.safeDrawingPadding()) {
content()
Scaffold(snackbarHost = snackbarHost) { contentPadding ->
Box(
Modifier
.fillMaxSize()
.padding(contentPadding)
) {
content()
}
}
}
}