From c5fe65f99ea9359e4bddb89d55674c5414dde6f3 Mon Sep 17 00:00:00 2001 From: Luong Vo Date: Fri, 6 Oct 2023 11:07:56 +0700 Subject: [PATCH] [#553] Define an initial "BaseScreen" component in compose-template --- .../nimblehq/template/compose/ui/base/BaseScreen.kt | 13 +++++++++++++ .../compose/ui/screens/main/home/HomeScreen.kt | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 template-compose/app/src/main/java/co/nimblehq/template/compose/ui/base/BaseScreen.kt diff --git a/template-compose/app/src/main/java/co/nimblehq/template/compose/ui/base/BaseScreen.kt b/template-compose/app/src/main/java/co/nimblehq/template/compose/ui/base/BaseScreen.kt new file mode 100644 index 000000000..713fab898 --- /dev/null +++ b/template-compose/app/src/main/java/co/nimblehq/template/compose/ui/base/BaseScreen.kt @@ -0,0 +1,13 @@ +package co.nimblehq.template.compose.ui.base + +import androidx.compose.runtime.Composable + +@Composable +fun BaseScreen( + // TODO Base parameters to request on all screens here + content: @Composable () -> Unit, +) { + // TODO Base logic for all screens here + + content() +} diff --git a/template-compose/app/src/main/java/co/nimblehq/template/compose/ui/screens/main/home/HomeScreen.kt b/template-compose/app/src/main/java/co/nimblehq/template/compose/ui/screens/main/home/HomeScreen.kt index dda7bd4d4..c45fe8e2a 100644 --- a/template-compose/app/src/main/java/co/nimblehq/template/compose/ui/screens/main/home/HomeScreen.kt +++ b/template-compose/app/src/main/java/co/nimblehq/template/compose/ui/screens/main/home/HomeScreen.kt @@ -18,6 +18,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import co.nimblehq.template.compose.R import co.nimblehq.template.compose.extensions.collectAsEffect import co.nimblehq.template.compose.ui.base.BaseDestination +import co.nimblehq.template.compose.ui.base.BaseScreen import co.nimblehq.template.compose.ui.models.UiModel import co.nimblehq.template.compose.ui.showToast import co.nimblehq.template.compose.ui.theme.AppTheme.dimensions @@ -28,7 +29,7 @@ import timber.log.Timber fun HomeScreen( viewModel: HomeViewModel = hiltViewModel(), navigator: (destination: BaseDestination) -> Unit, -) { +) = BaseScreen { val context = LocalContext.current viewModel.error.collectAsEffect { e -> e.showToast(context) } viewModel.navigator.collectAsEffect { destination -> navigator(destination) }