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