Skip to content

Commit

Permalink
[fix] : model
Browse files Browse the repository at this point in the history
  • Loading branch information
014967 committed Sep 9, 2023
1 parent 09b10ea commit a8ad019
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ package com.mashup.twotoo.presenter.garden.mapper
import com.mashup.twotoo.presenter.garden.model.ChallengeCardInfoUiModel
import com.mashup.twotoo.presenter.model.toFlowerName
import com.mashup.twotoo.presenter.util.DateFormatter
import model.challenge.response.ChallengeResponseDomainModel
import model.challenge.response.HistoryChallengeDomainModel

fun ChallengeResponseDomainModel.toUiModel(index: Int): ChallengeCardInfoUiModel {
fun HistoryChallengeDomainModel.toUiModel(index: Int): ChallengeCardInfoUiModel {
return ChallengeCardInfoUiModel(
viewState = this.viewState ?: "InProgress",
challengeNo = challengeNo,
attempts = index + 1,
name = name,
period = toPeriod(),
meFlower = user1Flower.toFlowerName(),
partnerFlower = user2Flower.toFlowerName(),
user1CommitCnt = user1CommitCnt,
user2CommitCnt = user2CommitCnt
user2CommitCnt = user2CommitCnt,
)
}

fun ChallengeResponseDomainModel.toPeriod(): String {
fun HistoryChallengeDomainModel.toPeriod(): String {
return "${DateFormatter.dateConvertToPlusNineTime(startDate,"yyyy-MM-dd")} ~ ${DateFormatter.dateConvertToPlusNineTime(endDate,"yyyy-MM-dd")}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ package com.mashup.twotoo.presenter.garden.model
import com.mashup.twotoo.presenter.model.FlowerName

data class ChallengeCardInfoUiModel(
val viewState: String = "InProgress",
val challengeNo: Int,
val attempts: Int,
val name: String,
val period: String,
val meFlower: FlowerName,
val partnerFlower: FlowerName,
val user1CommitCnt: Int = 0,
val user2CommitCnt: Int = 0
val user2CommitCnt: Int = 0,
) {
companion object {
// Todo 14지우고 garden Card challengeNo와 매핑해야함.
val default: List<ChallengeCardInfoUiModel> = listOf(
ChallengeCardInfoUiModel(14, 1, "하루 30분 운동하기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(14, 2, "아침 밥 먹기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(14, 3, "하루 2시간 공부하기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(14, 4, "하루 책 20page 읽기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(viewState = "InProgress", 14, 1, "하루 30분 운동하기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(viewState = "InProgress", 14, 2, "아침 밥 먹기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(viewState = "InProgress", 14, 3, "하루 2시간 공부하기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(viewState = "InProgress", 14, 4, "하루 책 20page 읽기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
)
}
}
1 change: 1 addition & 0 deletions presenter/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@

<!-- history detail-->
<string name="challengeAttempts">%d번째 챌린지</string>
<string name="inProgressChallengeAttempts">%d번째 챌린지 중</string>
<string name="historyDetailTitle">%s의 기록</string>
<string name="historyDetailCreatedTime">입력 시간 : %s</string>
<string name="complimentFromPartner">%s의 칭찬 한마디</string>
Expand Down

0 comments on commit a8ad019

Please sign in to comment.