Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Jan 6, 2024
1 parent 6cd16cc commit 398ba09
Showing 1 changed file with 45 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.hoc081098.solivagant.sample.products.ProductsScreenRoute
import com.hoc081098.solivagant.sample.search_products.SearchProductScreenDestination
import com.hoc081098.solivagant.sample.search_products.SearchProductScreenRoute
import kotlinx.collections.immutable.persistentSetOf
import org.koin.compose.KoinContext
import org.koin.compose.koinInject

@OptIn(
Expand Down Expand Up @@ -64,50 +65,52 @@ fun SolivagantSampleApp(
)
}

MyApplicationTheme {
Surface(
modifier = modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Scaffold(
topBar = {
TopAppBar(
title = {
Text(
text = when (currentRoute) {
StartScreenRoute -> "KMP ViewModel Sample"
is ProductsScreenRoute -> "Products screen"
is SearchProductScreenRoute -> "Search products screen"
is ProductDetailScreenRoute -> "Product detail screen"
else -> "KMP ViewModel Sample"
},
)
},
navigationIcon = {
if (currentRoute !is NavRoot) {
IconButton(
onClick = remember { navigator::navigateBack },
) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = "Back",
)
KoinContext {
MyApplicationTheme {
Surface(
modifier = modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Scaffold(
topBar = {
TopAppBar(
title = {
Text(
text = when (currentRoute) {
StartScreenRoute -> "KMP ViewModel Sample"
is ProductsScreenRoute -> "Products screen"
is SearchProductScreenRoute -> "Search products screen"
is ProductDetailScreenRoute -> "Product detail screen"
else -> "KMP ViewModel Sample"
},
)
},
navigationIcon = {
if (currentRoute !is NavRoot) {
IconButton(
onClick = remember { navigator::navigateBack },
) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = "Back",
)
}
}
}
},
},
)
},
) { innerPadding ->
NavHost(
modifier = Modifier
.padding(innerPadding)
.consumeWindowInsets(innerPadding)
.fillMaxSize(),
startRoute = StartScreenRoute,
destinations = destinations,
navEventNavigator = navigator,
destinationChangedCallback = { currentRoute = it },
)
},
) { innerPadding ->
NavHost(
modifier = Modifier
.padding(innerPadding)
.consumeWindowInsets(innerPadding)
.fillMaxSize(),
startRoute = StartScreenRoute,
destinations = destinations,
navEventNavigator = navigator,
destinationChangedCallback = { currentRoute = it },
)
}
}
}
}
Expand Down

0 comments on commit 398ba09

Please sign in to comment.