-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[UI/YAF-000] 온보딩 Lottie Animation을 적용합니다.
- Loading branch information
Showing
20 changed files
with
409 additions
and
23 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
core/ui/src/main/java/com/yapp/ui/component/lottie/LottieAnimation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.yapp.ui.component.lottie | ||
|
||
import androidx.annotation.RawRes | ||
import androidx.compose.animation.core.Animatable | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.graphicsLayer | ||
import androidx.compose.ui.layout.ContentScale | ||
import com.airbnb.lottie.compose.LottieCompositionSpec | ||
import com.airbnb.lottie.compose.LottieConstants | ||
import com.airbnb.lottie.compose.animateLottieCompositionAsState | ||
import com.airbnb.lottie.compose.rememberLottieComposition | ||
|
||
@Composable | ||
fun LottieAnimation( | ||
modifier: Modifier = Modifier, | ||
@RawRes resId: Int, | ||
iterations: Int = LottieConstants.IterateForever, | ||
contentScale: ContentScale = ContentScale.FillWidth, | ||
scaleXAdjustment: Float = 1f, | ||
scaleYAdjustment: Float = 1f, | ||
) { | ||
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(resId)) | ||
val progress by animateLottieCompositionAsState( | ||
composition = composition, | ||
iterations = iterations, | ||
) | ||
val alpha = remember { Animatable(0f) } | ||
|
||
LaunchedEffect(composition) { | ||
if (composition != null) { | ||
alpha.animateTo( | ||
targetValue = 1f, | ||
animationSpec = tween(durationMillis = 500), | ||
) | ||
} | ||
} | ||
|
||
Box( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.graphicsLayer( | ||
scaleX = getScaleFromContentScale(contentScale) * scaleXAdjustment, | ||
scaleY = getScaleFromContentScale(contentScale) * scaleYAdjustment, | ||
alpha = alpha.value, | ||
), | ||
) { | ||
if (composition != null) { | ||
com.airbnb.lottie.compose.LottieAnimation( | ||
composition = composition, | ||
progress = { progress }, | ||
modifier = Modifier.fillMaxSize(), | ||
) | ||
} | ||
} | ||
} | ||
|
||
private fun getScaleFromContentScale(contentScale: ContentScale): Float { | ||
return when (contentScale) { | ||
ContentScale.Fit -> 1f | ||
ContentScale.FillWidth -> 1.2f | ||
ContentScale.FillHeight -> 1.5f | ||
else -> 1f | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
feature/onboarding/src/main/java/com/kms/onboarding/OnboardingCompleteScreen1.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.kms.onboarding | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.wrapContentSize | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.yapp.designsystem.theme.OrbitTheme | ||
import com.yapp.ui.component.lottie.LottieAnimation | ||
import com.yapp.ui.utils.heightForScreenPercentage | ||
import com.yapp.ui.utils.paddingForScreenPercentage | ||
import feature.onboarding.R | ||
|
||
@Composable | ||
fun OnboardingCompleteScreen1( | ||
state: OnboardingContract.State, | ||
onNextClick: () -> Unit, | ||
onBackClick: () -> Unit, | ||
) { | ||
OnboardingScreen( | ||
currentStep = 0, | ||
totalSteps = 0, | ||
isButtonEnabled = true, | ||
onNextClick = onNextClick, | ||
onBackClick = onBackClick, | ||
showTopAppBar = true, | ||
showTopAppBarActions = false, | ||
) { | ||
Column(modifier = Modifier.fillMaxSize()) { | ||
Spacer(modifier = Modifier.heightForScreenPercentage(0.05f)) | ||
Text( | ||
text = stringResource(id = R.string.onboarding_completed_step1_subtitle), | ||
style = OrbitTheme.typography.body2Regular, | ||
color = OrbitTheme.colors.main, | ||
modifier = Modifier.fillMaxWidth(), | ||
textAlign = TextAlign.Center, | ||
) | ||
Text( | ||
text = stringResource(id = R.string.onboarding_completed_step1_title), | ||
style = OrbitTheme.typography.heading1SemiBold, | ||
color = OrbitTheme.colors.white, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.paddingForScreenPercentage(topPercentage = 0.0147f, bottomPercentage = 0.1f), | ||
textAlign = TextAlign.Center, | ||
) | ||
LottieAnimation( | ||
modifier = Modifier.wrapContentSize(), | ||
resId = core.designsystem.R.raw.step2, | ||
contentScale = ContentScale.FillWidth, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun OnboardingCompleteScreen1Preview() { | ||
OrbitTheme { | ||
OnboardingCompleteScreen1( | ||
state = OnboardingContract.State(), | ||
onNextClick = {}, | ||
onBackClick = {}, | ||
) | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
feature/onboarding/src/main/java/com/kms/onboarding/OnboardingCompleteScreen2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.kms.onboarding | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.imePadding | ||
import androidx.compose.foundation.layout.navigationBarsPadding | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.statusBarsPadding | ||
import androidx.compose.foundation.layout.wrapContentSize | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.kms.onboarding.component.OnBoardingTopAppBar | ||
import com.yapp.designsystem.theme.OrbitTheme | ||
import com.yapp.ui.component.button.OrbitButton | ||
import com.yapp.ui.component.lottie.LottieAnimation | ||
import com.yapp.ui.utils.heightForScreenPercentage | ||
import com.yapp.ui.utils.paddingForScreenPercentage | ||
import feature.onboarding.R | ||
|
||
@Composable | ||
fun OnboardingCompleteScreen2( | ||
state: OnboardingContract.State, | ||
onNextClick: () -> Unit, | ||
onBackClick: () -> Unit, | ||
currentStep: Int = 0, | ||
totalSteps: Int = 0, | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(OrbitTheme.colors.gray_900) | ||
.statusBarsPadding() | ||
.navigationBarsPadding() | ||
.imePadding(), | ||
) { | ||
OnBoardingTopAppBar( | ||
currentStep = currentStep, | ||
totalSteps = totalSteps, | ||
onBackClick = onBackClick, | ||
showTopAppBarActions = false, | ||
) | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.weight(1f), | ||
) { | ||
Spacer(modifier = Modifier.heightForScreenPercentage(0.05f)) | ||
Text( | ||
text = stringResource(id = R.string.onboarding_completed_step1_subtitle), | ||
style = OrbitTheme.typography.body2Regular, | ||
color = OrbitTheme.colors.main, | ||
modifier = Modifier.fillMaxWidth(), | ||
textAlign = TextAlign.Center, | ||
) | ||
Text( | ||
text = stringResource(id = R.string.onboarding_completed_step2_title), | ||
style = OrbitTheme.typography.heading1SemiBold, | ||
color = OrbitTheme.colors.white, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.paddingForScreenPercentage(topPercentage = 0.0147f, bottomPercentage = 0.044f), | ||
textAlign = TextAlign.Center, | ||
) | ||
|
||
Box( | ||
modifier = Modifier.fillMaxSize(), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
LottieAnimation( | ||
modifier = Modifier.wrapContentSize(), | ||
resId = core.designsystem.R.raw.step3, | ||
contentScale = ContentScale.FillWidth, | ||
scaleXAdjustment = 0.85f, | ||
scaleYAdjustment = 0.95f, | ||
) | ||
OrbitButton( | ||
label = "시작하기", | ||
modifier = Modifier | ||
.padding(horizontal = 20.dp) | ||
.padding(bottom = 10.dp) | ||
.align(Alignment.BottomCenter), | ||
onClick = onNextClick, | ||
enabled = true, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun OnboardingCompleteScreen2Preview() { | ||
OrbitTheme { | ||
OnboardingCompleteScreen2( | ||
state = OnboardingContract.State(), | ||
onNextClick = {}, | ||
onBackClick = {}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.