-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/#56] 분철 내역 뷰 UI 구현 #58
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c3477d3
[Feat/#56] HistoryListScreen UI
sonyerim e55458d
[Feat/#56] HistoryListViewModel
sonyerim 56b7f2c
[Feat/#56] 내역 없을 때 Empty State UI 추가
sonyerim a6817c5
[Fix/#56] PotiEmptyStateBlock을 PotiEmptyStateInline으로 변경
sonyerim 81e988e
[Refactor/#56] 코드 리뷰 반영
sonyerim 7775bca
Merge branch 'develop' into feat/#56-history-list-ui
sonyerim 4181c36
[Refactor/#56] 코드 리뷰 반영
sonyerim 82e38b0
[Refactor/#57] processIntent 함수 분리
sonyerim 3f7485b
[Refactor/#57] 프레젠테이션 레이어 의존성 제거
sonyerim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/poti/android/domain/model/history/HistoryList.kt
This file contains hidden or 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,19 @@ | ||
| package com.poti.android.domain.model.history | ||
|
|
||
| import com.poti.android.domain.type.HistoryStage | ||
| import com.poti.android.domain.type.HistoryStatus | ||
|
|
||
| data class HistoryListContent( | ||
| val ongoingCount: Int, | ||
| val endedCount: Int, | ||
| val items: List<HistoryItem>, | ||
| ) | ||
|
|
||
| data class HistoryItem( | ||
| val id: Long, | ||
| val imageUrl: String?, | ||
| val artist: String, | ||
| val title: String, | ||
| val stage: HistoryStage, | ||
| val status: HistoryStatus, | ||
| ) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/poti/android/domain/type/HistoryType.kt
This file contains hidden or 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,14 @@ | ||
| package com.poti.android.domain.type | ||
|
|
||
| enum class HistoryStage { | ||
| DEPOSIT, | ||
| DELIVERY, | ||
| RECRUIT, | ||
| } | ||
|
|
||
| enum class HistoryStatus { | ||
| WAIT, | ||
| CHECK, | ||
| START, | ||
| DONE, | ||
| } |
204 changes: 197 additions & 7 deletions
204
app/src/main/java/com/poti/android/presentation/history/list/HistoryListScreen.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,18 +1,208 @@ | ||
| package com.poti.android.presentation.history.list | ||
|
|
||
| import androidx.compose.material3.Text | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.foundation.lazy.items | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel | ||
| import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
| import com.poti.android.core.common.state.ApiState | ||
| import com.poti.android.core.common.util.HandleSideEffects | ||
| import com.poti.android.core.designsystem.component.display.PotiEmptyStateInline | ||
| import com.poti.android.core.designsystem.component.navigation.PotiHeaderPage | ||
| import com.poti.android.core.designsystem.component.navigation.PotiHeaderSection | ||
| import com.poti.android.core.designsystem.component.navigation.PotiHeaderTabType | ||
| import com.poti.android.core.designsystem.theme.PotiTheme | ||
| import com.poti.android.domain.model.history.HistoryItem | ||
| import com.poti.android.domain.model.history.HistoryListContent | ||
| import com.poti.android.domain.type.HistoryStage | ||
| import com.poti.android.domain.type.HistoryStatus | ||
| import com.poti.android.presentation.history.component.CardHistorySize | ||
| import com.poti.android.presentation.history.component.HistoryCardItem | ||
| import com.poti.android.presentation.history.list.model.HistoryListUiEffect | ||
| import com.poti.android.presentation.history.list.model.HistoryListUiIntent | ||
| import com.poti.android.presentation.history.list.model.HistoryListUiState | ||
| import com.poti.android.presentation.history.list.model.toUiStage | ||
| import com.poti.android.presentation.history.list.model.toUiStatus | ||
|
|
||
| @Composable | ||
| fun HistoryListRoute(modifier: Modifier = Modifier) { | ||
| HistoryListScreen(modifier = modifier) | ||
| enum class HistoryMode { | ||
| RECRUIT, | ||
| PARTICIPATION, | ||
| } | ||
|
|
||
| @Composable | ||
| private fun HistoryListScreen(modifier: Modifier = Modifier) { | ||
| Text( | ||
| text = "분철 내역", | ||
| fun HistoryListRoute( | ||
| onPopBackStack: () -> Unit, | ||
| onNavigateToRecruiterDetail: () -> Unit, | ||
| onNavigateToParticipantDetail: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| viewModel: HistoryListViewModel = hiltViewModel(), | ||
| ) { | ||
| val uiState by viewModel.uiState.collectAsStateWithLifecycle() | ||
|
|
||
| HandleSideEffects(viewModel.sideEffect) { effect -> | ||
| when (effect) { | ||
| HistoryListUiEffect.NavigateBack -> onPopBackStack() | ||
| is HistoryListUiEffect.NavigateToDetail -> { | ||
| // TODO: [예림] effect.id 전달 | ||
| if (uiState.mode == HistoryMode.RECRUIT) { | ||
| onNavigateToRecruiterDetail() | ||
| } else { | ||
| onNavigateToParticipantDetail() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| HistoryListScreen( | ||
| uiState = uiState, | ||
| onBackClick = { viewModel.processIntent(HistoryListUiIntent.OnBackClick) }, | ||
| onSwitchModeClick = { viewModel.processIntent(HistoryListUiIntent.OnSwitchModeClick) }, | ||
| onTabSelected = { tab -> | ||
| viewModel.processIntent(HistoryListUiIntent.OnTabSelected(tab)) | ||
| }, | ||
| onCardClick = { id -> | ||
| viewModel.processIntent(HistoryListUiIntent.OnCardClick(id)) | ||
| }, | ||
| modifier = modifier, | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun HistoryListScreen( | ||
| uiState: HistoryListUiState, | ||
| onBackClick: () -> Unit, | ||
| onSwitchModeClick: () -> Unit, | ||
| onTabSelected: (PotiHeaderTabType) -> Unit, | ||
| onCardClick: (Long) -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| Scaffold( | ||
| modifier = modifier, | ||
| topBar = { | ||
| PotiHeaderPage( | ||
| onNavigationClick = onBackClick, | ||
| title = stringResource(uiState.titleRes), | ||
| onTrailingIconClick = onSwitchModeClick, | ||
| ) | ||
| }, | ||
| ) { innerPadding -> | ||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(innerPadding), | ||
| ) { | ||
| PotiHeaderSection( | ||
| selectedTab = uiState.selectedTab, | ||
| ongoingCount = uiState.ongoingCount, | ||
| endedCount = uiState.endedCount, | ||
| onTabSelected = onTabSelected, | ||
| ) | ||
|
|
||
| if (uiState.items.isEmpty()) { | ||
| PotiEmptyStateInline( | ||
| text = stringResource(uiState.emptyTextRes), | ||
| modifier = Modifier.fillMaxWidth(), | ||
| ) | ||
| } else { | ||
| LazyColumn( | ||
| modifier = Modifier.fillMaxSize(), | ||
| contentPadding = PaddingValues( | ||
| horizontal = 16.dp, | ||
| vertical = 12.dp, | ||
| ), | ||
| verticalArrangement = Arrangement.spacedBy(10.dp), | ||
| ) { | ||
| items( | ||
| items = uiState.items, | ||
| key = { it.id }, | ||
| ) { item -> | ||
| HistoryCardItem( | ||
| sizeType = CardHistorySize.SMALL, | ||
| imageUrl = item.imageUrl ?: "", | ||
| artist = item.artist, | ||
| title = item.title, | ||
| participantStageType = item.toUiStage(), | ||
| participantStatusType = item.toUiStatus(), | ||
| onClick = { onCardClick(item.id) }, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun HistoryListScreenPreview_Ongoing() { | ||
|
Contributor
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. p3: 네이밍이 신기방기하다 |
||
| PotiTheme { | ||
| HistoryListScreen( | ||
| uiState = HistoryListUiState( | ||
| historyListLoadState = ApiState.Success( | ||
| HistoryListContent( | ||
| ongoingCount = 2, | ||
| endedCount = 5, | ||
| items = listOf( | ||
| HistoryItem( | ||
| id = 1L, | ||
| imageUrl = "", | ||
| artist = "ive(아이브)", | ||
| title = "러브다이브 위드뮤", | ||
| stage = HistoryStage.DELIVERY, | ||
| status = HistoryStatus.WAIT, | ||
| ), | ||
| HistoryItem( | ||
| id = 2L, | ||
| imageUrl = "", | ||
| artist = "aespa", | ||
| title = "걸스 스페셜", | ||
| stage = HistoryStage.DEPOSIT, | ||
| status = HistoryStatus.DONE, | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| selectedTab = PotiHeaderTabType.ONGOING, | ||
| ), | ||
| onBackClick = {}, | ||
| onSwitchModeClick = {}, | ||
| onTabSelected = {}, | ||
| onCardClick = {}, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun HistoryListScreenPreview_Ended() { | ||
| PotiTheme { | ||
| HistoryListScreen( | ||
| uiState = HistoryListUiState( | ||
| historyListLoadState = ApiState.Success( | ||
| HistoryListContent( | ||
| ongoingCount = 2, | ||
| endedCount = 0, | ||
| items = emptyList(), | ||
| ), | ||
| ), | ||
| selectedTab = PotiHeaderTabType.ENDED, | ||
| ), | ||
| onBackClick = {}, | ||
| onSwitchModeClick = {}, | ||
| onTabSelected = {}, | ||
| onCardClick = {}, | ||
| ) | ||
| } | ||
| } | ||
116 changes: 114 additions & 2 deletions
116
app/src/main/java/com/poti/android/presentation/history/list/HistoryListViewModel.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1,121 @@ | ||
| package com.poti.android.presentation.history.list | ||
|
|
||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.poti.android.core.base.BaseViewModel | ||
| import com.poti.android.core.common.state.ApiState | ||
| import com.poti.android.core.designsystem.component.navigation.PotiHeaderTabType | ||
| import com.poti.android.domain.model.history.HistoryItem | ||
| import com.poti.android.domain.model.history.HistoryListContent | ||
| import com.poti.android.domain.type.HistoryStage | ||
| import com.poti.android.domain.type.HistoryStatus | ||
| import com.poti.android.presentation.history.list.model.HistoryListUiEffect | ||
| import com.poti.android.presentation.history.list.model.HistoryListUiIntent | ||
| import com.poti.android.presentation.history.list.model.HistoryListUiState | ||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||
| import kotlinx.coroutines.Job | ||
| import kotlinx.coroutines.launch | ||
| import javax.inject.Inject | ||
|
|
||
| @HiltViewModel | ||
| class HistoryListViewModel @Inject constructor() : ViewModel() { | ||
| class HistoryListViewModel @Inject constructor() : BaseViewModel<HistoryListUiState, HistoryListUiIntent, HistoryListUiEffect>( | ||
| initialState = HistoryListUiState(), | ||
| ) { | ||
| override fun processIntent(intent: HistoryListUiIntent) { | ||
| when (intent) { | ||
| HistoryListUiIntent.OnBackClick -> sendEffect(HistoryListUiEffect.NavigateBack) | ||
| HistoryListUiIntent.OnSwitchModeClick -> switchMode() | ||
| is HistoryListUiIntent.OnTabSelected -> selectTab(intent.tab) | ||
| is HistoryListUiIntent.OnCardClick -> { | ||
| sendEffect(HistoryListUiEffect.NavigateToDetail(intent.id)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| init { | ||
| loadUserHistoryList() | ||
| } | ||
|
|
||
| private fun switchMode() { | ||
| val newMode = if (uiState.value.mode == HistoryMode.RECRUIT) { | ||
| HistoryMode.PARTICIPATION | ||
| } else { | ||
| HistoryMode.RECRUIT | ||
| } | ||
|
|
||
| updateState { | ||
| copy( | ||
| mode = newMode, | ||
| selectedTab = PotiHeaderTabType.ONGOING, // 초기 탭 재설정 | ||
| ) | ||
| } | ||
|
|
||
| loadUserHistoryList() | ||
| } | ||
|
|
||
| private fun selectTab(tab: PotiHeaderTabType) { | ||
| updateState { copy(selectedTab = tab) } | ||
| loadUserHistoryList() | ||
| } | ||
|
|
||
| private var fetchJob: Job? = null | ||
|
|
||
| private fun loadUserHistoryList() { | ||
| fetchJob?.cancel() | ||
|
|
||
| fetchJob = viewModelScope.launch { | ||
| val dummyContent = createDummyContent() | ||
|
|
||
| updateState { | ||
| copy( | ||
| historyListLoadState = ApiState.Success(dummyContent), | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fun createDummyContent(): HistoryListContent { | ||
| val isOngoing = uiState.value.selectedTab == PotiHeaderTabType.ONGOING | ||
| val isRecruit = uiState.value.mode == HistoryMode.RECRUIT | ||
|
|
||
| val ongoingItems = listOf( | ||
| HistoryItem( | ||
| id = 1L, | ||
| imageUrl = "", | ||
| artist = if (isRecruit) "IVE" else "aespa", | ||
| title = if (isRecruit) "러브다이브 공동구매" else "걸스 앨범 분철", | ||
| stage = HistoryStage.DELIVERY, | ||
| status = HistoryStatus.WAIT, | ||
| ), | ||
| HistoryItem( | ||
| id = 2L, | ||
| imageUrl = "", | ||
| artist = "NewJeans", | ||
| title = "OMG 한정판", | ||
| stage = HistoryStage.DEPOSIT, | ||
| status = HistoryStatus.DONE, | ||
| ), | ||
| ) | ||
|
|
||
| val endedItems = listOf( | ||
| HistoryItem( | ||
| id = 3L, | ||
| imageUrl = "", | ||
| artist = "LE SSERAFIM", | ||
| title = "ANTIFRAGILE", | ||
| stage = HistoryStage.DELIVERY, | ||
| status = HistoryStatus.DONE, | ||
| ), | ||
| ) | ||
|
|
||
| return HistoryListContent( | ||
| ongoingCount = ongoingItems.size, | ||
| endedCount = endedItems.size, | ||
| items = if (isOngoing) ongoingItems else endedItems, | ||
| ) | ||
| } | ||
|
|
||
| // TODO: [예림] API 분기 | ||
| // mode == RECRUIT -> 모집내역 API | ||
| // mode == PARTICIPATION -> 참여내역 API | ||
| // selectedTab -> IN_PROGRESS / COMPLETED | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
상세 이동에 id가 전달되지 않아 항목 매칭이 깨질 수 있습니다.
Line 56-62:
NavigateToDetail의id가 네비게이션으로 사용되지 않습니다. 클릭한 카드와 상세 화면이 불일치할 수 있으니, 라우트에 id 파라미터를 추가해 전달하거나 id 자체를 제거해 일관성을 맞춰주세요.🤖 Prompt for AI Agents