Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOP-109] ToHotStateCard들이 UserCard와 동일한 UI를 가지도록 변경 #131

Merged
merged 4 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/ui/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<color name="gray_2d2d2d">#2d2d2d</color>
<color name="gray_4b4b4b">#4b4b4b</color>
<color name="gray_939393">#939393</color>
<color name="gray_414141">#414141</color>

<color name="black_222222">#222222</color>
<color name="black_2c2c2c">#2c2c2c</color>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -15,7 +14,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.tht.tht.domain.signup.model.IdealTypeModel
Expand Down Expand Up @@ -72,9 +70,7 @@ fun ToHotCard(
}

FallingCard(
modifier = modifier
.fillMaxSize()
.clip(RoundedCornerShape(12.dp)),
modifier = modifier,
fallingProgress = fallingAnimatedProgress.value
) {
ToHotCardImagePager(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tht.feature.tohot.component.card

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -13,6 +14,7 @@ import androidx.compose.material.ButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
Expand All @@ -36,10 +38,25 @@ fun ToHotNotifyCard(
Column(
modifier = modifier
.background(
colorResource(id = tht.core.ui.R.color.black_222222)
brush = Brush.linearGradient(
colors = listOf(
colorResource(tht.core.ui.R.color.black_1D1D1D),
colorResource(tht.core.ui.R.color.black_161616),
colorResource(tht.core.ui.R.color.black_1D1D1D)
)
),
shape = RoundedCornerShape(12.dp)
)
.border(
width = 1.dp,
brush = Brush.linearGradient(
colors = listOf(
colorResource(tht.core.ui.R.color.gray_414141).copy(alpha = 0.3f),
colorResource(tht.core.ui.R.color.black_1A1A1A).copy(alpha = 0.9f)
)
),
shape = RoundedCornerShape(12.dp)
)
.fillMaxSize()
.clip(RoundedCornerShape(12.dp))
) {
ToHotEmptyTimeProgressContainer(
modifier = Modifier
Expand Down Expand Up @@ -97,6 +114,10 @@ fun ToHotNotifyCard(
@Preview
private fun ToHotNotifyCardPreview() {
ToHotNotifyCard(
modifier = Modifier
.fillMaxSize()
.padding(start = 14.dp, end = 14.dp, top = 6.dp, bottom = 14.dp)
.clip(RoundedCornerShape(12.dp)),
image = painterResource(id = R.drawable.ic_mudy_none_initial_user),
title = "가나다라마바사",
description = "preview",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ fun TopicSelectTypeCardScreen(
width = 1.dp,
brush = Brush.linearGradient(
colors = listOf(
colorResource(R.color.gray_8d8d8d).copy(alpha = 0.3f),
colorResource(R.color.black_414141).copy(alpha = 0.9f)
colorResource(R.color.gray_414141).copy(alpha = 0.3f),
colorResource(R.color.black_1A1A1A).copy(alpha = 0.9f)
)
),
shape = RoundedCornerShape(12.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.VerticalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.collections.immutable.ImmutableList
Expand Down Expand Up @@ -76,12 +78,32 @@ internal fun ToHotScreen(
)
}

val cardModifier = Modifier
.fillMaxSize()
.padding(start = 14.dp, end = 14.dp, top = 6.dp, bottom = 14.dp)
.clip(RoundedCornerShape(12.dp))

when (toHotCardState) {
ToHotCardState.Enter -> ToHotEnterCard(onClick = onEnterClick)
ToHotCardState.NoneInitializeUser -> ToHotNoneInitialUserCard(onClick = onRefreshClick)
ToHotCardState.NoneNextUser -> ToHotNoneNextUserCard(onClick = onRefreshClick)
ToHotCardState.QuerySuccess -> ToHotQuerySuccessCard(onClick = onEnterClick)
ToHotCardState.Error -> ToHotErrorCard(onClick = onRefreshClick)
ToHotCardState.Enter -> ToHotEnterCard(
modifier = cardModifier,
onClick = onEnterClick
)
ToHotCardState.NoneInitializeUser -> ToHotNoneInitialUserCard(
modifier = cardModifier,
onClick = onRefreshClick
)
ToHotCardState.NoneNextUser -> ToHotNoneNextUserCard(
modifier = cardModifier,
onClick = onRefreshClick
)
ToHotCardState.QuerySuccess -> ToHotQuerySuccessCard(
modifier = cardModifier,
onClick = onEnterClick
)
ToHotCardState.Error -> ToHotErrorCard(
modifier = cardModifier,
onClick = onRefreshClick
)

ToHotCardState.NoneSelectTopic,
ToHotCardState.Running -> {
Expand All @@ -103,9 +125,7 @@ internal fun ToHotScreen(
val isCurrentCard = currentUserIdx == pagerState.currentPage &&
idx == currentUserIdx
ToHotCard(
modifier = Modifier
.fillMaxSize()
.padding(start = 14.dp, end = 14.dp, top = 6.dp, bottom = 14.dp),
modifier = cardModifier,
imageUrls = card.user.profileImgUrl,
name = card.user.nickname,
age = card.user.age,
Expand All @@ -132,9 +152,7 @@ internal fun ToHotScreen(

is ToHotCardUiModel.Topic -> {
TopicSelectCard(
modifier = Modifier
.fillMaxSize()
.padding(start = 14.dp, end = 14.dp, top = 6.dp, bottom = 14.dp),
modifier = cardModifier,
topicCard = card.topic,
selectTopicIdx = topicInfo.selectTopicIdx,
onSelectTopic = onSelectTopic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import com.example.compose_ui.common.viewmodel.Store
import com.example.compose_ui.common.viewmodel.intent
import com.example.compose_ui.common.viewmodel.store
import com.tht.tht.domain.tohot.FetchToHotStateUseCase
import com.tht.tht.domain.tohot.SelectTopicUseCase
import com.tht.tht.domain.tohot.ToHotStateModel
import com.tht.tht.domain.token.model.NeedLogoutException
import com.tht.tht.domain.tohot.SelectTopicUseCase
import com.tht.tht.domain.user.BlockUserUseCase
import com.tht.tht.domain.user.ReportUserUseCase
import com.tht.tht.domain.user.SendDislikeUseCase
Expand Down Expand Up @@ -115,6 +115,11 @@ class ToHotViewModel @Inject constructor(
reduce {
toHotState.toUiState(it, autoRunToHot)
}
if (autoRunToHot) {
tryScrollToNext(
currentIdx = store.state.value.enableTimerIdx
)
}
}.onFailure { e ->
e.printStackTrace()
reduce {
Expand Down Expand Up @@ -341,18 +346,17 @@ class ToHotViewModel @Inject constructor(
selectTopicIdx = store.state.value.topic.selectTopicIdx
)
if (selectTopic == null || selectTopic.idx < 0) return

intent {
reduce { it.copy(loading = ToHotLoading.TopicSelect) }
selectTopicUseCase(topicIdx = selectTopic.idx)
selectTopicUseCase.invoke(topicIdx = selectTopic.idx)
.unWrapTokenException()
.onSuccess {
when (it) {
true -> {
reduce { state ->
state.copy(
topic = state.topic.copy(
selectTopicIdx = -1,
selectTopicIdx = selectTopic.idx,
currentTopic = selectTopic
),
loading = ToHotLoading.None,
Expand Down
Loading