-
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.
* chore: DataStore 의존성 설정 * feat: Datastore 저장 로직 추가 * feat: 저장된 선택 데이터 UI 에 반영 * refactor: Skill 캐싱 * refactor: Test 객체 수정 * refactor: context 참조 수정 * refactor: 리팩토링 리뷰 반영 * refactor: 아이디 저장값 분리 * refactor: Map 형태 변경
- Loading branch information
1 parent
4c0fd35
commit 59efa72
Showing
15 changed files
with
239 additions
and
33 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
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
37 changes: 37 additions & 0 deletions
37
android/data/src/main/java/poke/rogue/helper/data/datasource/LocalBattleDataSource.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,37 @@ | ||
package poke.rogue.helper.data.datasource | ||
|
||
import android.content.Context | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import poke.rogue.helper.data.model.PokemonWithSkillIds | ||
import poke.rogue.helper.data.model.toData | ||
import poke.rogue.helper.local.datastore.BattleDataStore | ||
|
||
class LocalBattleDataSource(private val battleDataStore: BattleDataStore) { | ||
suspend fun savePokemonWithSkill( | ||
pokemonId: String, | ||
skillId: String, | ||
) { | ||
battleDataStore.savePokemonWithSkill(pokemonId, skillId) | ||
} | ||
|
||
suspend fun savePokemon(pokemonId: String) { | ||
battleDataStore.savePokemon(pokemonId) | ||
} | ||
|
||
fun pokemonWithSkill(): Flow<PokemonWithSkillIds?> = battleDataStore.pokemonWithSkillId().map { it?.toData() } | ||
|
||
fun pokemonId(): Flow<String?> = battleDataStore.pokemonId() | ||
|
||
companion object { | ||
private var instance: LocalBattleDataSource? = null | ||
|
||
fun instance(context: Context): LocalBattleDataSource { | ||
return instance ?: LocalBattleDataSource( | ||
BattleDataStore(context), | ||
).also { | ||
instance = it | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
android/data/src/main/java/poke/rogue/helper/data/model/PokemonWithSkillIds.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,9 @@ | ||
package poke.rogue.helper.data.model | ||
|
||
import poke.rogue.helper.local.datastore.SavedPokemonWithSkill | ||
|
||
data class PokemonWithSkillIds(val pokemonId: String, val skillId: String) | ||
|
||
fun SavedPokemonWithSkill.toData() = PokemonWithSkillIds(pokemonId, skillId) | ||
|
||
data class PokemonWithSkill(val pokemon: Pokemon, val skill: BattleSkill) |
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
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
Empty file.
Oops, something went wrong.