Skip to content

Commit 10ee8fe

Browse files
committed
Refactor: ReportCategory 확장함수 정의 및 기존 ui 모델 제거
1 parent cee3677 commit 10ee8fe

6 files changed

Lines changed: 59 additions & 69 deletions

File tree

presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private fun ReportScreen(
220220

221221
ReportField(title = "카테고리") {
222222
ReportCategorySelector(
223-
title = uiState.selectedCategory?.title,
223+
title = uiState.selectedCategory?.uiTitle,
224224
onClick = onShowReportCategoryBottomSheet,
225225
)
226226
}

presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import androidx.lifecycle.ViewModel
66
import com.threegap.bitnagil.domain.address.usecase.FetchCurrentAddressUseCase
77
import com.threegap.bitnagil.domain.file.usecase.UploadReportImagesUseCase
88
import com.threegap.bitnagil.domain.report.model.Report
9+
import com.threegap.bitnagil.domain.report.model.ReportCategory
910
import com.threegap.bitnagil.domain.report.usecase.SubmitReportUseCase
1011
import com.threegap.bitnagil.presentation.common.file.convertUriToImageFile
11-
import com.threegap.bitnagil.presentation.report.model.ReportCategoryUi
1212
import dagger.hilt.android.lifecycle.HiltViewModel
1313
import dagger.hilt.android.qualifiers.ApplicationContext
1414
import javax.inject.Inject
@@ -65,7 +65,7 @@ class ReportViewModel @Inject constructor(
6565
}
6666
}
6767

68-
fun selectReportCategory(category: ReportCategoryUi) {
68+
fun selectReportCategory(category: ReportCategory) {
6969
intent {
7070
reduce { state.copy(selectedCategory = category) }
7171
}

presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/CompleteReportCard.kt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,29 @@ import androidx.compose.ui.tooling.preview.Preview
2222
import androidx.compose.ui.unit.dp
2323
import coil3.compose.AsyncImage
2424
import com.threegap.bitnagil.designsystem.BitnagilTheme
25-
import com.threegap.bitnagil.presentation.report.model.ReportCategoryUi
25+
import com.threegap.bitnagil.domain.report.model.ReportCategory
26+
import com.threegap.bitnagil.presentation.report.model.uiTitle
2627

2728
@Composable
2829
fun CompleteReportCard(
2930
title: String,
30-
category: ReportCategoryUi?,
31+
category: ReportCategory?,
3132
address: String?,
3233
content: String,
3334
images: List<String>,
34-
modifier: Modifier = Modifier
35+
modifier: Modifier = Modifier,
3536
) {
3637
val context = LocalContext.current
3738

3839
Column(
3940
modifier = modifier
4041
.background(
4142
color = BitnagilTheme.colors.coolGray98,
42-
shape = RoundedCornerShape(12.dp)
43+
shape = RoundedCornerShape(12.dp),
4344
)
4445
.padding(20.dp)
4546
.fillMaxWidth(),
46-
verticalArrangement = Arrangement.spacedBy(20.dp)
47+
verticalArrangement = Arrangement.spacedBy(20.dp),
4748
) {
4849
Text(
4950
text = "제보 요약정보",
@@ -52,7 +53,7 @@ fun CompleteReportCard(
5253
)
5354

5455
CompleteReportCardItem(
55-
title = "제목"
56+
title = "제목",
5657
) {
5758
Text(
5859
text = title,
@@ -62,17 +63,17 @@ fun CompleteReportCard(
6263
}
6364

6465
CompleteReportCardItem(
65-
title = "키테고리"
66+
title = "키테고리",
6667
) {
6768
Text(
68-
text = category?.title ?: "카테고리 없음",
69+
text = category?.uiTitle ?: "카테고리 없음",
6970
color = BitnagilTheme.colors.coolGray10,
7071
style = BitnagilTheme.typography.body1Medium,
7172
)
7273
}
7374

7475
CompleteReportCardItem(
75-
title = "신고 위치"
76+
title = "신고 위치",
7677
) {
7778
Text(
7879
text = address ?: "주소 없음",
@@ -82,18 +83,18 @@ fun CompleteReportCard(
8283
}
8384

8485
CompleteReportCardItem(
85-
title = "제보 내용"
86+
title = "제보 내용",
8687
) {
8788
Text(
8889
text = content,
8990
color = BitnagilTheme.colors.coolGray10,
9091
style = BitnagilTheme.typography.body1Medium,
91-
textAlign = TextAlign.End
92+
textAlign = TextAlign.End,
9293
)
9394
}
9495

9596
CompleteReportCardItem(
96-
title = "제보 사진"
97+
title = "제보 사진",
9798
) {
9899
LazyRow(
99100
horizontalArrangement = Arrangement.End,
@@ -118,18 +119,18 @@ fun CompleteReportCard(
118119
private fun CompleteReportCardItem(
119120
title: String,
120121
modifier: Modifier = Modifier,
121-
content: @Composable () -> Unit
122+
content: @Composable () -> Unit,
122123
) {
123124
Row(
124125
modifier = modifier.fillMaxWidth(),
125126
horizontalArrangement = Arrangement.SpaceBetween,
126-
verticalAlignment = Alignment.CenterVertically
127+
verticalAlignment = Alignment.CenterVertically,
127128
) {
128129
Text(
129130
text = title,
130131
color = BitnagilTheme.colors.coolGray30,
131132
style = BitnagilTheme.typography.body1Medium,
132-
modifier = Modifier.padding(end = 12.dp)
133+
modifier = Modifier.padding(end = 12.dp),
133134
)
134135
content()
135136
}
@@ -140,7 +141,7 @@ private fun CompleteReportCardItem(
140141
private fun Preview() {
141142
CompleteReportCard(
142143
title = "어쩌구",
143-
category = ReportCategoryUi.WATERFACILITY,
144+
category = ReportCategory.WATERFACILITY,
144145
address = "서울특별시 강남구 역삼동",
145146
content = "어쩌구 저쩌구",
146147
images = listOf(),

presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/ReportCategoryBottomSheet.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ import com.threegap.bitnagil.designsystem.R
2424
import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon
2525
import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple
2626
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel
27-
import com.threegap.bitnagil.presentation.report.model.ReportCategoryUi
27+
import com.threegap.bitnagil.domain.report.model.ReportCategory
28+
import com.threegap.bitnagil.presentation.report.model.iconRes
29+
import com.threegap.bitnagil.presentation.report.model.uiDescription
30+
import com.threegap.bitnagil.presentation.report.model.uiTitle
2831
import kotlinx.coroutines.launch
2932

3033
@OptIn(ExperimentalMaterial3Api::class)
3134
@Composable
3235
fun ReportCategoryBottomSheet(
33-
selectedCategory: ReportCategoryUi?,
36+
selectedCategory: ReportCategory?,
3437
onDismiss: () -> Unit,
35-
onSelected: (ReportCategoryUi) -> Unit,
38+
onSelected: (ReportCategory) -> Unit,
3639
modifier: Modifier = Modifier,
3740
) {
3841
val sheetState = rememberModalBottomSheetState()
@@ -48,11 +51,11 @@ fun ReportCategoryBottomSheet(
4851
Column(
4952
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 28.dp),
5053
) {
51-
ReportCategoryUi.entries.forEachIndexed { index, category ->
54+
ReportCategory.entries.forEachIndexed { index, category ->
5255
ReportCategoryItem(
53-
icon = category.icon,
54-
title = category.title,
55-
description = category.description,
56+
icon = category.iconRes,
57+
title = category.uiTitle,
58+
description = category.uiDescription,
5659
isSelected = selectedCategory == category,
5760
onClick = {
5861
onSelected(category)
@@ -124,7 +127,7 @@ private fun ReportCategoryItem(
124127
@Composable
125128
private fun ReportCategoryBottomSheetPreview() {
126129
ReportCategoryBottomSheet(
127-
selectedCategory = ReportCategoryUi.WATERFACILITY,
130+
selectedCategory = ReportCategory.WATERFACILITY,
128131
onDismiss = {},
129132
onSelected = {},
130133
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.threegap.bitnagil.presentation.report.model
2+
3+
import com.threegap.bitnagil.designsystem.R
4+
import com.threegap.bitnagil.domain.report.model.ReportCategory
5+
6+
val ReportCategory.uiTitle: String
7+
get() = when (this) {
8+
ReportCategory.TRANSPORTATION -> "교통 시설"
9+
ReportCategory.LIGHTING -> "조명 시설"
10+
ReportCategory.WATERFACILITY -> "상하수도 시설"
11+
ReportCategory.AMENITY -> "편의 시설"
12+
}
13+
14+
val ReportCategory.uiDescription: String
15+
get() = when (this) {
16+
ReportCategory.TRANSPORTATION -> "신호등 고장, 표지판 파손, 횡단보도 등"
17+
ReportCategory.LIGHTING -> "가로등, 보안등 파손 등"
18+
ReportCategory.WATERFACILITY -> "맨홀 뚜껑 손상 등"
19+
ReportCategory.AMENITY -> "벤치 파손, 휴지통 넘침 등"
20+
}
21+
22+
val ReportCategory.iconRes: Int
23+
get() = when (this) {
24+
ReportCategory.TRANSPORTATION -> R.drawable.ic_car
25+
ReportCategory.LIGHTING -> R.drawable.ic_light
26+
ReportCategory.WATERFACILITY -> R.drawable.ic_water
27+
ReportCategory.AMENITY -> R.drawable.ic_hammer
28+
}

presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportCategoryUi.kt

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)