Skip to content

Commit

Permalink
[#553] Define an initial "BaseScreen" component in compose-template
Browse files Browse the repository at this point in the history
  • Loading branch information
luongvo committed Oct 31, 2023
1 parent 91520cc commit 2edce96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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.AppDestination
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
Expand All @@ -23,8 +24,8 @@ import timber.log.Timber
@Composable
fun HomeScreen(
viewModel: HomeViewModel = hiltViewModel(),
navigator: (destination: AppDestination) -> Unit
) {
navigator: (destination: AppDestination) -> Unit,
) = BaseScreen {
val context = LocalContext.current
viewModel.error.collectAsEffect { e -> e.showToast(context) }
viewModel.navigator.collectAsEffect { destination -> navigator(destination) }
Expand Down

0 comments on commit 2edce96

Please sign in to comment.