Skip to content

Commit df2095d

Browse files
committed
Refactor: Report 관련 Presentation 모델을 Domain 모델로 대체
- Presentation 레이어에서 사용하던 ReportCategory, ReportProcess enum 클래스를 삭제하고, Domain 레이어의 모델을 직접 사용하도록 변경합니다.
1 parent 5ad95fc commit df2095d

25 files changed

Lines changed: 193 additions & 345 deletions

presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportCategoryExtension.kt renamed to presentation/src/main/java/com/threegap/bitnagil/presentation/common/extension/ReportCategoryEtx.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
package com.threegap.bitnagil.presentation.report.model
1+
package com.threegap.bitnagil.presentation.common.extension
22

3+
import androidx.annotation.DrawableRes
34
import com.threegap.bitnagil.designsystem.R
45
import com.threegap.bitnagil.domain.report.model.ReportCategory
56

6-
val ReportCategory.uiTitle: String
7+
val ReportCategory.displayTitle: String
78
get() = when (this) {
89
ReportCategory.TRANSPORTATION -> "교통 시설"
910
ReportCategory.LIGHTING -> "조명 시설"
1011
ReportCategory.WATERFACILITY -> "상하수도 시설"
1112
ReportCategory.AMENITY -> "편의 시설"
1213
}
1314

14-
val ReportCategory.uiDescription: String
15+
val ReportCategory.displayExamples: String
1516
get() = when (this) {
1617
ReportCategory.TRANSPORTATION -> "신호등 고장, 표지판 파손, 횡단보도 등"
1718
ReportCategory.LIGHTING -> "가로등, 보안등 파손 등"
@@ -20,7 +21,7 @@ val ReportCategory.uiDescription: String
2021
}
2122

2223
val ReportCategory.iconRes: Int
23-
get() = when (this) {
24+
@DrawableRes get() = when (this) {
2425
ReportCategory.TRANSPORTATION -> R.drawable.ic_car
2526
ReportCategory.LIGHTING -> R.drawable.ic_light
2627
ReportCategory.WATERFACILITY -> R.drawable.ic_water
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.threegap.bitnagil.presentation.common.extension
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.ui.graphics.Color
5+
import com.threegap.bitnagil.designsystem.BitnagilTheme
6+
import com.threegap.bitnagil.domain.report.model.ReportStatus
7+
8+
val ReportStatus.displayTitle: String
9+
get() = when (this) {
10+
ReportStatus.PENDING -> "제보 완료"
11+
ReportStatus.IN_PROGRESS -> "처리 중"
12+
ReportStatus.COMPLETED -> "처리 완료"
13+
}
14+
15+
val ReportStatus.badgeBackgroundColor: Color
16+
@Composable get() = when (this) {
17+
ReportStatus.PENDING -> BitnagilTheme.colors.green10
18+
ReportStatus.IN_PROGRESS -> BitnagilTheme.colors.skyBlue10
19+
else -> BitnagilTheme.colors.coolGray95
20+
}
21+
22+
val ReportStatus.textColor: Color
23+
@Composable get() = when (this) {
24+
ReportStatus.PENDING -> BitnagilTheme.colors.green300
25+
ReportStatus.IN_PROGRESS -> BitnagilTheme.colors.blue300
26+
else -> BitnagilTheme.colors.coolGray40
27+
}

presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.threegap.bitnagil.domain.onboarding.usecase.RegisterRecommendOnBoardi
1111
import com.threegap.bitnagil.domain.user.usecase.FetchUserProfileUseCase
1212
import com.threegap.bitnagil.presentation.onboarding.contract.OnBoardingSideEffect
1313
import com.threegap.bitnagil.presentation.onboarding.contract.OnBoardingState
14-
import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingAbstractTextItemUiModel
1514
import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItemUiModel
1615
import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingPageInfo
1716
import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingSetType

presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingAbstractTextItemUiModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.threegap.bitnagil.presentation.onboarding.model
22

33
import android.os.Parcelable
4-
import kotlinx.parcelize.Parcelize
54
import com.threegap.bitnagil.domain.onboarding.model.OnBoardingAbstractTextItem
5+
import kotlinx.parcelize.Parcelize
66

77
@Parcelize
88
data class OnBoardingAbstractTextItemUiModel(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton
5353
import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButtonColor
5454
import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextField
5555
import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar
56+
import com.threegap.bitnagil.presentation.common.extension.displayTitle
5657
import com.threegap.bitnagil.presentation.common.file.createCameraImageUri
5758
import com.threegap.bitnagil.presentation.common.premission.rememberPermissionHandler
5859
import com.threegap.bitnagil.presentation.report.component.AddPhotoButton
@@ -68,7 +69,6 @@ import com.threegap.bitnagil.presentation.report.contract.ReportSideEffect
6869
import com.threegap.bitnagil.presentation.report.contract.ReportState
6970
import com.threegap.bitnagil.presentation.report.contract.ReportState.Companion.MAX_IMAGE_COUNT
7071
import com.threegap.bitnagil.presentation.report.model.SubmitState
71-
import com.threegap.bitnagil.presentation.report.model.uiTitle
7272
import kotlinx.coroutines.delay
7373
import org.orbitmvi.orbit.compose.collectAsState
7474
import org.orbitmvi.orbit.compose.collectSideEffect
@@ -284,7 +284,7 @@ private fun ReportScreen(
284284

285285
ReportField(title = "카테고리") {
286286
ReportCategorySelector(
287-
title = uiState.selectedCategory?.uiTitle,
287+
title = uiState.selectedCategory?.displayTitle,
288288
onClick = {
289289
focusManager.clearFocus()
290290
onShowReportCategoryBottomSheet()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import androidx.compose.ui.unit.dp
2323
import coil3.compose.AsyncImage
2424
import com.threegap.bitnagil.designsystem.BitnagilTheme
2525
import com.threegap.bitnagil.domain.report.model.ReportCategory
26-
import com.threegap.bitnagil.presentation.report.model.uiTitle
26+
import com.threegap.bitnagil.presentation.common.extension.displayTitle
2727

2828
@Composable
2929
fun CompleteReportCard(
@@ -66,7 +66,7 @@ fun CompleteReportCard(
6666
title = "카테고리",
6767
) {
6868
Text(
69-
text = category?.uiTitle ?: "카테고리 없음",
69+
text = category?.displayTitle ?: "카테고리 없음",
7070
color = BitnagilTheme.colors.coolGray10,
7171
style = BitnagilTheme.typography.body1Medium,
7272
)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ 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.report.model.ReportCategory
27-
import com.threegap.bitnagil.presentation.report.model.iconRes
28-
import com.threegap.bitnagil.presentation.report.model.uiDescription
29-
import com.threegap.bitnagil.presentation.report.model.uiTitle
27+
import com.threegap.bitnagil.presentation.common.extension.displayExamples
28+
import com.threegap.bitnagil.presentation.common.extension.displayTitle
29+
import com.threegap.bitnagil.presentation.common.extension.iconRes
3030
import kotlinx.coroutines.launch
3131

3232
@OptIn(ExperimentalMaterial3Api::class)
@@ -54,8 +54,8 @@ fun ReportCategoryBottomSheet(
5454
categories.forEachIndexed { index, category ->
5555
ReportCategoryItem(
5656
icon = category.iconRes,
57-
title = category.uiTitle,
58-
description = category.uiDescription,
57+
title = category.displayTitle,
58+
description = category.displayExamples,
5959
isSelected = selectedCategory == category,
6060
onClick = {
6161
onSelected(category)

presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import coil3.compose.AsyncImage
2727
import coil3.request.ImageRequest
2828
import com.threegap.bitnagil.designsystem.BitnagilTheme
2929
import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar
30+
import com.threegap.bitnagil.presentation.common.extension.displayTitle
3031
import com.threegap.bitnagil.presentation.reportdetail.component.atom.ReportProcessBadge
3132
import com.threegap.bitnagil.presentation.reportdetail.component.block.ReportDetailLabeledContent
3233
import com.threegap.bitnagil.presentation.reportdetail.contract.ReportDetailState
@@ -74,7 +75,7 @@ private fun ReportDetailScreen(
7475
) {
7576
Spacer(modifier = Modifier.height(20.dp))
7677

77-
ReportProcessBadge(reportProcess = state.reportProcess)
78+
ReportProcessBadge(reportStatus = state.reportProcess)
7879

7980
Spacer(modifier = Modifier.height(6.dp))
8081

@@ -116,7 +117,7 @@ private fun ReportDetailScreen(
116117

117118
ReportDetailLabeledContent(
118119
label = "카테고리",
119-
content = state.reportCategory.title,
120+
content = state.reportCategory.displayTitle,
120121
)
121122

122123
ReportDetailLabeledContent(

presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailViewModel.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import androidx.lifecycle.ViewModel
44
import com.threegap.bitnagil.domain.report.usecase.GetReportUseCase
55
import com.threegap.bitnagil.presentation.reportdetail.contract.ReportDetailSideEffect
66
import com.threegap.bitnagil.presentation.reportdetail.contract.ReportDetailState
7-
import com.threegap.bitnagil.presentation.reportdetail.model.ReportCategory
8-
import com.threegap.bitnagil.presentation.reportdetail.model.ReportProcess
97
import com.threegap.bitnagil.presentation.reportdetail.model.navarg.ReportDetailScreenArg
108
import dagger.assisted.Assisted
119
import dagger.assisted.AssistedFactory
@@ -36,10 +34,10 @@ class ReportDetailViewModel @AssistedInject constructor(
3634
onSuccess = { reportDetail ->
3735
reduce {
3836
state.copy(
39-
reportProcess = ReportProcess.fromDomain(reportDetail.status),
37+
reportProcess = reportDetail.status,
4038
reportTitle = reportDetail.title,
4139
reportContent = reportDetail.content,
42-
reportCategory = ReportCategory.fromDomain(reportDetail.category),
40+
reportCategory = reportDetail.category,
4341
imageUrls = reportDetail.imageUrls,
4442
location = reportDetail.address,
4543
date = reportDetail.date,

presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/component/atom/ReportProcessBadge.kt

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,42 @@ import androidx.compose.foundation.shape.RoundedCornerShape
88
import androidx.compose.material3.Text
99
import androidx.compose.runtime.Composable
1010
import androidx.compose.ui.Modifier
11-
import androidx.compose.ui.graphics.Color
1211
import androidx.compose.ui.tooling.preview.Preview
1312
import androidx.compose.ui.unit.dp
1413
import com.threegap.bitnagil.designsystem.BitnagilTheme
15-
import com.threegap.bitnagil.presentation.reportdetail.model.ReportProcess
14+
import com.threegap.bitnagil.domain.report.model.ReportStatus
15+
import com.threegap.bitnagil.presentation.common.extension.badgeBackgroundColor
16+
import com.threegap.bitnagil.presentation.common.extension.displayTitle
17+
import com.threegap.bitnagil.presentation.common.extension.textColor
1618

1719
@Composable
1820
fun ReportProcessBadge(
1921
modifier: Modifier = Modifier,
20-
reportProcess: ReportProcess,
22+
reportStatus: ReportStatus,
2123
) {
2224
Text(
23-
text = reportProcess.title,
25+
text = reportStatus.displayTitle,
2426
style = BitnagilTheme.typography.caption1SemiBold,
25-
color = reportProcess.getProcessBadgeTextColor(),
27+
color = reportStatus.textColor,
2628
modifier = modifier
27-
.background(color = reportProcess.getProcessBadgeBackgroundColor(), shape = RoundedCornerShape(6.dp))
29+
.background(
30+
color = reportStatus.badgeBackgroundColor,
31+
shape = RoundedCornerShape(6.dp),
32+
)
2833
.padding(horizontal = 10.dp, vertical = 4.dp),
2934
)
3035
}
3136

32-
@Composable
33-
private fun ReportProcess.getProcessBadgeBackgroundColor(): Color =
34-
when (this) {
35-
ReportProcess.Reported -> BitnagilTheme.colors.green10
36-
ReportProcess.Progress -> BitnagilTheme.colors.skyBlue10
37-
else -> BitnagilTheme.colors.coolGray95
38-
}
39-
40-
@Composable
41-
private fun ReportProcess.getProcessBadgeTextColor(): Color =
42-
when (this) {
43-
ReportProcess.Reported -> BitnagilTheme.colors.green300
44-
ReportProcess.Progress -> BitnagilTheme.colors.blue300
45-
else -> BitnagilTheme.colors.coolGray40
46-
}
47-
4837
@Composable
4938
@Preview
5039
private fun ReportProcessBadgePreview() {
5140
BitnagilTheme {
5241
Column(
5342
verticalArrangement = Arrangement.spacedBy(4.dp),
5443
) {
55-
ReportProcessBadge(reportProcess = ReportProcess.Progress)
56-
ReportProcessBadge(reportProcess = ReportProcess.Reported)
57-
ReportProcessBadge(reportProcess = ReportProcess.Complete)
44+
ReportProcessBadge(reportStatus = ReportStatus.PENDING)
45+
ReportProcessBadge(reportStatus = ReportStatus.IN_PROGRESS)
46+
ReportProcessBadge(reportStatus = ReportStatus.COMPLETED)
5847
}
5948
}
6049
}

0 commit comments

Comments
 (0)