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

[1.2.0/AN-FEAT, AN-UI] 포켓몬 스탯 프로그레스 바에 애니메이션 적용 #484

Merged
merged 23 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5ab9c82
feat(ProgressBarAnimation): from 에서 to 까지 프로그레스바의 애니메이션
sh1mj1 Dec 6, 2024
69a118d
feat(PokemonStatAdapter): progressBar 에 애니메이션 적용
sh1mj1 Dec 6, 2024
f5986fa
feat(strings.xml): 스탯 라벨 정의
sh1mj1 Dec 6, 2024
01551dc
refactor(StatUiModel): 국제화를 위해 name 프로퍼티를 @StringRes Int 로
sh1mj1 Dec 6, 2024
2d0b076
feat(ko-rKR-strings): pokemon stat 한글
sh1mj1 Dec 6, 2024
41c8f12
refactor(StatUiModel): name 프로퍼티가 Int
sh1mj1 Dec 6, 2024
e3fda63
chore(PokemonDetailUiState): remove useless function
sh1mj1 Dec 6, 2024
cdc6658
fix(item_type_result.xml): 내 타입 상성 결과는 visible 이 아닌 invisible 바인딩 어댑터…
sh1mj1 Dec 6, 2024
ba92d01
fix(PokemonDetailViewModel): 진화체가 같은 포켓몬이면 선택하지 않는다
sh1mj1 Dec 6, 2024
09f0a0f
feat(PokemonEvolutionEvent): 포켓몬 진화체 클릭 이벤트
sh1mj1 Dec 6, 2024
544be67
refactor(PokemonDetailViewModel): 진화체 클릭시 이벤트
sh1mj1 Dec 6, 2024
f5f91a4
feat(PokemonDetailActivity): 현재 화면과 같은 포켓몬이면 보여주는 토스트 메시지를 지역화
sh1mj1 Dec 6, 2024
e7513df
feat(PokemonDetailViewModel): 홈, 특성 상세, 바이옴 상세 네비게이션 이벤트
sh1mj1 Dec 6, 2024
aa9db64
refactor(PokemonDetailViewModel, Activity): 홈, 특성 상세, 바이옴 상세 네비게이션 이벤트
sh1mj1 Dec 6, 2024
9d2e18c
refactor(PokemonDetailViewModel, Activity): 배틀로 네비게이션하는 이벤트를 한 객체로 합친다
sh1mj1 Dec 6, 2024
fe39194
refactor(PokemonDetailViewModel): 배틀로 네비게이션 시에 파이어베이스 로깅 수정
sh1mj1 Dec 6, 2024
1db5f42
refactor(PokemonDetailViewModel, Activity): 포켓몬 상세로 가는 이벤트 병합
sh1mj1 Dec 6, 2024
f995cc3
refactor(PokemonDetailActivity): 포켓몬 상세로 이동 처리 함수화
sh1mj1 Dec 6, 2024
9ad269b
fix(ko-rKR-strings): 현재 화면의 포켓몬과 같은 포켓몬의 상세 화면으로 이동할 때 메시지
sh1mj1 Dec 6, 2024
618baaa
Merge branch 'an/fix/pokemon-evolution-navigation' into an/refactor/p…
sh1mj1 Dec 6, 2024
bbeac80
chore(ProgressBarAnimation): progressBar 에 progress 를 중복으로 설정해주는 부분 수정
sh1mj1 Dec 13, 2024
c73f4d2
Merging an/refactor/pokemon-stats-animation from an/develop
sh1mj1 Dec 15, 2024
cfd8bae
Merge branch 'an/develop' into an/refactor/pokemon-stats-animation
sh1mj1 Dec 19, 2024
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 @@ -7,6 +7,7 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder
import poke.rogue.helper.databinding.ItemStatBinding
import poke.rogue.helper.presentation.dex.model.StatUiModel
import poke.rogue.helper.presentation.util.view.ItemDiffCallback
import poke.rogue.helper.presentation.util.view.animation

class PokemonStatAdapter :
ListAdapter<StatUiModel, PokemonStatAdapter.PokemonStatViewHolder>(statComparator) {
Expand All @@ -33,6 +34,17 @@ class PokemonStatAdapter :
ViewHolder(binding.root) {
fun bind(stat: StatUiModel) {
binding.stat = stat
binding.progressBarStat.apply {
startAnimation(
animation(from = 0f, to = stat.amount.toFloat()).apply {
duration = ANIMATION_DURATION
},
)
}
}
Comment on lines +37 to +44
Copy link
Contributor

Choose a reason for hiding this comment

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

오 생각보다 간단하게 되는 군요 ㅋㅋㅋ


companion object {
private const val ANIMATION_DURATION: Long = 800
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package poke.rogue.helper.presentation.dex.model

import androidx.annotation.ColorRes
import androidx.annotation.StringRes
import poke.rogue.helper.R
import poke.rogue.helper.data.model.Stat

data class StatUiModel(
val name: String,
@StringRes val name: Int,
val amount: Int,
val limit: Int,
@ColorRes val color: Int = 0,
Expand All @@ -14,59 +15,59 @@ data class StatUiModel(
get() = amount * 100 / limit
}

fun Stat.toUi() =
fun Stat.toUi(): StatUiModel =
when (name) {
"hp" ->
StatUiModel(
name = "HP",
name = R.string.pokemon_stat_hp,
amount = amount,
limit = MAX_HP_LIMIT,
color = R.color.stat_hp,
)

"attack" ->
StatUiModel(
name = "공격",
name = R.string.pokemon_stat_attack,
amount = amount,
limit = MAX_ATTACK_LIMIT,
color = R.color.stat_attack,
)

"defense" ->
StatUiModel(
name = "방어",
name = R.string.pokemon_stat_defense,
amount = amount,
limit = MAX_DEFENSE_LIMIT,
color = R.color.stat_defense,
)

"specialAttack" ->
StatUiModel(
name = "특수공격",
name = R.string.pokemon_stat_special_attack,
amount = amount,
limit = MAX_SPECIAL_ATTACK_LIMIT,
color = R.color.stat_special_attack,
)

"specialDefense" ->
StatUiModel(
name = "특수방어",
name = R.string.pokemon_stat_special_defense,
amount = amount,
limit = MAX_SPECIAL_DEFENSE_LIMIT,
color = R.color.stat_special_defense,
)

"speed" ->
StatUiModel(
name = "스피드",
name = R.string.pokemon_stat_speed,
amount = amount,
limit = MAX_SPEED_LIMIT,
color = R.color.stat_speed,
)

"total" ->
StatUiModel(
name = "종족값",
name = R.string.pokemon_stat_base_stat,
amount = amount,
limit = MAX_TOTAL_LIMIT,
color = R.color.stat_total,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package poke.rogue.helper.presentation.util.view

import android.view.animation.Animation
import android.view.animation.Transformation
import android.widget.ProgressBar

class ProgressBarAnimation(
private val progressBar: ProgressBar,
private val from: Float,
private val to: Float,
) : Animation() {
override fun applyTransformation(
interpolatedTime: Float,
t: Transformation?,
) {
super.applyTransformation(interpolatedTime, t)
val value = from + to * interpolatedTime
progressBar.progress = value.toInt()
}
}

fun ProgressBar.animation(
from: Float,
to: Float,
): ProgressBarAnimation = ProgressBarAnimation(this, from, to)
8 changes: 4 additions & 4 deletions android/app/src/main/res/layout/item_stat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:foregroundGravity="center"
android:gravity="start"
android:gravity="center"
android:orientation="horizontal"
android:paddingHorizontal="4dp"
android:paddingVertical="4dp">
Expand All @@ -28,7 +28,7 @@
android:text="@{stat.name}"
android:textSize="@dimen/pokemon_stat_text_size"
tools:ignore="SpUsage"
tools:text="HPD" />
tools:text="Base stat sdf" />

<Space
android:layout_width="12dp"
Expand All @@ -50,9 +50,9 @@
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
progressColor="@{stat.color}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="16dp"
android:max="@{stat.limit}"
android:paddingHorizontal="4dp"
android:max="100"
android:progress="@{stat.progress}"
tools:progress="70"
tools:progressDrawable="@drawable/progress_dex_stat" />
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/layout/item_type_result.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<TextView
android:id="@+id/tv_my_type_result"
style="@style/TextAppearance.Poke.Title"
visible="@{typeResult.isMyType}"
invisible="@{!typeResult.isMyType}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
Expand Down
9 changes: 9 additions & 0 deletions android/app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
<string name="pokemon_detail_to_battle_with_enemy_pop_up_descriptions">상대 포켓몬으로</string>
<string name="pokemon_detail_to_battle_with_mine_pop_up_descriptions">내 포켓몬으로</string>

<!-- pokemon stat-->
<string name="pokemon_stat_hp">HP</string>
<string name="pokemon_stat_attack">공격</string>
<string name="pokemon_stat_defense">방어</string>
<string name="pokemon_stat_special_attack">특수공격</string>
<string name="pokemon_stat_special_defense">특수방어</string>
<string name="pokemon_stat_speed">스피드</string>
<string name="pokemon_stat_base_stat">종족값</string>

<!-- pokemon detail skills-->
<string name="pokemon_detail_skill_level">레벨</string>
<string name="pokemon_detail_skill_name">기술명</string>
Expand Down
10 changes: 9 additions & 1 deletion android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<string name="by_special_defense">By Special Defense</string>
<string name="by_hp">By HP</string>


<!-- pokemon detail-->
<string name="dex_detail_pokemon_stats_title">Base Stats</string>

Expand All @@ -97,6 +96,15 @@
<string name="pokemon_detail_to_battle_with_enemy_pop_up_descriptions">As Opponent Pokémon</string>
<string name="pokemon_detail_to_battle_with_mine_pop_up_descriptions">As My Pokémon</string>

<!-- pokemon stat-->
<string name="pokemon_stat_hp">Max.HP</string>
<string name="pokemon_stat_attack">Attack</string>
<string name="pokemon_stat_defense">Defense</string>
<string name="pokemon_stat_special_attack">Sp.Atk</string>
<string name="pokemon_stat_special_defense">Sp.Def</string>
<string name="pokemon_stat_speed">Speed</string>
<string name="pokemon_stat_base_stat">Base Stat</string>

<!-- pokemon detail skills-->
<string name="pokemon_detail_skill_level">Level</string>
<string name="pokemon_detail_skill_name">Move</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class PokemonDetailViewModelTest : KoinTest {
),
stats =
listOf(
StatUiModel("HP", 45, 255, R.color.stat_hp),
StatUiModel("공격", 49, 190, R.color.stat_attack),
StatUiModel("방어", 49, 250, R.color.stat_defense),
StatUiModel("특수공격", 65, 194, R.color.stat_special_attack),
StatUiModel("특수방어", 65, 250, R.color.stat_special_defense),
StatUiModel("스피드", 45, 200, R.color.stat_speed),
StatUiModel("종족값", 318, 800, R.color.stat_total),
StatUiModel(R.string.pokemon_stat_hp, 45, 255, R.color.stat_hp),
StatUiModel(R.string.pokemon_stat_attack, 49, 190, R.color.stat_attack),
StatUiModel(R.string.pokemon_stat_defense, 49, 250, R.color.stat_defense),
StatUiModel(R.string.pokemon_stat_special_attack, 65, 194, R.color.stat_special_attack),
StatUiModel(R.string.pokemon_stat_special_defense, 65, 250, R.color.stat_special_defense),
StatUiModel(R.string.pokemon_stat_speed, 45, 200, R.color.stat_speed),
StatUiModel(R.string.pokemon_stat_base_stat, 318, 800, R.color.stat_total),
),
abilities =
listOf(
Expand Down
Loading