diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/datasource/AuthRemoteDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/datasource/AuthRemoteDataSource.kt index 8de92dc3..f711a103 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/datasource/AuthRemoteDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/auth/datasource/AuthRemoteDataSource.kt @@ -1,13 +1,13 @@ package com.threegap.bitnagil.data.auth.datasource -import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto -import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequestDto -import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto +import com.threegap.bitnagil.data.auth.model.request.LoginRequest +import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequest +import com.threegap.bitnagil.data.auth.model.response.LoginResponse interface AuthRemoteDataSource { - suspend fun login(socialAccessToken: String, loginRequestDto: LoginRequestDto): Result - suspend fun submitAgreement(termsAgreementRequestDto: TermsAgreementRequestDto): Result + suspend fun login(socialAccessToken: String, loginRequest: LoginRequest): Result + suspend fun submitAgreement(termsAgreementRequest: TermsAgreementRequest): Result suspend fun logout(): Result suspend fun withdrawal(reason: String): Result - suspend fun reissueToken(refreshToken: String): Result + suspend fun reissueToken(refreshToken: String): Result } diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt index 96a1e8b0..05b67739 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt @@ -1,10 +1,10 @@ package com.threegap.bitnagil.data.auth.datasourceimpl import com.threegap.bitnagil.data.auth.datasource.AuthRemoteDataSource -import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto -import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequestDto +import com.threegap.bitnagil.data.auth.model.request.LoginRequest +import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequest import com.threegap.bitnagil.data.auth.model.request.WithdrawalReasonRequest -import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto +import com.threegap.bitnagil.data.auth.model.response.LoginResponse import com.threegap.bitnagil.data.auth.service.AuthService import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.common.safeUnitApiCall @@ -13,14 +13,14 @@ import javax.inject.Inject class AuthRemoteDataSourceImpl @Inject constructor( private val authService: AuthService, ) : AuthRemoteDataSource { - override suspend fun login(socialAccessToken: String, loginRequestDto: LoginRequestDto): Result = + override suspend fun login(socialAccessToken: String, loginRequest: LoginRequest): Result = safeApiCall { - authService.postLogin(socialAccessToken, loginRequestDto) + authService.postLogin(socialAccessToken, loginRequest) } - override suspend fun submitAgreement(termsAgreementRequestDto: TermsAgreementRequestDto): Result = + override suspend fun submitAgreement(termsAgreementRequest: TermsAgreementRequest): Result = safeUnitApiCall { - authService.submitAgreement(termsAgreementRequestDto) + authService.submitAgreement(termsAgreementRequest) } override suspend fun logout(): Result = @@ -33,7 +33,7 @@ class AuthRemoteDataSourceImpl @Inject constructor( authService.postWithdrawal(WithdrawalReasonRequest(reason)) } - override suspend fun reissueToken(refreshToken: String): Result = + override suspend fun reissueToken(refreshToken: String): Result = safeApiCall { authService.postReissueToken(refreshToken) } diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/mapper/AuthMapper.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/mapper/AuthMapper.kt deleted file mode 100644 index aa0e7434..00000000 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/mapper/AuthMapper.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.threegap.bitnagil.data.auth.mapper - -import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequestDto -import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto -import com.threegap.bitnagil.domain.auth.model.AuthSession -import com.threegap.bitnagil.domain.auth.model.TermsAgreement - -// toDomain -internal fun LoginResponseDto.toDomain() = - AuthSession( - accessToken = this.accessToken, - refreshToken = this.refreshToken, - role = this.role, - ) - -// toDto -internal fun TermsAgreement.toDto() = - TermsAgreementRequestDto( - agreedToTermsOfService = this.agreedToTermsOfService, - agreedToPrivacyPolicy = this.agreedToPrivacyPolicy, - isOverFourteen = this.isOverFourteen, - ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequestDto.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequest.kt similarity index 88% rename from data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequestDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequest.kt index 9ffbb088..aad59938 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequestDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequest.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class LoginRequestDto( +data class LoginRequest( @SerialName("socialType") val socialType: String, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequestDto.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequest.kt similarity index 53% rename from data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequestDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequest.kt index 170b994a..5a7210c1 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequestDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequest.kt @@ -1,10 +1,11 @@ package com.threegap.bitnagil.data.auth.model.request +import com.threegap.bitnagil.domain.auth.model.TermsAgreement import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class TermsAgreementRequestDto( +data class TermsAgreementRequest( @SerialName("agreedToTermsOfService") val agreedToTermsOfService: Boolean, @SerialName("agreedToPrivacyPolicy") @@ -12,3 +13,10 @@ data class TermsAgreementRequestDto( @SerialName("isOverFourteen") val isOverFourteen: Boolean, ) + +internal fun TermsAgreement.toDto() = + TermsAgreementRequest( + agreedToTermsOfService = this.agreedToTermsOfService, + agreedToPrivacyPolicy = this.agreedToPrivacyPolicy, + isOverFourteen = this.isOverFourteen, + ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponseDto.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponse.kt similarity index 59% rename from data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponseDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponse.kt index 8542f22f..84c14892 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponseDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponse.kt @@ -1,11 +1,12 @@ package com.threegap.bitnagil.data.auth.model.response +import com.threegap.bitnagil.domain.auth.model.AuthSession import com.threegap.bitnagil.domain.auth.model.UserRole import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class LoginResponseDto( +data class LoginResponse( @SerialName("accessToken") val accessToken: String, @SerialName("refreshToken") @@ -13,3 +14,10 @@ data class LoginResponseDto( @SerialName("role") val role: UserRole, ) + +internal fun LoginResponse.toDomain() = + AuthSession( + accessToken = this.accessToken, + refreshToken = this.refreshToken, + role = this.role, + ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/repositoryimpl/AuthRepositoryImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/repositoryimpl/AuthRepositoryImpl.kt index 5901ed92..1ad4b1d8 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/repositoryimpl/AuthRepositoryImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/auth/repositoryimpl/AuthRepositoryImpl.kt @@ -2,9 +2,9 @@ package com.threegap.bitnagil.data.auth.repositoryimpl import com.threegap.bitnagil.data.auth.datasource.AuthLocalDataSource import com.threegap.bitnagil.data.auth.datasource.AuthRemoteDataSource -import com.threegap.bitnagil.data.auth.mapper.toDomain -import com.threegap.bitnagil.data.auth.mapper.toDto -import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto +import com.threegap.bitnagil.data.auth.model.request.LoginRequest +import com.threegap.bitnagil.data.auth.model.request.toDto +import com.threegap.bitnagil.data.auth.model.response.toDomain import com.threegap.bitnagil.domain.auth.model.AuthSession import com.threegap.bitnagil.domain.auth.model.TermsAgreement import com.threegap.bitnagil.domain.auth.repository.AuthRepository @@ -15,7 +15,7 @@ class AuthRepositoryImpl @Inject constructor( private val authLocalDataSource: AuthLocalDataSource, ) : AuthRepository { override suspend fun login(socialAccessToken: String, socialType: String): Result = - authRemoteDataSource.login(socialAccessToken, LoginRequestDto(socialType)) + authRemoteDataSource.login(socialAccessToken, LoginRequest(socialType)) .map { it.toDomain() } override suspend fun submitAgreement(termsAgreement: TermsAgreement): Result = diff --git a/data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt b/data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt index e360c61c..8b74dc6a 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt @@ -1,9 +1,9 @@ package com.threegap.bitnagil.data.auth.service -import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto -import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequestDto +import com.threegap.bitnagil.data.auth.model.request.LoginRequest +import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequest import com.threegap.bitnagil.data.auth.model.request.WithdrawalReasonRequest -import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto +import com.threegap.bitnagil.data.auth.model.response.LoginResponse import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.Body import retrofit2.http.Header @@ -15,12 +15,12 @@ interface AuthService { @Headers("No-Service-Token: true") suspend fun postLogin( @Header("SocialAccessToken") socialAccessToken: String, - @Body loginRequestDto: LoginRequestDto, - ): BaseResponse + @Body loginRequest: LoginRequest, + ): BaseResponse @POST("/api/v1/auth/agreements") suspend fun submitAgreement( - @Body termsAgreementRequestDto: TermsAgreementRequestDto, + @Body termsAgreementRequest: TermsAgreementRequest, ): BaseResponse @POST("/api/v1/auth/withdrawal") @@ -33,5 +33,5 @@ interface AuthService { @Headers("No-Service-Token: true", "Auto-Login: true") suspend fun postReissueToken( @Header("Refresh-Token") refreshToken: String, - ): BaseResponse + ): BaseResponse } diff --git a/data/src/main/java/com/threegap/bitnagil/data/emotion/datasource/EmotionDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/emotion/datasource/EmotionDataSource.kt index 634b984c..c3f81e30 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/emotion/datasource/EmotionDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/emotion/datasource/EmotionDataSource.kt @@ -1,11 +1,11 @@ package com.threegap.bitnagil.data.emotion.datasource import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto +import com.threegap.bitnagil.data.emotion.model.response.DailyEmotionResponse import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse -import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto interface EmotionDataSource { suspend fun getEmotions(): Result> suspend fun registerEmotion(emotion: String): Result - suspend fun fetchTodayEmotion(currentDate: String): Result + suspend fun fetchDailyEmotion(currentDate: String): Result } diff --git a/data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt index cb49e964..20035b56 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt @@ -4,8 +4,8 @@ import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest +import com.threegap.bitnagil.data.emotion.model.response.DailyEmotionResponse import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse -import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto import com.threegap.bitnagil.data.emotion.service.EmotionService import javax.inject.Inject @@ -25,8 +25,8 @@ class EmotionDataSourceImpl @Inject constructor( } } - override suspend fun fetchTodayEmotion(currentDate: String): Result = + override suspend fun fetchDailyEmotion(currentDate: String): Result = safeApiCall { - emotionService.fetchTodayEmotion(currentDate) + emotionService.fetchDailyEmotion(currentDate) } } diff --git a/data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/DailyEmotionResponse.kt b/data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/DailyEmotionResponse.kt new file mode 100644 index 00000000..7dbebbc7 --- /dev/null +++ b/data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/DailyEmotionResponse.kt @@ -0,0 +1,26 @@ +package com.threegap.bitnagil.data.emotion.model.response + +import com.threegap.bitnagil.domain.emotion.model.DailyEmotion +import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class DailyEmotionResponse( + @SerialName("emotionMarbleType") + val emotionMarbleType: EmotionMarbleType?, + @SerialName("emotionMarbleName") + val emotionMarbleName: String?, + @SerialName("imageUrl") + val imageUrl: String?, + @SerialName("emotionMarbleHomeMessage") + val emotionMarbleHomeMessage: String?, +) + +fun DailyEmotionResponse.toDomain(): DailyEmotion = + DailyEmotion( + type = emotionMarbleType, + name = emotionMarbleName, + imageUrl = imageUrl, + homeMessage = emotionMarbleHomeMessage, + ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/TodayEmotionResponseDto.kt b/data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/TodayEmotionResponseDto.kt deleted file mode 100644 index 07d33a83..00000000 --- a/data/src/main/java/com/threegap/bitnagil/data/emotion/model/response/TodayEmotionResponseDto.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.threegap.bitnagil.data.emotion.model.response - -import com.threegap.bitnagil.domain.emotion.model.TodayEmotion -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class TodayEmotionResponseDto( - @SerialName("emotionMarbleType") - val emotionMarbleType: String?, - @SerialName("emotionMarbleName") - val emotionMarbleName: String?, - @SerialName("imageUrl") - val imageUrl: String?, - @SerialName("emotionMarbleHomeMessage") - val emotionMarbleHomeMessage: String?, -) - -fun TodayEmotionResponseDto.toDomain(): TodayEmotion? { - return if (emotionMarbleType != null && emotionMarbleName != null && imageUrl != null && emotionMarbleHomeMessage != null) { - TodayEmotion( - type = emotionMarbleType, - name = emotionMarbleName, - imageUrl = imageUrl, - homeMessage = emotionMarbleHomeMessage, - ) - } else { - null - } -} diff --git a/data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt index f2f69abd..811209dc 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/emotion/repositoryImpl/EmotionRepositoryImpl.kt @@ -2,10 +2,10 @@ package com.threegap.bitnagil.data.emotion.repositoryImpl import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource import com.threegap.bitnagil.data.emotion.model.response.toDomain +import com.threegap.bitnagil.domain.emotion.model.DailyEmotion import com.threegap.bitnagil.domain.emotion.model.Emotion import com.threegap.bitnagil.domain.emotion.model.EmotionChangeEvent import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine -import com.threegap.bitnagil.domain.emotion.model.TodayEmotion import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -34,8 +34,8 @@ class EmotionRepositoryImpl @Inject constructor( } } - override suspend fun fetchTodayEmotion(currentDate: String): Result = - emotionDataSource.fetchTodayEmotion(currentDate).map { it.toDomain() } + override suspend fun fetchDailyEmotion(currentDate: String): Result = + emotionDataSource.fetchDailyEmotion(currentDate).map { it.toDomain() } private val _emotionChangeEventFlow = MutableSharedFlow() override suspend fun getEmotionChangeEventFlow(): Flow = _emotionChangeEventFlow.asSharedFlow() diff --git a/data/src/main/java/com/threegap/bitnagil/data/emotion/service/EmotionService.kt b/data/src/main/java/com/threegap/bitnagil/data/emotion/service/EmotionService.kt index 15abfeac..1d715fbb 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/emotion/service/EmotionService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/emotion/service/EmotionService.kt @@ -2,8 +2,8 @@ package com.threegap.bitnagil.data.emotion.service import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest +import com.threegap.bitnagil.data.emotion.model.response.DailyEmotionResponse import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse -import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.Body import retrofit2.http.GET @@ -20,7 +20,7 @@ interface EmotionService { ): BaseResponse @GET("/api/v2/emotion-marbles/{searchDate}") - suspend fun fetchTodayEmotion( + suspend fun fetchDailyEmotion( @Path("searchDate") date: String, - ): BaseResponse + ): BaseResponse } diff --git a/data/src/main/java/com/threegap/bitnagil/data/file/datasource/FileDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/file/datasource/FileDataSource.kt index 62bf670b..5b90a804 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/file/datasource/FileDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/file/datasource/FileDataSource.kt @@ -1,6 +1,6 @@ package com.threegap.bitnagil.data.file.datasource -import com.threegap.bitnagil.data.file.model.request.FileInfoRequestDto +import com.threegap.bitnagil.data.file.model.request.FileInfoRequest interface FileDataSource { /** @@ -8,5 +8,5 @@ interface FileDataSource { * @param fileInfos 파일 정보 리스트 (prefix + fileName) * @return key: S3 경로, value: presigned URL */ - suspend fun fetchPresignedUrls(fileInfos: List): Result> + suspend fun fetchPresignedUrls(fileInfos: List): Result> } diff --git a/data/src/main/java/com/threegap/bitnagil/data/file/datasourceImpl/FileDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/file/datasourceImpl/FileDataSourceImpl.kt index b584d017..1e159cdc 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/file/datasourceImpl/FileDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/file/datasourceImpl/FileDataSourceImpl.kt @@ -2,14 +2,14 @@ package com.threegap.bitnagil.data.file.datasourceImpl import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.file.datasource.FileDataSource -import com.threegap.bitnagil.data.file.model.request.FileInfoRequestDto +import com.threegap.bitnagil.data.file.model.request.FileInfoRequest import com.threegap.bitnagil.data.file.service.FileService import javax.inject.Inject class FileDataSourceImpl @Inject constructor( private val fileService: FileService, ) : FileDataSource { - override suspend fun fetchPresignedUrls(fileInfos: List): Result> { + override suspend fun fetchPresignedUrls(fileInfos: List): Result> { return safeApiCall { fileService.fetchPresignedUrls(fileInfos) } } } diff --git a/data/src/main/java/com/threegap/bitnagil/data/file/model/request/FileInfoRequestDto.kt b/data/src/main/java/com/threegap/bitnagil/data/file/model/request/FileInfoRequest.kt similarity index 89% rename from data/src/main/java/com/threegap/bitnagil/data/file/model/request/FileInfoRequestDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/file/model/request/FileInfoRequest.kt index abbc4049..f3a4e895 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/file/model/request/FileInfoRequestDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/file/model/request/FileInfoRequest.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class FileInfoRequestDto( +data class FileInfoRequest( @SerialName("prefix") val prefix: String, @SerialName("fileName") diff --git a/data/src/main/java/com/threegap/bitnagil/data/file/repositoryImpl/FileRepositoryImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/file/repositoryImpl/FileRepositoryImpl.kt index dcfb0658..595641d4 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/file/repositoryImpl/FileRepositoryImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/file/repositoryImpl/FileRepositoryImpl.kt @@ -1,7 +1,7 @@ package com.threegap.bitnagil.data.file.repositoryImpl import com.threegap.bitnagil.data.file.datasource.FileDataSource -import com.threegap.bitnagil.data.file.model.request.FileInfoRequestDto +import com.threegap.bitnagil.data.file.model.request.FileInfoRequest import com.threegap.bitnagil.data.file.uploader.ImageUploader import com.threegap.bitnagil.domain.file.model.ImageFile import com.threegap.bitnagil.domain.file.repository.FileRepository @@ -17,7 +17,7 @@ class FileRepositoryImpl @Inject constructor( override suspend fun uploadImages(imageFiles: List): Result> { return runCatching { val fileInfos = imageFiles.map { imageFile -> - FileInfoRequestDto(prefix = imageFile.prefix, fileName = imageFile.name) + FileInfoRequest(prefix = imageFile.prefix, fileName = imageFile.name) } val presignedUrlMap: Map = fileDataSource diff --git a/data/src/main/java/com/threegap/bitnagil/data/file/service/FileService.kt b/data/src/main/java/com/threegap/bitnagil/data/file/service/FileService.kt index 240fe324..a3922cc2 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/file/service/FileService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/file/service/FileService.kt @@ -1,6 +1,6 @@ package com.threegap.bitnagil.data.file.service -import com.threegap.bitnagil.data.file.model.request.FileInfoRequestDto +import com.threegap.bitnagil.data.file.model.request.FileInfoRequest import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.Body import retrofit2.http.POST @@ -8,6 +8,6 @@ import retrofit2.http.POST interface FileService { @POST("/api/v2/files/presigned-urls") suspend fun fetchPresignedUrls( - @Body fileInfos: List, + @Body fileInfos: List, ): BaseResponse> } diff --git a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasource/RecommendRoutineDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasource/RecommendRoutineDataSource.kt index e4538c40..0bc3279a 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasource/RecommendRoutineDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasource/RecommendRoutineDataSource.kt @@ -1,9 +1,9 @@ package com.threegap.bitnagil.data.recommendroutine.datasource -import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto -import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto +import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesResponse +import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineResponse interface RecommendRoutineDataSource { - suspend fun fetchRecommendRoutines(): Result - suspend fun getRecommendRoutine(recommendRoutineId: Int): Result + suspend fun fetchRecommendRoutines(): Result + suspend fun getRecommendRoutine(recommendRoutineId: Long): Result } diff --git a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasourceImpl/RecommendRoutineDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasourceImpl/RecommendRoutineDataSourceImpl.kt index 859c22e1..38b469ed 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasourceImpl/RecommendRoutineDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/datasourceImpl/RecommendRoutineDataSourceImpl.kt @@ -2,8 +2,8 @@ package com.threegap.bitnagil.data.recommendroutine.datasourceImpl import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.recommendroutine.datasource.RecommendRoutineDataSource -import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto -import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto +import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesResponse +import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineResponse import com.threegap.bitnagil.data.recommendroutine.service.RecommendRoutineService import javax.inject.Inject @@ -11,12 +11,12 @@ class RecommendRoutineDataSourceImpl @Inject constructor( private val recommendRoutineService: RecommendRoutineService, ) : RecommendRoutineDataSource { - override suspend fun fetchRecommendRoutines(): Result = + override suspend fun fetchRecommendRoutines(): Result = safeApiCall { recommendRoutineService.fetchRecommendRoutines() } - override suspend fun getRecommendRoutine(recommendRoutineId: Int): Result = + override suspend fun getRecommendRoutine(recommendRoutineId: Long): Result = safeApiCall { recommendRoutineService.getRecommendRoutine(recommendRoutineId) } diff --git a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesDto.kt b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesResponse.kt similarity index 67% rename from data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesResponse.kt index 03e88e0b..d18f8d80 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendRoutinesResponse.kt @@ -1,23 +1,23 @@ package com.threegap.bitnagil.data.recommendroutine.model.response -import com.threegap.bitnagil.domain.recommendroutine.model.EmotionMarbleType +import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutines import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class RecommendRoutinesDto( +data class RecommendRoutinesResponse( @SerialName("recommendedRoutines") - val recommendedRoutinesByCategory: Map>, + val recommendedRoutinesByCategory: Map>, @SerialName("emotionMarbleType") val emotionMarbleType: EmotionMarbleType?, ) -fun RecommendRoutinesDto.toDomain(): RecommendRoutines = +fun RecommendRoutinesResponse.toDomain(): RecommendRoutines = RecommendRoutines( - recommendRoutinesByCategory = this.recommendedRoutinesByCategory.map { (category, routines) -> - category to routines.map { it.toDomain() } - }.toMap(), + recommendRoutinesByCategory = this.recommendedRoutinesByCategory.mapValues { (_, routines) -> + routines.map { it.toDomain() } + }, emotionMarbleType = this.emotionMarbleType, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineDto.kt b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineResponse.kt similarity index 80% rename from data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineResponse.kt index 9853ac05..7959f183 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineResponse.kt @@ -7,9 +7,9 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class RecommendedRoutineDto( +data class RecommendedRoutineResponse( @SerialName("recommendedRoutineId") - val recommendedRoutineId: Int, + val recommendedRoutineId: Long, @SerialName("recommendedRoutineName") val recommendedRoutineName: String, @SerialName("recommendedRoutineDescription") @@ -21,16 +21,16 @@ data class RecommendedRoutineDto( @SerialName("recommendedRoutineType") val recommendedRoutineType: RecommendCategory, @SerialName("recommendedSubRoutineSearchResult") - val recommendedSubRoutineSearchResult: List, + val recommendedSubRoutineSearchResult: List, ) -fun RecommendedRoutineDto.toDomain(): RecommendRoutine = +fun RecommendedRoutineResponse.toDomain(): RecommendRoutine = RecommendRoutine( id = this.recommendedRoutineId, name = this.recommendedRoutineName, description = this.recommendedRoutineDescription, level = this.recommendedRoutineLevel, executionTime = this.executionTime, - recommendedRoutineType = this.recommendedRoutineType, - recommendSubRoutines = this.recommendedSubRoutineSearchResult.map { it.toDomain() }, + category = this.recommendedRoutineType, + subRoutines = this.recommendedSubRoutineSearchResult.map { it.toDomain() }, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineDto.kt b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineResponse.kt similarity index 76% rename from data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineResponse.kt index cf27e915..79f02286 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedSubRoutineResponse.kt @@ -5,14 +5,14 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class RecommendedSubRoutineDto( +data class RecommendedSubRoutineResponse( @SerialName("recommendedSubRoutineId") - val recommendedSubRoutineId: Int, + val recommendedSubRoutineId: Long, @SerialName("recommendedSubRoutineName") val recommendedSubRoutineName: String, ) -fun RecommendedSubRoutineDto.toDomain(): RecommendSubRoutine = +fun RecommendedSubRoutineResponse.toDomain(): RecommendSubRoutine = RecommendSubRoutine( id = recommendedSubRoutineId, name = recommendedSubRoutineName, diff --git a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/repositoryImpl/RecommendRoutineRepositoryImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/repositoryImpl/RecommendRoutineRepositoryImpl.kt index 05ca53fe..1f0a9d76 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/repositoryImpl/RecommendRoutineRepositoryImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/repositoryImpl/RecommendRoutineRepositoryImpl.kt @@ -15,7 +15,7 @@ class RecommendRoutineRepositoryImpl @Inject constructor( .map { it.toDomain() } override suspend fun getRecommendRoutine(recommendRoutineId: String): Result { - val recommendRoutineIdInt = recommendRoutineId.toIntOrNull() ?: return Result.failure( + val recommendRoutineIdInt = recommendRoutineId.toLongOrNull() ?: return Result.failure( IllegalArgumentException("recommendRoutineId is not a valid integer"), ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/service/RecommendRoutineService.kt b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/service/RecommendRoutineService.kt index dccdf851..8b6734f3 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/service/RecommendRoutineService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/recommendroutine/service/RecommendRoutineService.kt @@ -1,17 +1,17 @@ package com.threegap.bitnagil.data.recommendroutine.service -import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesDto -import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineDto +import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendRoutinesResponse +import com.threegap.bitnagil.data.recommendroutine.model.response.RecommendedRoutineResponse import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.GET import retrofit2.http.Path interface RecommendRoutineService { @GET("/api/v1/recommend-routines") - suspend fun fetchRecommendRoutines(): BaseResponse + suspend fun fetchRecommendRoutines(): BaseResponse @GET("/api/v1/recommend-routines/{recommendedRoutineId}") suspend fun getRecommendRoutine( - @Path("recommendedRoutineId") recommendedRoutineId: Int, - ): BaseResponse + @Path("recommendedRoutineId") recommendedRoutineId: Long, + ): BaseResponse } diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/datasource/ReportDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/report/datasource/ReportDataSource.kt index 82cdf53a..c2fa87bf 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/datasource/ReportDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/datasource/ReportDataSource.kt @@ -1,11 +1,11 @@ package com.threegap.bitnagil.data.report.datasource -import com.threegap.bitnagil.data.report.model.request.ReportRequestDto -import com.threegap.bitnagil.data.report.model.response.ReportDetailDto -import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto +import com.threegap.bitnagil.data.report.model.request.ReportRequest +import com.threegap.bitnagil.data.report.model.response.ReportDetailResponse +import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateResponse interface ReportDataSource { - suspend fun submitReport(reportRequestDto: ReportRequestDto): Result - suspend fun getReports(): Result - suspend fun getReport(reportId: String): Result + suspend fun submitReport(reportRequest: ReportRequest): Result + suspend fun getReports(): Result + suspend fun getReport(reportId: String): Result } diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/datasourceImpl/ReportDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/report/datasourceImpl/ReportDataSourceImpl.kt index 0351d514..f0651adb 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/datasourceImpl/ReportDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/datasourceImpl/ReportDataSourceImpl.kt @@ -2,24 +2,24 @@ package com.threegap.bitnagil.data.report.datasourceImpl import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.report.datasource.ReportDataSource -import com.threegap.bitnagil.data.report.model.request.ReportRequestDto -import com.threegap.bitnagil.data.report.model.response.ReportDetailDto -import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto +import com.threegap.bitnagil.data.report.model.request.ReportRequest +import com.threegap.bitnagil.data.report.model.response.ReportDetailResponse +import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateResponse import com.threegap.bitnagil.data.report.service.ReportService import javax.inject.Inject class ReportDataSourceImpl @Inject constructor( private val reportService: ReportService, ) : ReportDataSource { - override suspend fun submitReport(reportRequestDto: ReportRequestDto): Result { - return safeApiCall { reportService.submitReport(reportRequestDto) } + override suspend fun submitReport(reportRequest: ReportRequest): Result { + return safeApiCall { reportService.submitReport(reportRequest) } } - override suspend fun getReports(): Result { + override suspend fun getReports(): Result { return safeApiCall { reportService.getReports() } } - override suspend fun getReport(reportId: String): Result { + override suspend fun getReport(reportId: String): Result { return safeApiCall { reportService.getReport(reportId = reportId) } } } diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt b/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequest.kt similarity index 91% rename from data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequest.kt index e35790ff..238a0151 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequest.kt @@ -6,7 +6,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ReportRequestDto( +data class ReportRequest( @SerialName("reportTitle") val reportTitle: String, @SerialName("reportContent") @@ -23,8 +23,8 @@ data class ReportRequestDto( val longitude: Double, ) -fun Report.toDto(): ReportRequestDto { - return ReportRequestDto( +fun Report.toDto(): ReportRequest { + return ReportRequest( reportTitle = this.title, reportContent = this.content, reportCategory = this.category, diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailResponse.kt similarity index 92% rename from data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailResponse.kt index db949bfc..48e1801e 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailResponse.kt @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable import java.time.LocalDate @Serializable -class ReportDetailDto( +class ReportDetailResponse( @SerialName("reportDate") val reportDate: String, @SerialName("reportStatus") @@ -25,7 +25,7 @@ class ReportDetailDto( val reportImageUrls: List, ) -fun ReportDetailDto.toDomain(id: String?): ReportDetail = +fun ReportDetailResponse.toDomain(id: String?): ReportDetail = ReportDetail( id = id ?: "", date = LocalDate.parse(this.reportDate), diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportHistoriesPerDateDto.kt b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportHistoriesPerDateResponse.kt similarity index 69% rename from data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportHistoriesPerDateDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportHistoriesPerDateResponse.kt index 27577b76..6933e595 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportHistoriesPerDateDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportHistoriesPerDateResponse.kt @@ -6,12 +6,12 @@ import kotlinx.serialization.Serializable import java.time.LocalDate @Serializable -data class ReportHistoriesPerDateDto( +data class ReportHistoriesPerDateResponse( @SerialName("reportInfos") - val reportInfos: Map>, + val reportInfos: Map>, ) -fun ReportHistoriesPerDateDto.toDomainMap(): Map> = +fun ReportHistoriesPerDateResponse.toDomainMap(): Map> = this.reportInfos .mapKeys { LocalDate.parse(it.key) } .mapValues { entry -> diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemResponse.kt similarity index 92% rename from data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemResponse.kt index aca22611..e413c273 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemResponse.kt @@ -7,7 +7,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ReportItemDto( +data class ReportItemResponse( @SerialName("reportId") val reportId: Int, @SerialName("reportStatus") @@ -22,7 +22,7 @@ data class ReportItemDto( val reportImageUrl: String, ) -fun ReportItemDto.toDomain(): ReportItem = +fun ReportItemResponse.toDomain(): ReportItem = ReportItem( id = this.reportId, status = this.reportStatus, diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/service/ReportService.kt b/data/src/main/java/com/threegap/bitnagil/data/report/service/ReportService.kt index f89d71de..0bc35bf4 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/service/ReportService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/service/ReportService.kt @@ -1,8 +1,8 @@ package com.threegap.bitnagil.data.report.service -import com.threegap.bitnagil.data.report.model.request.ReportRequestDto -import com.threegap.bitnagil.data.report.model.response.ReportDetailDto -import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateDto +import com.threegap.bitnagil.data.report.model.request.ReportRequest +import com.threegap.bitnagil.data.report.model.response.ReportDetailResponse +import com.threegap.bitnagil.data.report.model.response.ReportHistoriesPerDateResponse import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.Body import retrofit2.http.GET @@ -12,14 +12,14 @@ import retrofit2.http.Path interface ReportService { @POST("/api/v2/reports") suspend fun submitReport( - @Body reportRequestDto: ReportRequestDto, + @Body reportRequest: ReportRequest, ): BaseResponse @GET("/api/v2/reports") - suspend fun getReports(): BaseResponse + suspend fun getReports(): BaseResponse @GET("/api/v2/reports/{reportId}") suspend fun getReport( @Path("reportId") reportId: String, - ): BaseResponse + ): BaseResponse } diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/datasource/RoutineRemoteDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/datasource/RoutineRemoteDataSource.kt index f325afcf..9df14a8c 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/datasource/RoutineRemoteDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/datasource/RoutineRemoteDataSource.kt @@ -1,13 +1,13 @@ package com.threegap.bitnagil.data.routine.datasource -import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto -import com.threegap.bitnagil.data.routine.model.response.RoutineDto -import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto +import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequest +import com.threegap.bitnagil.data.routine.model.response.RoutineResponse +import com.threegap.bitnagil.data.routine.model.response.RoutineScheduleResponse interface RoutineRemoteDataSource { - suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result - suspend fun syncRoutineCompletion(routineCompletionRequestDto: RoutineCompletionRequestDto): Result - suspend fun getRoutine(routineId: String): Result + suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result + suspend fun syncRoutineCompletion(routineCompletionRequest: RoutineCompletionRequest): Result + suspend fun getRoutine(routineId: String): Result suspend fun deleteRoutine(routineId: String): Result suspend fun deleteRoutineForDay(routineId: String): Result } diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/datasourceImpl/RoutineRemoteDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/datasourceImpl/RoutineRemoteDataSourceImpl.kt index 799d3a75..8d683be5 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/datasourceImpl/RoutineRemoteDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/datasourceImpl/RoutineRemoteDataSourceImpl.kt @@ -3,26 +3,26 @@ package com.threegap.bitnagil.data.routine.datasourceImpl import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.common.safeUnitApiCall import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource -import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto -import com.threegap.bitnagil.data.routine.model.response.RoutineDto -import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto +import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequest +import com.threegap.bitnagil.data.routine.model.response.RoutineResponse +import com.threegap.bitnagil.data.routine.model.response.RoutineScheduleResponse import com.threegap.bitnagil.data.routine.service.RoutineService import javax.inject.Inject class RoutineRemoteDataSourceImpl @Inject constructor( private val routineService: RoutineService, ) : RoutineRemoteDataSource { - override suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result = + override suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result = safeApiCall { - routineService.fetchRoutines(startDate, endDate) + routineService.fetchRoutineSchedule(startDate, endDate) } - override suspend fun syncRoutineCompletion(routineCompletionRequestDto: RoutineCompletionRequestDto): Result = + override suspend fun syncRoutineCompletion(routineCompletionRequest: RoutineCompletionRequest): Result = safeUnitApiCall { - routineService.routineCompletion(routineCompletionRequestDto) + routineService.routineCompletion(routineCompletionRequest) } - override suspend fun getRoutine(routineId: String): Result = + override suspend fun getRoutine(routineId: String): Result = safeApiCall { routineService.getRoutine(routineId) } diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionInfoDto.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionInfoRequest.kt similarity index 89% rename from data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionInfoDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionInfoRequest.kt index 06427e87..cd72b9b0 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionInfoDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionInfoRequest.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class RoutineCompletionInfoDto( +data class RoutineCompletionInfoRequest( @SerialName("routineId") val routineId: String, @SerialName("routineCompleteYn") @@ -15,7 +15,7 @@ data class RoutineCompletionInfoDto( ) internal fun RoutineCompletionInfo.toDto() = - RoutineCompletionInfoDto( + RoutineCompletionInfoRequest( routineId = this.routineId, routineCompleteYn = this.routineCompleteYn, subRoutineCompleteYn = this.subRoutineCompleteYn, diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionRequestDto.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionRequest.kt similarity index 74% rename from data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionRequestDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionRequest.kt index 464e0d93..80f9075c 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionRequestDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineCompletionRequest.kt @@ -5,12 +5,12 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class RoutineCompletionRequestDto( +data class RoutineCompletionRequest( @SerialName("routineCompletionInfos") - val routineCompletionInfos: List, + val routineCompletionInfos: List, ) internal fun RoutineCompletionInfos.toDto() = - RoutineCompletionRequestDto( + RoutineCompletionRequest( routineCompletionInfos = this.routineCompletionInfos.map { it.toDto() }, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/SubRoutineDeletionInfoDto.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/SubRoutineDeletionInfoDto.kt deleted file mode 100644 index f10463ec..00000000 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/model/request/SubRoutineDeletionInfoDto.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.threegap.bitnagil.data.routine.model.request - -import com.threegap.bitnagil.domain.routine.model.SubRoutineDeletionInfo -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class SubRoutineDeletionInfoDto( - @SerialName("routineCompletionId") - val routineCompletionId: Int?, - @SerialName("subRoutineId") - val subRoutineId: String, -) - -fun SubRoutineDeletionInfo.toDto() = - SubRoutineDeletionInfoDto( - routineCompletionId = this.routineCompletionId, - subRoutineId = this.subRoutineId, - ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/DayRoutinesDto.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/DailyRoutinesResponse.kt similarity index 67% rename from data/src/main/java/com/threegap/bitnagil/data/routine/model/response/DayRoutinesDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/routine/model/response/DailyRoutinesResponse.kt index 28bbdfcb..ee06f1e6 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/DayRoutinesDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/DailyRoutinesResponse.kt @@ -5,15 +5,15 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class DayRoutinesDto( +data class DailyRoutinesResponse( @SerialName("routineList") - val routineList: List, + val routines: List, @SerialName("allCompleted") val allCompleted: Boolean, ) -fun DayRoutinesDto.toDomain(): DailyRoutines = +fun DailyRoutinesResponse.toDomain(): DailyRoutines = DailyRoutines( - routines = routineList.map { it.toDomain() }, + routines = routines.map { it.toDomain() }, isAllCompleted = allCompleted, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineDto.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineResponse.kt similarity index 88% rename from data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineResponse.kt index 87d782e0..65a764dc 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineResponse.kt @@ -1,13 +1,13 @@ package com.threegap.bitnagil.data.routine.model.response +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.routine.model.DayOfWeek -import com.threegap.bitnagil.domain.routine.model.RecommendedRoutineType import com.threegap.bitnagil.domain.routine.model.Routine import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class RoutineDto( +data class RoutineResponse( @SerialName("routineId") val routineId: String, @SerialName("routineName") @@ -25,7 +25,7 @@ data class RoutineDto( @SerialName("subRoutineCompleteYn") val subRoutineCompleteYn: List, @SerialName("recommendedRoutineType") - val recommendedRoutineType: RecommendedRoutineType?, + val recommendedRoutineType: RecommendCategory?, @SerialName("routineDeletedYn") val routineDeletedYn: Boolean, @SerialName("routineStartDate") @@ -34,7 +34,7 @@ data class RoutineDto( val routineEndDate: String, ) -fun RoutineDto.toDomain(): Routine = +fun RoutineResponse.toDomain(): Routine = Routine( id = this.routineId, name = this.routineName, diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutinesResponseDto.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineScheduleResponse.kt similarity index 50% rename from data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutinesResponseDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineScheduleResponse.kt index 5f9fd500..6d14f0ce 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutinesResponseDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/model/response/RoutineScheduleResponse.kt @@ -5,14 +5,12 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class RoutinesResponseDto( +data class RoutineScheduleResponse( @SerialName("routines") - val routines: Map, + val dailyRoutines: Map, ) -fun RoutinesResponseDto.toDomain() = +fun RoutineScheduleResponse.toDomain(): RoutineSchedule = RoutineSchedule( - dailyRoutines = this.routines.mapValues { (_, dayRoutinesDto) -> - dayRoutinesDto.toDomain() - }, + dailyRoutines = this.dailyRoutines.mapValues { (_, dailyRoutinesResponse) -> dailyRoutinesResponse.toDomain() }, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/routine/service/RoutineService.kt b/data/src/main/java/com/threegap/bitnagil/data/routine/service/RoutineService.kt index 23b6c35e..fc504e9b 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/routine/service/RoutineService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/routine/service/RoutineService.kt @@ -1,8 +1,8 @@ package com.threegap.bitnagil.data.routine.service -import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto -import com.threegap.bitnagil.data.routine.model.response.RoutineDto -import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto +import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequest +import com.threegap.bitnagil.data.routine.model.response.RoutineResponse +import com.threegap.bitnagil.data.routine.model.response.RoutineScheduleResponse import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.Body import retrofit2.http.DELETE @@ -13,19 +13,19 @@ import retrofit2.http.Query interface RoutineService { @GET("/api/v2/routines") - suspend fun fetchRoutines( + suspend fun fetchRoutineSchedule( @Query("startDate") startDate: String, @Query("endDate") endDate: String, - ): BaseResponse + ): BaseResponse @GET("/api/v2/routines/{routineId}") suspend fun getRoutine( @Path("routineId") routineId: String, - ): BaseResponse + ): BaseResponse @PUT("/api/v2/routines/completions") suspend fun routineCompletion( - @Body request: RoutineCompletionRequestDto, + @Body request: RoutineCompletionRequest, ): BaseResponse @DELETE("/api/v1/routines/{routineId}") diff --git a/data/src/main/java/com/threegap/bitnagil/data/user/datasource/UserDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/user/datasource/UserDataSource.kt index 55cac914..c492b8e0 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/user/datasource/UserDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/user/datasource/UserDataSource.kt @@ -1,7 +1,7 @@ package com.threegap.bitnagil.data.user.datasource -import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto +import com.threegap.bitnagil.data.user.model.response.UserProfileResponse interface UserDataSource { - suspend fun fetchUserProfile(): Result + suspend fun fetchUserProfile(): Result } diff --git a/data/src/main/java/com/threegap/bitnagil/data/user/datasourceImpl/UserDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/user/datasourceImpl/UserDataSourceImpl.kt index dbde8d74..9b7f9190 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/user/datasourceImpl/UserDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/user/datasourceImpl/UserDataSourceImpl.kt @@ -2,14 +2,14 @@ package com.threegap.bitnagil.data.user.datasourceImpl import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.user.datasource.UserDataSource -import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto +import com.threegap.bitnagil.data.user.model.response.UserProfileResponse import com.threegap.bitnagil.data.user.service.UserService import javax.inject.Inject class UserDataSourceImpl @Inject constructor( private val userService: UserService, ) : UserDataSource { - override suspend fun fetchUserProfile(): Result = + override suspend fun fetchUserProfile(): Result = safeApiCall { userService.fetchUserProfile() } diff --git a/data/src/main/java/com/threegap/bitnagil/data/user/model/response/UserProfileResponseDto.kt b/data/src/main/java/com/threegap/bitnagil/data/user/model/response/UserProfileResponse.kt similarity index 81% rename from data/src/main/java/com/threegap/bitnagil/data/user/model/response/UserProfileResponseDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/user/model/response/UserProfileResponse.kt index 5f3749d2..1c9b4c2f 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/user/model/response/UserProfileResponseDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/user/model/response/UserProfileResponse.kt @@ -5,12 +5,12 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class UserProfileResponseDto( +data class UserProfileResponse( @SerialName("nickname") val nickname: String, ) -fun UserProfileResponseDto.toDomain() = +fun UserProfileResponse.toDomain() = UserProfile( nickname = this.nickname, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/user/service/UserService.kt b/data/src/main/java/com/threegap/bitnagil/data/user/service/UserService.kt index d2fc21db..39b6147d 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/user/service/UserService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/user/service/UserService.kt @@ -1,10 +1,10 @@ package com.threegap.bitnagil.data.user.service -import com.threegap.bitnagil.data.user.model.response.UserProfileResponseDto +import com.threegap.bitnagil.data.user.model.response.UserProfileResponse import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.GET interface UserService { @GET("/api/v1/users/infos") - suspend fun fetchUserProfile(): BaseResponse + suspend fun fetchUserProfile(): BaseResponse } diff --git a/data/src/main/java/com/threegap/bitnagil/data/version/datasource/VersionDataSource.kt b/data/src/main/java/com/threegap/bitnagil/data/version/datasource/VersionDataSource.kt index bfdaf968..c6e5ec24 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/version/datasource/VersionDataSource.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/version/datasource/VersionDataSource.kt @@ -1,7 +1,7 @@ package com.threegap.bitnagil.data.version.datasource -import com.threegap.bitnagil.data.version.model.response.VersionCheckResponseDto +import com.threegap.bitnagil.data.version.model.response.VersionCheckResponse interface VersionDataSource { - suspend fun checkVersion(): Result + suspend fun checkVersion(): Result } diff --git a/data/src/main/java/com/threegap/bitnagil/data/version/datasourceImpl/VersionDataSourceImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/version/datasourceImpl/VersionDataSourceImpl.kt index e83a11e6..1726afd5 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/version/datasourceImpl/VersionDataSourceImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/version/datasourceImpl/VersionDataSourceImpl.kt @@ -3,7 +3,7 @@ package com.threegap.bitnagil.data.version.datasourceImpl import com.threegap.bitnagil.data.BuildConfig import com.threegap.bitnagil.data.common.safeApiCall import com.threegap.bitnagil.data.version.datasource.VersionDataSource -import com.threegap.bitnagil.data.version.model.response.VersionCheckResponseDto +import com.threegap.bitnagil.data.version.model.response.VersionCheckResponse import com.threegap.bitnagil.data.version.service.VersionService import javax.inject.Inject @@ -11,7 +11,7 @@ class VersionDataSourceImpl @Inject constructor( private val versionService: VersionService, ) : VersionDataSource { - override suspend fun checkVersion(): Result = + override suspend fun checkVersion(): Result = safeApiCall { versionService.checkVersion( majorVersion = BuildConfig.VERSION_MAJOR, diff --git a/data/src/main/java/com/threegap/bitnagil/data/version/model/response/VersionCheckResponseDto.kt b/data/src/main/java/com/threegap/bitnagil/data/version/model/response/VersionCheckResponse.kt similarity index 82% rename from data/src/main/java/com/threegap/bitnagil/data/version/model/response/VersionCheckResponseDto.kt rename to data/src/main/java/com/threegap/bitnagil/data/version/model/response/VersionCheckResponse.kt index c31481e8..3b8503c7 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/version/model/response/VersionCheckResponseDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/version/model/response/VersionCheckResponse.kt @@ -5,12 +5,12 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class VersionCheckResponseDto( +data class VersionCheckResponse( @SerialName("forceUpdateYn") val forceUpdateYn: Boolean, ) -fun VersionCheckResponseDto.toDomain() = +fun VersionCheckResponse.toDomain() = UpdateRequirement( isForced = this.forceUpdateYn, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/version/service/VersionService.kt b/data/src/main/java/com/threegap/bitnagil/data/version/service/VersionService.kt index 4f8441b4..c5204633 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/version/service/VersionService.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/version/service/VersionService.kt @@ -1,6 +1,6 @@ package com.threegap.bitnagil.data.version.service -import com.threegap.bitnagil.data.version.model.response.VersionCheckResponseDto +import com.threegap.bitnagil.data.version.model.response.VersionCheckResponse import com.threegap.bitnagil.network.model.BaseResponse import retrofit2.http.GET import retrofit2.http.Query @@ -11,5 +11,5 @@ interface VersionService { @Query("major") majorVersion: Int, @Query("minor") minorVersion: Int, @Query("patch") patchVersion: Int, - ): BaseResponse + ): BaseResponse } diff --git a/data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt b/data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt index 7fff74e2..0c4a72c7 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt @@ -1,5 +1,6 @@ package com.threegap.bitnagil.data.writeroutine.model.request +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.writeroutine.model.RepeatDay import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -19,5 +20,5 @@ data class RegisterRoutineRequest( @SerialName("subRoutineName") val subRoutineName: List, @SerialName("recommendedRoutineType") - val recommendedRoutineType: String?, + val recommendedRoutineType: RecommendCategory?, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt b/data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt index be64ae27..80e5dcbf 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt @@ -3,6 +3,7 @@ package com.threegap.bitnagil.data.writeroutine.repositoryImpl import com.threegap.bitnagil.data.writeroutine.datasource.WriteRoutineDataSource import com.threegap.bitnagil.data.writeroutine.model.request.EditRoutineRequest import com.threegap.bitnagil.data.writeroutine.model.request.RegisterRoutineRequest +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.writeroutine.model.RepeatDay import com.threegap.bitnagil.domain.writeroutine.model.RoutineUpdateType import com.threegap.bitnagil.domain.writeroutine.model.WriteRoutineEvent @@ -24,7 +25,7 @@ class WriteRoutineRepositoryImpl @Inject constructor( startDate: LocalDate, endDate: LocalDate, subRoutines: List, - recommendedRoutineType: String?, + recommendedRoutineType: RecommendCategory?, ): Result { val request = RegisterRoutineRequest( routineName = name, diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/DailyEmotion.kt b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/DailyEmotion.kt new file mode 100644 index 00000000..ab27dd52 --- /dev/null +++ b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/DailyEmotion.kt @@ -0,0 +1,8 @@ +package com.threegap.bitnagil.domain.emotion.model + +data class DailyEmotion( + val type: EmotionMarbleType?, + val name: String?, + val imageUrl: String?, + val homeMessage: String?, +) diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/EmotionMarbleType.kt b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/EmotionMarbleType.kt new file mode 100644 index 00000000..36d62daf --- /dev/null +++ b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/EmotionMarbleType.kt @@ -0,0 +1,16 @@ +package com.threegap.bitnagil.domain.emotion.model + +import kotlinx.serialization.Serializable + +/** + * 감정구슬 타입 + * + * @property CALM 평온함 + * @property VITALITY 활기참 + * @property LETHARGY 무기력함 + * @property ANXIETY 활기참 + * @property SATISFACTION 만족함 + * @property FATIGUE 피곤함 + */ +@Serializable +enum class EmotionMarbleType { CALM, VITALITY, LETHARGY, ANXIETY, SATISFACTION, FATIGUE } diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/TodayEmotion.kt b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/TodayEmotion.kt deleted file mode 100644 index bbcddc64..00000000 --- a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/model/TodayEmotion.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.threegap.bitnagil.domain.emotion.model - -data class TodayEmotion( - val type: String, - val name: String, - val imageUrl: String, - val homeMessage: String, -) diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/repository/EmotionRepository.kt b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/repository/EmotionRepository.kt index 526e1ec1..d2a1df80 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/repository/EmotionRepository.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/repository/EmotionRepository.kt @@ -1,14 +1,14 @@ package com.threegap.bitnagil.domain.emotion.repository +import com.threegap.bitnagil.domain.emotion.model.DailyEmotion import com.threegap.bitnagil.domain.emotion.model.Emotion import com.threegap.bitnagil.domain.emotion.model.EmotionChangeEvent import com.threegap.bitnagil.domain.emotion.model.EmotionRecommendRoutine -import com.threegap.bitnagil.domain.emotion.model.TodayEmotion import kotlinx.coroutines.flow.Flow interface EmotionRepository { suspend fun getEmotions(): Result> suspend fun registerEmotion(emotionMarbleType: String): Result> - suspend fun fetchTodayEmotion(currentDate: String): Result + suspend fun fetchDailyEmotion(currentDate: String): Result suspend fun getEmotionChangeEventFlow(): Flow } diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/usecase/FetchTodayEmotionUseCase.kt b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/usecase/FetchDailyEmotionUseCase.kt similarity index 55% rename from domain/src/main/java/com/threegap/bitnagil/domain/emotion/usecase/FetchTodayEmotionUseCase.kt rename to domain/src/main/java/com/threegap/bitnagil/domain/emotion/usecase/FetchDailyEmotionUseCase.kt index b98453e4..0b5d5bdb 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/emotion/usecase/FetchTodayEmotionUseCase.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/emotion/usecase/FetchDailyEmotionUseCase.kt @@ -1,15 +1,15 @@ package com.threegap.bitnagil.domain.emotion.usecase -import com.threegap.bitnagil.domain.emotion.model.TodayEmotion +import com.threegap.bitnagil.domain.emotion.model.DailyEmotion import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository import java.time.LocalDate import javax.inject.Inject -class FetchTodayEmotionUseCase @Inject constructor( +class FetchDailyEmotionUseCase @Inject constructor( private val emotionRepository: EmotionRepository, ) { - suspend operator fun invoke(): Result { + suspend operator fun invoke(): Result { val currentDate = LocalDate.now().toString() - return emotionRepository.fetchTodayEmotion(currentDate) + return emotionRepository.fetchDailyEmotion(currentDate) } } diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/EmotionMarbleType.kt b/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/EmotionMarbleType.kt deleted file mode 100644 index be751c95..00000000 --- a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/EmotionMarbleType.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.threegap.bitnagil.domain.recommendroutine.model - -import kotlinx.serialization.Serializable - -@Serializable -enum class EmotionMarbleType { - CALM, - VITALITY, - LETHARGY, - ANXIETY, - SATISFACTION, - FATIGUE, -} diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutine.kt b/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutine.kt index 8cea9010..6227e08a 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutine.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutine.kt @@ -1,11 +1,11 @@ package com.threegap.bitnagil.domain.recommendroutine.model data class RecommendRoutine( - val id: Int, + val id: Long, val name: String, val description: String, val level: RecommendLevel, val executionTime: String, - val recommendedRoutineType: RecommendCategory, - val recommendSubRoutines: List, + val category: RecommendCategory, + val subRoutines: List, ) diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutines.kt b/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutines.kt index 21804f6b..771903f3 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutines.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutines.kt @@ -1,5 +1,7 @@ package com.threegap.bitnagil.domain.recommendroutine.model +import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType + data class RecommendRoutines( val recommendRoutinesByCategory: Map>, val emotionMarbleType: EmotionMarbleType?, diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendSubRoutine.kt b/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendSubRoutine.kt index ec1c05ca..3d6e93fa 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendSubRoutine.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendSubRoutine.kt @@ -1,6 +1,6 @@ package com.threegap.bitnagil.domain.recommendroutine.model data class RecommendSubRoutine( - val id: Int, + val id: Long, val name: String, ) diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RecommendedRoutineType.kt b/domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RecommendedRoutineType.kt deleted file mode 100644 index 9f1b8475..00000000 --- a/domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RecommendedRoutineType.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.threegap.bitnagil.domain.routine.model - -import kotlinx.serialization.Serializable - -@Serializable -enum class RecommendedRoutineType { - PERSONALIZED, - OUTING, - WAKE_UP, - CONNECT, - REST, - GROW, - OUTING_REPORT, - ; -} diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/routine/model/Routine.kt b/domain/src/main/java/com/threegap/bitnagil/domain/routine/model/Routine.kt index d275d11f..4377c70b 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/routine/model/Routine.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/routine/model/Routine.kt @@ -1,5 +1,7 @@ package com.threegap.bitnagil.domain.routine.model +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory + data class Routine( val id: String, val name: String, @@ -12,5 +14,5 @@ data class Routine( val isDeleted: Boolean, val subRoutineNames: List, val subRoutineCompletionStates: List, - val recommendedRoutineType: RecommendedRoutineType?, + val recommendedRoutineType: RecommendCategory?, ) diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt b/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt index 9a8b933a..3ff5059f 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt @@ -1,5 +1,6 @@ package com.threegap.bitnagil.domain.writeroutine.repository +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.writeroutine.model.RepeatDay import com.threegap.bitnagil.domain.writeroutine.model.RoutineUpdateType import com.threegap.bitnagil.domain.writeroutine.model.WriteRoutineEvent @@ -15,7 +16,7 @@ interface WriteRoutineRepository { startDate: LocalDate, endDate: LocalDate, subRoutines: List, - recommendedRoutineType: String?, + recommendedRoutineType: RecommendCategory?, ): Result suspend fun editRoutine( diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.kt b/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.kt index a25ec8f6..ae9ed932 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.kt @@ -1,5 +1,6 @@ package com.threegap.bitnagil.domain.writeroutine.usecase +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.writeroutine.model.RepeatDay import com.threegap.bitnagil.domain.writeroutine.repository.WriteRoutineRepository import java.time.LocalDate @@ -16,7 +17,7 @@ class RegisterRoutineUseCase @Inject constructor( startDate: LocalDate, endDate: LocalDate, subRoutines: List, - recommendedRoutineType: String?, + recommendedRoutineType: RecommendCategory?, ): Result { return writeRoutineRepository.registerRoutine( name = name, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportCategoryExtension.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/common/extension/ReportCategoryEtx.kt similarity index 81% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportCategoryExtension.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/common/extension/ReportCategoryEtx.kt index de494241..5a717661 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportCategoryExtension.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/common/extension/ReportCategoryEtx.kt @@ -1,9 +1,10 @@ -package com.threegap.bitnagil.presentation.report.model +package com.threegap.bitnagil.presentation.common.extension +import androidx.annotation.DrawableRes import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.domain.report.model.ReportCategory -val ReportCategory.uiTitle: String +val ReportCategory.displayTitle: String get() = when (this) { ReportCategory.TRANSPORTATION -> "교통 시설" ReportCategory.LIGHTING -> "조명 시설" @@ -11,7 +12,7 @@ val ReportCategory.uiTitle: String ReportCategory.AMENITY -> "편의 시설" } -val ReportCategory.uiDescription: String +val ReportCategory.displayExamples: String get() = when (this) { ReportCategory.TRANSPORTATION -> "신호등 고장, 표지판 파손, 횡단보도 등" ReportCategory.LIGHTING -> "가로등, 보안등 파손 등" @@ -20,7 +21,7 @@ val ReportCategory.uiDescription: String } val ReportCategory.iconRes: Int - get() = when (this) { + @DrawableRes get() = when (this) { ReportCategory.TRANSPORTATION -> R.drawable.ic_car ReportCategory.LIGHTING -> R.drawable.ic_light ReportCategory.WATERFACILITY -> R.drawable.ic_water diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/common/extension/ReportStatusEtx.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/common/extension/ReportStatusEtx.kt new file mode 100644 index 00000000..231541c5 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/common/extension/ReportStatusEtx.kt @@ -0,0 +1,27 @@ +package com.threegap.bitnagil.presentation.common.extension + +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import com.threegap.bitnagil.designsystem.BitnagilTheme +import com.threegap.bitnagil.domain.report.model.ReportStatus + +val ReportStatus.displayTitle: String + get() = when (this) { + ReportStatus.PENDING -> "제보 완료" + ReportStatus.IN_PROGRESS -> "처리 중" + ReportStatus.COMPLETED -> "처리 완료" + } + +val ReportStatus.badgeBackgroundColor: Color + @Composable get() = when (this) { + ReportStatus.PENDING -> BitnagilTheme.colors.green10 + ReportStatus.IN_PROGRESS -> BitnagilTheme.colors.skyBlue10 + else -> BitnagilTheme.colors.coolGray95 + } + +val ReportStatus.textColor: Color + @Composable get() = when (this) { + ReportStatus.PENDING -> BitnagilTheme.colors.green300 + ReportStatus.IN_PROGRESS -> BitnagilTheme.colors.blue300 + else -> BitnagilTheme.colors.coolGray40 + } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionScreen.kt index f3e64706..dc4c67a1 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionScreen.kt @@ -14,8 +14,8 @@ import com.threegap.bitnagil.presentation.common.toast.GlobalBitnagilToast import com.threegap.bitnagil.presentation.emotion.component.template.EmotionRecommendRoutineScreen import com.threegap.bitnagil.presentation.emotion.component.template.SimpleEmotionSelectionScreen import com.threegap.bitnagil.presentation.emotion.component.template.SwipeEmotionSelectionScreen +import com.threegap.bitnagil.presentation.emotion.contract.EmotionSideEffect import com.threegap.bitnagil.presentation.emotion.model.EmotionScreenStep -import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionSideEffect import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionViewModel.kt index 042607e1..2f6a6c89 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/EmotionViewModel.kt @@ -6,11 +6,10 @@ import androidx.lifecycle.viewModelScope import com.threegap.bitnagil.domain.emotion.usecase.GetEmotionsUseCase import com.threegap.bitnagil.domain.emotion.usecase.RegisterEmotionUseCase import com.threegap.bitnagil.domain.onboarding.usecase.RegisterRecommendOnBoardingRoutinesUseCase -import com.threegap.bitnagil.presentation.emotion.model.EmotionRecommendRoutineUiModel +import com.threegap.bitnagil.presentation.emotion.contract.EmotionSideEffect +import com.threegap.bitnagil.presentation.emotion.contract.EmotionState import com.threegap.bitnagil.presentation.emotion.model.EmotionScreenStep -import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel -import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionSideEffect -import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionState +import com.threegap.bitnagil.presentation.emotion.model.toUiModel import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -39,7 +38,7 @@ class EmotionViewModel @Inject constructor( onSuccess = { emotions -> reduce { state.copy( - emotionTypeUiModels = emotions.map { EmotionUiModel.fromDomain(it) }, + emotionTypeUiModels = emotions.map { it.toUiModel() }, isLoading = false, ) } @@ -69,7 +68,7 @@ class EmotionViewModel @Inject constructor( registerEmotionUseCase(emotionType = emotionType).fold( onSuccess = { emotionRecommendRoutines -> - val recommendRoutines = emotionRecommendRoutines.map { EmotionRecommendRoutineUiModel.fromEmotionRecommendRoutine(it) } + val recommendRoutines = emotionRecommendRoutines.map { it.toUiModel() } reduce { state.copy( recommendRoutines = recommendRoutines, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/EmotionRecommendRoutineScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/EmotionRecommendRoutineScreen.kt index 538383e3..748cc01a 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/EmotionRecommendRoutineScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/EmotionRecommendRoutineScreen.kt @@ -21,11 +21,11 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.component.atom.BitnagilSelectButton import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButtonColor +import com.threegap.bitnagil.presentation.emotion.contract.EmotionState import com.threegap.bitnagil.presentation.emotion.model.EmotionImageUiModel import com.threegap.bitnagil.presentation.emotion.model.EmotionRecommendRoutineUiModel import com.threegap.bitnagil.presentation.emotion.model.EmotionScreenStep import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel -import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionState @Composable fun EmotionRecommendRoutineScreen( diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SimpleEmotionSelectionScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SimpleEmotionSelectionScreen.kt index 95e14dfd..ef890ee5 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SimpleEmotionSelectionScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SimpleEmotionSelectionScreen.kt @@ -22,10 +22,10 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple import com.threegap.bitnagil.presentation.emotion.component.atom.EmotionMarbleImage +import com.threegap.bitnagil.presentation.emotion.contract.EmotionState import com.threegap.bitnagil.presentation.emotion.model.EmotionImageUiModel import com.threegap.bitnagil.presentation.emotion.model.EmotionScreenStep import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel -import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionState @Composable fun SimpleEmotionSelectionScreen( diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SwipeEmotionSelectionScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SwipeEmotionSelectionScreen.kt index 7398231b..f9feab73 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SwipeEmotionSelectionScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/component/template/SwipeEmotionSelectionScreen.kt @@ -62,10 +62,10 @@ import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar import com.threegap.bitnagil.presentation.common.dimension.dpToPx import com.threegap.bitnagil.presentation.emotion.component.atom.EmotionMarbleImage +import com.threegap.bitnagil.presentation.emotion.contract.EmotionState import com.threegap.bitnagil.presentation.emotion.model.EmotionImageUiModel import com.threegap.bitnagil.presentation.emotion.model.EmotionScreenStep import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel -import com.threegap.bitnagil.presentation.emotion.model.mvi.EmotionState import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlin.math.absoluteValue diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/contract/EmotionSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/contract/EmotionSideEffect.kt new file mode 100644 index 00000000..4f5c6e3f --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/contract/EmotionSideEffect.kt @@ -0,0 +1,6 @@ +package com.threegap.bitnagil.presentation.emotion.contract + +sealed interface EmotionSideEffect { + data object NavigateToBack : EmotionSideEffect + data class ShowToast(val message: String) : EmotionSideEffect +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/mvi/EmotionState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/contract/EmotionState.kt similarity index 94% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/mvi/EmotionState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/contract/EmotionState.kt index b4607781..e780d16d 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/mvi/EmotionState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/contract/EmotionState.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.emotion.model.mvi +package com.threegap.bitnagil.presentation.emotion.contract import android.os.Parcelable import androidx.compose.runtime.Immutable diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionRecommendRoutineUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionRecommendRoutineUiModel.kt index a93a3784..19c09326 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionRecommendRoutineUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionRecommendRoutineUiModel.kt @@ -10,17 +10,12 @@ data class EmotionRecommendRoutineUiModel( val name: String, val description: String, val selected: Boolean, -) : Parcelable { - companion object { - fun fromEmotionRecommendRoutine( - emotionRecommendRoutine: EmotionRecommendRoutine, - ): EmotionRecommendRoutineUiModel { - return EmotionRecommendRoutineUiModel( - id = emotionRecommendRoutine.routineId, - name = emotionRecommendRoutine.routineName, - description = emotionRecommendRoutine.routineDescription, - selected = false, - ) - } - } -} +) : Parcelable + +internal fun EmotionRecommendRoutine.toUiModel(): EmotionRecommendRoutineUiModel = + EmotionRecommendRoutineUiModel( + id = this.routineId, + name = this.routineName, + description = this.routineDescription, + selected = false, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionUiModel.kt index 487e7275..39a46e91 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/EmotionUiModel.kt @@ -3,6 +3,10 @@ package com.threegap.bitnagil.presentation.emotion.model import android.os.Parcelable import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.domain.emotion.model.Emotion +import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getMessage +import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getOfflineBackupImageResourceId +import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getSymbolBackgroundColor +import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getSymbolColor import kotlinx.parcelize.Parcelize @Parcelize @@ -16,19 +20,7 @@ data class EmotionUiModel( val symbolColor: Long = 0xFF878A93, ) : Parcelable { companion object { - fun fromDomain(emotion: Emotion) = EmotionUiModel( - emotionType = emotion.emotionType, - emotionMarbleName = emotion.emotionMarbleName, - image = EmotionImageUiModel.Url( - url = emotion.imageUrl, - offlineBackupImageResourceId = getOfflineBackupImageResourceId(emotion.emotionType), - ), - message = getMessage(emotion.emotionType), - symbolBackgroundColor = getSymbolBackgroundColor(emotion.emotionType), - symbolColor = getSymbolColor(emotion.emotionType), - ) - - private fun getOfflineBackupImageResourceId(emotionType: String): Int? { + fun getOfflineBackupImageResourceId(emotionType: String): Int? { return when (emotionType) { "CALM" -> R.drawable.calm "VITALITY" -> R.drawable.vitality @@ -40,7 +32,7 @@ data class EmotionUiModel( } } - private fun getMessage(emotionType: String): String? { + fun getMessage(emotionType: String): String? { return when (emotionType) { "CALM" -> "평온함은 마음이 고요하고 편안해\n균형을 이루는 상태에요." "VITALITY" -> "활기참은 생기가 가득 차\n활발하고 적극적인 상태예요." @@ -52,7 +44,7 @@ data class EmotionUiModel( } } - private fun getSymbolBackgroundColor(emotionType: String): Long { + fun getSymbolBackgroundColor(emotionType: String): Long { return when (emotionType) { "CALM" -> 0xFFEFECFF "VITALITY" -> 0xFFE9FAD0 @@ -64,7 +56,7 @@ data class EmotionUiModel( } } - private fun getSymbolColor(emotionType: String): Long { + fun getSymbolColor(emotionType: String): Long { return when (emotionType) { "CALM" -> 0xFF692BD0 "VITALITY" -> 0xFF609F00 @@ -87,3 +79,16 @@ data class EmotionUiModel( ) } } + +internal fun Emotion.toUiModel(): EmotionUiModel = + EmotionUiModel( + emotionType = this.emotionType, + emotionMarbleName = this.emotionMarbleName, + image = EmotionImageUiModel.Url( + url = this.imageUrl, + offlineBackupImageResourceId = getOfflineBackupImageResourceId(this.emotionType), + ), + message = getMessage(this.emotionType), + symbolBackgroundColor = getSymbolBackgroundColor(this.emotionType), + symbolColor = getSymbolColor(this.emotionType), + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/mvi/EmotionSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/mvi/EmotionSideEffect.kt deleted file mode 100644 index ce643e75..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/emotion/model/mvi/EmotionSideEffect.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.threegap.bitnagil.presentation.emotion.model.mvi - -sealed class EmotionSideEffect { - data object NavigateToBack : EmotionSideEffect() - data class ShowToast(val message: String) : EmotionSideEffect() -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideScreen.kt index 2e7512c2..aab98164 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideScreen.kt @@ -16,7 +16,7 @@ import androidx.hilt.navigation.compose.hiltViewModel import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar import com.threegap.bitnagil.presentation.guide.component.atom.GuideButton import com.threegap.bitnagil.presentation.guide.component.template.GuideBottomSheet -import com.threegap.bitnagil.presentation.guide.model.GuideSideEffect +import com.threegap.bitnagil.presentation.guide.contract.GuideSideEffect import com.threegap.bitnagil.presentation.guide.model.GuideType import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideViewModel.kt index ca1a64ca..f12a3ecd 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/GuideViewModel.kt @@ -1,8 +1,8 @@ package com.threegap.bitnagil.presentation.guide import androidx.lifecycle.ViewModel -import com.threegap.bitnagil.presentation.guide.model.GuideSideEffect -import com.threegap.bitnagil.presentation.guide.model.GuideState +import com.threegap.bitnagil.presentation.guide.contract.GuideSideEffect +import com.threegap.bitnagil.presentation.guide.contract.GuideState import com.threegap.bitnagil.presentation.guide.model.GuideType import dagger.hilt.android.lifecycle.HiltViewModel import org.orbitmvi.orbit.Container diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/model/GuideSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/contract/GuideSideEffect.kt similarity index 60% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/guide/model/GuideSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/guide/contract/GuideSideEffect.kt index 8c9e9d3a..b174c955 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/model/GuideSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/contract/GuideSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.guide.model +package com.threegap.bitnagil.presentation.guide.contract sealed interface GuideSideEffect { data object NavigateToBack : GuideSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/model/GuideState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/contract/GuideState.kt similarity index 66% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/guide/model/GuideState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/guide/contract/GuideState.kt index 0375371a..2a26eb37 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/model/GuideState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/guide/contract/GuideState.kt @@ -1,4 +1,6 @@ -package com.threegap.bitnagil.presentation.guide.model +package com.threegap.bitnagil.presentation.guide.contract + +import com.threegap.bitnagil.presentation.guide.model.GuideType data class GuideState( val guideType: GuideType?, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeScreen.kt index 8a8639b9..0db4f45f 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeScreen.kt @@ -28,8 +28,8 @@ import com.threegap.bitnagil.presentation.home.component.template.CollapsibleHom import com.threegap.bitnagil.presentation.home.component.template.EmptyRoutineView import com.threegap.bitnagil.presentation.home.component.template.RoutineSection import com.threegap.bitnagil.presentation.home.component.template.WeeklyDatePicker -import com.threegap.bitnagil.presentation.home.model.HomeSideEffect -import com.threegap.bitnagil.presentation.home.model.HomeState +import com.threegap.bitnagil.presentation.home.contract.HomeSideEffect +import com.threegap.bitnagil.presentation.home.contract.HomeState import com.threegap.bitnagil.presentation.home.util.rememberCollapsibleHeaderState import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect @@ -37,11 +37,11 @@ import java.time.LocalDate @Composable fun HomeScreenContainer( + viewModel: HomeViewModel = hiltViewModel(), navigateToGuide: () -> Unit, navigateToRegisterRoutine: () -> Unit, navigateToEmotion: () -> Unit, navigateToRoutineList: (String) -> Unit, - viewModel: HomeViewModel = hiltViewModel(), ) { val uiState by viewModel.collectAsState() @@ -169,7 +169,7 @@ private fun HomeScreen( CollapsibleHomeHeader( userName = uiState.userNickname, - todayEmotion = uiState.todayEmotion, + dailyEmotion = uiState.dailyEmotion, collapsibleHeaderState = collapsibleHeaderState, onHelpClick = onHelpClick, onRegisterEmotion = onRegisterEmotionClick, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt index ea9a12f8..c4a9d347 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt @@ -2,7 +2,7 @@ package com.threegap.bitnagil.presentation.home import android.util.Log import androidx.lifecycle.ViewModel -import com.threegap.bitnagil.domain.emotion.usecase.FetchTodayEmotionUseCase +import com.threegap.bitnagil.domain.emotion.usecase.FetchDailyEmotionUseCase import com.threegap.bitnagil.domain.emotion.usecase.GetEmotionChangeEventFlowUseCase import com.threegap.bitnagil.domain.onboarding.usecase.GetOnBoardingRecommendRoutineEventFlowUseCase import com.threegap.bitnagil.domain.routine.model.RoutineCompletionInfo @@ -12,8 +12,8 @@ import com.threegap.bitnagil.domain.routine.usecase.RoutineCompletionUseCase import com.threegap.bitnagil.domain.routine.usecase.ToggleRoutineUseCase import com.threegap.bitnagil.domain.user.usecase.FetchUserProfileUseCase import com.threegap.bitnagil.domain.writeroutine.usecase.GetWriteRoutineEventFlowUseCase -import com.threegap.bitnagil.presentation.home.model.HomeSideEffect -import com.threegap.bitnagil.presentation.home.model.HomeState +import com.threegap.bitnagil.presentation.home.contract.HomeSideEffect +import com.threegap.bitnagil.presentation.home.contract.HomeState import com.threegap.bitnagil.presentation.home.model.ToggleStrategy import com.threegap.bitnagil.presentation.home.model.toUiModel import com.threegap.bitnagil.presentation.home.util.getCurrentWeekDays @@ -36,7 +36,7 @@ import javax.inject.Inject class HomeViewModel @Inject constructor( private val fetchWeeklyRoutinesUseCase: FetchWeeklyRoutinesUseCase, private val fetchUserProfileUseCase: FetchUserProfileUseCase, - private val fetchTodayEmotionUseCase: FetchTodayEmotionUseCase, + private val fetchDailyEmotionUseCase: FetchDailyEmotionUseCase, private val routineCompletionUseCase: RoutineCompletionUseCase, private val getWriteRoutineEventFlowUseCase: GetWriteRoutineEventFlowUseCase, private val getEmotionChangeEventFlowUseCase: GetEmotionChangeEventFlowUseCase, @@ -186,7 +186,7 @@ class HomeViewModel @Inject constructor( intent { coroutineScope { launch { fetchUserProfile() } - launch { fetchTodayEmotion() } + launch { fetchDailyEmotion() } launch { fetchWeeklyRoutines(state.currentWeeks) } launch { observeWriteRoutineEvent() } launch { observeEmotionChangeEvent() } @@ -208,7 +208,7 @@ class HomeViewModel @Inject constructor( private suspend fun observeEmotionChangeEvent() { subIntent { getEmotionChangeEventFlowUseCase().collect { - fetchTodayEmotion() + fetchDailyEmotion() } } } @@ -278,12 +278,12 @@ class HomeViewModel @Inject constructor( } } - private suspend fun fetchTodayEmotion() { + private suspend fun fetchDailyEmotion() { subIntent { reduce { state.copy(loadingCount = state.loadingCount + 1) } - fetchTodayEmotionUseCase().fold( + fetchDailyEmotionUseCase().fold( onSuccess = { - reduce { state.copy(todayEmotion = it?.toUiModel(), loadingCount = state.loadingCount - 1) } + reduce { state.copy(dailyEmotion = it.toUiModel(), loadingCount = state.loadingCount - 1) } }, onFailure = { Log.e("HomeViewModel", "나의 감정 실패: ${it.message}") diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/CollapsibleHomeHeader.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/CollapsibleHomeHeader.kt index f15b8e12..260fffe5 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/CollapsibleHomeHeader.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/CollapsibleHomeHeader.kt @@ -34,14 +34,14 @@ import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.designsystem.component.atom.BitnagilIconButton import com.threegap.bitnagil.presentation.home.component.atom.EmotionRegisterButton -import com.threegap.bitnagil.presentation.home.model.TodayEmotionUiModel +import com.threegap.bitnagil.presentation.home.model.DailyEmotionUiModel import com.threegap.bitnagil.presentation.home.util.CollapsibleHeaderState import com.threegap.bitnagil.presentation.home.util.rememberCollapsibleHeaderState @Composable fun CollapsibleHomeHeader( userName: String, - todayEmotion: TodayEmotionUiModel?, + dailyEmotion: DailyEmotionUiModel, collapsibleHeaderState: CollapsibleHeaderState, onHelpClick: () -> Unit, onRegisterEmotion: () -> Unit, @@ -53,12 +53,6 @@ fun CollapsibleHomeHeader( animationSpec = tween(durationMillis = 300), label = "header_alpha", ) - val hasEmotion = todayEmotion != null - val welcomeMessage = if (hasEmotion) { - "${userName}님,\n${todayEmotion?.homeMessage}" - } else { - "${userName}님, 오셨군요!\n오늘 기분은 어떤가요?" - } Column( modifier = modifier @@ -102,7 +96,7 @@ fun CollapsibleHomeHeader( verticalArrangement = Arrangement.spacedBy(20.dp), ) { Text( - text = welcomeMessage, + text = "$userName${dailyEmotion.homeMessage}", style = BitnagilTheme.typography.cafe24SsurroundAir, color = BitnagilTheme.colors.white, fontWeight = FontWeight.SemiBold, @@ -110,14 +104,14 @@ fun CollapsibleHomeHeader( EmotionRegisterButton( onClick = onRegisterEmotion, - enabled = !hasEmotion, + enabled = !dailyEmotion.hasEmotion, ) } AsyncImage( - model = remember(todayEmotion?.imageUrl) { + model = remember(dailyEmotion.imageUrl) { ImageRequest.Builder(context) - .data(todayEmotion?.imageUrl) + .data(dailyEmotion.imageUrl) .crossfade(true) .build() }, @@ -140,7 +134,7 @@ fun CollapsibleHomeHeader( private fun CollapsibleHomeHeaderPreview() { CollapsibleHomeHeader( userName = "대현", - todayEmotion = null, + dailyEmotion = DailyEmotionUiModel.INIT, collapsibleHeaderState = rememberCollapsibleHeaderState(), onHelpClick = {}, onRegisterEmotion = {}, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/WeeklyDatePicker.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/WeeklyDatePicker.kt index 0ee23625..c1c9d83a 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/WeeklyDatePicker.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/WeeklyDatePicker.kt @@ -197,7 +197,7 @@ private fun WeeklyDatePickerPreview() { WeeklyDatePicker( selectedDate = selectedDate, weeklyDates = selectedDate.getCurrentWeekDays(), - routines = RoutineScheduleUiModel(), + routines = RoutineScheduleUiModel.INIT, onDateSelect = { selectedDate = it }, onPreviousWeekClick = { selectedDate = selectedDate.minusWeeks(1) }, onNextWeekClick = { selectedDate = selectedDate.plusWeeks(1) }, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/HomeSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/contract/HomeSideEffect.kt similarity index 82% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/HomeSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/home/contract/HomeSideEffect.kt index 9f55ba02..0d0682c4 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/HomeSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/contract/HomeSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.home.model +package com.threegap.bitnagil.presentation.home.contract sealed interface HomeSideEffect { data object NavigateToGuide : HomeSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/HomeState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/contract/HomeState.kt similarity index 63% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/HomeState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/home/contract/HomeState.kt index a54c49a4..5baa825e 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/HomeState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/contract/HomeState.kt @@ -1,12 +1,15 @@ -package com.threegap.bitnagil.presentation.home.model +package com.threegap.bitnagil.presentation.home.contract +import com.threegap.bitnagil.presentation.home.model.DailyEmotionUiModel +import com.threegap.bitnagil.presentation.home.model.RoutineScheduleUiModel +import com.threegap.bitnagil.presentation.home.model.RoutineUiModel import com.threegap.bitnagil.presentation.home.util.getCurrentWeekDays import java.time.LocalDate data class HomeState( val loadingCount: Int, val userNickname: String, - val todayEmotion: TodayEmotionUiModel?, + val dailyEmotion: DailyEmotionUiModel, val selectedDate: LocalDate, val currentWeeks: List, val routineSchedule: RoutineScheduleUiModel, @@ -21,10 +24,10 @@ data class HomeState( val INIT = HomeState( loadingCount = 0, userNickname = "", - todayEmotion = null, + dailyEmotion = DailyEmotionUiModel.INIT, selectedDate = LocalDate.now(), currentWeeks = LocalDate.now().getCurrentWeekDays(), - routineSchedule = RoutineScheduleUiModel(), + routineSchedule = RoutineScheduleUiModel.INIT, ) } } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/DailyEmotionUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/DailyEmotionUiModel.kt new file mode 100644 index 00000000..c6cd5121 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/DailyEmotionUiModel.kt @@ -0,0 +1,28 @@ +package com.threegap.bitnagil.presentation.home.model + +import com.threegap.bitnagil.domain.emotion.model.DailyEmotion +import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType + +data class DailyEmotionUiModel( + val type: EmotionMarbleType?, + val imageUrl: String, + val homeMessage: String, +) { + val hasEmotion: Boolean + get() = type != null + + companion object { + val INIT = DailyEmotionUiModel( + type = null, + imageUrl = "", + homeMessage = "", + ) + } +} + +internal fun DailyEmotion.toUiModel() = + DailyEmotionUiModel( + type = this.type, + imageUrl = this.imageUrl ?: "", + homeMessage = this.homeMessage?.let { "님,\n$it" } ?: "님, 오셨군요!\n오늘 기분은 어떤가요?", + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/DailyRoutinesUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/DailyRoutinesUiModel.kt index 295415b8..5099a92a 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/DailyRoutinesUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/DailyRoutinesUiModel.kt @@ -1,16 +1,13 @@ package com.threegap.bitnagil.presentation.home.model -import android.os.Parcelable import com.threegap.bitnagil.domain.routine.model.DailyRoutines -import kotlinx.parcelize.Parcelize -@Parcelize data class DailyRoutinesUiModel( - val routines: List = emptyList(), - val isAllCompleted: Boolean = false, -) : Parcelable + val routines: List, + val isAllCompleted: Boolean, +) -fun DailyRoutines.toUiModel(): DailyRoutinesUiModel = +internal fun DailyRoutines.toUiModel(): DailyRoutinesUiModel = DailyRoutinesUiModel( routines = routines.map { it.toUiModel() }, isAllCompleted = isAllCompleted, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineScheduleUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineScheduleUiModel.kt index 3304cfda..9966a0a6 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineScheduleUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineScheduleUiModel.kt @@ -1,17 +1,16 @@ package com.threegap.bitnagil.presentation.home.model -import android.os.Parcelable import com.threegap.bitnagil.domain.routine.model.RoutineSchedule -import kotlinx.parcelize.Parcelize -@Parcelize data class RoutineScheduleUiModel( - val dailyRoutines: Map = emptyMap(), -) : Parcelable + val dailyRoutines: Map, +) { + companion object { + val INIT = RoutineScheduleUiModel(dailyRoutines = emptyMap()) + } +} -fun RoutineSchedule.toUiModel(): RoutineScheduleUiModel = +internal fun RoutineSchedule.toUiModel(): RoutineScheduleUiModel = RoutineScheduleUiModel( - dailyRoutines = this.dailyRoutines.mapValues { (_, dayRoutines) -> - dayRoutines.toUiModel() - }, + dailyRoutines = this.dailyRoutines.mapValues { (_, dayRoutines) -> dayRoutines.toUiModel() }, ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineUiModel.kt index 6b8e73c4..07e56276 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/RoutineUiModel.kt @@ -1,12 +1,9 @@ package com.threegap.bitnagil.presentation.home.model -import android.os.Parcelable +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.routine.model.DayOfWeek -import com.threegap.bitnagil.domain.routine.model.RecommendedRoutineType import com.threegap.bitnagil.domain.routine.model.Routine -import kotlinx.parcelize.Parcelize -@Parcelize data class RoutineUiModel( val id: String, val name: String, @@ -16,10 +13,10 @@ data class RoutineUiModel( val isCompleted: Boolean, val subRoutineNames: List, val subRoutineCompletionStates: List, - val recommendedRoutineType: RecommendedRoutineType?, -) : Parcelable + val recommendedRoutineType: RecommendCategory?, +) -fun Routine.toUiModel(): RoutineUiModel = +internal fun Routine.toUiModel(): RoutineUiModel = RoutineUiModel( id = this.id, name = this.name, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/TodayEmotionUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/TodayEmotionUiModel.kt deleted file mode 100644 index eaa9e79e..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/home/model/TodayEmotionUiModel.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.threegap.bitnagil.presentation.home.model - -import android.os.Parcelable -import com.threegap.bitnagil.domain.emotion.model.TodayEmotion -import kotlinx.parcelize.Parcelize - -@Parcelize -data class TodayEmotionUiModel( - val imageUrl: String, - val homeMessage: String, -) : Parcelable - -fun TodayEmotion.toUiModel() = TodayEmotionUiModel( - imageUrl = this.imageUrl, - homeMessage = this.homeMessage, -) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginScreen.kt index ef41e7ba..f753ee89 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginScreen.kt @@ -31,8 +31,8 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple +import com.threegap.bitnagil.presentation.login.contract.LoginSideEffect import com.threegap.bitnagil.presentation.login.kakao.KakaoLoginHandlerImpl -import com.threegap.bitnagil.presentation.login.model.LoginSideEffect import org.orbitmvi.orbit.compose.collectSideEffect @Composable diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginViewModel.kt index a331890b..686f7d37 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginViewModel.kt @@ -5,8 +5,8 @@ import androidx.lifecycle.ViewModel import com.kakao.sdk.auth.model.OAuthToken import com.threegap.bitnagil.domain.auth.model.UserRole import com.threegap.bitnagil.domain.auth.usecase.LoginUseCase -import com.threegap.bitnagil.presentation.login.model.LoginSideEffect -import com.threegap.bitnagil.presentation.login.model.LoginState +import com.threegap.bitnagil.presentation.login.contract.LoginSideEffect +import com.threegap.bitnagil.presentation.login.contract.LoginState import dagger.hilt.android.lifecycle.HiltViewModel import org.orbitmvi.orbit.Container import org.orbitmvi.orbit.ContainerHost diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/contract/LoginSideEffect.kt similarity index 71% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/login/contract/LoginSideEffect.kt index 3876c792..ba5f64ef 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/contract/LoginSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.login.model +package com.threegap.bitnagil.presentation.login.contract sealed interface LoginSideEffect { data object NavigateToHome : LoginSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/contract/LoginState.kt similarity index 78% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/login/contract/LoginState.kt index e84d295b..13d451c4 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/login/contract/LoginState.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.login.model +package com.threegap.bitnagil.presentation.login.contract data class LoginState( val isLoading: Boolean, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageScreen.kt index dbab8ac1..0111e740 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageScreen.kt @@ -28,7 +28,7 @@ import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.atom.BitnagilIconButton import com.threegap.bitnagil.designsystem.component.block.BitnagilOptionButton import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar -import com.threegap.bitnagil.presentation.mypage.model.MyPageState +import com.threegap.bitnagil.presentation.mypage.contract.MyPageState import org.orbitmvi.orbit.compose.collectAsState @Composable diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageViewModel.kt index d9b591d1..3ab9725a 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/MyPageViewModel.kt @@ -2,8 +2,8 @@ package com.threegap.bitnagil.presentation.mypage import androidx.lifecycle.ViewModel import com.threegap.bitnagil.domain.user.usecase.FetchUserProfileUseCase -import com.threegap.bitnagil.presentation.mypage.model.MyPageSideEffect -import com.threegap.bitnagil.presentation.mypage.model.MyPageState +import com.threegap.bitnagil.presentation.mypage.contract.MyPageSideEffect +import com.threegap.bitnagil.presentation.mypage.contract.MyPageState import dagger.hilt.android.lifecycle.HiltViewModel import org.orbitmvi.orbit.Container import org.orbitmvi.orbit.ContainerHost @@ -14,7 +14,7 @@ import javax.inject.Inject class MyPageViewModel @Inject constructor( private val fetchUserProfileUseCase: FetchUserProfileUseCase, ) : ContainerHost, ViewModel() { - override val container: Container = container(initialState = MyPageState.Init) + override val container: Container = container(initialState = MyPageState.INIT) init { loadMyPageInfo() diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/contract/MyPageSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/contract/MyPageSideEffect.kt new file mode 100644 index 00000000..196446a0 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/contract/MyPageSideEffect.kt @@ -0,0 +1,3 @@ +package com.threegap.bitnagil.presentation.mypage.contract + +sealed interface MyPageSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/contract/MyPageState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/contract/MyPageState.kt new file mode 100644 index 00000000..76e68dfe --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/contract/MyPageState.kt @@ -0,0 +1,13 @@ +package com.threegap.bitnagil.presentation.mypage.contract + +data class MyPageState( + val name: String, + val profileUrl: String, +) { + companion object { + val INIT = MyPageState( + name = "", + profileUrl = "", + ) + } +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/model/MyPageSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/model/MyPageSideEffect.kt deleted file mode 100644 index a11e85c2..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/model/MyPageSideEffect.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.threegap.bitnagil.presentation.mypage.model - -sealed class MyPageSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/model/MyPageState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/model/MyPageState.kt deleted file mode 100644 index 0c17af7c..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/mypage/model/MyPageState.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.threegap.bitnagil.presentation.mypage.model - -data class MyPageState( - val name: String, - val profileUrl: String, -) { - companion object { - val Init = MyPageState(name = "", profileUrl = "") - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingScreen.kt index b781d995..39bff7ef 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingScreen.kt @@ -15,11 +15,11 @@ import com.threegap.bitnagil.presentation.common.toast.GlobalBitnagilToast import com.threegap.bitnagil.presentation.onboarding.component.template.OnBoardingAbstractTemplate import com.threegap.bitnagil.presentation.onboarding.component.template.OnBoardingIntroTemplate import com.threegap.bitnagil.presentation.onboarding.component.template.OnBoardingSelectTemplate -import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItem +import com.threegap.bitnagil.presentation.onboarding.contract.OnBoardingSideEffect +import com.threegap.bitnagil.presentation.onboarding.contract.OnBoardingState +import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItemUiModel import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingPageInfo import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingSetType -import com.threegap.bitnagil.presentation.onboarding.model.mvi.OnBoardingSideEffect -import com.threegap.bitnagil.presentation.onboarding.model.mvi.OnBoardingState import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect @@ -163,7 +163,7 @@ fun OnBoardingScreenPreview() { nextButtonEnable = false, currentOnBoardingPageInfo = OnBoardingPageInfo.RecommendRoutines( listOf( - OnBoardingItem("1", "루틴명", "세부 루틴 한 줄 설명", null), + OnBoardingItemUiModel("1", "루틴명", "세부 루틴 한 줄 설명", null), ), ), totalStep = 5, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingViewModel.kt index 7723bc1f..76191453 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/OnBoardingViewModel.kt @@ -9,13 +9,13 @@ import com.threegap.bitnagil.domain.onboarding.usecase.GetRecommendOnBoardingRou import com.threegap.bitnagil.domain.onboarding.usecase.GetUserOnBoardingUseCase import com.threegap.bitnagil.domain.onboarding.usecase.RegisterRecommendOnBoardingRoutinesUseCase import com.threegap.bitnagil.domain.user.usecase.FetchUserProfileUseCase -import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingAbstractTextItem -import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItem +import com.threegap.bitnagil.presentation.onboarding.contract.OnBoardingSideEffect +import com.threegap.bitnagil.presentation.onboarding.contract.OnBoardingState +import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItemUiModel import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingPageInfo import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingSetType -import com.threegap.bitnagil.presentation.onboarding.model.mvi.OnBoardingSideEffect -import com.threegap.bitnagil.presentation.onboarding.model.mvi.OnBoardingState import com.threegap.bitnagil.presentation.onboarding.model.navarg.OnBoardingScreenArg +import com.threegap.bitnagil.presentation.onboarding.model.toUiModel import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject @@ -100,9 +100,7 @@ class OnBoardingViewModel @AssistedInject constructor( val abstractPagePrefixText = onBoardingAbstract.prefix val abstractTexts = onBoardingAbstract.abstractTexts.map { onBoardingAbstractText -> - onBoardingAbstractText.textItems.map { onBoardingAbstractTextItem -> - OnBoardingAbstractTextItem.fromOnBoardingAbstractTextItem(onBoardingAbstractTextItem) - } + onBoardingAbstractText.textItems.map { it.toUiModel() } } val existedOnBoardingAbstract = OnBoardingPageInfo.ExistedOnBoardingAbstract( @@ -125,9 +123,7 @@ class OnBoardingViewModel @AssistedInject constructor( fun loadOnBoardingItems() = intent { val onBoardings = getOnBoardingsUseCase() - val onBoardingPages = onBoardings.map { onBoarding -> - OnBoardingPageInfo.SelectOnBoarding.fromOnBoarding(onBoarding = onBoarding) - } + val onBoardingPages = onBoardings.map { it.toUiModel() } val currentState = state if (currentState !is OnBoardingState.Idle) return@intent @@ -175,9 +171,7 @@ class OnBoardingViewModel @AssistedInject constructor( val abstractPagePrefixText = onBoardingAbstract.prefix val abstractTexts = onBoardingAbstract.abstractTexts.map { onBoardingAbstractText -> - onBoardingAbstractText.textItems.map { onBoardingAbstractTextItem -> - OnBoardingAbstractTextItem.fromOnBoardingAbstractTextItem(onBoardingAbstractTextItem) - } + onBoardingAbstractText.textItems.map { it.toUiModel() } } reduce { @@ -291,9 +285,7 @@ class OnBoardingViewModel @AssistedInject constructor( onSuccess = { recommendRoutines -> if (isActive) { applyRecommendRoutines( - routines = recommendRoutines.map { - OnBoardingItem.fromOnBoardingRecommendRoutine(it) - }, + routines = recommendRoutines.map { it.toUiModel() }, ) } }, @@ -303,7 +295,7 @@ class OnBoardingViewModel @AssistedInject constructor( } } - private fun applyRecommendRoutines(routines: List) = intent { + private fun applyRecommendRoutines(routines: List) = intent { val currentState = state if (currentState !is OnBoardingState.Idle) return@intent diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingAbstractTemplate.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingAbstractTemplate.kt index 9c07d7e0..5c92dc8d 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingAbstractTemplate.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingAbstractTemplate.kt @@ -38,14 +38,14 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton import com.threegap.bitnagil.presentation.common.ninepatch.ninePatchBackgroundNode -import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingAbstractTextItem +import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingAbstractTextItemUiModel @Composable fun OnBoardingAbstractTemplate( modifier: Modifier = Modifier, title: String, userName: String, - onBoardingAbstractTexts: List>, + onBoardingAbstractTexts: List>, onDispose: () -> Unit, onClickNextButton: () -> Unit, nextButtonEnable: Boolean, @@ -120,7 +120,7 @@ private fun getIndexIconResourceId(index: Int): Int { @Composable private fun OnBoardingAbstractText( - onBoardingAbstractTextList: List, + onBoardingAbstractTextList: List, iconResourceId: Int, ) { val annotatedString = buildAnnotatedString { @@ -214,31 +214,31 @@ private fun OnBoardingAbstractTemplatePreview() { userName = "안드로이드", onBoardingAbstractTexts = listOf( listOf( - OnBoardingAbstractTextItem( + OnBoardingAbstractTextItemUiModel( text = "텍스트1", isBold = true, ), - OnBoardingAbstractTextItem( + OnBoardingAbstractTextItemUiModel( text = "텍스트2 아아아아아아아아아ㅏ아앙아아ㅏ아아아아아", isBold = false, ), ), listOf( - OnBoardingAbstractTextItem( + OnBoardingAbstractTextItemUiModel( text = "텍스트1", isBold = true, ), - OnBoardingAbstractTextItem( + OnBoardingAbstractTextItemUiModel( text = "텍스트2", isBold = false, ), ), listOf( - OnBoardingAbstractTextItem( + OnBoardingAbstractTextItemUiModel( text = "텍스트1", isBold = true, ), - OnBoardingAbstractTextItem( + OnBoardingAbstractTextItemUiModel( text = "텍스트2", isBold = false, ), diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingSelectTemplate.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingSelectTemplate.kt index 64dbf04d..c0305dd7 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingSelectTemplate.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/OnBoardingSelectTemplate.kt @@ -16,14 +16,14 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.component.atom.BitnagilSelectButton import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButtonColor -import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItem +import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItemUiModel @Composable fun OnBoardingSelectTemplate( modifier: Modifier = Modifier, title: String, subText: String? = null, - items: List, + items: List, nextButtonEnable: Boolean = false, onClickNextButton: () -> Unit, onClickItem: ((String) -> Unit)?, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/Preview.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/Preview.kt index 78aeaf80..def6e45c 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/Preview.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/component/template/Preview.kt @@ -2,7 +2,7 @@ package com.threegap.bitnagil.presentation.onboarding.component.template import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview -import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItem +import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingItemUiModel @Preview(showBackground = true) @Composable @@ -11,22 +11,22 @@ fun OnBoardingTemplatePreview() { title = "title", subText = "subText", items = listOf( - OnBoardingItem( + OnBoardingItemUiModel( id = "item1", title = "title1", description = "description1", ), - OnBoardingItem( + OnBoardingItemUiModel( id = "item2", title = "title2", description = "description2", ), - OnBoardingItem( + OnBoardingItemUiModel( id = "item3", title = "title3", description = "description3", ), - OnBoardingItem( + OnBoardingItemUiModel( id = "item4", title = "title4", description = "description4", diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/contract/OnBoardingSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/contract/OnBoardingSideEffect.kt new file mode 100644 index 00000000..6f17298d --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/contract/OnBoardingSideEffect.kt @@ -0,0 +1,7 @@ +package com.threegap.bitnagil.presentation.onboarding.contract + +sealed interface OnBoardingSideEffect { + data object MoveToPreviousScreen : OnBoardingSideEffect + data object NavigateToHomeScreen : OnBoardingSideEffect + data class ShowToast(val message: String) : OnBoardingSideEffect +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/mvi/OnBoardingState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/contract/OnBoardingState.kt similarity index 93% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/mvi/OnBoardingState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/contract/OnBoardingState.kt index 99932577..7f8f76b4 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/mvi/OnBoardingState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/contract/OnBoardingState.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.onboarding.model.mvi +package com.threegap.bitnagil.presentation.onboarding.contract import android.os.Parcelable import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingPageInfo diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingAbstractTextItem.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingAbstractTextItem.kt deleted file mode 100644 index c1310e62..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingAbstractTextItem.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.threegap.bitnagil.presentation.onboarding.model - -import android.os.Parcelable -import kotlinx.parcelize.Parcelize -import com.threegap.bitnagil.domain.onboarding.model.OnBoardingAbstractTextItem as DomainOnBoardingAbstractTextItem - -@Parcelize -data class OnBoardingAbstractTextItem( - val text: String, - val isBold: Boolean, -) : Parcelable { - companion object { - fun fromOnBoardingAbstractTextItem(onBoardingAbstractTextItem: DomainOnBoardingAbstractTextItem): OnBoardingAbstractTextItem { - return OnBoardingAbstractTextItem( - text = onBoardingAbstractTextItem.text, - isBold = onBoardingAbstractTextItem.isBold, - ) - } - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingAbstractTextItemUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingAbstractTextItemUiModel.kt new file mode 100644 index 00000000..08b5debe --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingAbstractTextItemUiModel.kt @@ -0,0 +1,17 @@ +package com.threegap.bitnagil.presentation.onboarding.model + +import android.os.Parcelable +import com.threegap.bitnagil.domain.onboarding.model.OnBoardingAbstractTextItem +import kotlinx.parcelize.Parcelize + +@Parcelize +data class OnBoardingAbstractTextItemUiModel( + val text: String, + val isBold: Boolean, +) : Parcelable + +internal fun OnBoardingAbstractTextItem.toUiModel(): OnBoardingAbstractTextItemUiModel = + OnBoardingAbstractTextItemUiModel( + text = this.text, + isBold = this.isBold, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingItem.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingItem.kt deleted file mode 100644 index 116dce3a..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingItem.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.threegap.bitnagil.presentation.onboarding.model - -import android.os.Parcelable -import com.threegap.bitnagil.domain.onboarding.model.OnBoardingRecommendRoutine -import kotlinx.parcelize.Parcelize -import com.threegap.bitnagil.domain.onboarding.model.OnBoardingItem as DomainOnBoardingItem - -@Parcelize -data class OnBoardingItem( - val id: String, - val title: String, - val description: String?, - val selectedIndex: Int? = null, -) : Parcelable { - companion object { - fun fromOnBoardingItem(onBoardingItem: DomainOnBoardingItem): OnBoardingItem { - return OnBoardingItem( - id = onBoardingItem.id, - title = onBoardingItem.title, - description = onBoardingItem.description, - selectedIndex = null, - ) - } - - fun fromOnBoardingRecommendRoutine(onBoardingRecommendRoutine: OnBoardingRecommendRoutine): OnBoardingItem { - return OnBoardingItem( - id = onBoardingRecommendRoutine.id, - title = onBoardingRecommendRoutine.name, - description = onBoardingRecommendRoutine.description, - selectedIndex = null, - ) - } - } - - val selected: Boolean get() = selectedIndex != null -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingItemUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingItemUiModel.kt new file mode 100644 index 00000000..0f265884 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingItemUiModel.kt @@ -0,0 +1,33 @@ +package com.threegap.bitnagil.presentation.onboarding.model + +import android.os.Parcelable +import com.threegap.bitnagil.domain.onboarding.model.OnBoardingItem +import com.threegap.bitnagil.domain.onboarding.model.OnBoardingRecommendRoutine +import kotlinx.parcelize.Parcelize + +@Parcelize +data class OnBoardingItemUiModel( + val id: String, + val title: String, + val description: String?, + val selectedIndex: Int? = null, +) : Parcelable { + val selected: Boolean + get() = selectedIndex != null +} + +internal fun OnBoardingItem.toUiModel(): OnBoardingItemUiModel = + OnBoardingItemUiModel( + id = this.id, + title = this.title, + description = this.description, + selectedIndex = null, + ) + +internal fun OnBoardingRecommendRoutine.toUiModel(): OnBoardingItemUiModel = + OnBoardingItemUiModel( + id = this.id, + title = this.name, + description = this.description, + selectedIndex = null, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingPageInfo.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingPageInfo.kt index 72eee88c..a0dd4ad2 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingPageInfo.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/OnBoardingPageInfo.kt @@ -3,6 +3,7 @@ package com.threegap.bitnagil.presentation.onboarding.model import android.os.Parcelable import androidx.compose.runtime.Stable import com.threegap.bitnagil.domain.onboarding.model.OnBoarding +import com.threegap.bitnagil.presentation.onboarding.model.OnBoardingPageInfo.SelectOnBoarding import kotlinx.parcelize.Parcelize @Parcelize @@ -13,7 +14,7 @@ sealed class OnBoardingPageInfo : Parcelable { @Parcelize data class ExistedOnBoardingAbstract( val prefix: String, - @Stable val abstractTexts: List>, + @Stable val abstractTexts: List>, ) : OnBoardingPageInfo() @Parcelize @@ -21,22 +22,10 @@ sealed class OnBoardingPageInfo : Parcelable { val id: String, val title: String, val description: String?, - @Stable val items: List = emptyList(), + @Stable val items: List = emptyList(), val multipleSelectable: Boolean = false, ) : OnBoardingPageInfo() { companion object { - fun fromOnBoarding(onBoarding: OnBoarding): SelectOnBoarding { - return SelectOnBoarding( - id = onBoarding.id, - title = onBoarding.title, - description = onBoarding.description, - items = onBoarding.onboardingItemList.map { - OnBoardingItem.fromOnBoardingItem(it) - }, - multipleSelectable = onBoarding.multipleSelectable, - ) - } - private var lastSelectedIndex = 0 } @@ -68,11 +57,11 @@ sealed class OnBoardingPageInfo : Parcelable { @Parcelize data class Abstract( val prefix: String, - @Stable val abstractTexts: List>, + @Stable val abstractTexts: List>, ) : OnBoardingPageInfo() @Parcelize - data class RecommendRoutines(@Stable val routines: List) : OnBoardingPageInfo() { + data class RecommendRoutines(@Stable val routines: List) : OnBoardingPageInfo() { companion object { private var lastSelectedIndex = 0 } @@ -98,3 +87,12 @@ sealed class OnBoardingPageInfo : Parcelable { } } } + +internal fun OnBoarding.toUiModel(): SelectOnBoarding = + SelectOnBoarding( + id = this.id, + title = this.title, + description = this.description, + items = this.onboardingItemList.map { it.toUiModel() }, + multipleSelectable = this.multipleSelectable, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/mvi/OnBoardingSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/mvi/OnBoardingSideEffect.kt deleted file mode 100644 index e02b5efe..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/onboarding/model/mvi/OnBoardingSideEffect.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.threegap.bitnagil.presentation.onboarding.model.mvi - -sealed class OnBoardingSideEffect { - data object MoveToPreviousScreen : OnBoardingSideEffect() - data object NavigateToHomeScreen : OnBoardingSideEffect() - data class ShowToast(val message: String) : OnBoardingSideEffect() -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineScreen.kt index b5370056..68323038 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineScreen.kt @@ -40,8 +40,8 @@ import com.threegap.bitnagil.presentation.recommendroutine.component.block.Emoti import com.threegap.bitnagil.presentation.recommendroutine.component.block.RecommendRoutineItem import com.threegap.bitnagil.presentation.recommendroutine.component.template.EmptyRecommendRoutineView import com.threegap.bitnagil.presentation.recommendroutine.component.template.RecommendLevelBottomSheet -import com.threegap.bitnagil.presentation.recommendroutine.model.RecommendRoutineSideEffect -import com.threegap.bitnagil.presentation.recommendroutine.model.RecommendRoutineState +import com.threegap.bitnagil.presentation.recommendroutine.contract.RecommendRoutineSideEffect +import com.threegap.bitnagil.presentation.recommendroutine.contract.RecommendRoutineState import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineViewModel.kt index 00a5b072..dc663b41 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/RecommendRoutineViewModel.kt @@ -6,8 +6,8 @@ import com.threegap.bitnagil.domain.emotion.usecase.GetEmotionChangeEventFlowUse import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel import com.threegap.bitnagil.domain.recommendroutine.usecase.FetchRecommendRoutinesUseCase -import com.threegap.bitnagil.presentation.recommendroutine.model.RecommendRoutineSideEffect -import com.threegap.bitnagil.presentation.recommendroutine.model.RecommendRoutineState +import com.threegap.bitnagil.presentation.recommendroutine.contract.RecommendRoutineSideEffect +import com.threegap.bitnagil.presentation.recommendroutine.contract.RecommendRoutineState import com.threegap.bitnagil.presentation.recommendroutine.model.RecommendRoutineUiModel import com.threegap.bitnagil.presentation.recommendroutine.model.RecommendRoutinesUiModel import com.threegap.bitnagil.presentation.recommendroutine.model.toUiModel @@ -32,7 +32,7 @@ class RecommendRoutineViewModel @Inject constructor( observeEmotionChangeEvent() } - private var recommendRoutines: RecommendRoutinesUiModel = RecommendRoutinesUiModel() + private var recommendRoutines: RecommendRoutinesUiModel = RecommendRoutinesUiModel.INIT fun updateRoutineCategory(category: RecommendCategory) { intent { diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/component/block/RecommendRoutineItem.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/component/block/RecommendRoutineItem.kt index 7544b8bb..0adfaefd 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/component/block/RecommendRoutineItem.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/component/block/RecommendRoutineItem.kt @@ -49,11 +49,11 @@ fun RecommendRoutineItem( verticalAlignment = Alignment.CenterVertically, ) { BitnagilIcon( - id = routine.recommendedRoutineType?.displayIcon ?: R.drawable.ic_shine, + id = routine.category?.displayIcon ?: R.drawable.ic_shine, tint = null, modifier = Modifier .background( - color = routine.recommendedRoutineType?.displayColor ?: BitnagilTheme.colors.yellow10, + color = routine.category?.displayColor ?: BitnagilTheme.colors.yellow10, shape = RoundedCornerShape(4.dp), ) .padding(4.dp), @@ -75,7 +75,7 @@ fun RecommendRoutineItem( ) } - if (routine.recommendSubRoutines.isNotEmpty()) { + if (routine.subRoutines.isNotEmpty()) { HorizontalDivider( thickness = 1.dp, color = BitnagilTheme.colors.coolGray97, @@ -93,7 +93,7 @@ fun RecommendRoutineItem( style = BitnagilTheme.typography.body2Medium, ) - routine.recommendSubRoutines.forEach { subRoutine -> + routine.subRoutines.forEach { subRoutine -> Text( text = "• ${subRoutine.name}", color = BitnagilTheme.colors.coolGray40, @@ -113,8 +113,8 @@ private fun RecommendRoutineItemPreview() { id = 1, name = "개운하게 일어나기", level = RecommendLevel.LEVEL1, - recommendedRoutineType = RecommendCategory.WAKE_UP, - recommendSubRoutines = listOf( + category = RecommendCategory.WAKE_UP, + subRoutines = listOf( RecommendSubRoutineUiModel( id = 1, name = "일어나기", @@ -133,8 +133,8 @@ private fun EmptySubRoutineRecommendRoutineItemPreview() { id = 1, name = "개운하게 일어나기", level = RecommendLevel.LEVEL1, - recommendedRoutineType = RecommendCategory.WAKE_UP, - recommendSubRoutines = emptyList(), + category = RecommendCategory.WAKE_UP, + subRoutines = emptyList(), ), onAddRoutineClick = {}, ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/contract/RecommendRoutineSideEffect.kt similarity index 74% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/contract/RecommendRoutineSideEffect.kt index 61c49a4c..2b170381 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/contract/RecommendRoutineSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.recommendroutine.model +package com.threegap.bitnagil.presentation.recommendroutine.contract sealed interface RecommendRoutineSideEffect { data object NavigateToEmotion : RecommendRoutineSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/contract/RecommendRoutineState.kt similarity index 80% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/contract/RecommendRoutineState.kt index 6b9e95b9..e206eca9 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/contract/RecommendRoutineState.kt @@ -1,8 +1,9 @@ -package com.threegap.bitnagil.presentation.recommendroutine.model +package com.threegap.bitnagil.presentation.recommendroutine.contract -import com.threegap.bitnagil.domain.recommendroutine.model.EmotionMarbleType +import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel +import com.threegap.bitnagil.presentation.recommendroutine.model.RecommendRoutineUiModel data class RecommendRoutineState( val isLoading: Boolean, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineUiModel.kt index 770207a5..8e1982de 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineUiModel.kt @@ -1,25 +1,22 @@ package com.threegap.bitnagil.presentation.recommendroutine.model -import android.os.Parcelable import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutine -import kotlinx.parcelize.Parcelize -@Parcelize data class RecommendRoutineUiModel( - val id: Int = 0, - val name: String = "", - val level: RecommendLevel? = null, - val recommendedRoutineType: RecommendCategory? = null, - val recommendSubRoutines: List = emptyList(), -) : Parcelable + val id: Long, + val name: String, + val level: RecommendLevel?, + val category: RecommendCategory?, + val subRoutines: List, +) -fun RecommendRoutine.toUiModel() = +internal fun RecommendRoutine.toUiModel(): RecommendRoutineUiModel = RecommendRoutineUiModel( id = this.id, name = this.name, level = this.level, - recommendedRoutineType = this.recommendedRoutineType, - recommendSubRoutines = this.recommendSubRoutines.map { it.toUiModel() }, + category = this.category, + subRoutines = this.subRoutines.map { it.toUiModel() }, ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutinesUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutinesUiModel.kt index ef8c98e8..c6f270a1 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutinesUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutinesUiModel.kt @@ -1,18 +1,22 @@ package com.threegap.bitnagil.presentation.recommendroutine.model -import android.os.Parcelable -import com.threegap.bitnagil.domain.recommendroutine.model.EmotionMarbleType +import com.threegap.bitnagil.domain.emotion.model.EmotionMarbleType import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutines -import kotlinx.parcelize.Parcelize -@Parcelize data class RecommendRoutinesUiModel( - val recommendRoutinesByCategory: Map> = emptyMap(), - val emotionMarbleType: EmotionMarbleType? = null, -) : Parcelable + val recommendRoutinesByCategory: Map>, + val emotionMarbleType: EmotionMarbleType?, +) { + companion object { + val INIT = RecommendRoutinesUiModel( + recommendRoutinesByCategory = emptyMap(), + emotionMarbleType = null, + ) + } +} -fun RecommendRoutines.toUiModel() = +internal fun RecommendRoutines.toUiModel(): RecommendRoutinesUiModel = RecommendRoutinesUiModel( recommendRoutinesByCategory = this.recommendRoutinesByCategory.mapValues { (_, routines) -> routines.map { it.toUiModel() } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendSubRoutineUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendSubRoutineUiModel.kt index ee33f574..043a1458 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendSubRoutineUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendSubRoutineUiModel.kt @@ -1,16 +1,13 @@ package com.threegap.bitnagil.presentation.recommendroutine.model -import android.os.Parcelable import com.threegap.bitnagil.domain.recommendroutine.model.RecommendSubRoutine -import kotlinx.parcelize.Parcelize -@Parcelize data class RecommendSubRoutineUiModel( - val id: Int = 0, - val name: String = "", -) : Parcelable + val id: Long, + val name: String, +) -fun RecommendSubRoutine.toUiModel() = +internal fun RecommendSubRoutine.toUiModel(): RecommendSubRoutineUiModel = RecommendSubRoutineUiModel( id = this.id, name = this.name, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportScreen.kt index cec60de3..4caf654d 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportScreen.kt @@ -53,6 +53,7 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButtonColor import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextField import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar +import com.threegap.bitnagil.presentation.common.extension.displayTitle import com.threegap.bitnagil.presentation.common.file.createCameraImageUri import com.threegap.bitnagil.presentation.common.premission.rememberPermissionHandler import com.threegap.bitnagil.presentation.report.component.AddPhotoButton @@ -64,11 +65,10 @@ import com.threegap.bitnagil.presentation.report.component.ReportCategorySelecto import com.threegap.bitnagil.presentation.report.component.ReportField import com.threegap.bitnagil.presentation.report.component.template.CompleteReportContent import com.threegap.bitnagil.presentation.report.component.template.SubmittingReportContent -import com.threegap.bitnagil.presentation.report.model.ReportSideEffect -import com.threegap.bitnagil.presentation.report.model.ReportState -import com.threegap.bitnagil.presentation.report.model.ReportState.Companion.MAX_IMAGE_COUNT +import com.threegap.bitnagil.presentation.report.contract.ReportSideEffect +import com.threegap.bitnagil.presentation.report.contract.ReportState +import com.threegap.bitnagil.presentation.report.contract.ReportState.Companion.MAX_IMAGE_COUNT import com.threegap.bitnagil.presentation.report.model.SubmitState -import com.threegap.bitnagil.presentation.report.model.uiTitle import kotlinx.coroutines.delay import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect @@ -284,7 +284,7 @@ private fun ReportScreen( ReportField(title = "카테고리") { ReportCategorySelector( - title = uiState.selectedCategory?.uiTitle, + title = uiState.selectedCategory?.displayTitle, onClick = { focusManager.clearFocus() onShowReportCategoryBottomSheet() diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportViewModel.kt index 761dff11..fc653fad 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/ReportViewModel.kt @@ -9,9 +9,9 @@ import com.threegap.bitnagil.domain.report.model.Report import com.threegap.bitnagil.domain.report.model.ReportCategory import com.threegap.bitnagil.domain.report.usecase.SubmitReportUseCase import com.threegap.bitnagil.presentation.common.file.convertUriToImageFile -import com.threegap.bitnagil.presentation.report.model.ReportSideEffect -import com.threegap.bitnagil.presentation.report.model.ReportState -import com.threegap.bitnagil.presentation.report.model.ReportState.Companion.MAX_IMAGE_COUNT +import com.threegap.bitnagil.presentation.report.contract.ReportSideEffect +import com.threegap.bitnagil.presentation.report.contract.ReportState +import com.threegap.bitnagil.presentation.report.contract.ReportState.Companion.MAX_IMAGE_COUNT import com.threegap.bitnagil.presentation.report.model.SubmitState import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.qualifiers.ApplicationContext diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/CompleteReportCard.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/CompleteReportCard.kt index 8b29abfc..0d8efc66 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/CompleteReportCard.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/CompleteReportCard.kt @@ -23,7 +23,7 @@ import androidx.compose.ui.unit.dp import coil3.compose.AsyncImage import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.domain.report.model.ReportCategory -import com.threegap.bitnagil.presentation.report.model.uiTitle +import com.threegap.bitnagil.presentation.common.extension.displayTitle @Composable fun CompleteReportCard( @@ -66,7 +66,7 @@ fun CompleteReportCard( title = "카테고리", ) { Text( - text = category?.uiTitle ?: "카테고리 없음", + text = category?.displayTitle ?: "카테고리 없음", color = BitnagilTheme.colors.coolGray10, style = BitnagilTheme.typography.body1Medium, ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/ReportCategoryBottomSheet.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/ReportCategoryBottomSheet.kt index 8a4ea0d1..7b1a96cc 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/ReportCategoryBottomSheet.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/ReportCategoryBottomSheet.kt @@ -24,9 +24,9 @@ import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple import com.threegap.bitnagil.domain.report.model.ReportCategory -import com.threegap.bitnagil.presentation.report.model.iconRes -import com.threegap.bitnagil.presentation.report.model.uiDescription -import com.threegap.bitnagil.presentation.report.model.uiTitle +import com.threegap.bitnagil.presentation.common.extension.displayExamples +import com.threegap.bitnagil.presentation.common.extension.displayTitle +import com.threegap.bitnagil.presentation.common.extension.iconRes import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) @@ -54,8 +54,8 @@ fun ReportCategoryBottomSheet( categories.forEachIndexed { index, category -> ReportCategoryItem( icon = category.iconRes, - title = category.uiTitle, - description = category.uiDescription, + title = category.displayTitle, + description = category.displayExamples, isSelected = selectedCategory == category, onClick = { onSelected(category) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/template/CompleteReportContent.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/template/CompleteReportContent.kt index 8a819ebb..c1bcad01 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/template/CompleteReportContent.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/component/template/CompleteReportContent.kt @@ -25,7 +25,7 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButtonColor import com.threegap.bitnagil.presentation.report.component.CompleteReportCard -import com.threegap.bitnagil.presentation.report.model.ReportState +import com.threegap.bitnagil.presentation.report.contract.ReportState @Composable fun CompleteReportContent( diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/contract/ReportSideEffect.kt similarity index 70% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/report/contract/ReportSideEffect.kt index c3374c47..348a6d5a 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/contract/ReportSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.report.model +package com.threegap.bitnagil.presentation.report.contract sealed interface ReportSideEffect { data object NavigateToBack : ReportSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/contract/ReportState.kt similarity index 92% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/report/contract/ReportState.kt index 4676d8b0..cf39b3d9 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/report/model/ReportState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/report/contract/ReportState.kt @@ -1,7 +1,8 @@ -package com.threegap.bitnagil.presentation.report.model +package com.threegap.bitnagil.presentation.report.contract import android.net.Uri import com.threegap.bitnagil.domain.report.model.ReportCategory +import com.threegap.bitnagil.presentation.report.model.SubmitState data class ReportState( val reportImages: List, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailScreen.kt index 96ed075e..1fdfe9d4 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailScreen.kt @@ -27,9 +27,10 @@ import coil3.compose.AsyncImage import coil3.request.ImageRequest import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar +import com.threegap.bitnagil.presentation.common.extension.displayTitle import com.threegap.bitnagil.presentation.reportdetail.component.atom.ReportProcessBadge import com.threegap.bitnagil.presentation.reportdetail.component.block.ReportDetailLabeledContent -import com.threegap.bitnagil.presentation.reportdetail.model.mvi.ReportDetailState +import com.threegap.bitnagil.presentation.reportdetail.contract.ReportDetailState import com.threegap.bitnagil.presentation.reportdetail.util.toPresentationFormatInReportDetail import org.orbitmvi.orbit.compose.collectAsState @@ -74,7 +75,7 @@ private fun ReportDetailScreen( ) { Spacer(modifier = Modifier.height(20.dp)) - ReportProcessBadge(reportProcess = state.reportProcess) + ReportProcessBadge(reportStatus = state.reportProcess) Spacer(modifier = Modifier.height(6.dp)) @@ -116,7 +117,7 @@ private fun ReportDetailScreen( ReportDetailLabeledContent( label = "카테고리", - content = state.reportCategory.title, + content = state.reportCategory.displayTitle, ) ReportDetailLabeledContent( diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailViewModel.kt index d28ddc4d..532fe214 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/ReportDetailViewModel.kt @@ -2,10 +2,8 @@ package com.threegap.bitnagil.presentation.reportdetail import androidx.lifecycle.ViewModel import com.threegap.bitnagil.domain.report.usecase.GetReportUseCase -import com.threegap.bitnagil.presentation.reportdetail.model.ReportCategory -import com.threegap.bitnagil.presentation.reportdetail.model.ReportProcess -import com.threegap.bitnagil.presentation.reportdetail.model.mvi.ReportDetailSideEffect -import com.threegap.bitnagil.presentation.reportdetail.model.mvi.ReportDetailState +import com.threegap.bitnagil.presentation.reportdetail.contract.ReportDetailSideEffect +import com.threegap.bitnagil.presentation.reportdetail.contract.ReportDetailState import com.threegap.bitnagil.presentation.reportdetail.model.navarg.ReportDetailScreenArg import dagger.assisted.Assisted import dagger.assisted.AssistedFactory @@ -36,10 +34,10 @@ class ReportDetailViewModel @AssistedInject constructor( onSuccess = { reportDetail -> reduce { state.copy( - reportProcess = ReportProcess.fromDomain(reportDetail.status), + reportProcess = reportDetail.status, reportTitle = reportDetail.title, reportContent = reportDetail.content, - reportCategory = ReportCategory.fromDomain(reportDetail.category), + reportCategory = reportDetail.category, imageUrls = reportDetail.imageUrls, location = reportDetail.address, date = reportDetail.date, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/component/atom/ReportProcessBadge.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/component/atom/ReportProcessBadge.kt index 9977e533..e2e1a3d5 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/component/atom/ReportProcessBadge.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/component/atom/ReportProcessBadge.kt @@ -8,43 +8,32 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.threegap.bitnagil.designsystem.BitnagilTheme -import com.threegap.bitnagil.presentation.reportdetail.model.ReportProcess +import com.threegap.bitnagil.domain.report.model.ReportStatus +import com.threegap.bitnagil.presentation.common.extension.badgeBackgroundColor +import com.threegap.bitnagil.presentation.common.extension.displayTitle +import com.threegap.bitnagil.presentation.common.extension.textColor @Composable fun ReportProcessBadge( modifier: Modifier = Modifier, - reportProcess: ReportProcess, + reportStatus: ReportStatus, ) { Text( - text = reportProcess.title, + text = reportStatus.displayTitle, style = BitnagilTheme.typography.caption1SemiBold, - color = reportProcess.getProcessBadgeTextColor(), + color = reportStatus.textColor, modifier = modifier - .background(color = reportProcess.getProcessBadgeBackgroundColor(), shape = RoundedCornerShape(6.dp)) + .background( + color = reportStatus.badgeBackgroundColor, + shape = RoundedCornerShape(6.dp), + ) .padding(horizontal = 10.dp, vertical = 4.dp), ) } -@Composable -private fun ReportProcess.getProcessBadgeBackgroundColor(): Color = - when (this) { - ReportProcess.Reported -> BitnagilTheme.colors.green10 - ReportProcess.Progress -> BitnagilTheme.colors.skyBlue10 - else -> BitnagilTheme.colors.coolGray95 - } - -@Composable -private fun ReportProcess.getProcessBadgeTextColor(): Color = - when (this) { - ReportProcess.Reported -> BitnagilTheme.colors.green300 - ReportProcess.Progress -> BitnagilTheme.colors.blue300 - else -> BitnagilTheme.colors.coolGray40 - } - @Composable @Preview private fun ReportProcessBadgePreview() { @@ -52,9 +41,9 @@ private fun ReportProcessBadgePreview() { Column( verticalArrangement = Arrangement.spacedBy(4.dp), ) { - ReportProcessBadge(reportProcess = ReportProcess.Progress) - ReportProcessBadge(reportProcess = ReportProcess.Reported) - ReportProcessBadge(reportProcess = ReportProcess.Complete) + ReportProcessBadge(reportStatus = ReportStatus.PENDING) + ReportProcessBadge(reportStatus = ReportStatus.IN_PROGRESS) + ReportProcessBadge(reportStatus = ReportStatus.COMPLETED) } } } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/contract/ReportDetailSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/contract/ReportDetailSideEffect.kt new file mode 100644 index 00000000..6cdb8a22 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/contract/ReportDetailSideEffect.kt @@ -0,0 +1,3 @@ +package com.threegap.bitnagil.presentation.reportdetail.contract + +interface ReportDetailSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/mvi/ReportDetailState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/contract/ReportDetailState.kt similarity index 56% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/mvi/ReportDetailState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/contract/ReportDetailState.kt index 834a5a9f..66292845 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/mvi/ReportDetailState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/contract/ReportDetailState.kt @@ -1,11 +1,11 @@ -package com.threegap.bitnagil.presentation.reportdetail.model.mvi +package com.threegap.bitnagil.presentation.reportdetail.contract -import com.threegap.bitnagil.presentation.reportdetail.model.ReportCategory -import com.threegap.bitnagil.presentation.reportdetail.model.ReportProcess +import com.threegap.bitnagil.domain.report.model.ReportCategory +import com.threegap.bitnagil.domain.report.model.ReportStatus import java.time.LocalDate data class ReportDetailState( - val reportProcess: ReportProcess, + val reportProcess: ReportStatus, val reportTitle: String, val reportContent: String, val reportCategory: ReportCategory, @@ -15,10 +15,10 @@ data class ReportDetailState( ) { companion object { val Init = ReportDetailState( - reportProcess = ReportProcess.Reported, + reportProcess = ReportStatus.PENDING, reportTitle = "", reportContent = "", - reportCategory = ReportCategory.TrafficFacilities, + reportCategory = ReportCategory.TRANSPORTATION, imageUrls = emptyList(), location = "", date = LocalDate.now(), diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportCategory.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportCategory.kt deleted file mode 100644 index 96a91f1d..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportCategory.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.threegap.bitnagil.presentation.reportdetail.model -import com.threegap.bitnagil.domain.report.model.ReportCategory as DomainReportCategory - -enum class ReportCategory( - val title: String, -) { - TrafficFacilities( - title = "교통 시설", - ), - LightingFacilities( - title = "조명 시설", - ), - WaterFacilities( - title = "상하수도 시설", - ), - Amenities( - title = "편의 시설", - ), - ; - - companion object { - fun fromDomain(domainReportCategory: com.threegap.bitnagil.domain.report.model.ReportCategory): ReportCategory { - return when (domainReportCategory) { - DomainReportCategory.TRANSPORTATION -> TrafficFacilities - DomainReportCategory.LIGHTING -> LightingFacilities - DomainReportCategory.WATERFACILITY -> WaterFacilities - DomainReportCategory.AMENITY -> Amenities - } - } - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt deleted file mode 100644 index 96f889c0..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.threegap.bitnagil.presentation.reportdetail.model - -import com.threegap.bitnagil.domain.report.model.ReportStatus - -enum class ReportProcess( - val title: String, -) { - Reported(title = "제보 완료"), - Progress(title = "처리 중"), - Complete(title = "처리 완료"), - ; - - companion object { - fun fromDomain(status: ReportStatus): ReportProcess { - return when (status) { - ReportStatus.PENDING -> Reported - ReportStatus.IN_PROGRESS -> Progress - ReportStatus.COMPLETED -> Complete - } - } - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/mvi/ReportDetailSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/mvi/ReportDetailSideEffect.kt deleted file mode 100644 index 40bdd9b7..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/mvi/ReportDetailSideEffect.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.threegap.bitnagil.presentation.reportdetail.model.mvi - -interface ReportDetailSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryScreen.kt index a9280669..d84eb94d 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryScreen.kt @@ -32,15 +32,18 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilChip import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple +import com.threegap.bitnagil.domain.report.model.ReportCategory +import com.threegap.bitnagil.domain.report.model.ReportStatus +import com.threegap.bitnagil.presentation.common.extension.displayTitle import com.threegap.bitnagil.presentation.reporthistory.component.block.ReportHistoryItem import com.threegap.bitnagil.presentation.reporthistory.component.template.ReportCategoryBottomSheet -import com.threegap.bitnagil.presentation.reporthistory.model.ReportCategory +import com.threegap.bitnagil.presentation.reporthistory.contract.ReportHistoryState import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoriesPerDayUiModel -import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoryState import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoryUiModel -import com.threegap.bitnagil.presentation.reporthistory.model.ReportProcess +import com.threegap.bitnagil.presentation.reporthistory.model.ReportStatusFilter import com.threegap.bitnagil.presentation.reporthistory.util.toPresentationFormat import org.orbitmvi.orbit.compose.collectAsState +import java.time.LocalDate @Composable fun ReportHistoryScreenContainer( @@ -61,7 +64,7 @@ fun ReportHistoryScreenContainer( ReportHistoryScreen( state = state, onClickPreviousButton = navigateToBack, - onClickReportProcessChip = viewModel::selectReportProcess, + onClickReportStatusFilterChip = viewModel::selectReportStatusFilter, onClickReportCategoryButton = viewModel::showReportCategoryBottomSheet, onClickReportItem = navigateToReportDetail, ) @@ -72,7 +75,7 @@ private fun ReportHistoryScreen( modifier: Modifier = Modifier, state: ReportHistoryState, onClickPreviousButton: () -> Unit, - onClickReportProcessChip: (ReportProcess) -> Unit, + onClickReportStatusFilterChip: (ReportStatusFilter) -> Unit, onClickReportCategoryButton: () -> Unit, onClickReportItem: (String) -> Unit, ) { @@ -98,12 +101,12 @@ private fun ReportHistoryScreen( ) { Spacer(modifier = Modifier.width(8.dp)) - state.reportProcessWithCounts.forEach { reportProcessWithCount -> + state.reportStatusFilterWithCounts.forEach { filterWithCount -> BitnagilChip( - title = reportProcessWithCount.titleWithCount, - isSelected = state.selectedReportProcess == reportProcessWithCount.process, + title = filterWithCount.titleWithCount, + isSelected = state.selectedReportStatusFilter == filterWithCount.filter, onCategorySelected = { - onClickReportProcessChip(reportProcessWithCount.process) + onClickReportStatusFilterChip(filterWithCount.filter) }, ) } @@ -171,7 +174,7 @@ private fun ReportHistoryScreen( .clickableWithoutRipple(onClick = onClickReportCategoryButton), ) { Text( - text = state.selectedReportCategory?.title ?: "카테고리", + text = state.selectedReportCategory?.displayTitle ?: "카테고리", color = BitnagilTheme.colors.coolGray40, style = BitnagilTheme.typography.body2Medium, modifier = Modifier.padding(start = 10.dp), @@ -198,30 +201,30 @@ private fun ReportHistoryScreenPreview() { state = ReportHistoryState.Init.copy( reportHistoriesPerDays = List(10) { ReportHistoriesPerDayUiModel( - date = java.time.LocalDate.now(), + date = LocalDate.now(), reports = listOf( ReportHistoryUiModel( id = "1", title = "제보 1", imageUrl = "-", location = "서울특별시 성북구 안암로 106", - process = ReportProcess.Reported, - category = ReportCategory.Amenities, + status = ReportStatus.PENDING, + category = ReportCategory.AMENITY, ), ReportHistoryUiModel( id = "1", title = "제보 1", imageUrl = "-", location = "서울특별시 성북구 안암로 106", - process = ReportProcess.Progress, - category = ReportCategory.Amenities, + status = ReportStatus.IN_PROGRESS, + category = ReportCategory.AMENITY, ), ), ) }, ), onClickPreviousButton = {}, - onClickReportProcessChip = {}, + onClickReportStatusFilterChip = {}, onClickReportCategoryButton = {}, onClickReportItem = {}, ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryViewModel.kt index 28028bae..63e00c58 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/ReportHistoryViewModel.kt @@ -1,13 +1,13 @@ package com.threegap.bitnagil.presentation.reporthistory import androidx.lifecycle.ViewModel +import com.threegap.bitnagil.domain.report.model.ReportCategory import com.threegap.bitnagil.domain.report.usecase.GetReportHistoriesUseCase -import com.threegap.bitnagil.presentation.reporthistory.model.ReportCategory +import com.threegap.bitnagil.presentation.reporthistory.contract.ReportHistorySideEffect +import com.threegap.bitnagil.presentation.reporthistory.contract.ReportHistoryState import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoriesPerDayUiModel -import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistorySideEffect -import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoryState -import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoryUiModel -import com.threegap.bitnagil.presentation.reporthistory.model.ReportProcess +import com.threegap.bitnagil.presentation.reporthistory.model.ReportStatusFilter +import com.threegap.bitnagil.presentation.reporthistory.model.toUiModel import dagger.hilt.android.lifecycle.HiltViewModel import org.orbitmvi.orbit.Container import org.orbitmvi.orbit.ContainerHost @@ -31,9 +31,7 @@ class ReportHistoryViewModel @Inject constructor( .map { reportHistoryPerDateMap -> ReportHistoriesPerDayUiModel( date = reportHistoryPerDateMap.key, - reports = reportHistoryPerDateMap.value.map { - ReportHistoryUiModel.fromDomain(it) - }, + reports = reportHistoryPerDateMap.value.map { it.toUiModel() }, ) } .sortedByDescending { reportHistoryPerDate -> @@ -61,10 +59,10 @@ class ReportHistoryViewModel @Inject constructor( } } - fun selectReportProcess(reportProcess: ReportProcess) = intent { + fun selectReportStatusFilter(reportStatusFilter: ReportStatusFilter) = intent { reduce { state.copy( - selectedReportProcess = reportProcess, + selectedReportStatusFilter = reportStatusFilter, ) } } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/atom/ReportProcessBadge.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/atom/ReportProcessBadge.kt deleted file mode 100644 index b93bf260..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/atom/ReportProcessBadge.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.threegap.bitnagil.presentation.reporthistory.component.atom - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import com.threegap.bitnagil.designsystem.BitnagilTheme -import com.threegap.bitnagil.presentation.reporthistory.model.ReportProcess - -@Composable -fun ReportProcessBadge( - modifier: Modifier = Modifier, - reportProcess: ReportProcess, -) { - Text( - text = reportProcess.title, - style = BitnagilTheme.typography.caption1SemiBold, - color = reportProcess.getProcessBadgeTextColor(), - modifier = modifier - .background(color = reportProcess.getProcessBadgeBackgroundColor(), shape = RoundedCornerShape(6.dp)) - .padding(horizontal = 10.dp, vertical = 4.dp), - ) -} - -@Composable -private fun ReportProcess.getProcessBadgeBackgroundColor(): Color = - when (this) { - ReportProcess.Reported -> BitnagilTheme.colors.green10 - ReportProcess.Progress -> BitnagilTheme.colors.skyBlue10 - else -> BitnagilTheme.colors.coolGray95 - } - -@Composable -private fun ReportProcess.getProcessBadgeTextColor(): Color = - when (this) { - ReportProcess.Reported -> BitnagilTheme.colors.green300 - ReportProcess.Progress -> BitnagilTheme.colors.blue300 - else -> BitnagilTheme.colors.coolGray40 - } - -@Composable -@Preview -private fun ReportProcessBadgePreview() { - BitnagilTheme { - Column( - verticalArrangement = Arrangement.spacedBy(4.dp), - ) { - ReportProcessBadge(reportProcess = ReportProcess.Progress) - ReportProcessBadge(reportProcess = ReportProcess.Reported) - ReportProcessBadge(reportProcess = ReportProcess.Complete) - } - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/block/ReportHistoryItem.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/block/ReportHistoryItem.kt index 57b940ac..8732c60f 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/block/ReportHistoryItem.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/block/ReportHistoryItem.kt @@ -25,10 +25,11 @@ import coil3.compose.AsyncImage import coil3.request.ImageRequest import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple -import com.threegap.bitnagil.presentation.reporthistory.component.atom.ReportProcessBadge -import com.threegap.bitnagil.presentation.reporthistory.model.ReportCategory +import com.threegap.bitnagil.domain.report.model.ReportCategory +import com.threegap.bitnagil.domain.report.model.ReportStatus +import com.threegap.bitnagil.presentation.common.extension.displayTitle +import com.threegap.bitnagil.presentation.reportdetail.component.atom.ReportProcessBadge import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoryUiModel -import com.threegap.bitnagil.presentation.reporthistory.model.ReportProcess @Composable fun ReportHistoryItem( @@ -46,7 +47,7 @@ fun ReportHistoryItem( Column( modifier = Modifier.weight(1f), ) { - ReportProcessBadge(reportProcess = report.process) + ReportProcessBadge(reportStatus = report.status) Spacer(modifier = Modifier.height(8.dp)) @@ -59,7 +60,7 @@ fun ReportHistoryItem( horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically, ) { - Text(text = report.category.title, style = BitnagilTheme.typography.caption1Medium.copy(color = BitnagilTheme.colors.coolGray50)) + Text(text = report.category.displayTitle, style = BitnagilTheme.typography.caption1Medium.copy(color = BitnagilTheme.colors.coolGray50)) Box( modifier = Modifier @@ -103,8 +104,8 @@ private fun ReportHistoryItemPreview() { title = "다이소 덕소점 앞 가로등 심해요", imageUrl = "-", location = "서울특별시 성북구 안암로 106", - process = ReportProcess.Reported, - category = ReportCategory.TrafficFacilities, + status = ReportStatus.PENDING, + category = ReportCategory.TRANSPORTATION, ), onClick = {}, ) @@ -115,8 +116,8 @@ private fun ReportHistoryItemPreview() { title = "다이소 덕소점 앞 가로등 깜빡이는데 어쩌죠 이거 진짜로 심각한 문제인데 이 뒷부분은 figma에서 짤려 보여서 임의로 채웁니다", imageUrl = "-", location = "서울특별시 성북구 안암로 106", - process = ReportProcess.Progress, - category = ReportCategory.TrafficFacilities, + status = ReportStatus.IN_PROGRESS, + category = ReportCategory.TRANSPORTATION, ), onClick = {}, ) @@ -127,8 +128,8 @@ private fun ReportHistoryItemPreview() { title = "퇴근하고 싶어요", imageUrl = "-", location = "서울특별시 성북구 안암로 106 서울특별시 성북구 안암로 106 서울특별시 성북구 안암로 106", - process = ReportProcess.Complete, - category = ReportCategory.Amenities, + status = ReportStatus.COMPLETED, + category = ReportCategory.AMENITY, ), onClick = {}, ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/template/ReportCategoryBottomSheet.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/template/ReportCategoryBottomSheet.kt index 1e1ce5d5..af4603c7 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/template/ReportCategoryBottomSheet.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/component/template/ReportCategoryBottomSheet.kt @@ -23,7 +23,10 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple -import com.threegap.bitnagil.presentation.reporthistory.model.ReportCategory +import com.threegap.bitnagil.domain.report.model.ReportCategory +import com.threegap.bitnagil.presentation.common.extension.displayExamples +import com.threegap.bitnagil.presentation.common.extension.displayTitle +import com.threegap.bitnagil.presentation.common.extension.iconRes import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) @@ -49,9 +52,9 @@ fun ReportCategoryBottomSheet( ) { ReportCategory.entries.forEachIndexed { index, category -> ReportCategoryItem( - icon = category.iconResourceId, - title = category.title, - description = category.description, + icon = category.iconRes, + title = category.displayTitle, + description = category.displayExamples, isSelected = selectedCategory == category, onClick = { onSelected(category) @@ -123,7 +126,7 @@ private fun ReportCategoryItem( @Composable private fun ReportCategoryBottomSheetPreview() { ReportCategoryBottomSheet( - selectedCategory = ReportCategory.WaterFacilities, + selectedCategory = ReportCategory.WATERFACILITY, onDismiss = {}, onSelected = {}, ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/contract/ReportHistorySideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/contract/ReportHistorySideEffect.kt new file mode 100644 index 00000000..5a0b6908 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/contract/ReportHistorySideEffect.kt @@ -0,0 +1,3 @@ +package com.threegap.bitnagil.presentation.reporthistory.contract + +sealed interface ReportHistorySideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/contract/ReportHistoryState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/contract/ReportHistoryState.kt new file mode 100644 index 00000000..50ba53f7 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/contract/ReportHistoryState.kt @@ -0,0 +1,54 @@ +package com.threegap.bitnagil.presentation.reporthistory.contract + +import com.threegap.bitnagil.domain.report.model.ReportCategory +import com.threegap.bitnagil.presentation.reporthistory.model.ReportHistoriesPerDayUiModel +import com.threegap.bitnagil.presentation.reporthistory.model.ReportStatusFilter +import com.threegap.bitnagil.presentation.reporthistory.model.ReportStatusFilterWithCount + +data class ReportHistoryState( + val selectedReportCategory: ReportCategory?, + val selectedReportStatusFilter: ReportStatusFilter, + val reportHistoriesPerDays: List, + val showSelectReportCategoryBottomSheet: Boolean, +) { + val filteredReportHistoriesPerDays: List = + reportHistoriesPerDays + .map { reportHistoriesPerDay -> + reportHistoriesPerDay.copy( + reports = reportHistoriesPerDay.reports.filter { report -> + val statusMatched = selectedReportStatusFilter.matches(report.status) + + val categoryMatched = when (selectedReportCategory) { + null -> true + else -> report.category == selectedReportCategory + } + + statusMatched && categoryMatched + }, + ) + } + .filter { reportHistoriesPerDay -> + reportHistoriesPerDay.reports.isNotEmpty() + } + + val reportStatusFilterWithCounts: List = + ReportStatusFilter.values().map { filter -> + val count = reportHistoriesPerDays.sumOf { day -> + day.reports.count { report -> + filter.matches(report.status) + } + } + ReportStatusFilterWithCount(filter, count) + } + + val showCategorySelectButton: Boolean = reportHistoriesPerDays.isNotEmpty() + + companion object { + val Init = ReportHistoryState( + selectedReportCategory = null, + selectedReportStatusFilter = ReportStatusFilter.All, + reportHistoriesPerDays = listOf(), + showSelectReportCategoryBottomSheet = false, + ) + } +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportCategory.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportCategory.kt deleted file mode 100644 index 642eca1c..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportCategory.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.threegap.bitnagil.presentation.reporthistory.model - -import com.threegap.bitnagil.designsystem.R -import com.threegap.bitnagil.domain.report.model.ReportCategory as DomainReportCategory - -enum class ReportCategory( - val title: String, - val description: String, - val iconResourceId: Int, -) { - TrafficFacilities( - title = "교통 시설", - description = "신호등 고장, 표지판 파손, 횡단보도 등", - iconResourceId = R.drawable.ic_car, - ), - LightingFacilities( - title = "조명 시설", - description = "가로등, 보안등 파손 등", - iconResourceId = R.drawable.ic_light, - ), - WaterFacilities( - title = "상하수도 시설", - description = "맨홀 뚜껑 손상 등", - iconResourceId = R.drawable.ic_water, - ), - Amenities( - title = "편의 시설", - description = "벤치 파손, 휴지통 넘침 등", - iconResourceId = R.drawable.ic_hammer, - ), - ; - - companion object { - fun fromDomain(domainReportCategory: DomainReportCategory): ReportCategory { - return when (domainReportCategory) { - DomainReportCategory.TRANSPORTATION -> TrafficFacilities - DomainReportCategory.LIGHTING -> LightingFacilities - DomainReportCategory.WATERFACILITY -> WaterFacilities - DomainReportCategory.AMENITY -> Amenities - } - } - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistorySideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistorySideEffect.kt deleted file mode 100644 index 9bf7b78a..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistorySideEffect.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.threegap.bitnagil.presentation.reporthistory.model - -sealed interface ReportHistorySideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryState.kt deleted file mode 100644 index 80de9be4..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryState.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.threegap.bitnagil.presentation.reporthistory.model - -data class ReportHistoryState( - val selectedReportCategory: ReportCategory?, - val selectedReportProcess: ReportProcess, - val reportHistoriesPerDays: List, - val showSelectReportCategoryBottomSheet: Boolean, -) { - val filteredReportHistoriesPerDays: List = reportHistoriesPerDays - .map { reportHistoriesPerDay -> - reportHistoriesPerDay.copy( - reports = reportHistoriesPerDay.reports.filter { - val processMatched = when (selectedReportProcess) { - ReportProcess.Total -> true - ReportProcess.Reported -> it.process == ReportProcess.Reported - ReportProcess.Progress -> it.process == ReportProcess.Progress - ReportProcess.Complete -> it.process == ReportProcess.Complete - } - - val categoryMatched = when (selectedReportCategory) { - ReportCategory.TrafficFacilities -> it.category == ReportCategory.TrafficFacilities - ReportCategory.LightingFacilities -> it.category == ReportCategory.LightingFacilities - ReportCategory.WaterFacilities -> it.category == ReportCategory.WaterFacilities - ReportCategory.Amenities -> it.category == ReportCategory.Amenities - null -> true - } - - processMatched && categoryMatched - }, - ) - } - .filter { reportHistoriesPerDay -> - reportHistoriesPerDay.reports.isNotEmpty() - } - - val reportProcessWithCounts: List = listOf( - ReportProcessWithCount(ReportProcess.Total, reportHistoriesPerDays.sumOf { it.reports.size }), - ReportProcessWithCount( - ReportProcess.Reported, - reportHistoriesPerDays.sumOf { it.reports.filter { report -> report.process == ReportProcess.Reported }.size }, - ), - ReportProcessWithCount( - ReportProcess.Progress, - reportHistoriesPerDays.sumOf { it.reports.filter { report -> report.process == ReportProcess.Progress }.size }, - ), - ReportProcessWithCount( - ReportProcess.Complete, - reportHistoriesPerDays.sumOf { it.reports.filter { report -> report.process == ReportProcess.Complete }.size }, - ), - ) - - val showCategorySelectButton: Boolean = reportHistoriesPerDays.isNotEmpty() - - companion object { - val Init = ReportHistoryState( - selectedReportCategory = null, - selectedReportProcess = ReportProcess.Total, - reportHistoriesPerDays = listOf(), - showSelectReportCategoryBottomSheet = false, - ) - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryUiModel.kt index ee6f32af..b89977e2 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportHistoryUiModel.kt @@ -1,25 +1,24 @@ package com.threegap.bitnagil.presentation.reporthistory.model +import com.threegap.bitnagil.domain.report.model.ReportCategory import com.threegap.bitnagil.domain.report.model.ReportItem +import com.threegap.bitnagil.domain.report.model.ReportStatus data class ReportHistoryUiModel( val id: String, val title: String, val imageUrl: String, val location: String, - val process: ReportProcess, + val status: ReportStatus, val category: ReportCategory, -) { - companion object { - fun fromDomain(reportItem: ReportItem): ReportHistoryUiModel { - return ReportHistoryUiModel( - id = "${reportItem.id}", - title = reportItem.title, - imageUrl = reportItem.imageUrl, - location = reportItem.address, - process = ReportProcess.fromDomain(reportItem.status), - category = ReportCategory.fromDomain(reportItem.category), - ) - } - } -} +) + +internal fun ReportItem.toUiModel(): ReportHistoryUiModel = + ReportHistoryUiModel( + id = this.id.toString(), + title = this.title, + imageUrl = this.imageUrl, + location = this.address, + status = this.status, + category = this.category, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt deleted file mode 100644 index 5ab5729f..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.threegap.bitnagil.presentation.reporthistory.model - -import com.threegap.bitnagil.domain.report.model.ReportStatus - -enum class ReportProcess( - val title: String, -) { - Total(title = "전체"), - Reported(title = "제보 완료"), - Progress(title = "처리 중"), - Complete(title = "처리 완료"), - ; - - companion object { - fun fromDomain(status: ReportStatus): ReportProcess { - return when (status) { - ReportStatus.PENDING -> Reported - ReportStatus.IN_PROGRESS -> Progress - ReportStatus.COMPLETED -> Complete - } - } - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcessWithCount.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcessWithCount.kt deleted file mode 100644 index df6409b4..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcessWithCount.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.threegap.bitnagil.presentation.reporthistory.model - -data class ReportProcessWithCount( - val process: ReportProcess, - val count: Int, -) { - val titleWithCount: String = if (count == 0) process.title else "${process.title} $count" - - companion object { - val Init = ReportProcessWithCount( - process = ReportProcess.Total, - count = 0, - ) - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportStatusFilter.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportStatusFilter.kt new file mode 100644 index 00000000..711d4a2a --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportStatusFilter.kt @@ -0,0 +1,25 @@ +package com.threegap.bitnagil.presentation.reporthistory.model + +import com.threegap.bitnagil.domain.report.model.ReportStatus +import com.threegap.bitnagil.presentation.common.extension.displayTitle + +sealed class ReportStatusFilter { + data object All : ReportStatusFilter() + data class Specific(val status: ReportStatus) : ReportStatusFilter() + + fun getTitle(): String = when (this) { + is All -> "전체" + is Specific -> status.displayTitle + } + + fun matches(status: ReportStatus): Boolean = when (this) { + is All -> true + is Specific -> this.status == status + } + + companion object { + fun values(): List { + return listOf(All) + ReportStatus.entries.map { Specific(it) } + } + } +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportStatusFilterWithCount.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportStatusFilterWithCount.kt new file mode 100644 index 00000000..99286100 --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportStatusFilterWithCount.kt @@ -0,0 +1,15 @@ +package com.threegap.bitnagil.presentation.reporthistory.model + +data class ReportStatusFilterWithCount( + val filter: ReportStatusFilter, + val count: Int, +) { + val titleWithCount: String = if (count == 0) filter.getTitle() else "${filter.getTitle()} $count" + + companion object { + val Init = ReportStatusFilterWithCount( + filter = ReportStatusFilter.All, + count = 0, + ) + } +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListScreen.kt index 29408e92..bae62ca1 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListScreen.kt @@ -26,8 +26,8 @@ import com.threegap.bitnagil.presentation.routinelist.component.template.EditCon import com.threegap.bitnagil.presentation.routinelist.component.template.EmptyRoutineListView import com.threegap.bitnagil.presentation.routinelist.component.template.RoutineDetailsCard import com.threegap.bitnagil.presentation.routinelist.component.template.WeeklyDatePicker -import com.threegap.bitnagil.presentation.routinelist.model.RoutineListSideEffect -import com.threegap.bitnagil.presentation.routinelist.model.RoutineListState +import com.threegap.bitnagil.presentation.routinelist.contract.RoutineListSideEffect +import com.threegap.bitnagil.presentation.routinelist.contract.RoutineListState import com.threegap.bitnagil.presentation.routinelist.model.RoutineUiModel import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt index 34df31ef..b2a780d4 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt @@ -9,8 +9,8 @@ import com.threegap.bitnagil.domain.routine.usecase.DeleteRoutineUseCase import com.threegap.bitnagil.domain.routine.usecase.FetchWeeklyRoutinesUseCase import com.threegap.bitnagil.domain.writeroutine.usecase.GetWriteRoutineEventFlowUseCase import com.threegap.bitnagil.presentation.home.util.getCurrentWeekDays -import com.threegap.bitnagil.presentation.routinelist.model.RoutineListSideEffect -import com.threegap.bitnagil.presentation.routinelist.model.RoutineListState +import com.threegap.bitnagil.presentation.routinelist.contract.RoutineListSideEffect +import com.threegap.bitnagil.presentation.routinelist.contract.RoutineListState import com.threegap.bitnagil.presentation.routinelist.model.RoutineUiModel import com.threegap.bitnagil.presentation.routinelist.model.toUiModel import dagger.hilt.android.lifecycle.HiltViewModel diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/component/template/RoutineDetailsCard.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/component/template/RoutineDetailsCard.kt index d10ef718..18e0f5d1 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/component/template/RoutineDetailsCard.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/component/template/RoutineDetailsCard.kt @@ -22,10 +22,10 @@ import com.threegap.bitnagil.designsystem.R import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.designsystem.component.atom.BitnagilIconButton import com.threegap.bitnagil.domain.routine.model.DayOfWeek +import com.threegap.bitnagil.presentation.common.extension.displayColor +import com.threegap.bitnagil.presentation.common.extension.displayIcon import com.threegap.bitnagil.presentation.common.extension.displayTitle import com.threegap.bitnagil.presentation.routinelist.model.RoutineUiModel -import com.threegap.bitnagil.presentation.routinelist.model.getColor -import com.threegap.bitnagil.presentation.routinelist.model.getIcon @Composable fun RoutineDetailsCard( @@ -56,11 +56,11 @@ fun RoutineDetailsCard( verticalAlignment = Alignment.CenterVertically, ) { BitnagilIcon( - id = if (routine.recommendedRoutineType != null) routine.recommendedRoutineType.getIcon() else R.drawable.ic_shine, + id = if (routine.recommendedRoutineType != null) routine.recommendedRoutineType.displayIcon else R.drawable.ic_shine, tint = null, modifier = Modifier .background( - color = if (routine.recommendedRoutineType != null) routine.recommendedRoutineType.getColor() else BitnagilTheme.colors.yellow10, + color = if (routine.recommendedRoutineType != null) routine.recommendedRoutineType.displayColor else BitnagilTheme.colors.yellow10, shape = RoundedCornerShape(4.dp), ) .padding(4.dp), diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineListSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/contract/RoutineListSideEffect.kt similarity index 84% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineListSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/contract/RoutineListSideEffect.kt index 0d4d2e91..417a3465 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineListSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/contract/RoutineListSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.routinelist.model +package com.threegap.bitnagil.presentation.routinelist.contract sealed interface RoutineListSideEffect { data object NavigateToBack : RoutineListSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineListState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/contract/RoutineListState.kt similarity index 71% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineListState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/contract/RoutineListState.kt index aa0b9947..fdcf5b88 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineListState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/contract/RoutineListState.kt @@ -1,11 +1,13 @@ -package com.threegap.bitnagil.presentation.routinelist.model +package com.threegap.bitnagil.presentation.routinelist.contract import com.threegap.bitnagil.presentation.home.util.getCurrentWeekDays +import com.threegap.bitnagil.presentation.routinelist.model.RoutineScheduleUiModel +import com.threegap.bitnagil.presentation.routinelist.model.RoutineUiModel import java.time.LocalDate data class RoutineListState( val isLoading: Boolean, - val routines: RoutinesUiModel, + val routines: RoutineScheduleUiModel, val selectedRoutine: RoutineUiModel?, val selectedDate: LocalDate, val deleteConfirmBottomSheetVisible: Boolean, @@ -15,12 +17,12 @@ data class RoutineListState( get() = selectedDate.getCurrentWeekDays() val selectedDateRoutines: List - get() = routines.routines[selectedDate.toString()]?.routineList ?: emptyList() + get() = routines.routines[selectedDate.toString()]?.routines ?: emptyList() companion object { val INIT = RoutineListState( isLoading = false, - routines = RoutinesUiModel(), + routines = RoutineScheduleUiModel.INIT, selectedRoutine = null, selectedDate = LocalDate.now(), deleteConfirmBottomSheetVisible = false, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/DailyRoutinesUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/DailyRoutinesUiModel.kt new file mode 100644 index 00000000..46ab041a --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/DailyRoutinesUiModel.kt @@ -0,0 +1,12 @@ +package com.threegap.bitnagil.presentation.routinelist.model + +import com.threegap.bitnagil.domain.routine.model.DailyRoutines + +data class DailyRoutinesUiModel( + val routines: List, +) + +internal fun DailyRoutines.toUiModel(): DailyRoutinesUiModel = + DailyRoutinesUiModel( + routines = routines.map { it.toUiModel() }, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/DayRoutinesUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/DayRoutinesUiModel.kt deleted file mode 100644 index 7516e137..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/DayRoutinesUiModel.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.threegap.bitnagil.presentation.routinelist.model - -import android.os.Parcelable -import com.threegap.bitnagil.domain.routine.model.DailyRoutines -import kotlinx.parcelize.Parcelize - -@Parcelize -data class DayRoutinesUiModel( - val routineList: List = emptyList(), -) : Parcelable - -fun DailyRoutines.toUiModel(): DayRoutinesUiModel = - DayRoutinesUiModel( - routineList = routines.map { it.toUiModel() }, - ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineScheduleUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineScheduleUiModel.kt new file mode 100644 index 00000000..c415490b --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineScheduleUiModel.kt @@ -0,0 +1,18 @@ +package com.threegap.bitnagil.presentation.routinelist.model + +import com.threegap.bitnagil.domain.routine.model.RoutineSchedule + +data class RoutineScheduleUiModel( + val routines: Map, +) { + companion object { + val INIT = RoutineScheduleUiModel( + routines = emptyMap(), + ) + } +} + +internal fun RoutineSchedule.toUiModel(): RoutineScheduleUiModel = + RoutineScheduleUiModel( + routines = this.dailyRoutines.mapValues { (_, dailyRoutines) -> dailyRoutines.toUiModel() }, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineUiModel.kt index 41a1b9eb..a0d20211 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineUiModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineUiModel.kt @@ -1,18 +1,11 @@ package com.threegap.bitnagil.presentation.routinelist.model -import android.os.Parcelable -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import com.threegap.bitnagil.designsystem.BitnagilTheme -import com.threegap.bitnagil.designsystem.R +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.domain.routine.model.DayOfWeek -import com.threegap.bitnagil.domain.routine.model.RecommendedRoutineType import com.threegap.bitnagil.domain.routine.model.Routine import com.threegap.bitnagil.presentation.home.util.formatExecutionTime12Hour import com.threegap.bitnagil.presentation.home.util.toShortDateFormat -import kotlinx.parcelize.Parcelize -@Parcelize data class RoutineUiModel( val routineId: String, val routineName: String, @@ -23,13 +16,13 @@ data class RoutineUiModel( val endDate: String, val routineDeletedYn: Boolean, val subRoutineNames: List, - val recommendedRoutineType: RecommendedRoutineType?, -) : Parcelable { + val recommendedRoutineType: RecommendCategory?, +) { val formattedDateRange: String get() = "${startDate.toShortDateFormat()} - ${endDate.toShortDateFormat()}" } -fun Routine.toUiModel(): RoutineUiModel = +internal fun Routine.toUiModel(): RoutineUiModel = RoutineUiModel( routineId = this.id, routineName = this.name, @@ -42,26 +35,3 @@ fun Routine.toUiModel(): RoutineUiModel = subRoutineNames = this.subRoutineNames, recommendedRoutineType = this.recommendedRoutineType, ) - -fun RecommendedRoutineType.getIcon(): Int = - when (this) { - RecommendedRoutineType.OUTING -> R.drawable.ic_outside - RecommendedRoutineType.WAKE_UP -> R.drawable.ic_wakeup - RecommendedRoutineType.CONNECT -> R.drawable.ic_connect - RecommendedRoutineType.REST -> R.drawable.ic_rest - RecommendedRoutineType.GROW -> R.drawable.ic_grow - RecommendedRoutineType.PERSONALIZED -> R.drawable.ic_shine - RecommendedRoutineType.OUTING_REPORT -> R.drawable.ic_shine - } - -@Composable -fun RecommendedRoutineType.getColor(): Color = - when (this) { - RecommendedRoutineType.OUTING -> BitnagilTheme.colors.skyBlue10 - RecommendedRoutineType.WAKE_UP -> BitnagilTheme.colors.orange25 - RecommendedRoutineType.CONNECT -> BitnagilTheme.colors.purple10 - RecommendedRoutineType.REST -> BitnagilTheme.colors.green10 - RecommendedRoutineType.GROW -> BitnagilTheme.colors.pink10 - RecommendedRoutineType.PERSONALIZED -> BitnagilTheme.colors.yellow10 - RecommendedRoutineType.OUTING_REPORT -> BitnagilTheme.colors.yellow10 - } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutinesUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutinesUiModel.kt deleted file mode 100644 index 21fd81c7..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutinesUiModel.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.threegap.bitnagil.presentation.routinelist.model - -import android.os.Parcelable -import com.threegap.bitnagil.domain.routine.model.RoutineSchedule -import kotlinx.parcelize.Parcelize - -@Parcelize -data class RoutinesUiModel( - val routines: Map = emptyMap(), -) : Parcelable - -fun RoutineSchedule.toUiModel(): RoutinesUiModel = - RoutinesUiModel( - routines = this.dailyRoutines.mapValues { (_, dayRoutines) -> - dayRoutines.toUiModel() - }, - ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingScreen.kt index 5b69cd58..56c69db0 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingScreen.kt @@ -33,8 +33,8 @@ import com.threegap.bitnagil.presentation.common.playstore.UpdateAvailableState import com.threegap.bitnagil.presentation.common.playstore.openAppInPlayStore import com.threegap.bitnagil.presentation.common.playstore.updateAvailable import com.threegap.bitnagil.presentation.setting.component.atom.settingtitle.SettingTitle -import com.threegap.bitnagil.presentation.setting.model.mvi.SettingSideEffect -import com.threegap.bitnagil.presentation.setting.model.mvi.SettingState +import com.threegap.bitnagil.presentation.setting.contract.SettingSideEffect +import com.threegap.bitnagil.presentation.setting.contract.SettingState import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingViewModel.kt index 7c4e91e2..602f23cf 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/SettingViewModel.kt @@ -5,8 +5,8 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.threegap.bitnagil.domain.auth.usecase.LogoutUseCase import com.threegap.bitnagil.presentation.common.version.VersionNameProvider -import com.threegap.bitnagil.presentation.setting.model.mvi.SettingSideEffect -import com.threegap.bitnagil.presentation.setting.model.mvi.SettingState +import com.threegap.bitnagil.presentation.setting.contract.SettingSideEffect +import com.threegap.bitnagil.presentation.setting.contract.SettingState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Job import kotlinx.coroutines.delay diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/contract/SettingSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/contract/SettingSideEffect.kt new file mode 100644 index 00000000..3376354b --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/contract/SettingSideEffect.kt @@ -0,0 +1,6 @@ +package com.threegap.bitnagil.presentation.setting.contract + +sealed interface SettingSideEffect { + data object NavigateToLogin : SettingSideEffect + data object NavigateToWithdrawal : SettingSideEffect +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/model/mvi/SettingState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/contract/SettingState.kt similarity index 89% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/setting/model/mvi/SettingState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/setting/contract/SettingState.kt index aa29a342..87f9da67 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/model/mvi/SettingState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/contract/SettingState.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.setting.model.mvi +package com.threegap.bitnagil.presentation.setting.contract import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/model/mvi/SettingSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/model/mvi/SettingSideEffect.kt deleted file mode 100644 index e25e6a48..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/setting/model/mvi/SettingSideEffect.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.threegap.bitnagil.presentation.setting.model.mvi - -sealed class SettingSideEffect { - data object NavigateToLogin : SettingSideEffect() - data object NavigateToWithdrawal : SettingSideEffect() -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashScreen.kt index 0f9aed5b..600f9601 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashScreen.kt @@ -25,7 +25,7 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon import com.threegap.bitnagil.presentation.common.playstore.openAppInPlayStore import com.threegap.bitnagil.presentation.splash.component.template.BitnagilLottieAnimation import com.threegap.bitnagil.presentation.splash.component.template.ForceUpdateDialog -import com.threegap.bitnagil.presentation.splash.model.SplashSideEffect +import com.threegap.bitnagil.presentation.splash.contract.SplashSideEffect import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect import kotlin.system.exitProcess diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashViewModel.kt index d9c037fe..e209167a 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/SplashViewModel.kt @@ -5,8 +5,8 @@ import androidx.lifecycle.viewModelScope import com.threegap.bitnagil.domain.auth.model.UserRole import com.threegap.bitnagil.domain.auth.usecase.AutoLoginUseCase import com.threegap.bitnagil.domain.version.usecase.CheckUpdateRequirementUseCase -import com.threegap.bitnagil.presentation.splash.model.SplashSideEffect -import com.threegap.bitnagil.presentation.splash.model.SplashState +import com.threegap.bitnagil.presentation.splash.contract.SplashSideEffect +import com.threegap.bitnagil.presentation.splash.contract.SplashState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.delay import kotlinx.coroutines.launch diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/model/SplashSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/contract/SplashSideEffect.kt similarity index 81% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/splash/model/SplashSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/splash/contract/SplashSideEffect.kt index f55f3d68..0f4472a6 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/model/SplashSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/contract/SplashSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.splash.model +package com.threegap.bitnagil.presentation.splash.contract sealed interface SplashSideEffect { data object NavigateToLogin : SplashSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/model/SplashState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/contract/SplashState.kt similarity index 88% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/splash/model/SplashState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/splash/contract/SplashState.kt index 6368c7ee..3ec4d88f 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/model/SplashState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/splash/contract/SplashState.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.splash.model +package com.threegap.bitnagil.presentation.splash.contract import com.threegap.bitnagil.domain.auth.model.UserRole diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementScreen.kt index bd6ede7c..bfd273f7 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementScreen.kt @@ -19,8 +19,8 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar import com.threegap.bitnagil.presentation.terms.component.TermsAgreementItem import com.threegap.bitnagil.presentation.terms.component.ToggleAllAgreementsItem -import com.threegap.bitnagil.presentation.terms.model.TermsAgreementSideEffect -import com.threegap.bitnagil.presentation.terms.model.TermsAgreementState +import com.threegap.bitnagil.presentation.terms.contract.TermsAgreementSideEffect +import com.threegap.bitnagil.presentation.terms.contract.TermsAgreementState import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementViewModel.kt index eb73bd82..837857ab 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/TermsAgreementViewModel.kt @@ -4,8 +4,8 @@ import android.util.Log import androidx.lifecycle.ViewModel import com.threegap.bitnagil.domain.auth.model.TermsAgreement import com.threegap.bitnagil.domain.auth.usecase.SubmitTermsAgreementUseCase -import com.threegap.bitnagil.presentation.terms.model.TermsAgreementSideEffect -import com.threegap.bitnagil.presentation.terms.model.TermsAgreementState +import com.threegap.bitnagil.presentation.terms.contract.TermsAgreementSideEffect +import com.threegap.bitnagil.presentation.terms.contract.TermsAgreementState import dagger.hilt.android.lifecycle.HiltViewModel import org.orbitmvi.orbit.Container import org.orbitmvi.orbit.ContainerHost diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/model/TermsAgreementSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/contract/TermsAgreementSideEffect.kt similarity index 83% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/terms/model/TermsAgreementSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/terms/contract/TermsAgreementSideEffect.kt index 9e3e210f..1e2dac89 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/model/TermsAgreementSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/contract/TermsAgreementSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.terms.model +package com.threegap.bitnagil.presentation.terms.contract sealed interface TermsAgreementSideEffect { data object NavigateToTermsOfService : TermsAgreementSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/model/TermsAgreementState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/contract/TermsAgreementState.kt similarity index 91% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/terms/model/TermsAgreementState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/terms/contract/TermsAgreementState.kt index 2cc904f6..40db7bae 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/model/TermsAgreementState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/terms/contract/TermsAgreementState.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.terms.model +package com.threegap.bitnagil.presentation.terms.contract data class TermsAgreementState( val isLoading: Boolean, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalScreen.kt index 0c62953f..5ba4d6f2 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalScreen.kt @@ -40,9 +40,9 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilTextButton import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple import com.threegap.bitnagil.presentation.withdrawal.component.WithdrawalConfirmDialog +import com.threegap.bitnagil.presentation.withdrawal.contract.WithdrawalSideEffect +import com.threegap.bitnagil.presentation.withdrawal.contract.WithdrawalState import com.threegap.bitnagil.presentation.withdrawal.model.WithdrawalReason -import com.threegap.bitnagil.presentation.withdrawal.model.WithdrawalSideEffect -import com.threegap.bitnagil.presentation.withdrawal.model.WithdrawalState import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalViewModel.kt index e71b6328..ff6a0d62 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/WithdrawalViewModel.kt @@ -2,9 +2,9 @@ package com.threegap.bitnagil.presentation.withdrawal import androidx.lifecycle.ViewModel import com.threegap.bitnagil.domain.auth.usecase.WithdrawalUseCase +import com.threegap.bitnagil.presentation.withdrawal.contract.WithdrawalSideEffect +import com.threegap.bitnagil.presentation.withdrawal.contract.WithdrawalState import com.threegap.bitnagil.presentation.withdrawal.model.WithdrawalReason -import com.threegap.bitnagil.presentation.withdrawal.model.WithdrawalSideEffect -import com.threegap.bitnagil.presentation.withdrawal.model.WithdrawalState import dagger.hilt.android.lifecycle.HiltViewModel import org.orbitmvi.orbit.Container import org.orbitmvi.orbit.ContainerHost diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/model/WithdrawalSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/contract/WithdrawalSideEffect.kt similarity index 70% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/model/WithdrawalSideEffect.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/contract/WithdrawalSideEffect.kt index 76ab1d4b..928b95e8 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/model/WithdrawalSideEffect.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/contract/WithdrawalSideEffect.kt @@ -1,4 +1,4 @@ -package com.threegap.bitnagil.presentation.withdrawal.model +package com.threegap.bitnagil.presentation.withdrawal.contract sealed interface WithdrawalSideEffect { data object NavigateToBack : WithdrawalSideEffect diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/model/WithdrawalState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/contract/WithdrawalState.kt similarity index 83% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/model/WithdrawalState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/contract/WithdrawalState.kt index d1cfdf56..9f95c42d 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/model/WithdrawalState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/withdrawal/contract/WithdrawalState.kt @@ -1,4 +1,6 @@ -package com.threegap.bitnagil.presentation.withdrawal.model +package com.threegap.bitnagil.presentation.withdrawal.contract + +import com.threegap.bitnagil.presentation.withdrawal.model.WithdrawalReason data class WithdrawalState( val isLoading: Boolean, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineScreen.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineScreen.kt index 98741027..9beff2cc 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineScreen.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineScreen.kt @@ -37,12 +37,12 @@ import com.threegap.bitnagil.presentation.writeroutine.component.block.routinede import com.threegap.bitnagil.presentation.writeroutine.component.block.subroutinefield.SubRoutineField import com.threegap.bitnagil.presentation.writeroutine.component.template.datepickerbottomsheet.DatePickerBottomSheet import com.threegap.bitnagil.presentation.writeroutine.component.template.timepickerbottomsheet.TimePickerBottomSheet +import com.threegap.bitnagil.presentation.writeroutine.contract.WriteRoutineSideEffect +import com.threegap.bitnagil.presentation.writeroutine.contract.WriteRoutineState import com.threegap.bitnagil.presentation.writeroutine.model.Day import com.threegap.bitnagil.presentation.writeroutine.model.RepeatType import com.threegap.bitnagil.presentation.writeroutine.model.Time import com.threegap.bitnagil.presentation.writeroutine.model.WriteRoutineType -import com.threegap.bitnagil.presentation.writeroutine.model.mvi.WriteRoutineSideEffect -import com.threegap.bitnagil.presentation.writeroutine.model.mvi.WriteRoutineState import org.orbitmvi.orbit.compose.collectAsState import org.orbitmvi.orbit.compose.collectSideEffect @@ -359,7 +359,7 @@ private fun getSubRoutinePlaceHolder(index: Int): String { fun WriteRoutineScreenPreview() { BitnagilTheme { WriteRoutineScreen( - state = WriteRoutineState.Init.copy(periodUiExpanded = true, startTimeUiExpanded = true), + state = WriteRoutineState.INIT.copy(periodUiExpanded = true, startTimeUiExpanded = true), setRoutineName = {}, setSubRoutineName = { _, _ -> }, selectRepeatTime = {}, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineViewModel.kt index bd32df3d..1beb06f5 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/WriteRoutineViewModel.kt @@ -8,17 +8,17 @@ import com.threegap.bitnagil.domain.writeroutine.model.RepeatDay import com.threegap.bitnagil.domain.writeroutine.model.RoutineUpdateType import com.threegap.bitnagil.domain.writeroutine.usecase.EditRoutineUseCase import com.threegap.bitnagil.domain.writeroutine.usecase.RegisterRoutineUseCase -import com.threegap.bitnagil.presentation.common.extension.displayTitle +import com.threegap.bitnagil.presentation.writeroutine.contract.WriteRoutineSideEffect +import com.threegap.bitnagil.presentation.writeroutine.contract.WriteRoutineState import com.threegap.bitnagil.presentation.writeroutine.model.Date import com.threegap.bitnagil.presentation.writeroutine.model.Day import com.threegap.bitnagil.presentation.writeroutine.model.RepeatType import com.threegap.bitnagil.presentation.writeroutine.model.SelectableDay -import com.threegap.bitnagil.presentation.writeroutine.model.SubRoutine +import com.threegap.bitnagil.presentation.writeroutine.model.SubRoutineUiModel import com.threegap.bitnagil.presentation.writeroutine.model.Time import com.threegap.bitnagil.presentation.writeroutine.model.WriteRoutineType -import com.threegap.bitnagil.presentation.writeroutine.model.mvi.WriteRoutineSideEffect -import com.threegap.bitnagil.presentation.writeroutine.model.mvi.WriteRoutineState import com.threegap.bitnagil.presentation.writeroutine.model.navarg.WriteRoutineScreenArg +import com.threegap.bitnagil.presentation.writeroutine.model.toUiModel import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject @@ -42,11 +42,11 @@ class WriteRoutineViewModel @AssistedInject constructor( override val container: Container = container( savedStateHandle = savedStateHandle, - initialState = WriteRoutineState.Init, + initialState = WriteRoutineState.INIT, ) private var routineId: String? = null - private var oldSubRoutines: List = listOf() + private var oldSubRoutineUiModels: List = listOf() init { val navigationArg = writeRoutineArg @@ -131,7 +131,7 @@ class WriteRoutineViewModel @AssistedInject constructor( } getRecommendRoutineUseCase(recommendRoutineId).fold( onSuccess = { routine -> - oldSubRoutines = routine.recommendSubRoutines.map { SubRoutine.fromDomainRecommendSubRoutine(it) } + oldSubRoutineUiModels = routine.subRoutines.map { it.toUiModel() } reduce { state.copy( @@ -142,12 +142,12 @@ class WriteRoutineViewModel @AssistedInject constructor( startDate = Date.now(), endDate = Date.now(), subRoutineNames = listOf( - oldSubRoutines.getOrNull(0)?.name ?: "", - oldSubRoutines.getOrNull(1)?.name ?: "", - oldSubRoutines.getOrNull(2)?.name ?: "", + oldSubRoutineUiModels.getOrNull(0)?.name ?: "", + oldSubRoutineUiModels.getOrNull(1)?.name ?: "", + oldSubRoutineUiModels.getOrNull(2)?.name ?: "", ), loading = false, - recommendedRoutineType = routine.recommendedRoutineType.displayTitle, + recommendedRoutineType = routine.category, ) } }, diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/contract/WriteRoutineSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/contract/WriteRoutineSideEffect.kt new file mode 100644 index 00000000..cbf9497a --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/contract/WriteRoutineSideEffect.kt @@ -0,0 +1,6 @@ +package com.threegap.bitnagil.presentation.writeroutine.contract + +sealed interface WriteRoutineSideEffect { + data object MoveToPreviousScreen : WriteRoutineSideEffect + data class ShowToast(val message: String) : WriteRoutineSideEffect +} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/mvi/WriteRoutineState.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/contract/WriteRoutineState.kt similarity index 90% rename from presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/mvi/WriteRoutineState.kt rename to presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/contract/WriteRoutineState.kt index 5f67d6fe..d3523530 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/mvi/WriteRoutineState.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/contract/WriteRoutineState.kt @@ -1,6 +1,7 @@ -package com.threegap.bitnagil.presentation.writeroutine.model.mvi +package com.threegap.bitnagil.presentation.writeroutine.contract import android.os.Parcelable +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory import com.threegap.bitnagil.presentation.writeroutine.model.Date import com.threegap.bitnagil.presentation.writeroutine.model.Day import com.threegap.bitnagil.presentation.writeroutine.model.RepeatType @@ -29,10 +30,10 @@ data class WriteRoutineState( val repeatDaysUiExpanded: Boolean, val periodUiExpanded: Boolean, val startTimeUiExpanded: Boolean, - val recommendedRoutineType: String?, + val recommendedRoutineType: RecommendCategory?, ) : Parcelable { companion object { - val Init = WriteRoutineState( + val INIT = WriteRoutineState( routineName = "", subRoutineNames = listOf("", "", ""), selectNotUseSubRoutines = false, @@ -96,9 +97,8 @@ data class WriteRoutineState( null -> "" } - val periodText: String get() { - return "${startDate.toYearShrinkageFormattedString()} ~ ${endDate.toYearShrinkageFormattedString()}" - } + val periodText: String + get() = "${startDate.toYearShrinkageFormattedString()} ~ ${endDate.toYearShrinkageFormattedString()}" val startTimeText: String get() = if (selectAllTime) "하루종일" else startTime?.let { "${it.toAmPmFormattedString()}부터 시작" } ?: "" diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/SubRoutine.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/SubRoutine.kt deleted file mode 100644 index 89547aa2..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/SubRoutine.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.threegap.bitnagil.presentation.writeroutine.model - -import com.threegap.bitnagil.domain.recommendroutine.model.RecommendSubRoutine - -data class SubRoutine( - val id: String, - val name: String, -) { - companion object { - fun fromDomainRecommendSubRoutine(subRoutine: RecommendSubRoutine): SubRoutine { - return SubRoutine( - id = subRoutine.id.toString(), - name = subRoutine.name, - ) - } - } -} diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/SubRoutineUiModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/SubRoutineUiModel.kt new file mode 100644 index 00000000..14ebd61f --- /dev/null +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/SubRoutineUiModel.kt @@ -0,0 +1,14 @@ +package com.threegap.bitnagil.presentation.writeroutine.model + +import com.threegap.bitnagil.domain.recommendroutine.model.RecommendSubRoutine + +data class SubRoutineUiModel( + val id: String, + val name: String, +) + +internal fun RecommendSubRoutine.toUiModel(): SubRoutineUiModel = + SubRoutineUiModel( + id = id.toString(), + name = name, + ) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/mvi/WriteRoutineSideEffect.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/mvi/WriteRoutineSideEffect.kt deleted file mode 100644 index c9e52bd6..00000000 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/writeroutine/model/mvi/WriteRoutineSideEffect.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.threegap.bitnagil.presentation.writeroutine.model.mvi - -sealed class WriteRoutineSideEffect { - data object MoveToPreviousScreen : WriteRoutineSideEffect() - data class ShowToast(val message: String) : WriteRoutineSideEffect() -}