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:
k1ngsterr1
2026-02-07 06:30:16 +05:00
parent 8b5db46b3a
commit eef254a9cf
3 changed files with 607 additions and 1031 deletions

View File

@@ -69,7 +69,7 @@ fun Modifier.customBlur(blur: Float) = this.then(
.createBlurEffect(
blur,
blur,
Shader.TileMode.DECAL,
Shader.TileMode.CLAMP,
)
.asComposeRenderEffect()
}

View File

@@ -410,6 +410,28 @@ fun ProfileScreen(
}
}
// 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
// ═══════════════════════════════════════════════════════════════
// NESTED SCROLL - Telegram style