mirror of
https://github.com/pawelorzech/Swoosh.git
synced 2026-03-31 20:15:41 +00:00
feat: add bouncy FAB entrance and press animations
This commit is contained in:
parent
4d78029f9d
commit
677846a748
1 changed files with 37 additions and 1 deletions
|
|
@ -6,8 +6,11 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import com.swoosh.microblog.ui.animation.SwooshMotion
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
|
|
@ -112,6 +115,23 @@ fun FeedScreen(
|
|||
var showDeleteConfirmation by remember { mutableStateOf<GhostAccount?>(null) }
|
||||
var showRenameDialog by remember { mutableStateOf<GhostAccount?>(null) }
|
||||
|
||||
// FAB entrance animation
|
||||
var fabVisible by remember { mutableStateOf(false) }
|
||||
val fabScale by animateFloatAsState(
|
||||
targetValue = if (fabVisible) 1f else 0f,
|
||||
animationSpec = SwooshMotion.bouncy(),
|
||||
label = "fabEntrance"
|
||||
)
|
||||
LaunchedEffect(Unit) { fabVisible = true }
|
||||
|
||||
// FAB press animation
|
||||
var fabPressed by remember { mutableStateOf(false) }
|
||||
val fabPressScale by animateFloatAsState(
|
||||
targetValue = if (fabPressed) 0.85f else 1f,
|
||||
animationSpec = SwooshMotion.bouncyQuick(),
|
||||
label = "fabPress"
|
||||
)
|
||||
|
||||
// Pull-to-refresh
|
||||
val pullRefreshState = rememberPullRefreshState(
|
||||
refreshing = state.isRefreshing,
|
||||
|
|
@ -232,7 +252,23 @@ fun FeedScreen(
|
|||
},
|
||||
floatingActionButton = {
|
||||
if (!isSearchActive) {
|
||||
FloatingActionButton(onClick = onCompose) {
|
||||
FloatingActionButton(
|
||||
onClick = onCompose,
|
||||
modifier = Modifier
|
||||
.graphicsLayer {
|
||||
scaleX = fabScale * fabPressScale
|
||||
scaleY = fabScale * fabPressScale
|
||||
}
|
||||
.pointerInput(Unit) {
|
||||
detectTapGestures(
|
||||
onPress = {
|
||||
fabPressed = true
|
||||
tryAwaitRelease()
|
||||
fabPressed = false
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
Icon(Icons.Default.Add, contentDescription = "New post")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue