From 2fd00fbcf115ab9bf3ef761119c1176ce1e77b1d Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 2 Mar 2024 14:53:30 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[FEATURE]=20#140=20:=20NoticeDummyData=20->?= =?UTF-8?q?=20Event=20=EC=8B=A4=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/survey/SurveyRepositoryImpl.kt | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt index 11836b2d..562ca57d 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt @@ -3,6 +3,7 @@ package com.wap.wapp.core.data.repository.survey import com.wap.wapp.core.data.utils.toISOLocalDateTimeString import com.wap.wapp.core.model.survey.Survey import com.wap.wapp.core.model.survey.SurveyAnswer +import com.wap.wapp.core.network.source.event.EventDataSource import com.wap.wapp.core.network.source.survey.SurveyDataSource import com.wap.wapp.core.network.source.user.UserDataSource import java.time.LocalDateTime @@ -11,6 +12,7 @@ import javax.inject.Inject class SurveyRepositoryImpl @Inject constructor( private val surveyDataSource: SurveyDataSource, private val userDataSource: UserDataSource, + private val eventDataSource: EventDataSource, ) : SurveyRepository { override suspend fun getSurveyList(): Result> = surveyDataSource.getSurveyList().mapCatching { surveyList -> @@ -19,11 +21,12 @@ class SurveyRepositoryImpl @Inject constructor( .mapCatching { userProfileResponse -> val userName = userProfileResponse.toDomain().userName - noticeNameResponse.mapCatching { noticeNameResponse -> - val eventName = noticeNameResponse.toDomain() + eventDataSource.getEvent(eventId = surveyResponse.eventId) + .mapCatching { eventResponse -> + val eventName = eventResponse.toDomain().title - surveyResponse.toDomain(userName = userName, eventName = eventName) - }.getOrThrow() + surveyResponse.toDomain(userName = userName, eventName = eventName) + }.getOrThrow() }.getOrThrow() } } @@ -35,11 +38,12 @@ class SurveyRepositoryImpl @Inject constructor( .mapCatching { userProfileResponse -> val userName = userProfileResponse.toDomain().userName - noticeNameResponse.mapCatching { noticeNameResponse -> - val eventName = noticeNameResponse.toDomain() + eventDataSource.getEvent(eventId = eventId) + .mapCatching { eventResponse -> + val eventName = eventResponse.toDomain().title - surveyResponse.toDomain(userName = userName, eventName = eventName) - }.getOrThrow() + surveyResponse.toDomain(userName = userName, eventName = eventName) + }.getOrThrow() }.getOrThrow() } } @@ -51,11 +55,12 @@ class SurveyRepositoryImpl @Inject constructor( .mapCatching { userProfileResponse -> val userName = userProfileResponse.toDomain().userName - noticeNameResponse.mapCatching { noticeNameResponse -> - val eventName = noticeNameResponse.toDomain() + eventDataSource.getEvent(eventId = surveyResponse.eventId) + .mapCatching { eventResponse -> + val eventName = eventResponse.toDomain().title - surveyResponse.toDomain(userName = userName, eventName = eventName) - }.getOrThrow() + surveyResponse.toDomain(userName = userName, eventName = eventName) + }.getOrThrow() }.getOrThrow() } } @@ -67,11 +72,12 @@ class SurveyRepositoryImpl @Inject constructor( .mapCatching { userProfileResponse -> val userName = userProfileResponse.toDomain().userName - noticeNameResponse.mapCatching { noticeNameResponse -> - val eventName = noticeNameResponse.toDomain() + eventDataSource.getEvent(eventId = surveyResponse.eventId) + .mapCatching { eventResponse -> + val eventName = eventResponse.toDomain().title - surveyResponse.toDomain(userName = userName, eventName = eventName) - }.getOrThrow() + surveyResponse.toDomain(userName = userName, eventName = eventName) + }.getOrThrow() }.getOrThrow() } } @@ -82,11 +88,12 @@ class SurveyRepositoryImpl @Inject constructor( .mapCatching { userProfileResponse -> val userName = userProfileResponse.toDomain().userName - noticeNameResponse.mapCatching { noticeNameResponse -> - val eventName = noticeNameResponse.toDomain() + eventDataSource.getEvent(eventId = surveyResponse.eventId) + .mapCatching { eventResponse -> + val eventName = eventResponse.toDomain().title - surveyResponse.toDomain(userName = userName, eventName = eventName) - }.getOrThrow() + surveyResponse.toDomain(userName = userName, eventName = eventName) + }.getOrThrow() }.getOrThrow() } @@ -113,9 +120,4 @@ class SurveyRepositoryImpl @Inject constructor( override suspend fun isSubmittedSurvey(surveyFormId: String, userId: String): Result = surveyDataSource.isSubmittedSurvey(surveyFormId, userId) - - private val noticeNameResponse: Result = Result.success("notice datasource dummy data") - - // TODO 도메인 모델 구현을 위한 익스텐션, notice DataSource 구현 후 소거 - private fun String.toDomain(): String = this } From 29b528d284b605b172670bb37241059380379243 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 2 Mar 2024 15:04:36 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[FEATURE]=20#140=20:=20=EC=84=A4=EB=AC=B8?= =?UTF-8?q?=20=EC=8B=9C=EA=B0=81=20=EA=B3=84=EC=82=B0=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/model/survey/Survey.kt | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/core/model/src/main/java/com/wap/wapp/core/model/survey/Survey.kt b/core/model/src/main/java/com/wap/wapp/core/model/survey/Survey.kt index 1c39f74e..4662b99f 100644 --- a/core/model/src/main/java/com/wap/wapp/core/model/survey/Survey.kt +++ b/core/model/src/main/java/com/wap/wapp/core/model/survey/Survey.kt @@ -1,6 +1,9 @@ package com.wap.wapp.core.model.survey +import java.time.Duration import java.time.LocalDateTime +import java.time.ZoneId +import java.time.format.DateTimeFormatter /* 회원이 작성하는 설문 모델 @@ -15,4 +18,33 @@ data class Survey( val content: String, val surveyAnswerList: List, val surveyedAt: LocalDateTime, -) +) { + fun calculateSurveyedAt(): String { + val currentDateTime = LocalDateTime.now(TIME_ZONE_SEOUL) + val duration = Duration.between(surveyedAt, currentDateTime) + + if (duration.toMinutes() == 0L) { + return "방금" + } else if (duration.toMinutes() < 60) { + val leftMinutes = duration.toMinutes().toString() + return leftMinutes + "분 전 작성" + } + + if (duration.toHours() < 24) { + val leftHours = duration.toHours().toString() + return leftHours + "시간 전 작성" + } + + if (duration.toDays() < 31) { + val leftDays = duration.toDays().toString() + return leftDays + "일 전 작성" + } + + return surveyedAt.format(yyyyMMddFormatter) + " 작성" + } + + companion object { + val yyyyMMddFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd") + val TIME_ZONE_SEOUL = ZoneId.of("Asia/Seoul") + } +} From b3b495e25df5bf3d3219862bf9a96bfa630d6b9e Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 2 Mar 2024 15:04:53 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[FEATURE]=20#140=20:=20=EC=84=A4=EB=AC=B8,?= =?UTF-8?q?=20=EC=84=A4=EB=AC=B8=ED=98=95=EC=8B=9D=20=EC=B9=B4=EB=93=9C=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=ED=85=9C=20UI=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=8F=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/survey/check/SurveyItemCard.kt | 20 ++++++++++++------- .../wapp/feature/survey/SurveyFormItemCard.kt | 9 +++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyItemCard.kt b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyItemCard.kt index 8853e0b9..7fde7fc9 100644 --- a/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyItemCard.kt +++ b/feature/survey-check/src/main/java/com/wap/wapp/feature/survey/check/SurveyItemCard.kt @@ -10,7 +10,9 @@ import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.wap.designsystem.WappTheme import com.wap.wapp.core.model.survey.Survey @@ -30,31 +32,35 @@ internal fun SurveyItemCard( ) { Column( verticalArrangement = Arrangement.spacedBy(16.dp), - modifier = Modifier.padding(horizontal = 16.dp), + modifier = Modifier.padding(16.dp), ) { Row( horizontalArrangement = Arrangement.End, + verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth(), ) { Text( text = survey.title, - modifier = Modifier.weight(1f), - maxLines = 1, color = WappTheme.colors.white, style = WappTheme.typography.titleBold, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f), ) Text( - text = survey.eventName, - color = WappTheme.colors.grayA2, + text = survey.calculateSurveyedAt(), + color = WappTheme.colors.yellow34, style = WappTheme.typography.captionMedium, + modifier = Modifier.padding(start = 8.dp), ) } Text( - text = survey.userName, + text = "${survey.userName} • ${survey.eventName}", color = WappTheme.colors.grayBD, - style = WappTheme.typography.contentMedium, + style = WappTheme.typography.labelMedium, + maxLines = 1, ) } } diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyFormItemCard.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyFormItemCard.kt index 4936025d..3d1ab42f 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyFormItemCard.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/SurveyFormItemCard.kt @@ -10,7 +10,9 @@ import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.wap.designsystem.WappTheme import com.wap.wapp.core.model.survey.SurveyForm @@ -34,26 +36,29 @@ internal fun SurveyFormItemCard( ) { Row( horizontalArrangement = Arrangement.End, + verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth(), ) { Text( text = surveyForm.title, color = WappTheme.colors.white, modifier = Modifier.weight(1f), - maxLines = 1, style = WappTheme.typography.titleBold, + maxLines = 1, + overflow = TextOverflow.Ellipsis, ) Text( text = surveyForm.calculateDeadline(), color = WappTheme.colors.yellow34, style = WappTheme.typography.captionMedium, + modifier = Modifier.padding(start = 8.dp), ) } Text( text = surveyForm.content, color = WappTheme.colors.grayBD, maxLines = 1, - style = WappTheme.typography.contentMedium, + style = WappTheme.typography.labelMedium, ) } }