@@ -18,6 +18,8 @@ import android.content.ClipboardManager
1818import android.content.pm.PackageManager
1919import android.widget.Toast
2020import androidx.compose.animation.AnimatedVisibility
21+ import androidx.compose.animation.core.Animatable
22+ import androidx.compose.animation.core.tween
2123import androidx.compose.animation.fadeIn
2224import androidx.compose.animation.fadeOut
2325import androidx.compose.animation.slideInVertically
@@ -27,6 +29,7 @@ import androidx.compose.foundation.layout.Column
2729import androidx.compose.foundation.layout.Spacer
2830import androidx.compose.foundation.layout.fillMaxSize
2931import androidx.compose.foundation.layout.fillMaxWidth
32+ import androidx.compose.foundation.layout.offset
3033import androidx.compose.foundation.layout.padding
3134import androidx.compose.foundation.rememberScrollState
3235import androidx.compose.foundation.shape.RoundedCornerShape
@@ -55,6 +58,7 @@ import androidx.compose.ui.platform.LocalDensity
5558import androidx.compose.ui.platform.LocalHapticFeedback
5659import androidx.compose.ui.platform.LocalWindowInfo
5760import androidx.compose.ui.res.stringResource
61+ import androidx.compose.ui.unit.IntOffset
5862import androidx.compose.ui.unit.dp
5963import androidx.compose.ui.unit.sp
6064import androidx.core.content.ContextCompat
@@ -100,6 +104,18 @@ fun MainScreen(
100104
101105 val showCustomDialog = remember { mutableStateOf(false ) }
102106 val setupShakeKey = remember { mutableIntStateOf(0 ) }
107+ val textShakeKey = remember { mutableIntStateOf(0 ) }
108+
109+ // Text shake animation for the conditions text (shown when the threshold changes)
110+ val textOffsetAnim = remember { Animatable (0f ) }
111+ LaunchedEffect (textShakeKey.intValue) {
112+ if (textShakeKey.intValue > 0 ) {
113+ val offsets = listOf (- 3f , 3f , - 2f , 2f , - 1f , 1f , - 0.5f , 0.5f , 0f )
114+ for (o in offsets) {
115+ textOffsetAnim.animateTo(o, animationSpec = tween(durationMillis = 80 ))
116+ }
117+ }
118+ }
103119
104120 LaunchedEffect (mainViewModel) {
105121 mainViewModel.uiEvents.collect { event ->
@@ -178,7 +194,9 @@ fun MainScreen(
178194 )
179195 Spacer (modifier = Modifier .padding(top = 8 .dp))
180196 Text (
181- modifier = Modifier .padding(horizontal = horizontalOffsetPadding),
197+ modifier = Modifier
198+ .padding(horizontal = horizontalOffsetPadding)
199+ .offset { IntOffset (textOffsetAnim.value.dp.roundToPx(), 0 ) },
182200 text = stringResource(id = R .string.description_switching_conditions),
183201 style = MaterialTheme .typography.bodyLarge.copy(lineHeight = 21 .sp)
184202 )
@@ -253,6 +271,7 @@ fun MainScreen(
253271 onValueChange = { index ->
254272 mainViewModel.setPendingCustomSliderLux(lux[index])
255273 mainViewModel.onSliderValueCommitted(index)
274+ textShakeKey.intValue + = 1
256275 },
257276 enabled = uiState.adaptiveThemeEnabled,
258277 firstCard = true ,
0 commit comments