Enhance OnboardingScreen with smoother pager swipes and add pulse animation to Rosetta logo
- Implemented custom fling behavior for HorizontalPager to improve swipe experience. - Added pulse animation effect to the Rosetta logo on the onboarding screen for better visual appeal. - Updated the layout and animation specifications to enhance user interaction and aesthetics.
This commit is contained in:
@@ -12,6 +12,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.PagerDefaults
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
@@ -238,12 +239,23 @@ fun OnboardingScreen(
|
||||
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
|
||||
// Pager for text content
|
||||
// Pager for text content with easier swipes
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(150.dp)
|
||||
.height(150.dp),
|
||||
flingBehavior = PagerDefaults.flingBehavior(
|
||||
state = pagerState,
|
||||
lowVelocityAnimationSpec = tween(
|
||||
durationMillis = 300,
|
||||
easing = FastOutSlowInEasing
|
||||
),
|
||||
snapAnimationSpec = spring(
|
||||
dampingRatio = Spring.DampingRatioLowBouncy,
|
||||
stiffness = Spring.StiffnessLow
|
||||
)
|
||||
)
|
||||
) { page ->
|
||||
OnboardingPageContent(
|
||||
page = onboardingPages[page],
|
||||
@@ -381,14 +393,44 @@ fun AnimatedRosettaLogo(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
// Pre-render all animations to avoid lag
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
// Rosetta icon (page 0)
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
// Rosetta icon (page 0) with pulse animation
|
||||
if (currentPage == 0) {
|
||||
val pulseScale by rememberInfiniteTransition(label = "pulse").animateFloat(
|
||||
initialValue = 1f,
|
||||
targetValue = 1.08f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(1000, easing = FastOutSlowInEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
),
|
||||
label = "pulseScale"
|
||||
)
|
||||
|
||||
// Glow effect behind logo - separate Box without clipping
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(200.dp)
|
||||
.scale(pulseScale)
|
||||
.background(
|
||||
color = Color(0xFF54A9EB).copy(alpha = 0.15f),
|
||||
shape = CircleShape
|
||||
)
|
||||
)
|
||||
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.rosetta_icon),
|
||||
contentDescription = "Rosetta Logo",
|
||||
modifier = Modifier
|
||||
.size(180.dp)
|
||||
.scale(pulseScale)
|
||||
.clip(CircleShape)
|
||||
)
|
||||
}
|
||||
painter = painterResource(id = R.drawable.rosetta_icon),
|
||||
contentDescription = "Rosetta Logo",
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.scale(pulseScale)
|
||||
.clip(CircleShape)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user