-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/MZ-174-add-ledger-ui
# Conflicts: # core/ui/src/main/res/values/strings.xml
- Loading branch information
Showing
27 changed files
with
877 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.susu.core.model | ||
|
||
data class Term( | ||
val id: Int, | ||
val title: String, | ||
val isEssential: Boolean, | ||
) |
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,8 @@ | ||
package com.susu.core.model | ||
|
||
data class TermDetail( | ||
val id: Int, | ||
val title: String, | ||
val isEssential: Boolean, | ||
val description: String, | ||
) |
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
16 changes: 16 additions & 0 deletions
16
data/src/main/java/com/susu/data/data/repository/TermRepositoryImpl.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,16 @@ | ||
package com.susu.data.data.repository | ||
|
||
import com.susu.core.model.Term | ||
import com.susu.core.model.TermDetail | ||
import com.susu.data.remote.api.TermService | ||
import com.susu.data.remote.model.response.toModel | ||
import com.susu.domain.repository.TermRepository | ||
import javax.inject.Inject | ||
|
||
class TermRepositoryImpl @Inject constructor( | ||
private val termService: TermService, | ||
) : TermRepository { | ||
override suspend fun getTerms(): List<Term> = termService.getTerms().getOrThrow().map { it.toModel() } | ||
|
||
override suspend fun getTermDetail(id: Int): TermDetail = termService.getTermDetail(id).getOrThrow().toModel() | ||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/susu/data/remote/api/TermService.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,15 @@ | ||
package com.susu.data.remote.api | ||
|
||
import com.susu.data.remote.model.response.TermDetailResponse | ||
import com.susu.data.remote.model.response.TermResponse | ||
import com.susu.data.remote.retrofit.ApiResult | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface TermService { | ||
@GET("terms") | ||
suspend fun getTerms(): ApiResult<List<TermResponse>> | ||
|
||
@GET("terms/{id}") | ||
suspend fun getTermDetail(@Path("id") id: Int): ApiResult<TermDetailResponse> | ||
} |
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
33 changes: 33 additions & 0 deletions
33
data/src/main/java/com/susu/data/remote/model/response/TermResponse.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,33 @@ | ||
package com.susu.data.remote.model.response | ||
|
||
import com.susu.core.model.Term | ||
import com.susu.core.model.TermDetail | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class TermResponse( | ||
val id: Int, | ||
val title: String, | ||
val isEssential: Boolean, | ||
) | ||
|
||
@Serializable | ||
data class TermDetailResponse( | ||
val id: Int, | ||
val title: String, | ||
val description: String, | ||
val isEssential: Boolean, | ||
) | ||
|
||
fun TermResponse.toModel(): Term = Term( | ||
id = id, | ||
title = title, | ||
isEssential = isEssential, | ||
) | ||
|
||
fun TermDetailResponse.toModel(): TermDetail = TermDetail( | ||
id = id, | ||
title = title, | ||
description = description, | ||
isEssential = isEssential, | ||
) |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/com/susu/domain/repository/TermRepository.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 com.susu.domain.repository | ||
|
||
import com.susu.core.model.Term | ||
import com.susu.core.model.TermDetail | ||
|
||
interface TermRepository { | ||
suspend fun getTerms(): List<Term> | ||
suspend fun getTermDetail(id: Int): TermDetail | ||
} |
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/susu/domain/usecase/loginsignup/GetTermDetailUseCase.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,14 @@ | ||
package com.susu.domain.usecase.loginsignup | ||
|
||
import com.susu.core.common.runCatchingIgnoreCancelled | ||
import com.susu.domain.repository.TermRepository | ||
import javax.inject.Inject | ||
|
||
class GetTermDetailUseCase @Inject constructor( | ||
private val termRepository: TermRepository, | ||
) { | ||
|
||
suspend operator fun invoke(termId: Int) = runCatchingIgnoreCancelled { | ||
termRepository.getTermDetail(termId) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/susu/domain/usecase/loginsignup/GetTermsUseCase.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,14 @@ | ||
package com.susu.domain.usecase.loginsignup | ||
|
||
import com.susu.core.common.runCatchingIgnoreCancelled | ||
import com.susu.domain.repository.TermRepository | ||
import javax.inject.Inject | ||
|
||
class GetTermsUseCase @Inject constructor( | ||
private val termRepository: TermRepository, | ||
) { | ||
|
||
suspend operator fun invoke() = runCatchingIgnoreCancelled { | ||
termRepository.getTerms() | ||
} | ||
} |
34 changes: 13 additions & 21 deletions
34
...oginsignup/src/main/java/com/susu/feature/loginsignup/navigation/LoginSignupNavigation.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
56 changes: 46 additions & 10 deletions
56
feature/loginsignup/src/main/java/com/susu/feature/loginsignup/signup/SignUpContract.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,17 +1,53 @@ | ||
package com.susu.feature.loginsignup.signup | ||
|
||
import androidx.annotation.StringRes | ||
import com.susu.core.ui.base.SideEffect | ||
import com.susu.core.ui.base.UiState | ||
import com.susu.feature.loginsignup.R | ||
|
||
sealed interface SignUpContract { | ||
sealed class SignUpEffect : SideEffect { | ||
data object NavigateToReceived : SignUpEffect() | ||
data class ShowToast(val msg: String) : SignUpEffect() | ||
} | ||
sealed interface SignUpEffect : SideEffect { | ||
data object NavigateToLogin : SignUpEffect | ||
data object NavigateToReceived : SignUpEffect | ||
data class ShowToast(val msg: String) : SignUpEffect | ||
} | ||
|
||
data class SignUpState( | ||
val isLoading: Boolean = false, | ||
val currentStep: SignUpStep = SignUpStep.TERMS, | ||
val agreedTerms: List<Int> = emptyList(), | ||
val name: String = "", | ||
val isNameValid: Boolean = true, | ||
val gender: Gender = Gender.NONE, | ||
val birth: Int = -1, | ||
) : UiState | ||
|
||
enum class SignUpStep( | ||
@StringRes val appBarTitle: Int?, | ||
@StringRes val description: Int?, | ||
@StringRes val bottomButtonText: Int, | ||
) { | ||
TERMS( | ||
appBarTitle = R.string.signup_term_title, | ||
description = R.string.signup_term_description, | ||
bottomButtonText = com.susu.core.ui.R.string.word_next, | ||
), | ||
TERM_DETAIL( | ||
appBarTitle = R.string.signup_term_detail_title, | ||
description = null, | ||
bottomButtonText = R.string.signup_term_agree, | ||
), | ||
NAME( | ||
appBarTitle = null, | ||
description = R.string.signup_name_description, | ||
bottomButtonText = com.susu.core.ui.R.string.word_next, | ||
), | ||
ADDITIONAL( | ||
appBarTitle = null, | ||
description = R.string.signup_additional_description, | ||
bottomButtonText = com.susu.core.ui.R.string.word_done, | ||
), | ||
} | ||
|
||
data class SignUpState( | ||
val name: String = "", | ||
val gender: String = "M", | ||
val birth: String = "0", | ||
) : UiState | ||
enum class Gender(val content: String) { | ||
NONE(""), MALE("M"), FEMALE("F") | ||
} |
Oops, something went wrong.