-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.1.0/AN-FEAT] 배틀 선택 / 결과 UI 개선 (#316)
* feat: 기술 위력이 마이너스 값일 경우, 화면 표시 변경 * feat: 배수 값에 따라 색상 다르게 설정 * feat: 선택했던 값 위치로 스크롤 되도록 설정 * chore: 변수명 수정 * feat: 명중률이 마이너스 값일 경우 -로 표시 * feat: 위력이 마이너스일 경우, 배수 표기 방식 변경
- Loading branch information
1 parent
7ad0891
commit 854f204
Showing
7 changed files
with
59 additions
and
16 deletions.
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