Skip to content

Commit f86cc05

Browse files
committed
로그인 애니메이션 추가
1 parent 68881ad commit f86cc05

File tree

4 files changed

+83
-56
lines changed

4 files changed

+83
-56
lines changed
544 Bytes
Loading
19.6 KB
Loading
364 KB
Loading

feature/login/src/main/java/com/plottwist/feature/login/LoginScreen.kt

Lines changed: 83 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
package com.plottwist.feature.login
22

3+
import android.annotation.SuppressLint
34
import android.app.Activity
5+
import androidx.compose.animation.core.EaseInCubic
6+
import androidx.compose.animation.core.EaseInOut
7+
import androidx.compose.animation.core.FastOutLinearInEasing
8+
import androidx.compose.animation.core.FastOutSlowInEasing
9+
import androidx.compose.animation.core.LinearEasing
10+
import androidx.compose.animation.core.LinearOutSlowInEasing
11+
import androidx.compose.animation.core.RepeatMode
412
import androidx.compose.animation.core.animateDpAsState
13+
import androidx.compose.animation.core.animateFloat
14+
import androidx.compose.animation.core.infiniteRepeatable
15+
import androidx.compose.animation.core.keyframes
16+
import androidx.compose.animation.core.rememberInfiniteTransition
517
import androidx.compose.animation.core.tween
618
import androidx.compose.foundation.background
719
import androidx.compose.foundation.border
@@ -28,12 +40,16 @@ import androidx.compose.runtime.setValue
2840
import androidx.compose.ui.Alignment
2941
import androidx.compose.ui.Modifier
3042
import androidx.compose.ui.draw.clip
43+
import androidx.compose.ui.graphics.Brush
3144
import androidx.compose.ui.graphics.Color
3245
import androidx.compose.ui.layout.ContentScale
46+
import androidx.compose.ui.platform.LocalConfiguration
3347
import androidx.compose.ui.platform.LocalContext
48+
import androidx.compose.ui.platform.LocalDensity
3449
import androidx.compose.ui.res.stringResource
3550
import androidx.compose.ui.text.font.FontWeight
3651
import androidx.compose.ui.text.style.TextAlign
52+
import androidx.compose.ui.tooling.preview.Preview
3753
import androidx.compose.ui.unit.Dp
3854
import androidx.compose.ui.unit.dp
3955
import androidx.compose.ui.unit.sp
@@ -65,16 +81,24 @@ fun LoginScreen(
6581
).googleAuthProvider()
6682
}
6783

68-
var postCardAnimated by remember { mutableStateOf(false) }
69-
val postCardPadding by animateDpAsState(
70-
targetValue = if(postCardAnimated) 56.dp else 0.dp,
71-
animationSpec = tween(700)
72-
)
84+
val infiniteTransition = rememberInfiniteTransition()
85+
val postCardPadding by infiniteTransition.animateFloat(
86+
initialValue = 40f,
87+
targetValue = 40f, // 마지막 키프레임과 동일해야 함
88+
animationSpec = infiniteRepeatable(
89+
animation = keyframes {
90+
durationMillis = 1800
91+
delayMillis = 1000
7392

74-
LaunchedEffect(Unit) {
75-
delay(500)
76-
postCardAnimated = true
77-
}
93+
40f at 100 using LinearOutSlowInEasing
94+
380f at 420 using LinearOutSlowInEasing
95+
330f at 800 using FastOutLinearInEasing
96+
330f at 1200 using EaseInOut
97+
},
98+
repeatMode = RepeatMode.Restart
99+
),
100+
label = "piecewiseValue"
101+
)
78102

79103
viewModel.collectSideEffect { sideEffect ->
80104
when (sideEffect) {
@@ -114,7 +138,7 @@ fun LoginScreen(
114138

115139
@Composable
116140
private fun LoginScreen(
117-
postCardPadding : Dp,
141+
postCardPadding: Float,
118142
onCloseClicked: () -> Unit,
119143
onGoogleLoginButtonClick: () -> Unit,
120144
modifier: Modifier = Modifier
@@ -131,7 +155,7 @@ private fun LoginScreen(
131155
)
132156

133157
Text(
134-
modifier = Modifier.padding(top = 48.dp, bottom = 20.dp),
158+
modifier = Modifier.padding(top = 14.dp, bottom = 20.dp),
135159
text = "누군가 나를 떠올리며 \n" +
136160
"툭, 건넸어요",
137161
textAlign = TextAlign.Center,
@@ -142,11 +166,8 @@ private fun LoginScreen(
142166
modifier = Modifier.weight(1f),
143167
contentAlignment = Alignment.Center
144168
) {
145-
StableImage(
146-
modifier = Modifier
147-
.fillMaxWidth(),
148-
drawableResId = R.drawable.img_login_card,
149-
contentScale = ContentScale.FillWidth
169+
LoginContent(
170+
postCardPadding = postCardPadding
150171
)
151172
}
152173

@@ -175,31 +196,44 @@ fun LoginAppBar(
175196
)
176197
}
177198

199+
@SuppressLint("ConfigurationScreenWidthHeight")
178200
@Composable
179201
fun LoginContent(
180-
postCardPadding : Dp,
202+
postCardPadding: Float,
181203
modifier: Modifier = Modifier
182204
) {
205+
val configuration = LocalConfiguration.current
206+
val density = LocalDensity.current
207+
183208
Box(
184209
modifier = modifier,
185210
contentAlignment = Alignment.Center
186211
) {
187-
PostCard(
188-
modifier = Modifier
189-
.fillMaxWidth()
190-
.padding(bottom = 18.dp + postCardPadding)
191-
.padding(horizontal = 62.dp)
192-
.aspectRatio(260f / 334f)
193-
)
212+
with(density) {
213+
PostCard(
214+
modifier = Modifier
215+
.fillMaxWidth()
216+
.padding(bottom = postCardPadding.toDp() )
217+
.padding(horizontal = 180f.toDp())
218+
.aspectRatio(260f / 304f)
219+
)
220+
221+
StableImage(
222+
modifier = Modifier
223+
.fillMaxWidth()
224+
.padding(top = 4f.toDp())
225+
.aspectRatio(260f / 364f),
226+
drawableResId = R.drawable.img_login_cover,
227+
contentScale = ContentScale.FillWidth
228+
)
229+
}
230+
194231

195232
StableImage(
196-
modifier = Modifier
197-
.fillMaxWidth()
198-
.padding(top = 62.dp)
199-
.aspectRatio(260f / 364f),
200-
drawableResId = R.drawable.image_post_cover,
201-
contentScale = ContentScale.FillWidth
233+
modifier = Modifier.align(Alignment.Center),
234+
drawableResId = R.drawable.img_app_name,
202235
)
236+
203237
}
204238
}
205239

@@ -208,7 +242,7 @@ private fun PostCard(
208242
modifier: Modifier = Modifier,
209243
shape: RoundedCornerShape = RoundedCornerShape(10.dp)
210244
) {
211-
Column (
245+
Column(
212246
modifier = modifier
213247
.clip(shape)
214248
.border(
@@ -217,39 +251,22 @@ private fun PostCard(
217251
shape = shape
218252
)
219253
.background(
220-
color = Color(0xFFFAFAFA),
254+
brush = Brush.verticalGradient(
255+
listOf(
256+
Color(0xFFFF3838),
257+
Color(0xFFFFF9F9)
258+
)
259+
),
221260
shape = shape
222261
)
223262
.padding(top = 25.dp, bottom = 12.dp),
224263
horizontalAlignment = Alignment.CenterHorizontally,
225264
verticalArrangement = Arrangement.SpaceBetween
226265
) {
227266
StableImage(
228-
drawableResId = R.drawable.image_double_quotation_marks
267+
modifier = Modifier.size(20.dp),
268+
drawableResId = R.drawable.image_double_quotation_marks_white,
229269
)
230-
231-
Row(
232-
modifier = Modifier
233-
.fillMaxWidth()
234-
.padding(horizontal = 24.dp),
235-
horizontalArrangement = Arrangement.SpaceBetween
236-
) {
237-
Text(
238-
text = stringResource(R.string.post_card_bottom_description_start),
239-
style = TukSerifTypography.body14R.copy(
240-
fontSize = 12.sp
241-
),
242-
color = Color(0xFF1F1F1F)
243-
)
244-
245-
Text(
246-
text = stringResource(R.string.post_card_bottom_description_end),
247-
style = TukSerifTypography.body14R.copy(
248-
fontSize = 12.sp
249-
),
250-
color = Color(0xFF1F1F1F)
251-
)
252-
}
253270
}
254271
}
255272

@@ -318,3 +335,13 @@ fun GoogleLoginButton(
318335
)
319336
}
320337
}
338+
339+
@Preview
340+
@Composable
341+
private fun LoginScreenPreview() {
342+
LoginScreen(
343+
postCardPadding = 0f,
344+
onCloseClicked = {},
345+
onGoogleLoginButtonClick = {}
346+
)
347+
}

0 commit comments

Comments
 (0)