Add haptic feedback for profile avatar interactions
- Implemented haptic feedback on avatar collapse when reaching the notch. - Added haptic feedback for snap back action when the avatar returns from an expanded state. - Introduced state management for triggering haptic feedback to ensure it only occurs at appropriate times.
This commit is contained in:
@@ -409,6 +409,28 @@ fun ProfileScreen(
|
||||
hasTriggeredExpandHaptic = false
|
||||
}
|
||||
}
|
||||
|
||||
// Haptic on collapse — light tick when avatar reaches notch
|
||||
var hasTriggeredCollapseHaptic by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(collapseProgress) {
|
||||
if (collapseProgress >= 0.95f && !hasTriggeredCollapseHaptic) {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||
hasTriggeredCollapseHaptic = true
|
||||
} else if (collapseProgress < 0.5f) {
|
||||
hasTriggeredCollapseHaptic = false
|
||||
}
|
||||
}
|
||||
|
||||
// Haptic on snap back — when avatar snaps back from expanded
|
||||
var hasTriggeredSnapBackHaptic by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(isPulledDown, expansionProgress) {
|
||||
if (!isPulledDown && expansionProgress < 0.05f && hasTriggeredSnapBackHaptic) {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||
hasTriggeredSnapBackHaptic = false
|
||||
} else if (isPulledDown) {
|
||||
hasTriggeredSnapBackHaptic = true
|
||||
}
|
||||
}
|
||||
|
||||
// DEBUG LOGS
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user