mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Thank you, Google, very cool
RIP AnimatedVisibility in Lazy layouts
This commit is contained in:
parent
d039f00141
commit
050c0dbe1d
@ -26,11 +26,13 @@ import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentWidth
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Colorize
|
||||
import androidx.compose.material.icons.filled.DarkMode
|
||||
@ -153,162 +155,144 @@ private fun DisplayScreen(
|
||||
title = stringResource(R.string.display_settings),
|
||||
navigationIcon = { NavigateUpButton(navigateUp) }
|
||||
) { paddingValues ->
|
||||
LazyColumn(contentPadding = paddingValues) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(paddingValues)
|
||||
) {
|
||||
UnittoListItem(
|
||||
leadingContent = {
|
||||
Icon(
|
||||
Icons.Default.Palette,
|
||||
stringResource(R.string.color_theme),
|
||||
)
|
||||
},
|
||||
headlineContent = { Text(stringResource(R.string.color_theme)) },
|
||||
supportingContent = { Text(stringResource(R.string.color_theme_support)) },
|
||||
)
|
||||
|
||||
item { Header(stringResource(R.string.color_scheme)) }
|
||||
|
||||
item {
|
||||
UnittoListItem(
|
||||
leadingContent = {
|
||||
Icon(
|
||||
Icons.Default.Palette,
|
||||
stringResource(R.string.color_theme),
|
||||
)
|
||||
},
|
||||
headlineContent = { Text(stringResource(R.string.color_theme)) },
|
||||
supportingContent = { Text(stringResource(R.string.color_theme_support)) },
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
Row(
|
||||
Modifier
|
||||
.horizontalScroll(rememberScrollState())
|
||||
.wrapContentWidth()
|
||||
) {
|
||||
SegmentedButtonsRow(modifier = Modifier.padding(56.dp, 8.dp, 24.dp, 2.dp)) {
|
||||
SegmentedButton(
|
||||
label = stringResource(R.string.auto_label),
|
||||
onClick = { onThemeChange(ThemingMode.AUTO) },
|
||||
selected = ThemingMode.AUTO == currentThemingMode,
|
||||
icon = Icons.Outlined.HdrAuto
|
||||
)
|
||||
SegmentedButton(
|
||||
label = stringResource(R.string.force_light_mode),
|
||||
onClick = { onThemeChange(ThemingMode.FORCE_LIGHT) },
|
||||
selected = ThemingMode.FORCE_LIGHT == currentThemingMode,
|
||||
icon = Icons.Outlined.LightMode
|
||||
)
|
||||
SegmentedButton(
|
||||
label = stringResource(R.string.force_dark_mode),
|
||||
onClick = { onThemeChange(ThemingMode.FORCE_DARK) },
|
||||
selected = ThemingMode.FORCE_DARK == currentThemingMode,
|
||||
icon = Icons.Outlined.DarkMode
|
||||
)
|
||||
}
|
||||
Row(
|
||||
Modifier
|
||||
.horizontalScroll(rememberScrollState())
|
||||
.wrapContentWidth()
|
||||
) {
|
||||
SegmentedButtonsRow(modifier = Modifier.padding(56.dp, 8.dp, 24.dp, 2.dp)) {
|
||||
SegmentedButton(
|
||||
label = stringResource(R.string.auto_label),
|
||||
onClick = { onThemeChange(ThemingMode.AUTO) },
|
||||
selected = ThemingMode.AUTO == currentThemingMode,
|
||||
icon = Icons.Outlined.HdrAuto
|
||||
)
|
||||
SegmentedButton(
|
||||
label = stringResource(R.string.force_light_mode),
|
||||
onClick = { onThemeChange(ThemingMode.FORCE_LIGHT) },
|
||||
selected = ThemingMode.FORCE_LIGHT == currentThemingMode,
|
||||
icon = Icons.Outlined.LightMode
|
||||
)
|
||||
SegmentedButton(
|
||||
label = stringResource(R.string.force_dark_mode),
|
||||
onClick = { onThemeChange(ThemingMode.FORCE_DARK) },
|
||||
selected = ThemingMode.FORCE_DARK == currentThemingMode,
|
||||
icon = Icons.Outlined.DarkMode
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
AnimatedVisibility(
|
||||
visible = currentThemingMode != ThemingMode.FORCE_LIGHT,
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut(),
|
||||
) {
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.DarkMode,
|
||||
iconDescription = stringResource(R.string.force_amoled_mode),
|
||||
headlineText = stringResource(R.string.force_amoled_mode),
|
||||
supportingText = stringResource(R.string.force_amoled_mode_support),
|
||||
switchState = isAmoledThemeEnabled,
|
||||
onSwitchChange = onAmoledThemeChange
|
||||
)
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.Colorize,
|
||||
iconDescription = stringResource(R.string.enable_dynamic_colors),
|
||||
headlineText = stringResource(R.string.enable_dynamic_colors),
|
||||
supportingText = stringResource(R.string.enable_dynamic_colors_support),
|
||||
switchState = isDynamicThemeEnabled,
|
||||
onSwitchChange = onDynamicThemeChange
|
||||
)
|
||||
|
||||
AnimatedVisibility(
|
||||
visible = currentThemingMode != ThemingMode.FORCE_LIGHT,
|
||||
visible = !isDynamicThemeEnabled,
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut(),
|
||||
) {
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.DarkMode,
|
||||
iconDescription = stringResource(R.string.force_amoled_mode),
|
||||
headlineText = stringResource(R.string.force_amoled_mode),
|
||||
supportingText = stringResource(R.string.force_amoled_mode_support),
|
||||
switchState = isAmoledThemeEnabled,
|
||||
onSwitchChange = onAmoledThemeChange
|
||||
headlineContent = { Text(stringResource(R.string.selected_color)) },
|
||||
supportingContent = {
|
||||
ColorSelector(
|
||||
modifier = Modifier.padding(top = 12.dp),
|
||||
selected = selectedColor,
|
||||
onItemClick = onColorChange,
|
||||
colorSchemes = colorSchemes,
|
||||
defaultColor = Color(0xFF186c31)
|
||||
)
|
||||
},
|
||||
modifier = Modifier.padding(start = 40.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
item {
|
||||
AnimatedVisibility(
|
||||
visible = (!isDynamicThemeEnabled) and (selectedColor != Color.Unspecified),
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut(),
|
||||
) {
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.Colorize,
|
||||
iconDescription = stringResource(R.string.enable_dynamic_colors),
|
||||
headlineText = stringResource(R.string.enable_dynamic_colors),
|
||||
supportingText = stringResource(R.string.enable_dynamic_colors_support),
|
||||
switchState = isDynamicThemeEnabled,
|
||||
onSwitchChange = onDynamicThemeChange
|
||||
headlineContent = { Text(stringResource(R.string.monet_mode)) },
|
||||
supportingContent = {
|
||||
MonetModeSelector(
|
||||
modifier = Modifier.padding(top = 12.dp),
|
||||
selected = monetMode,
|
||||
onItemClick = onMonetModeChange,
|
||||
monetModes = remember { MonetMode.values().toList() },
|
||||
customColor = selectedColor,
|
||||
themingMode = currentThemingMode,
|
||||
)
|
||||
},
|
||||
modifier = Modifier.padding(start = 40.dp)
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
AnimatedVisibility(
|
||||
visible = !isDynamicThemeEnabled,
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut(),
|
||||
) {
|
||||
UnittoListItem(
|
||||
headlineContent = { Text(stringResource(R.string.selected_color)) },
|
||||
supportingContent = {
|
||||
ColorSelector(
|
||||
modifier = Modifier.padding(top = 12.dp),
|
||||
selected = selectedColor,
|
||||
onItemClick = onColorChange,
|
||||
colorSchemes = colorSchemes,
|
||||
defaultColor = Color(0xFF186c31)
|
||||
)
|
||||
},
|
||||
modifier = Modifier.padding(start = 40.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
AnimatedVisibility(
|
||||
visible = (!isDynamicThemeEnabled) and (selectedColor != Color.Unspecified),
|
||||
enter = expandVertically() + fadeIn(),
|
||||
exit = shrinkVertically() + fadeOut(),
|
||||
) {
|
||||
UnittoListItem(
|
||||
headlineContent = { Text(stringResource(R.string.monet_mode)) },
|
||||
supportingContent = {
|
||||
MonetModeSelector(
|
||||
modifier = Modifier.padding(top = 12.dp),
|
||||
selected = monetMode,
|
||||
onItemClick = onMonetModeChange,
|
||||
monetModes = remember { MonetMode.values().toList() },
|
||||
customColor = selectedColor,
|
||||
themingMode = currentThemingMode,
|
||||
)
|
||||
},
|
||||
modifier = Modifier.padding(start = 40.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item { Header(stringResource(R.string.additional_settings_group)) }
|
||||
Header(stringResource(R.string.additional_settings_group))
|
||||
|
||||
item {
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.FontDownload,
|
||||
iconDescription = stringResource(R.string.system_font_setting),
|
||||
headlineText = stringResource(R.string.system_font_setting),
|
||||
supportingText = stringResource(R.string.system_font_setting_support),
|
||||
switchState = systemFont,
|
||||
onSwitchChange = updateSystemFont
|
||||
)
|
||||
}
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.FontDownload,
|
||||
iconDescription = stringResource(R.string.system_font_setting),
|
||||
headlineText = stringResource(R.string.system_font_setting),
|
||||
supportingText = stringResource(R.string.system_font_setting_support),
|
||||
switchState = systemFont,
|
||||
onSwitchChange = updateSystemFont
|
||||
)
|
||||
|
||||
// MIDDLE ZERO
|
||||
item {
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.ExposureZero,
|
||||
iconDescription = stringResource(R.string.middle_zero_option),
|
||||
headlineText = stringResource(R.string.middle_zero_option),
|
||||
supportingText = stringResource(R.string.middle_zero_option_support),
|
||||
switchState = middleZero,
|
||||
onSwitchChange = updateMiddleZero
|
||||
)
|
||||
}
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.ExposureZero,
|
||||
iconDescription = stringResource(R.string.middle_zero_option),
|
||||
headlineText = stringResource(R.string.middle_zero_option),
|
||||
supportingText = stringResource(R.string.middle_zero_option_support),
|
||||
switchState = middleZero,
|
||||
onSwitchChange = updateMiddleZero
|
||||
)
|
||||
|
||||
// LANGUAGE
|
||||
item {
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.Language,
|
||||
iconDescription = stringResource(R.string.language_setting),
|
||||
headlineText = stringResource(R.string.language_setting),
|
||||
supportingText = stringResource(R.string.language_setting_support),
|
||||
modifier = Modifier.clickable { navigateToLanguages() }
|
||||
)
|
||||
}
|
||||
UnittoListItem(
|
||||
icon = Icons.Default.Language,
|
||||
iconDescription = stringResource(R.string.language_setting),
|
||||
headlineText = stringResource(R.string.language_setting),
|
||||
supportingText = stringResource(R.string.language_setting_support),
|
||||
modifier = Modifier.clickable { navigateToLanguages() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user