feat: Haptic on dismiss announcement
This commit is contained in:
1 parent
10deb8737c
commit
5ea3194bcf
2 files changed
+19
-1
No files matched your search
@@ -32,6 +32,7 @@ Compatibility list:
|
||||
* [Lawnchair] Set GestureNavContract on by default on Google device
|
||||
* [Lawnchair] Set GestureNavContract on by default on Nothing device
|
||||
* [Lawnchair] Don't show warning on known compatible device
|
||||
* [Lawnchair] Swipe to dismiss announcement perform haptic on successful dismiss
|
||||
|
||||
#### Fixes
|
||||
* [Launcher3] Widget preview crash for no reason at all on compatible Android version
|
||||
@@ -41,6 +42,8 @@ Compatibility list:
|
||||
* [Lawnchair/Recents] Reimplement recents overview opacity
|
||||
* [Lawnchair/Preference] Misaligned slider and text preference
|
||||
* [Lawnchair/Smartspace] Allow disabling the smartspace feature
|
||||
* [Lawnchair] Settings now correctly animate expand/shrink items
|
||||
* [Lawnchair] Correctly display warning in experimental features (race conditions)
|
||||
|
||||
### 🥞 Development 3 Release 2
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package app.lawnchair.ui.preferences.components
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -34,7 +37,9 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
@@ -77,8 +82,15 @@ fun AnnouncementPreference(
|
||||
onDismiss: (Announcement) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
// 1. Add animateContentSize with a spring spec to the Column
|
||||
// This makes the list "spring" into place when an item is removed.
|
||||
Column(
|
||||
modifier = modifier,
|
||||
modifier = modifier.animateContentSize(
|
||||
animationSpec = spring(
|
||||
stiffness = Spring.StiffnessMediumLow,
|
||||
dampingRatio = Spring.DampingRatioLowBouncy
|
||||
)
|
||||
),
|
||||
) {
|
||||
announcements.forEachIndexed { index, announcement ->
|
||||
var dismissed by rememberSaveable { mutableStateOf(false) }
|
||||
@@ -123,10 +135,13 @@ private fun AnnouncementItemContent(
|
||||
modifier: Modifier = Modifier,
|
||||
onClose: () -> Unit,
|
||||
) {
|
||||
val haptic = LocalHapticFeedback.current
|
||||
|
||||
val state = rememberSwipeToDismissBoxState(
|
||||
confirmValueChange = {
|
||||
when (it) {
|
||||
SwipeToDismissBoxValue.StartToEnd -> {
|
||||
haptic.performHapticFeedback(HapticFeedbackType.GestureEnd)
|
||||
onClose()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user