@@ -66,9 +66,9 @@ import androidx.compose.ui.unit.Dp
66
66
import androidx.compose.ui.unit.IntOffset
67
67
import androidx.compose.ui.unit.dp
68
68
import androidx.compose.ui.unit.times
69
+ import androidx.compose.ui.util.lerp
69
70
import com.getcode.R
70
71
import com.getcode.theme.CodeTheme
71
- import com.getcode.theme.White
72
72
import com.getcode.theme.White50
73
73
import com.getcode.ui.utils.addIf
74
74
import kotlinx.coroutines.CoroutineScope
@@ -175,6 +175,7 @@ fun SlideToConfirm(
175
175
var loading by remember(isLoading) {
176
176
mutableStateOf(isLoading)
177
177
}
178
+
178
179
val hapticFeedback = LocalHapticFeedback .current
179
180
val swipeState = rememberSwipeableState(
180
181
initialValue = if (loading) Anchor .End else Anchor .Start ,
@@ -216,26 +217,23 @@ fun SlideToConfirm(
216
217
hint(swipeFraction, PaddingValues (horizontal = Thumb .Size + CodeTheme .dimens.grid.x2), label)
217
218
}
218
219
219
- when {
220
- isSuccess -> {
221
- Image (
222
- painter = painterResource(id = R .drawable.ic_check),
223
- contentDescription = " " ,
224
- modifier = Modifier
225
- .size(CodeTheme .dimens.grid.x4)
226
- .align(Alignment .Center ),
227
- )
228
- }
229
220
230
- loading -> {
231
- CodeCircularProgressIndicator (
232
- strokeWidth = CodeTheme .dimens.thickBorder,
233
- color = White ,
234
- modifier = Modifier
235
- .size(CodeTheme .dimens.grid.x4)
236
- .align(Alignment .Center ),
237
- )
238
- }
221
+ if (isSuccess) {
222
+ Image (
223
+ painter = painterResource(id = R .drawable.ic_check),
224
+ contentDescription = " " ,
225
+ modifier = Modifier
226
+ .size(CodeTheme .dimens.grid.x4)
227
+ .align(Alignment .Center ),
228
+ )
229
+ } else {
230
+ CodeCircularProgressIndicator (
231
+ strokeWidth = CodeTheme .dimens.thickBorder,
232
+ color = calculateLoadingColor(swipeFraction),
233
+ modifier = Modifier
234
+ .size(CodeTheme .dimens.grid.x4)
235
+ .align(Alignment .Center ),
236
+ )
239
237
}
240
238
241
239
val thumbAlpha by animateFloatAsState(
@@ -364,6 +362,11 @@ private fun calculateHintTextColor(swipeFraction: Float): Color {
364
362
return lerp(Color .White , Color .White .copy(alpha = 0f ), fraction)
365
363
}
366
364
365
+ private fun calculateLoadingColor (swipeFraction : Float ): Color {
366
+ if (swipeFraction < 0.1f ) return Color .White .copy(0f )
367
+ return Color .White
368
+ }
369
+
367
370
@Preview
368
371
@Composable
369
372
private fun Preview () {
0 commit comments