Skip to content

Commit

Permalink
Merge pull request #264 from 014967/feature/#issue_261
Browse files Browse the repository at this point in the history
진행중인챌린지 히스토리에서는 이미지 변경하기
  • Loading branch information
014967 authored Oct 10, 2023
2 parents c99281d + 2ef0692 commit 4b6af30
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.mashup.twotoo.presenter.R
import com.mashup.twotoo.presenter.designsystem.component.TwoTooImageView
import com.mashup.twotoo.presenter.designsystem.theme.TwoTooRound10
import com.mashup.twotoo.presenter.designsystem.theme.TwoTooTheme
import com.mashup.twotoo.presenter.designsystem.theme.TwotooPink
import com.mashup.twotoo.presenter.garden.model.ChallengeCardInfoUiModel
import com.mashup.twotoo.presenter.garden.model.FlowerHead

Expand Down Expand Up @@ -97,14 +98,18 @@ private fun ChallengeInfo(challengeCardInfoUiModel: ChallengeCardInfoUiModel) {
) {
Text(
text = stringResource(
id = if (challengeCardInfoUiModel.viewState == "InProgress") {
id = if (challengeCardInfoUiModel.viewState.isInProgress()) {
R.string.inProgressChallengeAttempts
} else {
R.string.challengeAttempts
},
challengeCardInfoUiModel.attempts,
),
color = TwoTooTheme.color.mainPink,
color = if (challengeCardInfoUiModel.viewState.isInProgress()) {
TwoTooTheme.color.mainPink
} else {
TwotooPink
},
)
Text(
modifier = Modifier.padding(top = 16.dp),
Expand All @@ -120,6 +125,10 @@ private fun ChallengeInfo(challengeCardInfoUiModel: ChallengeCardInfoUiModel) {
}
}

private fun String.isInProgress(): Boolean {
return this == "InProgress"
}

@Composable
private fun BoxScope.Flowers(challengeCardInfoUiModel: ChallengeCardInfoUiModel) {
Row(
Expand All @@ -130,23 +139,34 @@ private fun BoxScope.Flowers(challengeCardInfoUiModel: ChallengeCardInfoUiModel)
val context = LocalContext.current
val screenWidth = LocalConfiguration.current.screenWidthDp
val screenHeight = LocalConfiguration.current.screenHeightDp
val meFlower = FlowerHead(challengeCardInfoUiModel.meFlower).getFlowerImage(context, screenWidth, screenHeight)
val partnerFlower = FlowerHead(challengeCardInfoUiModel.partnerFlower).getFlowerImage(context, screenWidth, screenHeight)
val isUser1Success = challengeCardInfoUiModel.user1CommitCnt > 15
val isUser2Success = challengeCardInfoUiModel.user2CommitCnt > 15

TwoTooImageView(
modifier = Modifier.size(meFlower.width, meFlower.height),
model = if (isUser1Success) meFlower.image else R.drawable.img_not_success,
contentScale = ContentScale.Fit,
previewPlaceholder = R.drawable.img_head_fig_sm,
)
TwoTooImageView(
modifier = Modifier.size(partnerFlower.width, partnerFlower.height),
model = if (isUser2Success) partnerFlower.image else R.drawable.img_not_success,
contentScale = ContentScale.Fit,
previewPlaceholder = R.drawable.img_head_camellia_sm,
)
if (challengeCardInfoUiModel.viewState.isInProgress()) {
val inProgressImageHeight = 64 * screenHeight / 812
TwoTooImageView(
modifier = Modifier.padding(horizontal = 29.dp).fillMaxWidth().height(inProgressImageHeight.dp),
model = R.drawable.img_challenge_in_progress,
previewPlaceholder = R.drawable.img_challenge_in_progress,
contentScale = ContentScale.Fit,
)
} else {
val meFlower = FlowerHead(challengeCardInfoUiModel.meFlower).getFlowerImage(context, screenWidth, screenHeight)
val partnerFlower = FlowerHead(challengeCardInfoUiModel.partnerFlower).getFlowerImage(context, screenWidth, screenHeight)
val isUser1Success = challengeCardInfoUiModel.user1CommitCnt > 15
val isUser2Success = challengeCardInfoUiModel.user2CommitCnt > 15

TwoTooImageView(
modifier = Modifier.size(meFlower.width, meFlower.height),
model = if (isUser1Success) meFlower.image else R.drawable.img_not_success,
contentScale = ContentScale.Fit,
previewPlaceholder = R.drawable.img_head_fig_sm,
)
TwoTooImageView(
modifier = Modifier.size(partnerFlower.width, partnerFlower.height),
model = if (isUser2Success) partnerFlower.image else R.drawable.img_not_success,
contentScale = ContentScale.Fit,
previewPlaceholder = R.drawable.img_head_camellia_sm,
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ data class ChallengeCardInfoUiModel(
// Todo 14지우고 garden Card challengeNo와 매핑해야함.
val default: List<ChallengeCardInfoUiModel> = listOf(
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),
ChallengeCardInfoUiModel(viewState = "Complete", 15, 2, "아침 밥 먹기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(viewState = "Complete", 16, 3, "하루 2시간 공부하기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
ChallengeCardInfoUiModel(viewState = "Complete", 17, 4, "하루 책 20page 읽기", "2023/05/01 ~ 05/22", FlowerName.Fig, FlowerName.Camellia),
)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4b6af30

Please sign in to comment.