Skip to content

Commit

Permalink
better navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
iakanoe committed Nov 2, 2023
1 parent 78a7e42 commit d2135fd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.iakanoe.github.dolarcito.ui

import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -115,9 +118,11 @@ fun DolarcitoNavigation() {
}
) { innerPadding ->
NavHost(
modifier = Modifier.padding(innerPadding),
navController = navController,
startDestination = Screen.RATES,
modifier = Modifier.padding(innerPadding)
enterTransition = { slideIntoContainer(towards = AnimatedContentTransitionScope.SlideDirection.Start) + fadeIn() },
exitTransition = { slideOutOfContainer(towards = AnimatedContentTransitionScope.SlideDirection.End) + fadeOut() }
) {
composable(Screen.RATES) {
ExchangeRatesScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -99,21 +100,23 @@ fun ExchangeRatesScreen(
)
}

Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
when (val state = viewState) {
is ExchangeRatesViewState.Loading -> CircularProgressIndicator()
Surface {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
when (val state = viewState) {
is ExchangeRatesViewState.Loading -> CircularProgressIndicator()

is ExchangeRatesViewState.Error -> ErrorContent(
onRetryClick = { viewModel.update() }
)
is ExchangeRatesViewState.Error -> ErrorContent(
onRetryClick = { viewModel.update() }
)

is ExchangeRatesViewState.Loaded -> ExchangeRateList(
exchangeRates = state.exchangeRates,
hiddenExchangeRates = state.hiddenExchangeRates
)
is ExchangeRatesViewState.Loaded -> ExchangeRateList(
exchangeRates = state.exchangeRates,
hiddenExchangeRates = state.hiddenExchangeRates
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -78,14 +79,16 @@ fun SettingsScreen(
)
}

Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
when (viewState) {
is SettingsViewState.Loading -> CircularProgressIndicator()
is SettingsViewState.Loaded -> OrderableList()
else -> Unit
Surface {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
when (viewState) {
is SettingsViewState.Loading -> CircularProgressIndicator()
is SettingsViewState.Loaded -> OrderableList()
else -> Unit
}
}
}
}
Expand Down

0 comments on commit d2135fd

Please sign in to comment.