-
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.alpha/AN_FEAT, AN_UI] 도감 상세 UI 수정, 바이옴에서의 포켓몬 타입 가져오기 (#308)
* feat(PokemonBiomeUiModel): 포켓몬 바이옴 리스트와 모든 바이옴 정보를 통해 ui 모델로 * refactor(PokemonBiomeUiModel): 포켓몬 바이옴 리스트와 모든 바이옴 정보를 통해 ui 모델로 * feat(PokemonDetailUiState2): PokemonUiModel 을 가진다 * refactor(PokemonDetailViewModel): 바이옴 레포지토리를 추가로 가진다 * feat(PokemonDetailSkillFragment): PokemonDetailUiState2 에 대한 함수 추가 * feat(PokemonEvolutionFragment): PokemonDetailUiState2 에 대한 함수 추가 * feat(PokemonInformationFragment): PokemonDetailUiState2 에 대한 함수 추가 * feat(PokemonStatFragment): PokemonDetailUiState2 에 대한 함수 추가 * feat(PokemonDetailBiomeAdapter): PokemonDetailUiState2 에 대한 함수 추가 * refactor(PokemonDetailActivity): PokemonDetailUiState 에 대한 참조 제거 * refactor(PokemonEvolutionFragment): PokemonDetailUiState 에 대한 참조 제거 * refactor(PokemonInformationFragment): PokemonDetailUiState 에 대한 참조 제거 * refactor(PokemonDetailSkillFragment): PokemonDetailUiState 에 대한 참조 제거 * refactor(PokemonStatFragment): PokemonDetailUiState 에 대한 참조 제거 * refactor(PokemonDetailUiState.kt): PokemonDetailUiState2 -> PokemonDetailUiState * test(PokemonDetailViewModelTest): 포켓모 상세에서 바이옴 정보 * ui(PokemonDetailBiomeTypesAdapter): 바이옴의 타입 정보 추가 * ui(PokemonDetailBiomeViewHolder): 바이옴의 타입 정보 추가 * feat(PokemonInformationFragment.kt): 체중, 키를 서버로부터 로드한 데이터 보여준다 * feat(PokemonBiome): 바이옴에서 출연하는 포켓몬 타입 프로퍼티 추가 * feat(DefaultDexRepository): 바이옴 레포지토리 생성자 추가 * feat(PokemonBiomeUiModel): PokemonBiome 에서 ui 모델로 매핑 * refactor(PokemonBiomeUiModel): 포켓몬 뷰모델은 이전처럼 dex repository 하나만 갖는다 * refactor(PokemonBiomeUiModel): ui 모델로 매핑할 때 다른 파라미터를 갖지 않는다 * test(PokemonDetailViewModelTest): 포켓몬 상세 로드 * chore: ktlint * refactor(DefaultDexRepository): 포켓몬 상세 로직 가독성 개선
- Loading branch information
Showing
16 changed files
with
219 additions
and
74 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
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
39 changes: 39 additions & 0 deletions
39
...a/poke/rogue/helper/presentation/dex/detail/information/PokemonDetailBiomeTypesAdapter.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package poke.rogue.helper.presentation.dex.detail.information | ||
|
||
import android.content.Context | ||
import android.widget.ImageView | ||
import com.google.android.flexbox.FlexboxLayout | ||
import poke.rogue.helper.presentation.type.model.TypeUiModel | ||
import poke.rogue.helper.presentation.util.view.dp | ||
|
||
class PokemonDetailBiomeTypesAdapter(private val context: Context, private val viewGroup: FlexboxLayout) { | ||
fun addTypes( | ||
types: List<TypeUiModel>, | ||
spacingBetweenTypes: Int = 0.dp, | ||
iconSize: Int = 18.dp, | ||
) { | ||
viewGroup.removeAllViews() | ||
|
||
types.forEach { type -> | ||
val imageView = | ||
ImageView(context).apply { | ||
setImageResource(type.typeIconResId) | ||
|
||
layoutParams = | ||
FlexboxLayout.LayoutParams( | ||
iconSize, | ||
iconSize, | ||
).apply { | ||
setMargins( | ||
spacingBetweenTypes, | ||
0, | ||
0, | ||
0, | ||
) | ||
} | ||
} | ||
|
||
viewGroup.addView(imageView) | ||
} | ||
} | ||
} |
22 changes: 20 additions & 2 deletions
22
...ava/poke/rogue/helper/presentation/dex/detail/information/PokemonDetailBiomeViewHolder.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,18 +1,36 @@ | ||
package poke.rogue.helper.presentation.dex.detail.information | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import poke.rogue.helper.data.model.PokemonBiome | ||
import poke.rogue.helper.databinding.ItemPokemonDetailInformationBiomeBinding | ||
import poke.rogue.helper.presentation.dex.detail.PokemonDetailNavigateHandler | ||
import poke.rogue.helper.presentation.dex.model.PokemonBiomeUiModel | ||
import poke.rogue.helper.presentation.util.view.dp | ||
|
||
class PokemonDetailBiomeViewHolder( | ||
private val binding: ItemPokemonDetailInformationBiomeBinding, | ||
private val onClickBiomeItem: PokemonDetailNavigateHandler, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
fun bind(biome: PokemonBiome) { | ||
fun bind(biome: PokemonBiomeUiModel) { | ||
binding.apply { | ||
this.biome = biome | ||
uiEventHandler = onClickBiomeItem | ||
} | ||
|
||
val typesLayout = binding.flBiomeTypeIcons | ||
val biomeTypesAdapter = | ||
PokemonDetailBiomeTypesAdapter( | ||
context = binding.root.context, | ||
viewGroup = typesLayout, | ||
) | ||
biomeTypesAdapter.addTypes( | ||
types = biome.types, | ||
spacingBetweenTypes = TYPES_SPACING, | ||
iconSize = TYPE_ICON_SIZE, | ||
) | ||
} | ||
|
||
companion object { | ||
private val TYPES_SPACING = 5.dp | ||
private val TYPE_ICON_SIZE = 18.dp | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
android/app/src/main/java/poke/rogue/helper/presentation/dex/model/PokemonBiomeUiModel.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package poke.rogue.helper.presentation.dex.model | ||
|
||
import poke.rogue.helper.data.model.PokemonBiome | ||
import poke.rogue.helper.presentation.type.model.TypeUiModel | ||
import poke.rogue.helper.presentation.type.model.toUi | ||
|
||
data class PokemonBiomeUiModel( | ||
val id: String, | ||
val name: String, | ||
val imageUrl: String, | ||
val types: List<TypeUiModel>, | ||
) | ||
|
||
fun PokemonBiome.toUi(): PokemonBiomeUiModel = | ||
PokemonBiomeUiModel( | ||
id = id, | ||
name = name, | ||
imageUrl = imageUrl, | ||
types = pokemonType.toUi(), | ||
) | ||
|
||
fun List<PokemonBiome>.toUi(): List<PokemonBiomeUiModel> = this.map(PokemonBiome::toUi) |
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.