Skip to content

Commit

Permalink
[1.1.1-AN/UI,Fix] 포켓몬 formName 중복 적용 삭제, 포켓몬리스트 이름 MaxLine 1지정, 바이옴 D…
Browse files Browse the repository at this point in the history
…etail 에 포켓몬 없는 tier 필터링 (#438)

* feat: formName PascalCase로 변환 후 포켓몬 이름에 포메팅

* feat: 야생, 보스 Biome pokemon 이 없는 tier 는 filtering

* feat: 바이옴 포켓몬들 PokemonUiModel hashId 부여

* ui: biome item 포켓몬 maxLine 1

* ui: pokemonList item 포켓몬 maxLine 1

* ui: Battle maxLine 1 적용

* style: ktFormat

* feat: biomePokemon Adapter diffUtill id 에서 hashId로 변경

* feat: 바이옴 리스트 itemsame 에 grade로 비교
  • Loading branch information
murjune authored Oct 28, 2024
1 parent 734de30 commit 12e45dc
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BiomPokemonAdapter(private val onClickPokemon: PokemonListNavigateHandler)
companion object {
val poketmonComparator =
ItemDiffCallback<PokemonUiModel>(
onItemsTheSame = { oldItem, newItem -> oldItem.id == newItem.id },
onItemsTheSame = { oldItem, newItem -> oldItem.hashId == newItem.hashId },
onContentsTheSame = { oldItem, newItem -> oldItem == newItem },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BiomeBossAdapter(
companion object {
val wildPokemonComparator =
ItemDiffCallback<BiomePokemonUiModel>(
onItemsTheSame = { oldItem, newItem -> oldItem == newItem },
onItemsTheSame = { oldItem, newItem -> oldItem.grade == newItem.grade },
onContentsTheSame = { oldItem, newItem -> oldItem == newItem },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BiomeGymAdapter(
companion object {
val gymPokemonComparator =
ItemDiffCallback<BiomePokemonUiModel>(
onItemsTheSame = { oldItem, newItem -> oldItem == newItem },
onItemsTheSame = { oldItem, newItem -> oldItem.grade == newItem.grade },
onContentsTheSame = { oldItem, newItem -> oldItem == newItem },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BiomeWildAdapter(
companion object {
val wildPokemonComparator =
ItemDiffCallback<BiomePokemonUiModel>(
onItemsTheSame = { oldItem, newItem -> oldItem == newItem },
onItemsTheSame = { oldItem, newItem -> oldItem.grade == newItem.grade },
onContentsTheSame = { oldItem, newItem -> oldItem == newItem },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,38 @@ fun WildPokemon.toUi(): BiomePokemonUiModel =
grade = tier,
gymLeaderUrl = null,
type = null,
pokemons = pokemons.map(BiomePokemon::toPokemonUiModel),
pokemons =
pokemons.mapIndexed { index, biomePokemon ->
biomePokemon.toPokemonUiModel(index)
},
)

fun BossPokemon.toUi(): BiomePokemonUiModel =
BiomePokemonUiModel(
grade = tier,
gymLeaderUrl = null,
type = null,
pokemons = pokemons.map(BiomePokemon::toPokemonUiModel),
pokemons =
pokemons.mapIndexed { index, biomePokemon ->
biomePokemon.toPokemonUiModel(index)
},
)

fun GymPokemon.toUi(): BiomePokemonUiModel =
BiomePokemonUiModel(
grade = gymLeaderName,
gymLeaderUrl = gymLeaderImage,
type = gymLeaderTypeLogos.firstOrNull()?.toUi(),
pokemons = pokemons.map(BiomePokemon::toPokemonUiModel),
pokemons =
pokemons.mapIndexed { index, biomePokemon ->
biomePokemon.toPokemonUiModel(index)
},
)

fun BiomePokemon.toPokemonUiModel(): PokemonUiModel =
fun BiomePokemon.toPokemonUiModel(hashId: Int): PokemonUiModel =
PokemonUiModel(
id = id,
hashId = hashId.toLong(),
dexNumber = 0,
name = name,
imageUrl = imageUrl,
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/res/layout/activity_battle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:gravity="end"
android:maxLines="1"
android:text="@string/battle_opponent_pokemon_selection"
android:textAlignment="viewEnd"
app:layout_constraintBottom_toBottomOf="@id/flexbox_opponent_types"
Expand Down Expand Up @@ -162,7 +164,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginBottom="12dp"
android:ellipsize="end"
android:gravity="start"
android:maxLines="1"
android:text="@string/battle_mine_pokemon_selection"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/tv_skill_title"
Expand Down
10 changes: 6 additions & 4 deletions android/app/src/main/res/layout/item_ability_detail_pokemon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:background="@drawable/shape_pokemon_corner_radius">
android:background="@drawable/shape_pokemon_corner_radius"
android:paddingTop="12dp">

<ImageView
android:id="@+id/iv_ability_detail_pokemon"
Expand All @@ -41,22 +41,24 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="5dp"
android:ellipsize="end"
android:maxLines="1"
android:paddingHorizontal="10dp"
android:text="@{pokemon.name}"
android:textAlignment="center"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_ability_detail_pokemon"
tools:text="피카츄" />
tools:text="피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄" />

<LinearLayout
android:id="@+id/layout_ability_detail_pokemon_types"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shape_pokemon_corner_radius"
android:orientation="horizontal"
android:layout_marginTop="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="5dp"
android:ellipsize="end"
android:maxLines="1"
android:paddingHorizontal="10dp"
android:text="@{pokemon.name}"
android:textAlignment="center"
Expand All @@ -64,7 +66,7 @@
app:layout_constraintEnd_toEndOf="@id/iv_item_poketmon_poketmon"
app:layout_constraintStart_toStartOf="@id/iv_item_poketmon_poketmon"
app:layout_constraintTop_toBottomOf="@id/iv_item_poketmon_poketmon"
tools:text="피카츄" />
tools:text="피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄피카츄" />

<LinearLayout
android:id="@+id/layout_item_pokemon_pokemon_types"
Expand Down
22 changes: 11 additions & 11 deletions android/data/src/main/java/poke/rogue/helper/data/model/Pokemon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,22 @@ fun PokemonResponse.toData(): Pokemon =
)

fun PokemonResponse2.toData(): Pokemon {
// TODO : 바꿔야 함 - 임시로 걍 바꿈
val newFormName =
formName.split("_").joinToString("_") {
if (it.isBlank()) {
it
// TODO : 지금 포켓몬 이름을 보여주는거 모든 곳에서 통일이 안됨..
val pureName = name.substringBefore("_")
val pascalCaseFormName =
formName.split("_").joinToString("") { original ->
if (original.isBlank()) {
original
} else {
it[0].uppercase() + it.substring(1).lowercase()
original.replaceFirstChar { it.uppercase() }
}
}

val formattedName =
if (formName.isBlank() || formName.trim().lowercase() == "empty" || formName.trim()
.lowercase() == "normal"
) {
name
if (formName.isBlank() || formName.trim().lowercase() == "normal") {
pureName
} else {
"$name-$newFormName"
"$pureName-$pascalCaseFormName"
}

return Pokemon(
Expand All @@ -96,6 +95,7 @@ fun PokemonEntity.toData(): Pokemon =
id = id,
dexNumber = dexNumber,
name = name,
formName = formName,
imageUrl = imageUrl,
backImageUrl = backImageUrl,
types = types.map(Type::valueOf),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ fun BossPokemonResponse.toData(): BossPokemon =
pokemons = pokemons.toData(),
)

fun List<BossPokemonResponse>.toData(): List<BossPokemon> = map(BossPokemonResponse::toData)
fun List<BossPokemonResponse>.toData(): List<BossPokemon> =
filter {
it.pokemons.isNotEmpty()
}.map(BossPokemonResponse::toData)
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ fun WildPokemonResponse.toData(): WildPokemon =
pokemons = pokemons.toData(),
)

fun List<WildPokemonResponse>.toData(): List<WildPokemon> = map(WildPokemonResponse::toData)
fun List<WildPokemonResponse>.toData(): List<WildPokemon> = filter { it.pokemons.isNotEmpty() }.map(WildPokemonResponse::toData)

0 comments on commit 12e45dc

Please sign in to comment.