-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT/#66] 홈 화면 UI 구현 #71
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
Changes from all commits
90d176c
2687f5f
230f96c
c31c41c
6abd0cb
bf92a62
fd87b62
7ccaf2d
2a87c1f
fb11b98
fa7380f
32d2dd0
845d806
a1a41d2
4463420
fb85534
cf729be
6a19974
0217f2f
1ba3ee9
4588e29
9aca02c
accf90a
5292bab
2c1be3d
9c71ba2
d3c296c
0e31553
a7126f9
15eddec
66f243f
145b33d
f5cea56
0d6bbb9
b0154d4
fbd3a50
742bcdb
c1aceb5
e935651
087b68c
dcb0790
a23dbbf
ade572c
6126fff
79989bb
029f185
bff9adc
633f598
723e2be
6223004
2ed13e0
9c14a36
c8c5d25
66e2ea4
8cd7507
7612b28
7eaf10f
94a355c
4215e1a
2e5a9ef
07fe55e
c0b0d17
b51671e
c13ca9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| package com.cherrish.android.core.designsystem.component.type | ||
|
|
||
| import androidx.annotation.DrawableRes | ||
| import com.cherrish.android.R | ||
|
|
||
| enum class CherrishGaugeType( | ||
| val step: Int | ||
| val step: Int, | ||
| val percent: Int, | ||
| @DrawableRes val image: Int | ||
| ) { | ||
| LEVEL1(1), | ||
| LEVEL2(2), | ||
| LEVEL3(3), | ||
| LEVEL4(4) | ||
| LEVEL1(step = 1, percent = 25, image = R.drawable.img_lv1), | ||
| LEVEL2(step = 2, percent = 50, image = R.drawable.img_lv2), | ||
| LEVEL3(step = 3, percent = 75, image = R.drawable.img_lv3), | ||
| LEVEL4(step = 4, percent = 100, image = R.drawable.img_lv4) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,138 @@ | ||
| package com.cherrish.android.presentation.home | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Brush | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.hilt.navigation.compose.hiltViewModel | ||
| import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
| import com.cherrish.android.core.common.state.UiState | ||
| import com.cherrish.android.core.designsystem.theme.CherrishTheme | ||
| import com.cherrish.android.core.designsystem.theme.graEnd | ||
| import com.cherrish.android.core.designsystem.theme.graStart | ||
| import com.cherrish.android.presentation.home.component.ChallengeSection | ||
| import com.cherrish.android.presentation.home.component.PlanBoxSection | ||
| import com.cherrish.android.presentation.home.component.UpcomingPlanSection | ||
| import java.time.LocalDate | ||
| import kotlinx.collections.immutable.persistentListOf | ||
|
|
||
| @Composable | ||
| fun HomeRoute( | ||
| paddingValues: PaddingValues | ||
| paddingValues: PaddingValues, | ||
| viewModel: HomeViewModel = hiltViewModel() | ||
| ) { | ||
| HomeScreen(paddingValues = paddingValues) | ||
| val uiState by viewModel.uiState.collectAsStateWithLifecycle() | ||
|
|
||
| when (val state = uiState) { | ||
| is UiState.Loading -> { | ||
| } | ||
|
|
||
| is UiState.Failure -> { | ||
| } | ||
|
|
||
| is UiState.Success -> { | ||
| HomeScreen( | ||
| uiState = state.data, | ||
| paddingValues = paddingValues, | ||
| onUpcomingPlanClick = viewModel::onUpcomingPlanClick, | ||
| onChallengeStartClick = viewModel::onAddChallengeClick, | ||
| onAddPlanClick = viewModel::onAddPlanClick | ||
| ) | ||
| } | ||
|
|
||
| else -> {} | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun HomeScreen( | ||
| uiState: HomeUiState, | ||
| paddingValues: PaddingValues, | ||
| onUpcomingPlanClick: (LocalDate) -> Unit, | ||
| onChallengeStartClick: () -> Unit, | ||
| onAddPlanClick: () -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| Text( | ||
| text = "Home", | ||
| modifier = modifier.padding(paddingValues) | ||
| ) | ||
| Box( | ||
| modifier = modifier | ||
| .fillMaxSize() | ||
| .background(color = CherrishTheme.colors.graEnd) | ||
| ) { | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .height(270.dp) | ||
| .background( | ||
| brush = Brush.verticalGradient( | ||
| colors = persistentListOf( | ||
| graStart, | ||
| graEnd | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| LazyColumn( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(paddingValues), | ||
| contentPadding = PaddingValues( | ||
| start = 17.dp, | ||
|
sohee6989 marked this conversation as resolved.
|
||
| end = 17.dp, | ||
| top = 30.dp, | ||
| bottom = 20.dp | ||
| ), | ||
| verticalArrangement = Arrangement.spacedBy(12.dp) | ||
| ) { | ||
| item { | ||
| ChallengeSection( | ||
| imageRes = uiState.gauges[uiState.selectedIndex].image, | ||
| currentStep = uiState.currentStep, | ||
| gauges = uiState.gauges, | ||
| onChallengeStartClick = onChallengeStartClick, | ||
| challengeName = uiState.challengeName | ||
| ) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| item { | ||
| PlanBoxSection( | ||
| todayDate = uiState.todayDate, | ||
| plans = uiState.plans | ||
| ) | ||
| } | ||
|
|
||
| item { | ||
| UpcomingPlanSection( | ||
| onAddPlanClick = onAddPlanClick, | ||
| plans = uiState.upcomingPlans, | ||
| onUpcomingPlanClick = onUpcomingPlanClick | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun Preview() { | ||
| CherrishTheme { | ||
| HomeScreen( | ||
| uiState = HomeUiState.fake, | ||
| paddingValues = PaddingValues(0.dp), | ||
| onUpcomingPlanClick = {}, | ||
| onAddPlanClick = {}, | ||
| onChallengeStartClick = {} | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package com.cherrish.android.presentation.home | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
| import com.cherrish.android.core.designsystem.component.type.CherrishGaugeType | ||
| import com.cherrish.android.presentation.home.model.PlanUiModel | ||
| import com.cherrish.android.presentation.home.model.UpcomingPlanUiModel | ||
| import com.cherrish.android.presentation.home.type.DowntimePhase | ||
| import java.time.LocalDate | ||
| import kotlinx.collections.immutable.ImmutableList | ||
| import kotlinx.collections.immutable.persistentListOf | ||
| import kotlinx.collections.immutable.toImmutableList | ||
|
|
||
| @Immutable | ||
| data class HomeUiState( | ||
| val currentStep: Int, | ||
| val gauges: ImmutableList<CherrishGaugeType>, | ||
| val challengeName: String, | ||
| val todayDate: String, | ||
| val plans: ImmutableList<PlanUiModel>, | ||
| val upcomingPlans: ImmutableList<UpcomingPlanUiModel>, | ||
| val selectedIndex: Int | ||
| ) { | ||
| companion object { | ||
| val fake = HomeUiState( | ||
| currentStep = 1, | ||
| gauges = CherrishGaugeType.entries.toImmutableList(), | ||
| challengeName = "웰니스 • 마음챙김", | ||
| todayDate = "2026년 1월 1일 (목)", | ||
| plans = List(10) { | ||
| PlanUiModel( | ||
| procedureName = "슈링크", | ||
| daysSince = 2, | ||
| downtimePhase = DowntimePhase.SENSITIVE | ||
| ) | ||
| }.toImmutableList(), | ||
| upcomingPlans = persistentListOf( | ||
| UpcomingPlanUiModel( | ||
| upcomingPlanDate = LocalDate.now().plusDays(3), | ||
| procedureName = "써마지", | ||
| procedureCount = 2, | ||
| dDay = 3 | ||
| ), | ||
| UpcomingPlanUiModel( | ||
| upcomingPlanDate = LocalDate.now().plusDays(3), | ||
| procedureName = "써마지", | ||
| procedureCount = 2, | ||
| dDay = 3 | ||
| ) | ||
| ), | ||
|
Comment on lines
+23
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd "$(git rev-parse --show-toplevel)" && \
wc -l app/src/main/java/com/cherrish/android/presentation/home/HomeUiState.ktRepository: TEAM-Cherrish/Cherrish-Android Length of output: 148 🏁 Script executed: cat -n app/src/main/java/com/cherrish/android/presentation/home/HomeUiState.ktRepository: TEAM-Cherrish/Cherrish-Android Length of output: 2366 🏁 Script executed: # Search for other usages of todayDate and upcomingPlanDate in the codebase
rg -A 3 -B 3 "todayDate|upcomingPlanDate" app/src/main/java/com/cherrish/android/presentation/home/ --type ktRepository: TEAM-Cherrish/Cherrish-Android Length of output: 100 🏁 Script executed: # Check if there are date comparisons or calculations in HomeScreen or related composables
rg -l "HomeUiState" app/src/main --type kt | head -10Repository: TEAM-Cherrish/Cherrish-Android Length of output: 100 🏁 Script executed: rg "HomeUiState.fake" app/src/main --type kotlinRepository: TEAM-Cherrish/Cherrish-Android Length of output: 300 🏁 Script executed: rg -A 5 -B 5 "todayDate" app/src/main/java/com/cherrish/android/presentation/home/ --type kotlinRepository: TEAM-Cherrish/Cherrish-Android Length of output: 7259 🏁 Script executed: # Search for date-based calculations or comparisons in home-related files
rg "LocalDate|dDay|daysSince" app/src/main/java/com/cherrish/android/presentation/home/ --type kotlin -A 2Repository: TEAM-Cherrish/Cherrish-Android Length of output: 14005 fake 데이터의 기준일 불일치를 수정하세요.
🔧 수정 제안 companion object {
+ private val fakeBaseDate = LocalDate.of(2026, 1, 1)
val fake = HomeUiState(
currentStep = 1,
gauges = CherrishGaugeType.entries.toImmutableList(),
challengeName = "웰니스 • 마음챙김",
todayDate = "2026년 1월 1일 (목)",
plans = List(10) {
PlanUiModel(
procedureName = "슈링크",
daysSince = 2,
downtimePhase = DowntimePhase.SENSITIVE
)
}.toImmutableList(),
upcomingPlans = persistentListOf(
UpcomingPlanUiModel(
- upcomingPlanDate = LocalDate.now().plusDays(3),
+ upcomingPlanDate = fakeBaseDate.plusDays(3),
procedureName = "써마지",
procedureCount = 2,
dDay = 3
),
UpcomingPlanUiModel(
- upcomingPlanDate = LocalDate.now().plusDays(3),
+ upcomingPlanDate = fakeBaseDate.plusDays(3),
procedureName = "써마지",
procedureCount = 2,
dDay = 3
)
),
selectedIndex = 0
)🤖 Prompt for AI Agents |
||
| selectedIndex = 0 | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.cherrish.android.presentation.home | ||
|
|
||
| import androidx.lifecycle.ViewModel | ||
| import com.cherrish.android.core.common.state.UiState | ||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||
| import java.time.LocalDate | ||
| import javax.inject.Inject | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.flow.asStateFlow | ||
|
|
||
| @HiltViewModel | ||
| class HomeViewModel @Inject constructor() : ViewModel() { | ||
|
|
||
| private val _uiState = MutableStateFlow<UiState<HomeUiState>>( | ||
| UiState.Success(HomeUiState.fake) | ||
| ) | ||
| val uiState: StateFlow<UiState<HomeUiState>> = _uiState.asStateFlow() | ||
|
|
||
| fun onUpcomingPlanClick(date: LocalDate) { | ||
| } | ||
|
|
||
| fun onAddChallengeClick() { | ||
| } | ||
|
|
||
| fun onAddPlanClick() { | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최고 최고 ㅎㅎㅎ 놓치고 잇엇다 !!