Use derived state for contrastColor in BrightDisplayActivity

This commit is contained in:
Ensar Sarajčić
2023-10-02 16:53:39 +02:00
parent 10fa019813
commit 2e1821320f
2 changed files with 9 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import com.simplemobiletools.flashlight.views.SleepTimer
@Composable
internal fun BrightDisplayScreen(
backgroundColor: Int,
contrastColor: Int,
timerText: String,
timerVisible: Boolean,
onChangeColorPress: () -> Unit,
@ -44,14 +45,14 @@ internal fun BrightDisplayScreen(
.align(Alignment.Center)
.border(
width = 1.dp,
color = Color(backgroundColor.getContrastColor()),
color = Color(contrastColor),
shape = MaterialTheme.shapes.extraLarge
),
onClick = onChangeColorPress
) {
Text(
text = stringResource(id = R.string.change_color),
color = Color(backgroundColor.getContrastColor())
color = Color(contrastColor)
)
}
@ -77,6 +78,7 @@ private fun BrightDisplayScreenPreview() {
AppThemeSurface {
BrightDisplayScreen(
backgroundColor = MaterialTheme.colorScheme.background.toArgb(),
contrastColor = MaterialTheme.colorScheme.background.toArgb().getContrastColor(),
timerText = "00:00",
timerVisible = true,
onChangeColorPress = {},