mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 00:35:26 +02:00
Little code clean up
This commit is contained in:
parent
e0ee67ee9c
commit
fb123d697e
@ -36,7 +36,7 @@ fun NavigateUpButton(onClick: () -> Unit) {
|
||||
IconButton(onClick = onClick) {
|
||||
Icon(
|
||||
Icons.Outlined.ArrowBack,
|
||||
contentDescription = stringResource(id = R.string.navigate_up_description)
|
||||
contentDescription = stringResource(R.string.navigate_up_description)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ fun MainScreen(
|
||||
IconButton(onClick = { navControllerAction(SETTINGS_SCREEN) }) {
|
||||
Icon(
|
||||
Icons.Outlined.MoreVert,
|
||||
contentDescription = stringResource(id = R.string.open_settings_description)
|
||||
contentDescription = stringResource(R.string.open_settings_description)
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -68,8 +68,8 @@ fun MyTextField(
|
||||
val clipboardManager = LocalClipboardManager.current
|
||||
val mc = LocalContext.current
|
||||
val textToShow = when {
|
||||
showError -> stringResource(id = R.string.error_label)
|
||||
showLoading -> stringResource(id = R.string.loading_label)
|
||||
showError -> stringResource(R.string.error_label)
|
||||
showLoading -> stringResource(R.string.loading_label)
|
||||
else -> Formatter.format(currentText)
|
||||
}
|
||||
val copiedText: String = stringResource(R.string.copied, textToShow)
|
||||
|
@ -87,14 +87,14 @@ fun TopScreenPart(
|
||||
MyTextField(
|
||||
Modifier.fillMaxWidth(),
|
||||
inputValue,
|
||||
stringResource(id = if (loadingDatabase) R.string.loading_label else unitFrom.shortName),
|
||||
stringResource(if (loadingDatabase) R.string.loading_label else unitFrom.shortName),
|
||||
loadingNetwork,
|
||||
networkError
|
||||
)
|
||||
MyTextField(
|
||||
Modifier.fillMaxWidth(),
|
||||
outputValue,
|
||||
stringResource(id = if (loadingDatabase) R.string.loading_label else unitTo.shortName),
|
||||
stringResource(if (loadingDatabase) R.string.loading_label else unitTo.shortName),
|
||||
loadingNetwork,
|
||||
networkError
|
||||
)
|
||||
|
@ -107,7 +107,7 @@ private fun BasicUnitListScreen(
|
||||
return@LazyColumn
|
||||
}
|
||||
uiState.unitsToShow.forEach { (unitGroup, listOfUnits) ->
|
||||
item { Header(text = stringResource(id = unitGroup.res)) }
|
||||
item { Header(text = stringResource(unitGroup.res)) }
|
||||
items(items = listOfUnits, key = { it.unitId }) { unit ->
|
||||
unitsListItem(unit) {
|
||||
selectAction(it)
|
||||
|
@ -82,12 +82,12 @@ fun ChipsRow(
|
||||
Icon(
|
||||
modifier = Modifier.height(18.dp),
|
||||
imageVector = Icons.Default.Check,
|
||||
contentDescription = stringResource(id = R.string.checked_filter_description)
|
||||
contentDescription = stringResource(R.string.checked_filter_description)
|
||||
)
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.padding(start = 8.dp),
|
||||
text = stringResource(id = item.res),
|
||||
text = stringResource(item.res),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = if (isSelected) MaterialTheme.colorScheme.onSecondaryContainer else MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
@ -108,7 +108,7 @@ fun ChipsRow(
|
||||
Icon(
|
||||
modifier = Modifier.height(18.dp),
|
||||
imageVector = Icons.Default.Settings,
|
||||
contentDescription = stringResource(id = R.string.open_settings_description)
|
||||
contentDescription = stringResource(R.string.open_settings_description)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ private fun SearchTextField(
|
||||
innerTextField()
|
||||
Text(
|
||||
modifier = Modifier.alpha(0.7f),
|
||||
text = stringResource(id = R.string.search_bar_placeholder),
|
||||
text = stringResource(R.string.search_bar_placeholder),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
@ -218,7 +218,7 @@ private fun SearchButton(
|
||||
IconButton(onClick) {
|
||||
Icon(
|
||||
Icons.Default.Search,
|
||||
contentDescription = stringResource(id = R.string.search_button_description)
|
||||
contentDescription = stringResource(R.string.search_button_description)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -237,7 +237,7 @@ private fun FavoritesButton(
|
||||
) {
|
||||
Icon(
|
||||
if (favoritesOnly) Icons.Filled.Favorite else Icons.Filled.FavoriteBorder,
|
||||
contentDescription = stringResource(id = R.string.favorite_button_description)
|
||||
contentDescription = stringResource(R.string.favorite_button_description)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -54,24 +54,24 @@ fun SearchPlaceholder(navigateToSettingsActtion: () -> Unit) {
|
||||
// Big icon in the middle
|
||||
Icon(
|
||||
Icons.Default.SearchOff,
|
||||
contentDescription = stringResource(id = R.string.empty_search_result_description),
|
||||
contentDescription = stringResource(R.string.empty_search_result_description),
|
||||
modifier = Modifier.size(48.dp)
|
||||
)
|
||||
// Primary text
|
||||
Text(
|
||||
text = stringResource(id = R.string.search_placeholder),
|
||||
text = stringResource(R.string.search_placeholder),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
// Secondary text with tips
|
||||
Text(
|
||||
text = stringResource(id = R.string.search_placeholder_secondary),
|
||||
text = stringResource(R.string.search_placeholder_secondary),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
// Open settings button
|
||||
ElevatedButton(onClick = navigateToSettingsActtion) {
|
||||
Text(text = stringResource(id = R.string.search_placeholder_button_label))
|
||||
Text(text = stringResource(R.string.search_placeholder_button_label))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ private fun BasicUnitListItem(
|
||||
RoundedCornerShape(24.dp)
|
||||
),
|
||||
paddingValues = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
|
||||
label = stringResource(id = unit.displayName),
|
||||
label = stringResource(unit.displayName),
|
||||
supportText = shortNameLabel,
|
||||
trailingItem = {
|
||||
AnimatedContent(
|
||||
@ -101,7 +101,7 @@ private fun BasicUnitListItem(
|
||||
) {
|
||||
Icon(
|
||||
if (unit.isFavorite) Icons.Filled.Favorite else Icons.Filled.FavoriteBorder,
|
||||
contentDescription = stringResource(id = R.string.favorite_button_description)
|
||||
contentDescription = stringResource(R.string.favorite_button_description)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -128,7 +128,7 @@ fun UnitListItem(
|
||||
isSelected = isSelected,
|
||||
selectAction = selectAction,
|
||||
favoriteAction = favoriteAction,
|
||||
shortNameLabel = stringResource(id = unit.shortName)
|
||||
shortNameLabel = stringResource(unit.shortName)
|
||||
)
|
||||
|
||||
/**
|
||||
@ -152,5 +152,5 @@ fun UnitListItem(
|
||||
isSelected = isSelected,
|
||||
selectAction = selectAction,
|
||||
favoriteAction = favoriteAction,
|
||||
shortNameLabel = "${convertValue(unit)} ${stringResource(id = unit.shortName)}"
|
||||
shortNameLabel = "${convertValue(unit)} ${stringResource(unit.shortName)}"
|
||||
)
|
||||
|
@ -54,7 +54,7 @@ fun AboutScreen(
|
||||
val mContext = LocalContext.current
|
||||
|
||||
UnittoLargeTopAppBar(
|
||||
title = stringResource(id = R.string.third_party_licenses),
|
||||
title = stringResource(R.string.third_party_licenses),
|
||||
navigateUpAction = navigateUpAction
|
||||
) { padding ->
|
||||
LazyColumn(
|
||||
|
@ -52,7 +52,7 @@ fun SettingsScreen(
|
||||
}
|
||||
|
||||
UnittoLargeTopAppBar(
|
||||
title = stringResource(id = R.string.settings_screen),
|
||||
title = stringResource(R.string.settings_screen),
|
||||
navigateUpAction = navigateUpAction
|
||||
) { padding ->
|
||||
LazyColumn(contentPadding = padding) {
|
||||
@ -63,7 +63,7 @@ fun SettingsScreen(
|
||||
// THEME
|
||||
item {
|
||||
UnittoListItem(
|
||||
label = stringResource(id = R.string.unit_groups_setting),
|
||||
label = stringResource(R.string.unit_groups_setting),
|
||||
onClick = { navControllerAction(UNIT_GROUPS_SCREEN) }
|
||||
)
|
||||
}
|
||||
@ -173,7 +173,7 @@ fun SettingsScreen(
|
||||
// APP VERSION
|
||||
item {
|
||||
UnittoListItem(
|
||||
label = stringResource(id = R.string.app_version_name_setting),
|
||||
label = stringResource(R.string.app_version_name_setting),
|
||||
supportText = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})",
|
||||
onClick = {}
|
||||
)
|
||||
@ -192,17 +192,17 @@ fun SettingsScreen(
|
||||
when (dialogState) {
|
||||
DialogState.PRECISION -> {
|
||||
AlertDialogWithList(
|
||||
title = stringResource(id = R.string.precision_setting),
|
||||
title = stringResource(R.string.precision_setting),
|
||||
listItems = PRECISIONS,
|
||||
selectedItemIndex = viewModel.userPrefs.digitsPrecision,
|
||||
selectAction = { viewModel.updatePrecision(it) },
|
||||
dismissAction = { resetDialog() },
|
||||
supportText = stringResource(id = R.string.precision_setting_info)
|
||||
supportText = stringResource(R.string.precision_setting_info)
|
||||
)
|
||||
}
|
||||
DialogState.SEPARATOR -> {
|
||||
AlertDialogWithList(
|
||||
title = stringResource(id = R.string.separator_setting),
|
||||
title = stringResource(R.string.separator_setting),
|
||||
listItems = SEPARATORS,
|
||||
selectedItemIndex = viewModel.userPrefs.separator,
|
||||
selectAction = { viewModel.updateSeparator(it) },
|
||||
@ -211,20 +211,20 @@ fun SettingsScreen(
|
||||
}
|
||||
DialogState.OUTPUT_FORMAT -> {
|
||||
AlertDialogWithList(
|
||||
title = stringResource(id = R.string.output_format_setting),
|
||||
title = stringResource(R.string.output_format_setting),
|
||||
listItems = OUTPUT_FORMAT,
|
||||
selectedItemIndex = viewModel.userPrefs.outputFormat,
|
||||
selectAction = { viewModel.updateOutputFormat(it) },
|
||||
dismissAction = { resetDialog() },
|
||||
supportText = stringResource(id = R.string.output_format_setting_info)
|
||||
supportText = stringResource(R.string.output_format_setting_info)
|
||||
)
|
||||
}
|
||||
DialogState.CURRENCY_RATE -> {
|
||||
AlertDialogWithList(
|
||||
title = stringResource(id = R.string.currency_rates_note_title),
|
||||
title = stringResource(R.string.currency_rates_note_title),
|
||||
dismissAction = { resetDialog() },
|
||||
supportText = stringResource(id = R.string.currency_rates_note_text),
|
||||
dismissButtonLabel = stringResource(id = R.string.ok_label)
|
||||
supportText = stringResource(R.string.currency_rates_note_text),
|
||||
dismissButtonLabel = stringResource(R.string.ok_label)
|
||||
)
|
||||
}
|
||||
// Dismissing alert dialog
|
||||
|
@ -76,7 +76,7 @@ fun UnitGroupsScreen(
|
||||
.reorderable(state)
|
||||
) {
|
||||
item(key = "enabled") {
|
||||
Header(text = stringResource(id = R.string.enabled_label))
|
||||
Header(text = stringResource(R.string.enabled_label))
|
||||
}
|
||||
|
||||
items(shownUnits.value, { it }) { item ->
|
||||
@ -97,7 +97,7 @@ fun UnitGroupsScreen(
|
||||
leadingItem = {
|
||||
Icon(
|
||||
Icons.Default.RemoveCircle,
|
||||
stringResource(id = R.string.disable_unit_group_description),
|
||||
stringResource(R.string.disable_unit_group_description),
|
||||
tint= MaterialTheme.colorScheme.outline,
|
||||
modifier = Modifier.clickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
@ -109,7 +109,7 @@ fun UnitGroupsScreen(
|
||||
trailingItem = {
|
||||
Icon(
|
||||
Icons.Default.DragIndicator,
|
||||
stringResource(id = R.string.reorder_unit_group_description),
|
||||
stringResource(R.string.reorder_unit_group_description),
|
||||
tint= MaterialTheme.colorScheme.outline,
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
@ -126,7 +126,7 @@ fun UnitGroupsScreen(
|
||||
|
||||
item(key = "disabled") {
|
||||
Header(
|
||||
text = stringResource(id = R.string.disabled_label),
|
||||
text = stringResource(R.string.disabled_label),
|
||||
modifier = Modifier.animateItemPlacement()
|
||||
)
|
||||
}
|
||||
@ -141,7 +141,7 @@ fun UnitGroupsScreen(
|
||||
trailingItem = {
|
||||
Icon(
|
||||
Icons.Default.AddCircleOutline,
|
||||
stringResource(id = R.string.enable_unit_group_description),
|
||||
stringResource(R.string.enable_unit_group_description),
|
||||
tint= MaterialTheme.colorScheme.outline,
|
||||
modifier = Modifier.clickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
|
Loading…
x
Reference in New Issue
Block a user