mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 00:35:26 +02:00
Settings button in calculator
This commit is contained in:
parent
951523a235
commit
30b97ef821
@ -91,7 +91,10 @@ fun UnittoNavigation(
|
||||
navigateToEpoch = { navController.navigateToEpoch(navController.clearStack) }
|
||||
)
|
||||
|
||||
calculatorScreen(navigateToMenu = navController::navigateToTools)
|
||||
calculatorScreen(
|
||||
navigateToMenu = navController::navigateToTools,
|
||||
navigateToSettings = navController::navigateToSettings
|
||||
)
|
||||
|
||||
epochScreen(navigateToMenu = navController::navigateToTools)
|
||||
}
|
||||
|
@ -18,10 +18,8 @@
|
||||
|
||||
package com.sadellie.unitto.feature.calculator
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.Crossfade
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.draggable
|
||||
@ -36,6 +34,7 @@ import androidx.compose.foundation.layout.sizeIn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.outlined.MoreVert
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@ -76,6 +75,7 @@ import kotlin.math.roundToInt
|
||||
@Composable
|
||||
internal fun CalculatorRoute(
|
||||
navigateToMenu: () -> Unit,
|
||||
navigateToSettings: () -> Unit,
|
||||
viewModel: CalculatorViewModel = hiltViewModel()
|
||||
) {
|
||||
val uiState = viewModel.uiState.collectAsStateWithLifecycle()
|
||||
@ -83,6 +83,7 @@ internal fun CalculatorRoute(
|
||||
CalculatorScreen(
|
||||
uiState = uiState.value,
|
||||
navigateToMenu = navigateToMenu,
|
||||
navigateToSettings = navigateToSettings,
|
||||
addSymbol = viewModel::addSymbol,
|
||||
clearSymbols = viewModel::clearSymbols,
|
||||
deleteSymbol = viewModel::deleteSymbol,
|
||||
@ -97,6 +98,7 @@ internal fun CalculatorRoute(
|
||||
private fun CalculatorScreen(
|
||||
uiState: CalculatorUIState,
|
||||
navigateToMenu: () -> Unit,
|
||||
navigateToSettings: () -> Unit,
|
||||
addSymbol: (String) -> Unit,
|
||||
clearSymbols: () -> Unit,
|
||||
deleteSymbol: () -> Unit,
|
||||
@ -118,11 +120,8 @@ private fun CalculatorScreen(
|
||||
navigationIcon = { MenuButton { navigateToMenu() } },
|
||||
colors = TopAppBarDefaults.topAppBarColors(MaterialTheme.colorScheme.surfaceVariant),
|
||||
actions = {
|
||||
AnimatedVisibility(
|
||||
visible = showClearHistoryButton,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
Crossfade(showClearHistoryButton) {
|
||||
if (it) {
|
||||
IconButton(
|
||||
onClick = { showClearHistoryDialog = true },
|
||||
content = {
|
||||
@ -132,6 +131,14 @@ private fun CalculatorScreen(
|
||||
)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
IconButton(onClick = navigateToSettings) {
|
||||
Icon(
|
||||
Icons.Outlined.MoreVert,
|
||||
contentDescription = stringResource(R.string.open_settings_description)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
) { paddingValues ->
|
||||
@ -288,6 +295,7 @@ private fun PreviewCalculatorScreen() {
|
||||
history = historyItems
|
||||
),
|
||||
navigateToMenu = {},
|
||||
navigateToSettings = {},
|
||||
addSymbol = {},
|
||||
clearSymbols = {},
|
||||
deleteSymbol = {},
|
||||
|
@ -32,13 +32,17 @@ fun NavController.navigateToCalculator(navOptions: NavOptions) {
|
||||
}
|
||||
|
||||
fun NavGraphBuilder.calculatorScreen(
|
||||
navigateToMenu: () -> Unit
|
||||
navigateToMenu: () -> Unit,
|
||||
navigateToSettings: () -> Unit
|
||||
) {
|
||||
composable(
|
||||
route = calculatorRoute,
|
||||
deepLinks = listOf(
|
||||
navDeepLink { uriPattern = "app://com.sadellie.unitto/$calculatorRoute" }
|
||||
)) {
|
||||
CalculatorRoute(navigateToMenu = navigateToMenu)
|
||||
CalculatorRoute(
|
||||
navigateToMenu = navigateToMenu,
|
||||
navigateToSettings = navigateToSettings
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user