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 May 27, 2024
1 parent ae5b31d commit a43d6c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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 @@ -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
Expand All @@ -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) }
Expand Down

0 comments on commit a43d6c0

Please sign in to comment.