Thank you, Google, very cool

RIP AnimatedVisibility in Lazy layouts
This commit is contained in:
Sad Ellie 2023-09-26 15:51:03 +03:00
parent d039f00141
commit 050c0dbe1d

View File

@ -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,11 +155,12 @@ 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
item { Header(stringResource(R.string.color_scheme)) } .fillMaxSize()
.verticalScroll(rememberScrollState())
item { .padding(paddingValues)
) {
UnittoListItem( UnittoListItem(
leadingContent = { leadingContent = {
Icon( Icon(
@ -168,9 +171,7 @@ private fun DisplayScreen(
headlineContent = { Text(stringResource(R.string.color_theme)) }, headlineContent = { Text(stringResource(R.string.color_theme)) },
supportingContent = { Text(stringResource(R.string.color_theme_support)) }, supportingContent = { Text(stringResource(R.string.color_theme_support)) },
) )
}
item {
Row( Row(
Modifier Modifier
.horizontalScroll(rememberScrollState()) .horizontalScroll(rememberScrollState())
@ -197,9 +198,7 @@ private fun DisplayScreen(
) )
} }
} }
}
item {
AnimatedVisibility( AnimatedVisibility(
visible = currentThemingMode != ThemingMode.FORCE_LIGHT, visible = currentThemingMode != ThemingMode.FORCE_LIGHT,
enter = expandVertically() + fadeIn(), enter = expandVertically() + fadeIn(),
@ -214,10 +213,8 @@ private fun DisplayScreen(
onSwitchChange = onAmoledThemeChange onSwitchChange = onAmoledThemeChange
) )
} }
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
item {
UnittoListItem( UnittoListItem(
icon = Icons.Default.Colorize, icon = Icons.Default.Colorize,
iconDescription = stringResource(R.string.enable_dynamic_colors), iconDescription = stringResource(R.string.enable_dynamic_colors),
@ -226,9 +223,7 @@ private fun DisplayScreen(
switchState = isDynamicThemeEnabled, switchState = isDynamicThemeEnabled,
onSwitchChange = onDynamicThemeChange onSwitchChange = onDynamicThemeChange
) )
}
item {
AnimatedVisibility( AnimatedVisibility(
visible = !isDynamicThemeEnabled, visible = !isDynamicThemeEnabled,
enter = expandVertically() + fadeIn(), enter = expandVertically() + fadeIn(),
@ -248,9 +243,7 @@ private fun DisplayScreen(
modifier = Modifier.padding(start = 40.dp), modifier = Modifier.padding(start = 40.dp),
) )
} }
}
item {
AnimatedVisibility( AnimatedVisibility(
visible = (!isDynamicThemeEnabled) and (selectedColor != Color.Unspecified), visible = (!isDynamicThemeEnabled) and (selectedColor != Color.Unspecified),
enter = expandVertically() + fadeIn(), enter = expandVertically() + fadeIn(),
@ -272,11 +265,9 @@ private fun DisplayScreen(
) )
} }
} }
}
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),
@ -285,10 +276,7 @@ private fun DisplayScreen(
switchState = systemFont, switchState = systemFont,
onSwitchChange = updateSystemFont onSwitchChange = updateSystemFont
) )
}
// MIDDLE ZERO
item {
UnittoListItem( UnittoListItem(
icon = Icons.Default.ExposureZero, icon = Icons.Default.ExposureZero,
iconDescription = stringResource(R.string.middle_zero_option), iconDescription = stringResource(R.string.middle_zero_option),
@ -297,10 +285,7 @@ private fun DisplayScreen(
switchState = middleZero, switchState = middleZero,
onSwitchChange = updateMiddleZero onSwitchChange = updateMiddleZero
) )
}
// LANGUAGE
item {
UnittoListItem( UnittoListItem(
icon = Icons.Default.Language, icon = Icons.Default.Language,
iconDescription = stringResource(R.string.language_setting), iconDescription = stringResource(R.string.language_setting),
@ -310,7 +295,6 @@ private fun DisplayScreen(
) )
} }
} }
}
} }
@Preview @Preview