-
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
Changes from 3 commits
87b1600
8586f3c
fa17004
58920b8
0a56ef3
eec2076
71b8634
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,40 @@ | ||
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(), | ||
fun BattlePrediction.toUi(format: String = DEFAULT_NUMBER_FORMAT): BattlePredictionUiModel { | ||
val formattedPower = if (power < 0) NO_EFFECT_VALUE else power.toString() | ||
val formattedResult = if (calculatedResult < 0) NO_EFFECT_VALUE else String.format(format, calculatedResult) | ||
val color = | ||
when { | ||
multiplier < 1.0 -> R.color.poke_grey_60 | ||
multiplier in 1.0..2.9 -> R.color.poke_red_20 | ||
multiplier >= 3 -> R.color.poke_green_20 | ||
else -> R.color.poke_white | ||
} | ||
|
||
return BattlePredictionUiModel( | ||
power = formattedPower, | ||
accuracy = String.format(format, accuracy), | ||
multiplier = String.format(format, multiplier), | ||
calculatedResult = String.format(format, calculatedResult), | ||
calculatedResult = formattedResult, | ||
colorRes = color, | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,7 @@ import poke.rogue.helper.presentation.util.view.LinearSpacingItemDecoration | |
import poke.rogue.helper.presentation.util.view.dp | ||
import poke.rogue.helper.presentation.util.view.setOnSearchAction | ||
|
||
class PokemonSelectionFragment : | ||
ErrorHandleFragment<FragmentPokemonSelectionBinding>(R.layout.fragment_pokemon_selection) { | ||
class PokemonSelectionFragment : ErrorHandleFragment<FragmentPokemonSelectionBinding>(R.layout.fragment_pokemon_selection) { | ||
private val sharedViewModel: BattleSelectionViewModel by activityViewModels() | ||
private val viewModel: PokemonSelectionViewModel by viewModels<PokemonSelectionViewModel> { | ||
PokemonSelectionViewModel.factory( | ||
|
@@ -72,7 +71,12 @@ class PokemonSelectionFragment : | |
private fun initObserver() { | ||
repeatOnStarted { | ||
viewModel.filteredPokemon.collect { | ||
pokemonAdapter.submitList(it) | ||
pokemonAdapter.submitList(it) { | ||
if (sharedViewModel.previousSelection.selectedPokemon() != null) { | ||
val position = it.indexOfFirst { it.isSelected } | ||
binding.rvPokemons.scrollToPosition(position) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 오 이게 되네 ㅋㅋㅋ |
||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,12 @@ class SkillSelectionFragment : | |
|
||
repeatOnStarted { | ||
viewModel.filteredSkills.collect { | ||
skillAdapter.submitList(it) | ||
skillAdapter.submitList(it) { | ||
if (viewModel.previousSkillsId != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 그러게 ㅋㅋㅋㅋ |
||
val position = it.indexOfFirst { it.isSelected } | ||
binding.rvSkills.scrollToPosition(position) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
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.
저는 배수는 1.0으로 보여주는 것도 좋아요 !
3개 다 - - - 로 보여주면 뭔가 어색할 것 같기도 해요
이 부분은 동의합니다 !
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.
저두요