Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion app/src/main/java/com/threegap/bitnagil/MainNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import com.threegap.bitnagil.presentation.onboarding.OnBoardingScreenContainer
import com.threegap.bitnagil.presentation.onboarding.OnBoardingViewModel
import com.threegap.bitnagil.presentation.onboarding.model.navarg.OnBoardingScreenArg
import com.threegap.bitnagil.presentation.report.ReportScreenContainer
import com.threegap.bitnagil.presentation.reportdetail.ReportDetailScreenContainer
import com.threegap.bitnagil.presentation.reportdetail.ReportDetailViewModel
import com.threegap.bitnagil.presentation.reportdetail.model.navarg.ReportDetailScreenArg
import com.threegap.bitnagil.presentation.reporthistory.ReportHistoryScreenContainer
import com.threegap.bitnagil.presentation.routinelist.RoutineListScreenContainer
import com.threegap.bitnagil.presentation.setting.SettingScreenContainer
Expand Down Expand Up @@ -319,7 +322,27 @@ fun MainNavHost(
navigator.navController.popBackStack()
}
},
navigateToReportDetail = {
navigateToReportDetail = { reportId ->
navigator.navController.navigate(Route.ReportDetail(reportId = reportId)) {
launchSingleTop = true
}
},
)
}

composable<Route.ReportDetail> { navBackStackEntry ->
val arg = navBackStackEntry.toRoute<Route.ReportDetail>()
val reportDetailScreenArg = ReportDetailScreenArg(reportId = arg.reportId)
val viewModel = hiltViewModel<ReportDetailViewModel, ReportDetailViewModel.Factory> { factory ->
factory.create(reportDetailScreenArg)
}

ReportDetailScreenContainer(
viewModel = viewModel,
navigateToBack = {
if (navigator.navController.previousBackStackEntry != null) {
navigator.navController.popBackStack()
}
},
)
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/threegap/bitnagil/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ sealed interface Route {

@Serializable
data object ReportHistory : Route

@Serializable
data class ReportDetail(val reportId: String) : Route
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data class Meta(
@Serializable
data class Document(
@SerialName("road_address")
val roadAddress: RoadAddress,
val roadAddress: RoadAddress?,
@SerialName("address")
val address: Address,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.threegap.bitnagil.data.report.datasource

import com.threegap.bitnagil.data.report.model.request.ReportRequestDto
import com.threegap.bitnagil.data.report.model.response.ReportDetailDto
import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto

interface ReportDataSource {
suspend fun submitReport(reportRequestDto: ReportRequestDto): Result<Long>
suspend fun getReports(): Result<ReportHistoriesPerDateDto>
suspend fun getReport(reportId: String): Result<ReportDetailDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.report.datasourceImpl
import com.threegap.bitnagil.data.common.safeApiCall
import com.threegap.bitnagil.data.report.datasource.ReportDataSource
import com.threegap.bitnagil.data.report.model.request.ReportRequestDto
import com.threegap.bitnagil.data.report.model.response.ReportDetailDto
import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto
import com.threegap.bitnagil.data.report.service.ReportService
import javax.inject.Inject
Expand All @@ -17,4 +18,8 @@ class ReportDataSourceImpl @Inject constructor(
override suspend fun getReports(): Result<ReportHistoriesPerDateDto> {
return safeApiCall { reportService.getReports() }
}

override suspend fun getReport(reportId: String): Result<ReportDetailDto> {
return safeApiCall { reportService.getReport(reportId = reportId) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.threegap.bitnagil.data.report.model.response

import com.threegap.bitnagil.domain.report.model.ReportCategory
import com.threegap.bitnagil.domain.report.model.ReportDetail
import com.threegap.bitnagil.domain.report.model.ReportStatus
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.time.LocalDate

@Serializable
class ReportDetailDto(
@SerialName("reportDate")
val reportDate: String,
@SerialName("reportStatus")
val reportStatus: String,
@SerialName("reportTitle")
val reportTitle: String,
@SerialName("reportContent")
val reportContent: String,
@SerialName("reportCategory")
val reportCategory: String,
@SerialName("reportLocation")
val reportLocation: String,
@SerialName("reportImageUrls")
val reportImageUrls: List<String>,
)

fun ReportDetailDto.toDomain(id: String?): ReportDetail =
ReportDetail(
id = id ?: "",
date = LocalDate.parse(this.reportDate),
status = ReportStatus.fromString(this.reportStatus),
title = this.reportTitle,
content = this.reportContent,
category = ReportCategory.fromString(this.reportCategory),
address = this.reportLocation,
imageUrls = this.reportImageUrls,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.threegap.bitnagil.data.report.repositoryImpl

import com.threegap.bitnagil.data.report.datasource.ReportDataSource
import com.threegap.bitnagil.data.report.model.request.toDto
import com.threegap.bitnagil.data.report.model.response.toDomain
import com.threegap.bitnagil.data.report.model.response.toDomainMap
import com.threegap.bitnagil.domain.report.model.Report
import com.threegap.bitnagil.domain.report.model.ReportDetail
import com.threegap.bitnagil.domain.report.model.ReportItem
import com.threegap.bitnagil.domain.report.repository.ReportRepository
import java.time.LocalDate
Expand All @@ -19,4 +21,8 @@ class ReportRepositoryImpl @Inject constructor(
override suspend fun getReportHistories(): Result<Map<LocalDate, List<ReportItem>>> {
return reportDataSource.getReports().map { it.toDomainMap() }
}

override suspend fun getReport(reportId: String): Result<ReportDetail> {
return reportDataSource.getReport(reportId = reportId).map { it.toDomain(id = reportId) }
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.threegap.bitnagil.data.report.service

import com.threegap.bitnagil.data.report.model.request.ReportRequestDto
import com.threegap.bitnagil.data.report.model.response.ReportDetailDto
import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto
import com.threegap.bitnagil.network.model.BaseResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

interface ReportService {
@POST("/api/v2/reports")
Expand All @@ -15,4 +17,9 @@ interface ReportService {

@GET("/api/v2/reports")
suspend fun getReports(): BaseResponse<ReportHistoriesPerDateDto>

@GET("/api/v2/reports/{reportId}")
suspend fun getReport(
@Path("reportId") reportId: String,
): BaseResponse<ReportDetailDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.threegap.bitnagil.domain.report.model

import java.time.LocalDate

data class ReportDetail(
val id: String,
val title: String,
val content: String,
val category: ReportCategory,
val status: ReportStatus,
val imageUrls: List<String>,
val address: String,
val date: LocalDate,
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.threegap.bitnagil.domain.report.repository

import com.threegap.bitnagil.domain.report.model.Report
import com.threegap.bitnagil.domain.report.model.ReportDetail
import com.threegap.bitnagil.domain.report.model.ReportItem
import java.time.LocalDate

interface ReportRepository {
suspend fun submitReport(report: Report): Result<Long>
suspend fun getReportHistories(): Result<Map<LocalDate, List<ReportItem>>>
suspend fun getReport(reportId: String): Result<ReportDetail>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.threegap.bitnagil.domain.report.usecase

import com.threegap.bitnagil.domain.report.model.ReportDetail
import com.threegap.bitnagil.domain.report.repository.ReportRepository
import javax.inject.Inject

class GetReportUseCase @Inject constructor(
private val reportRepository: ReportRepository,
) {
suspend operator fun invoke(id: String): Result<ReportDetail> {
return reportRepository.getReport(reportId = id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package com.threegap.bitnagil.presentation.reportdetail

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
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.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import com.threegap.bitnagil.designsystem.BitnagilTheme
import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar
import com.threegap.bitnagil.presentation.reportdetail.component.atom.ReportProcessBadge
import com.threegap.bitnagil.presentation.reportdetail.component.block.ReportDetailLabeledContent
import com.threegap.bitnagil.presentation.reportdetail.model.mvi.ReportDetailState
import com.threegap.bitnagil.presentation.reportdetail.util.toPresentationFormatInReportDetail
import org.orbitmvi.orbit.compose.collectAsState

@Composable
fun ReportDetailScreenContainer(
viewModel: ReportDetailViewModel,
navigateToBack: () -> Unit,
) {
val state by viewModel.collectAsState()

ReportDetailScreen(
state = state,
onClickPreviousButton = navigateToBack,
)
}

@Composable
private fun ReportDetailScreen(
modifier: Modifier = Modifier,
onClickPreviousButton: () -> Unit,
state: ReportDetailState,
) {
val verticalScrollState = rememberScrollState()

Column(
modifier = modifier
.fillMaxSize()
.background(color = BitnagilTheme.colors.white)
.statusBarsPadding(),
) {
BitnagilTopBar(
title = "제보하기",
showBackButton = true,
onBackClick = onClickPreviousButton,
)

Column(
modifier = Modifier
.weight(1f)
.verticalScroll(verticalScrollState)
.padding(horizontal = 20.dp),
) {
Spacer(modifier = Modifier.height(20.dp))

ReportProcessBadge(reportProcess = state.reportProcess)

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

Text(
text = state.date.toPresentationFormatInReportDetail(),
style = BitnagilTheme.typography.subtitle1SemiBold,
)

Spacer(modifier = Modifier.height(14.dp))

Row {
state.imageUrls.forEach { imageUrl ->
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data(imageUrl)
.build(),
modifier = Modifier
.size(74.dp)
.clip(shape = RoundedCornerShape(9.dp))
.background(color = BitnagilTheme.colors.black),
contentScale = ContentScale.Crop,
contentDescription = null,
)
}
}

Spacer(modifier = Modifier.height(24.dp))

Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(28.dp),
) {
ReportDetailLabeledContent(
label = "제목",
content = state.reportTitle,
)

ReportDetailLabeledContent(
label = "카테고리",
content = state.reportCategory.title,
)

ReportDetailLabeledContent(
label = "상세 제목 내용",
content = state.reportContent,
)

ReportDetailLabeledContent(
label = "내 위치",
content = state.location,
)
}

Spacer(modifier = Modifier.height(36.dp))
}
}
}

@Composable
@Preview
private fun ReportDetailScreenPreview() {
BitnagilTheme {
ReportDetailScreen(
state = ReportDetailState.Init.copy(
reportContent = "Lorem ipsum dolor sit amet, " +
"consectetur adipiscing elit," +
" sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"Nisl tincidunt eget nullam non.",
),
onClickPreviousButton = {},
)
}
}
Loading