Skip to content

Commit

Permalink
Merge pull request #218 from hellokitty-coding-club/feat/change_date_…
Browse files Browse the repository at this point in the history
…time_format

[FEAT] 앱 전반에 걸친 Timestamp 표기방식 변경 및 워딩 수정 (#208)
  • Loading branch information
KxxHyoRim authored Feb 29, 2024
2 parents 10923a0 + 3b3542a commit 8d16ba5
Show file tree
Hide file tree
Showing 24 changed files with 148 additions and 168 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.lgtm.android.common_ui.model

import android.text.SpannableString
import com.lgtm.android.common_ui.constant.ProcessStateUI

data class MemberMissionStatusUI(
val githubId: String,
val githubPrUrl: String,
val memberId: Int,
val nickname: String,
val missionFinishedDate: String,
val paymentDate: String,
val missionFinishedDate: SpannableString,
val paymentDate: SpannableString,
val processStatus: ProcessStateUI,
val profileImageUrl: String,
val isMissionSubmitted : Boolean
val isMissionSubmitted: Boolean,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lgtm.android.common_ui.model

import android.text.SpannableString
import com.lgtm.android.common_ui.constant.MissionDetailButtonStatus
import com.lgtm.android.common_ui.constant.MissionStatusUI
import com.lgtm.domain.constants.Role
Expand All @@ -21,5 +22,6 @@ data class MissionDetailUI(
val remainingRegisterDays: Int,
val scraped: Boolean,
val techTagList: List<TechTagVO>,
val missionDetailButtonStatusUI: MissionDetailButtonStatus
val missionDetailButtonStatusUI: MissionDetailButtonStatus,
val dateTime: SpannableString,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import android.text.SpannableString
import java.io.Serializable

data class MissionProcessInfoUI(
val waitingForPaymentDate: String?,
val waitingForPaymentDate: SpannableString?,
val waitingForPaymentDetail: SpannableString? = null,
val paymentConfirmationDate: String?,
val paymentConfirmationDate: SpannableString?,
val paymentConfirmationDetail: SpannableString? = null,
val missionProceedingDate: String?,
val missionProceedingDate: SpannableString?,
val missionProceedingDetail: SpannableString? = null,
val codeReviewDate: String?,
val codeReviewDate: SpannableString?,
val codeReviewDetail: SpannableString? = null,
val missionFinishedDate: String?,
val feedbackReviewedDate: String?,
val missionFinishedDate: SpannableString?,
val feedbackReviewedDate: SpannableString?,
val depositorName: String? = null,
) : Serializable
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.lgtm.android.common_ui.model

import android.text.SpannableString

data class NotificationUI(
val title: String,
val body: String,
val isRead: Boolean,
val notificationId: Int,
val date: String,
val time: String,
val dateTime: SpannableString,
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import com.lgtm.domain.util.dotStyleDateFormatter
import com.lgtm.domain.util.korean12HourTimeFormatter
import java.time.LocalDateTime

const val LGTM_RED = "#fe504f"
const val LGTM_GRAY_3 = "#cfd8e7"
const val LGTM_GRAY_5 = "#78879f"

fun MissionDetailVO.toUiModel(): MissionDetailUI = MissionDetailUI(
currentPeopleNumber = currentPeopleNumber,
description = description,
Expand All @@ -52,7 +56,8 @@ fun MissionDetailVO.toUiModel(): MissionDetailUI = MissionDetailUI(
remainingRegisterDays = remainingRegisterDays,
scraped = scraped,
techTagList = techTagList,
missionDetailButtonStatusUI = getButtonStatusUI(missionDetailStatus)
missionDetailButtonStatusUI = getButtonStatusUI(missionDetailStatus),
dateTime = createLgtmDateTimeSpannable(dateTime)
)

fun ProfileVO.toUiModel(): ProfileGlanceUI = ProfileGlanceUI(
Expand Down Expand Up @@ -96,8 +101,8 @@ fun MemberMissionStatusVO.toUiModel() = MemberMissionStatusUI(
githubPrUrl = githubPrUrl,
memberId = memberId,
nickname = nickname,
missionFinishedDate = missionFinishedDate,
paymentDate = paymentDate,
missionFinishedDate = createLgtmDateTimeSpannable(missionFinishedDate),
paymentDate = createLgtmDateTimeSpannable(paymentDate),
processStatus = getProcessStateUI(processStatus),
profileImageUrl = profileImageUrl,
isMissionSubmitted = isMissionSubmitted,
Expand All @@ -123,14 +128,42 @@ fun AccountInfoVO.toUiModel() = AccountInfoUI(
fun createRedSpannableText(text: String, redTextStart: Int, redTextEnd: Int): SpannableString {
val spannableText = SpannableString(text)
spannableText.setSpan(
ForegroundColorSpan(Color.RED),
ForegroundColorSpan(Color.parseColor(LGTM_RED)),
redTextStart,
redTextEnd,
Spannable.SPAN_EXCLUSIVE_INCLUSIVE
)
return spannableText
}

fun createLgtmDateTimeSpannable(
localDateTime: LocalDateTime?,
): SpannableString {
return when (localDateTime) {
null -> SpannableString("-")

else -> {
val time = localDateTime.format(korean12HourTimeFormatter)
val date = localDateTime.format(dotStyleDateFormatter)
val spannableText = SpannableString("$date | $time").apply {
setSpan(
ForegroundColorSpan(Color.parseColor(LGTM_GRAY_5)),
0,
this@apply.length,
Spannable.SPAN_EXCLUSIVE_INCLUSIVE
)
setSpan(
ForegroundColorSpan(Color.parseColor(LGTM_GRAY_3)),
date.length + 1,
date.length + 2,
Spannable.SPAN_EXCLUSIVE_INCLUSIVE
)
}
spannableText
}
}
}

fun MissionProcessInfoVO.toUiModel(
role: Role,
processStatus: ProcessState,
Expand Down Expand Up @@ -193,12 +226,12 @@ fun MissionProcessInfoVO.toUiModel(
else null

return MissionProcessInfoUI(
waitingForPaymentDate = waitingForPaymentDate,
paymentConfirmationDate = paymentConfirmationDate,
missionProceedingDate = missionProceedingDate,
codeReviewDate = codeReviewDate,
feedbackReviewedDate = feedbackReviewedDate,
missionFinishedDate = missionFinishedDate,
waitingForPaymentDate = createLgtmDateTimeSpannable(waitingForPaymentDate),
paymentConfirmationDate = createLgtmDateTimeSpannable(paymentConfirmationDate),
missionProceedingDate = createLgtmDateTimeSpannable(missionProceedingDate),
codeReviewDate = createLgtmDateTimeSpannable(codeReviewDate),
feedbackReviewedDate = createLgtmDateTimeSpannable(feedbackReviewedDate),
missionFinishedDate = createLgtmDateTimeSpannable(missionFinishedDate),
waitingForPaymentDetail = waitingForPaymentDetail,
paymentConfirmationDetail = paymentConfirmationDetail,
missionProceedingDetail = missionProceedingDetail,
Expand Down Expand Up @@ -237,7 +270,6 @@ fun NotificationVO.toUiModel(): NotificationUI {
body = body,
notificationId = notificationId,
isRead = isRead,
time = date?.format(korean12HourTimeFormatter) ?: "",
date = date?.format(dotStyleDateFormatter) ?: ""
dateTime = createLgtmDateTimeSpannable(dateTime)
)
}

This file was deleted.

8 changes: 4 additions & 4 deletions common-ui/src/main/res/layout/item_dashboard_participant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/inner_guideline"
android:text="0000.00.00"
android:text="0000.00.00 | 오후 00:00"
android:textAppearance="@style/Body3M"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/tv_deposit_date_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_deposit_date_label"
tools:ignore="HardcodedText"
tools:text="2023.09.16" />
tools:text="0000.00.00 | 오후 00:00" />


<TextView
Expand All @@ -202,7 +202,7 @@
app:layout_constraintEnd_toEndOf="@id/tv_dummy_for_alignment"
app:layout_constraintStart_toStartOf="@id/tv_dummy_for_alignment"
app:layout_constraintTop_toTopOf="@id/tv_deposit_date_label"
tools:text="2023.09.16" />
tools:text="0000.00.00 | 오후 00:00" />

<TextView
android:id="@+id/tv_mission_submit_date_label"
Expand All @@ -225,7 +225,7 @@
app:layout_constraintEnd_toEndOf="@id/tv_dummy_for_alignment"
app:layout_constraintStart_toStartOf="@id/tv_dummy_for_alignment"
app:layout_constraintTop_toTopOf="@id/tv_mission_submit_date_label"
tools:text="2023.09.23" />
tools:text="0000.00.00 | 오후 00:00" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_review_mission"
Expand Down
45 changes: 0 additions & 45 deletions common-ui/src/main/res/layout/layout_lgtm_timestamp.xml

This file was deleted.

4 changes: 2 additions & 2 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ dependencies {
implementation(libs.hilt)
kapt(libs.hilt.kapt)
implementation(libs.bundles.basic.test)
api(platform(libs.firebase))
api(libs.bundles.firebase)
implementation(platform(libs.firebase))
implementation(libs.bundles.firebase)

// app 모듈에 전달 (NetworkModule)
api(libs.bundles.retrofit)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.lgtm.android.data.model.mapper

import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import java.time.LocalDateTime
import java.time.format.DateTimeParseException

fun parseDate(date: String?): LocalDateTime? {
return try {
checkNotNull(date)
LocalDateTime.parse(date)
} catch (e: DateTimeParseException) {
Firebase.crashlytics.log("$e / Wrong Date format : $date")
null
} catch (e: IllegalStateException) {
Firebase.crashlytics.log("$e / created value might be null : $date")
null
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lgtm.android.data.model.response

import com.lgtm.android.data.model.mapper.parseDate
import com.lgtm.domain.constants.ProcessState
import com.lgtm.domain.constants.ProcessState.Companion.getProcessState
import com.lgtm.domain.constants.UNKNOWN
Expand All @@ -13,16 +14,16 @@ data class MemberMissionStatusDTO(
val nickname: String?,
val paymentDate: String?,
val processStatus: String?,
val profileImageUrl: String?
val profileImageUrl: String?,
) {
fun toVO(): MemberMissionStatusVO {
return MemberMissionStatusVO(
githubId = githubId ?: UNKNOWN,
githubPrUrl = githubPrUrl ?: UNKNOWN,
memberId = requireNotNull(memberId),
nickname = nickname ?: UNKNOWN,
missionFinishedDate = missionFinishedDate ?: UNKNOWN,
paymentDate = paymentDate ?: UNKNOWN,
missionFinishedDate = parseDate(missionFinishedDate),
paymentDate = parseDate(paymentDate),
processStatus = getProcessState(processStatus),
profileImageUrl = profileImageUrl ?: UNKNOWN,
isMissionSubmitted = ProcessState.isMissionSubmitted(processStatus)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lgtm.android.data.model.response

import com.google.gson.annotations.SerializedName
import com.lgtm.android.data.model.mapper.parseDate
import com.lgtm.domain.constants.MissionDetailStatus.Companion.getMissionDetailStatus
import com.lgtm.domain.constants.MissionStatus.Companion.getMissionStatus
import com.lgtm.domain.constants.Role
Expand All @@ -25,7 +26,8 @@ data class MissionDetailDTO(
@SerializedName("participated")
val isParticipated: Boolean?,
@SerializedName("closed")
val isClosed: Boolean?
val isClosed: Boolean?,
val createdAt: String?,
) {
fun toVO(role: Role?): MissionDetailVO {
val memberType: Role = Role.getRole(requireNotNull(memberType)) ?: requireNotNull(role)
Expand All @@ -49,7 +51,8 @@ data class MissionDetailDTO(
memberType,
requireNotNull(isParticipated),
requireNotNull(isClosed)
)
),
dateTime = parseDate(createdAt)
)
}
}
Loading

0 comments on commit 8d16ba5

Please sign in to comment.