Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

진행중인챌린지 히스토리에서는 이미지 변경하기 #264

Merged
merged 4 commits into from
Oct 10, 2023
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
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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통 코드 빼는것 좋은거 같아요~ 멋졍! 👍

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.