-
Notifications
You must be signed in to change notification settings - Fork 0
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
[1.1.0/AN-FEAT] 배틀 선택 / 결과 UI 개선 #316
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
87b1600
feat: 기술 위력이 마이너스 값일 경우, 화면 표시 변경
JoYehyun99 8586f3c
feat: 배수 값에 따라 색상 다르게 설정
JoYehyun99 fa17004
feat: 선택했던 값 위치로 스크롤 되도록 설정
JoYehyun99 58920b8
chore: 변수명 수정
JoYehyun99 0a56ef3
feat: 명중률이 마이너스 값일 경우 -로 표시
JoYehyun99 eec2076
feat: 위력이 마이너스일 경우, 배수 표기 방식 변경
JoYehyun99 71b8634
Merge branch 'an/develop' into an/feat/battle-result-ui
JoYehyun99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 40 additions & 7 deletions
47
.../app/src/main/java/poke/rogue/helper/presentation/battle/model/BattlePredictionUiModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,46 @@ | ||
package poke.rogue.helper.presentation.battle.model | ||
|
||
import androidx.annotation.ColorRes | ||
import poke.rogue.helper.R | ||
import poke.rogue.helper.data.model.BattlePrediction | ||
import poke.rogue.helper.presentation.battle.model.BattlePredictionUiModel.Companion.DEFAULT_NUMBER_FORMAT | ||
import poke.rogue.helper.presentation.battle.model.BattlePredictionUiModel.Companion.NO_EFFECT_VALUE | ||
|
||
data class BattlePredictionUiModel(val power: String, val accuracy: String, val multiplier: String, val calculatedResult: String) | ||
data class BattlePredictionUiModel( | ||
val power: String, | ||
val accuracy: String, | ||
val multiplier: String, | ||
val calculatedResult: String, | ||
@ColorRes val colorRes: Int, | ||
) { | ||
companion object { | ||
const val NO_EFFECT_VALUE = "-" | ||
const val DEFAULT_NUMBER_FORMAT = "%.1f" | ||
} | ||
} | ||
|
||
fun BattlePrediction.toUi(format: String = "%.1f"): BattlePredictionUiModel = | ||
BattlePredictionUiModel( | ||
power = power.toString(), | ||
accuracy = String.format(format, accuracy), | ||
multiplier = String.format(format, multiplier), | ||
calculatedResult = String.format(format, calculatedResult), | ||
fun BattlePrediction.toUi(format: String = DEFAULT_NUMBER_FORMAT): BattlePredictionUiModel { | ||
val formattedPower = if (power < 0) NO_EFFECT_VALUE else power.toString() | ||
val formattedAccuracy = if (accuracy < 0) NO_EFFECT_VALUE else String.format(format, accuracy) | ||
val formattedMultiplier = if (power < 0) NO_EFFECT_VALUE else String.format(format, multiplier) | ||
val formattedResult = | ||
if (calculatedResult < 0) NO_EFFECT_VALUE else String.format(format, calculatedResult) | ||
|
||
val color = selectedColorResource(multiplier) | ||
|
||
return BattlePredictionUiModel( | ||
power = formattedPower, | ||
accuracy = formattedAccuracy, | ||
multiplier = formattedMultiplier, | ||
calculatedResult = formattedResult, | ||
colorRes = color, | ||
) | ||
} | ||
|
||
private fun selectedColorResource(value: Double): Int = | ||
when { | ||
value < 1.0 -> R.color.poke_grey_60 | ||
value in 1.0..2.9 -> R.color.poke_red_20 | ||
value >= 3 -> R.color.poke_green_20 | ||
else -> R.color.poke_white | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 섬세한데요~
submitList 에 람다로 바로 콜백을 지정할 수 있군요~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헐 대박.. 제 코드 수정하러 갑니다 ㅋㅋ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이게 되네 ㅋㅋㅋ