-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: TodayFortuneBox 구현 * feat: 오늘의 운세(TodayFortuneDashboard) UI 구현 * feat: FortuneDetailRoute, FortuneDetailScreen 파일 분리 * refactor: 패키지 네이밍 수정 * feat: fortune 데이터레이어 구현 - di 모듈 추가 - network api 구현 * feat: fortune 도메인레이어 구현, internal 키워드 일괄 적용 - mapper 구현 - 레포지토리 인터페이스 생성 및 적용 - 힐트모듈 수정 * refactor: internal 키워드 삭제 * refactor: 함수 네이밍 수정 * feat: 레이어 의존성 추가 * refactor: 네트워크 path 수정 * feat: 네트워크 통신 구현 및 state 적용 * feat: 오늘의 솝마디 관련 유즈케이스 생성 * refactor: TodayFortuneBox 패딩값 추가 * refactor: 타입 및 네이밍 수정 * refactor: internal 추가 * test: FortuneDetailScreenTest 구현 * feat: 콕 찌르기 대시보드 UI 구현 * feat: 콕 찌르기 유저 추천 API 연결 * refactor: UI State 수정 및 적용 * refactor: SimpleDataFormatter로 리팩터링 * refactor: Timber 적용 * build: 의존성 수정 * refactor: break strategy 적용 * refactor: 뷰모델 수정 * refactor: 프로필 사진 사이즈 수정 * refactor: 배경색 수정 * feat: 프로필 클릭 시 플레이그라운드로 이동 * feat: 프로필 기본 이미지 구현 * refactor: 자잘한 개행 및 import * feature #875: delete paddingValue * feature #875: connect TodayFortuneCard api * feature #875: connect TodayFortuneCard data * feature #875: delete paddingValue * feature #875: change function name * feature #875: apply typealias * feature #875: apply slot for amuletDescription * feature #875: connect navigation * feature #875: set nameSuffix --------- Co-authored-by: s9hn <[email protected]>
- Loading branch information
Showing
10 changed files
with
171 additions
and
52 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...tune/src/main/java/org/sopt/official/domain/fortune/usecase/GetTodayFortuneCardUseCase.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,11 @@ | ||
package org.sopt.official.domain.fortune.usecase | ||
|
||
import org.sopt.official.domain.fortune.model.TodayFortuneCard | ||
import org.sopt.official.domain.fortune.repository.FortuneRepository | ||
import javax.inject.Inject | ||
|
||
class GetTodayFortuneCardUseCase @Inject constructor( | ||
private val fortuneRepository: FortuneRepository, | ||
) { | ||
suspend operator fun invoke(): TodayFortuneCard = fortuneRepository.fetchTodayFortuneCard() | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...c/main/java/org/sopt/official/feature/fortune/feature/fortuneAmulet/FortuneAmuletState.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,13 @@ | ||
package org.sopt.official.feature.fortune.feature.fortuneAmulet | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
data class FortuneAmuletState( | ||
val isLoading: Boolean = false, | ||
val isFailure: Boolean = false, | ||
val description: String = "", | ||
val imageColor: Color = Color.White, | ||
val imageUrl: String = "", | ||
val name: String = "", | ||
val nameSuffix: String = "이 왔솝" | ||
) |
50 changes: 50 additions & 0 deletions
50
...in/java/org/sopt/official/feature/fortune/feature/fortuneAmulet/FortuneAmuletViewModel.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,50 @@ | ||
package org.sopt.official.feature.fortune.feature.fortuneAmulet | ||
|
||
import androidx.compose.ui.graphics.Color | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.update | ||
import kotlinx.coroutines.launch | ||
import org.sopt.official.domain.fortune.usecase.GetTodayFortuneCardUseCase | ||
import javax.inject.Inject | ||
|
||
typealias GraphicColor = android.graphics.Color | ||
|
||
@HiltViewModel | ||
internal class FortuneAmuletViewModel @Inject constructor( | ||
getTodayFortuneCardUseCase: GetTodayFortuneCardUseCase, | ||
) : ViewModel() { | ||
private val _state: MutableStateFlow<FortuneAmuletState> = MutableStateFlow(FortuneAmuletState()) | ||
val state: StateFlow<FortuneAmuletState> = _state.asStateFlow() | ||
|
||
init { | ||
viewModelScope.launch { | ||
runCatching { | ||
_state.value = _state.value.copy(isLoading = true) | ||
getTodayFortuneCardUseCase() | ||
}.onSuccess { todayFortuneCard -> | ||
_state.update { | ||
it.copy( | ||
description = todayFortuneCard.description, | ||
imageColor = parseColor(todayFortuneCard.imageColorCode), | ||
imageUrl = todayFortuneCard.imageUrl, | ||
name = todayFortuneCard.name, | ||
isLoading = false | ||
) | ||
} | ||
}.onFailure { | ||
_state.value = _state.value.copy(isFailure = true) | ||
} | ||
} | ||
} | ||
|
||
private fun parseColor(colorCode: String): Color = try { | ||
Color(GraphicColor.parseColor(colorCode)) | ||
} catch (e: IllegalArgumentException) { | ||
Color.White | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...rg/sopt/official/feature/fortune/feature/fortuneDetail/component/TodayFortuneDashboard.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
Oops, something went wrong.