Skip to content

Commit 91f55d4

Browse files
committed
Feat: 제보 목록 화면에 제보 목록 조회 UseCase 적용 및 마이페이지에서 제보 목록 화면 이동 로직 추가
1 parent 71aac61 commit 91f55d4

10 files changed

Lines changed: 121 additions & 45 deletions

File tree

app/src/main/java/com/threegap/bitnagil/MainNavHost.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.threegap.bitnagil.presentation.onboarding.OnBoardingScreenContainer
1414
import com.threegap.bitnagil.presentation.onboarding.OnBoardingViewModel
1515
import com.threegap.bitnagil.presentation.onboarding.model.navarg.OnBoardingScreenArg
1616
import com.threegap.bitnagil.presentation.report.ReportScreenContainer
17+
import com.threegap.bitnagil.presentation.reporthistory.ReportHistoryScreenContainer
1718
import com.threegap.bitnagil.presentation.routinelist.RoutineListScreenContainer
1819
import com.threegap.bitnagil.presentation.setting.SettingScreenContainer
1920
import com.threegap.bitnagil.presentation.splash.SplashScreenContainer
@@ -140,6 +141,11 @@ fun MainNavHost(
140141
launchSingleTop = true
141142
}
142143
},
144+
navigateToReportHistory = {
145+
navigator.navController.navigate(Route.ReportHistory) {
146+
launchSingleTop = true
147+
}
148+
},
143149
)
144150
}
145151

@@ -305,5 +311,17 @@ fun MainNavHost(
305311
},
306312
)
307313
}
314+
315+
composable<Route.ReportHistory> {
316+
ReportHistoryScreenContainer(
317+
navigateToBack = {
318+
if (navigator.navController.previousBackStackEntry != null) {
319+
navigator.navController.popBackStack()
320+
}
321+
},
322+
navigateToReportDetail = {
323+
},
324+
)
325+
}
308326
}
309327
}

app/src/main/java/com/threegap/bitnagil/Route.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ sealed interface Route {
5151

5252
@Serializable
5353
data object Report : Route
54+
55+
@Serializable
56+
data object ReportHistory : Route
5457
}

app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavHost.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fun HomeNavHost(
4444
navigateToEmotion: () -> Unit,
4545
navigateToRoutineList: (String) -> Unit,
4646
navigateToReport: () -> Unit,
47+
navigateToReportHistory: () -> Unit,
4748
) {
4849
val navigator = rememberHomeNavigator()
4950
var showFloatingOverlay by remember { mutableStateOf(false) }
@@ -89,6 +90,7 @@ fun HomeNavHost(
8990
navigateToOnBoarding = navigateToOnBoarding,
9091
navigateToNotice = navigateToNotice,
9192
navigateToQnA = navigateToQnA,
93+
navigateToReportHistory = navigateToReportHistory,
9294
)
9395
}
9496
}

presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageScreen.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fun MyPageScreenContainer(
3838
navigateToNotice: () -> Unit,
3939
navigateToQnA: () -> Unit,
4040
navigateToOnBoarding: () -> Unit,
41+
navigateToReportHistory: () -> Unit,
4142
) {
4243
val state by myPageViewModel.stateFlow.collectAsState()
4344

@@ -47,6 +48,7 @@ fun MyPageScreenContainer(
4748
onClickNotice = navigateToNotice,
4849
onClickResetOnBoarding = navigateToOnBoarding,
4950
onClickQnA = navigateToQnA,
51+
onClickReportHistory = navigateToReportHistory,
5052
)
5153
}
5254

@@ -57,6 +59,7 @@ private fun MyPageScreen(
5759
onClickNotice: () -> Unit,
5860
onClickResetOnBoarding: () -> Unit,
5961
onClickQnA: () -> Unit,
62+
onClickReportHistory: () -> Unit,
6063
) {
6164
Column(
6265
modifier = Modifier
@@ -100,6 +103,11 @@ private fun MyPageScreen(
100103

101104
Spacer(modifier = Modifier.height(16.dp))
102105

106+
BitnagilOptionButton(
107+
title = "내 제보 기록",
108+
onClick = onClickReportHistory,
109+
)
110+
103111
BitnagilOptionButton(
104112
title = "내 목표 재설정",
105113
onClick = onClickResetOnBoarding,
@@ -127,6 +135,7 @@ fun MyPageScreenPreview() {
127135
onClickNotice = { },
128136
onClickResetOnBoarding = { },
129137
onClickQnA = { },
138+
onClickReportHistory = { },
130139
)
131140
}
132141
}

presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryScreen.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,20 @@ fun ReportHistoryScreenContainer(
4949
) {
5050
val state by viewModel.collectAsState()
5151

52-
if (state.showSelectReportCategoryBottomSheet)
52+
if (state.showSelectReportCategoryBottomSheet) {
5353
ReportCategoryBottomSheet(
5454
selectedCategory = state.selectedReportCategory,
5555
onDismiss = viewModel::hideReportCategoryBottomSheet,
56-
onSelected = viewModel::selectReportCategory
56+
onSelected = viewModel::selectReportCategory,
5757
)
58+
}
5859

5960
ReportHistoryScreen(
6061
state = state,
6162
onClickPreviousButton = navigateToBack,
6263
onClickReportProcessChip = viewModel::selectReportProcess,
6364
onClickReportCategoryButton = viewModel::showReportCategoryBottomSheet,
64-
onClickReportItem = navigateToReportDetail
65+
onClickReportItem = navigateToReportDetail,
6566
)
6667
}
6768

@@ -117,7 +118,7 @@ private fun ReportHistoryScreen(
117118
.fillMaxWidth()
118119
.weight(1f),
119120
) {
120-
if (state.filteredReportHistoriesPerDays.isNotEmpty())
121+
if (state.filteredReportHistoriesPerDays.isNotEmpty()) {
121122
LazyColumn(
122123
modifier = Modifier.fillMaxSize(),
123124
contentPadding = PaddingValues(horizontal = 16.dp),
@@ -149,17 +150,18 @@ private fun ReportHistoryScreen(
149150
}
150151
}
151152
}
152-
else
153+
} else {
153154
Column(
154155
modifier = Modifier.align(Alignment.Center),
155156
verticalArrangement = Arrangement.spacedBy(2.dp),
156-
horizontalAlignment = Alignment.CenterHorizontally
157+
horizontalAlignment = Alignment.CenterHorizontally,
157158
) {
158159
Text(text = "제보한 내역이 없어요.", style = BitnagilTheme.typography.subtitle1SemiBold)
159160
Text(text = "원하는 카테고리로 제보를 시작해 보세요.", style = BitnagilTheme.typography.body2Regular, color = BitnagilTheme.colors.coolGray70)
160161
}
162+
}
161163

162-
if (state.showCategorySelectButton)
164+
if (state.showCategorySelectButton) {
163165
Row(
164166
verticalAlignment = Alignment.CenterVertically,
165167
horizontalArrangement = Arrangement.spacedBy(5.dp),
@@ -183,6 +185,7 @@ private fun ReportHistoryScreen(
183185
.size(16.dp),
184186
)
185187
}
188+
}
186189
}
187190
}
188191
}

presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryViewModel.kt

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.threegap.bitnagil.presentation.reporthistory
22

33
import androidx.lifecycle.ViewModel
4+
import com.threegap.bitnagil.domain.report.usecase.GetReportHistoriesUseCase
45
import com.threegap.bitnagil.presentation.reporthistory.model.ReportCategory
56
import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoriesPerDayUiModel
67
import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistorySideEffect
@@ -14,73 +15,72 @@ import org.orbitmvi.orbit.viewmodel.container
1415
import javax.inject.Inject
1516

1617
@HiltViewModel
17-
class ReportHistoryViewModel @Inject constructor() : ContainerHost<ReportHistoryState, ReportHistorySideEffect>, ViewModel() {
18+
class ReportHistoryViewModel @Inject constructor(
19+
private val getReportHistoriesUseCase: GetReportHistoriesUseCase,
20+
) : ContainerHost<ReportHistoryState, ReportHistorySideEffect>, ViewModel() {
1821
override val container: Container<ReportHistoryState, ReportHistorySideEffect> = container(initialState = ReportHistoryState.Init)
1922

2023
init {
2124
loadReportHistories()
2225
}
2326

2427
private fun loadReportHistories() = intent {
25-
reduce {
26-
state.copy(
27-
reportHistoriesPerDays = List(10) {
28-
ReportHistoriesPerDayUiModel(
29-
date = java.time.LocalDate.now(),
30-
reports = listOf(
31-
ReportHistoryUiModel(
32-
id = "1",
33-
title = "제보 1",
34-
imageUrl = "-",
35-
location = "서울특별시 성북구 안암로 106",
36-
process = ReportProcess.Reported,
37-
category = ReportCategory.Amenities,
38-
),
39-
ReportHistoryUiModel(
40-
id = "1",
41-
title = "제보 1",
42-
imageUrl = "-",
43-
location = "서울특별시 성북구 안암로 106",
44-
process = ReportProcess.Progress,
45-
category = ReportCategory.Amenities,
46-
),
47-
),
28+
getReportHistoriesUseCase.invoke().fold(
29+
onSuccess = { reportHistoriesPerDate ->
30+
val reportHistoriesPerDays = reportHistoriesPerDate
31+
.map { reportHistoryPerDateMap ->
32+
ReportHistoriesPerDayUiModel(
33+
date = reportHistoryPerDateMap.key,
34+
reports = reportHistoryPerDateMap.value.map {
35+
ReportHistoryUiModel.fromDomain(it)
36+
},
37+
)
38+
}
39+
.sortedByDescending { reportHistoryPerDate ->
40+
reportHistoryPerDate.date
41+
}
42+
43+
reduce {
44+
state.copy(
45+
reportHistoriesPerDays = reportHistoriesPerDays,
4846
)
49-
},
50-
)
51-
}
47+
}
48+
},
49+
onFailure = {
50+
},
51+
)
5252
}
5353

5454
fun selectReportCategory(reportCategory: ReportCategory) = intent {
5555
val currentSelectedReportCategory = state.selectedReportCategory
5656

5757
reduce {
5858
state.copy(
59-
selectedReportCategory = if (currentSelectedReportCategory == reportCategory) null else reportCategory
59+
selectedReportCategory = if (currentSelectedReportCategory == reportCategory) null else reportCategory,
6060
)
6161
}
6262
}
6363

6464
fun selectReportProcess(reportProcess: ReportProcess) = intent {
6565
reduce {
6666
state.copy(
67-
selectedReportProcess = reportProcess
67+
selectedReportProcess = reportProcess,
6868
)
6969
}
7070
}
7171

7272
fun showReportCategoryBottomSheet() = intent {
7373
reduce {
7474
state.copy(
75-
showSelectReportCategoryBottomSheet = true
75+
showSelectReportCategoryBottomSheet = true,
7676
)
7777
}
7878
}
7979

8080
fun hideReportCategoryBottomSheet() = intent {
8181
reduce {
8282
state.copy(
83-
showSelectReportCategoryBottomSheet = false
83+
showSelectReportCategoryBottomSheet = false,
8484
)
8585
}
8686
}
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.threegap.bitnagil.presentation.reporthistory.model
22

33
import com.threegap.bitnagil.designsystem.R
4+
import com.threegap.bitnagil.domain.report.model.ReportCategory as DomainReportCategory
45

56
enum class ReportCategory(
67
val title: String,
@@ -10,21 +11,33 @@ enum class ReportCategory(
1011
TrafficFacilities(
1112
title = "교통 시설",
1213
description = "신호등 고장, 표지판 파손, 횡단보도 등",
13-
iconResourceId = R.drawable.ic_check_md,
14+
iconResourceId = R.drawable.ic_car,
1415
),
1516
LightingFacilities(
1617
title = "조명 시설",
1718
description = "가로등, 보안등 파손 등",
18-
iconResourceId = R.drawable.ic_check_md,
19+
iconResourceId = R.drawable.ic_light,
1920
),
2021
WaterFacilities(
2122
title = "상하수도 시설",
2223
description = "맨홀 뚜껑 손상 등",
23-
iconResourceId = R.drawable.ic_check_md,
24+
iconResourceId = R.drawable.ic_water,
2425
),
2526
Amenities(
2627
title = "편의 시설",
2728
description = "벤치 파손, 휴지통 넘침 등",
28-
iconResourceId = R.drawable.ic_check_md,
29+
iconResourceId = R.drawable.ic_hammer,
2930
),
31+
;
32+
33+
companion object {
34+
fun fromDomain(domainReportCategory: DomainReportCategory): ReportCategory {
35+
return when (domainReportCategory) {
36+
DomainReportCategory.TRANSPORTATION -> TrafficFacilities
37+
DomainReportCategory.LIGHTING -> LightingFacilities
38+
DomainReportCategory.WATERFACILITY -> WaterFacilities
39+
DomainReportCategory.AMENITY -> Amenities
40+
}
41+
}
42+
}
3043
}

presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ data class ReportHistoryState(
1717
ReportProcess.Complete -> it.process == ReportProcess.Complete
1818
}
1919

20-
val categoryMatched = when(selectedReportCategory) {
20+
val categoryMatched = when (selectedReportCategory) {
2121
ReportCategory.TrafficFacilities -> it.category == ReportCategory.TrafficFacilities
2222
ReportCategory.LightingFacilities -> it.category == ReportCategory.LightingFacilities
2323
ReportCategory.WaterFacilities -> it.category == ReportCategory.WaterFacilities
@@ -56,7 +56,7 @@ data class ReportHistoryState(
5656
selectedReportCategory = null,
5757
selectedReportProcess = ReportProcess.Total,
5858
reportHistoriesPerDays = listOf(),
59-
showSelectReportCategoryBottomSheet = false
59+
showSelectReportCategoryBottomSheet = false,
6060
)
6161
}
6262
}
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
package com.threegap.bitnagil.presentation.reporthistory.model
22

3+
import com.threegap.bitnagil.domain.report.model.ReportItem
4+
35
data class ReportHistoryUiModel(
46
val id: String,
57
val title: String,
68
val imageUrl: String,
79
val location: String,
810
val process: ReportProcess,
911
val category: ReportCategory,
10-
)
12+
) {
13+
companion object {
14+
fun fromDomain(reportItem: ReportItem): ReportHistoryUiModel {
15+
return ReportHistoryUiModel(
16+
id = "${reportItem.id}",
17+
title = reportItem.title,
18+
imageUrl = reportItem.imageUrl,
19+
location = reportItem.address,
20+
process = ReportProcess.fromDomain(reportItem.status),
21+
category = ReportCategory.fromDomain(reportItem.category),
22+
)
23+
}
24+
}
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
package com.threegap.bitnagil.presentation.reporthistory.model
22

3+
import com.threegap.bitnagil.domain.report.model.ReportStatus
4+
35
enum class ReportProcess(
46
val title: String,
57
) {
68
Total(title = "전체"),
79
Reported(title = "제보 완료"),
810
Progress(title = "처리 중"),
911
Complete(title = "처리 완료"),
12+
;
13+
14+
companion object {
15+
fun fromDomain(status: ReportStatus): ReportProcess {
16+
return when (status) {
17+
ReportStatus.Pending -> Reported
18+
ReportStatus.InProgress -> Progress
19+
ReportStatus.Completed -> Complete
20+
}
21+
}
22+
}
1023
}

0 commit comments

Comments
 (0)