From 48560e8226ebf60c4c0b13f6138b65cda1eb3b82 Mon Sep 17 00:00:00 2001 From: uiel Date: Wed, 12 Jun 2024 20:20:55 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20LocalTime=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team/aliens/dms/android/shared/date/util/Utils.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/date/src/main/java/team/aliens/dms/android/shared/date/util/Utils.kt b/shared/date/src/main/java/team/aliens/dms/android/shared/date/util/Utils.kt index 5637768a2..1bdc45411 100644 --- a/shared/date/src/main/java/team/aliens/dms/android/shared/date/util/Utils.kt +++ b/shared/date/src/main/java/team/aliens/dms/android/shared/date/util/Utils.kt @@ -2,9 +2,13 @@ package team.aliens.dms.android.shared.date.util import org.threeten.bp.LocalDate import org.threeten.bp.LocalDateTime +import org.threeten.bp.LocalTime val today: LocalDate inline get() = LocalDate.now() val now: LocalDateTime inline get() = LocalDateTime.now() + +val timeNow: LocalTime + inline get() = LocalTime.now() From 3abdc3dd6a6edaf50dd8af8a975e63f78f47263f Mon Sep 17 00:00:00 2001 From: uiel Date: Wed, 12 Jun 2024 21:23:08 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dms/android/data/outing/model/OutingApplicationTime.kt | 2 ++ .../network/outing/model/OutingAvailableTimeResponse.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/data/src/main/java/team/aliens/dms/android/data/outing/model/OutingApplicationTime.kt b/data/src/main/java/team/aliens/dms/android/data/outing/model/OutingApplicationTime.kt index f30811a53..2173a7a04 100644 --- a/data/src/main/java/team/aliens/dms/android/data/outing/model/OutingApplicationTime.kt +++ b/data/src/main/java/team/aliens/dms/android/data/outing/model/OutingApplicationTime.kt @@ -6,6 +6,7 @@ import java.util.UUID data class OutingApplicationTime( val id: UUID, + val schoolId: UUID, val startTime: String, val endTime: String, val available: Boolean, @@ -21,6 +22,7 @@ fun List.toModel(): List, ) { data class AvailableTimeResponse( - @SerializedName("outing_available_time_id") val id: String, + @SerializedName("id") val id: String, + @SerializedName("school_id") val schoolId: String, @SerializedName("outing_time") val startTime: String, @SerializedName("arrival_time") val endTime: String, @SerializedName("enabled") val available: Boolean, From ae1954d504816c6eaf64f5380799c1b0391b744b Mon Sep 17 00:00:00 2001 From: uiel Date: Wed, 12 Jun 2024 21:23:53 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20type=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../outing/repository/OutingRepository.kt | 5 ++-- .../outing/repository/OutingRepositoryImpl.kt | 11 ++++----- .../feature/outing/OutingApplicationScreen.kt | 23 +++++++------------ 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepository.kt b/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepository.kt index 4fb15db9a..a3b910829 100644 --- a/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepository.kt +++ b/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepository.kt @@ -3,6 +3,7 @@ package team.aliens.dms.android.data.outing.repository import org.threeten.bp.DayOfWeek import org.threeten.bp.LocalDate import org.threeten.bp.LocalDateTime +import org.threeten.bp.LocalTime import team.aliens.dms.android.data.outing.model.CurrentAppliedOutingApplication import team.aliens.dms.android.data.outing.model.OutingApplicationId import team.aliens.dms.android.data.outing.model.OutingApplicationTime @@ -13,8 +14,8 @@ abstract class OutingRepository { abstract suspend fun applyOuting( date: LocalDate, - startTime: LocalDateTime, - endTime: LocalDateTime, + startTime: LocalTime, + endTime: LocalTime, type: String, reason: String?, companionIds: List, diff --git a/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepositoryImpl.kt b/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepositoryImpl.kt index 025f55aa7..a82293bf4 100644 --- a/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepositoryImpl.kt +++ b/data/src/main/java/team/aliens/dms/android/data/outing/repository/OutingRepositoryImpl.kt @@ -2,7 +2,7 @@ package team.aliens.dms.android.data.outing.repository import org.threeten.bp.DayOfWeek import org.threeten.bp.LocalDate -import org.threeten.bp.LocalDateTime +import org.threeten.bp.LocalTime import org.threeten.bp.format.DateTimeFormatter import team.aliens.dms.android.data.outing.model.CurrentAppliedOutingApplication import team.aliens.dms.android.data.outing.model.OutingApplicationId @@ -10,7 +10,6 @@ import team.aliens.dms.android.data.outing.model.OutingApplicationTime import team.aliens.dms.android.data.outing.model.toModel import team.aliens.dms.android.network.outing.datasource.OutingNetworkDataSource import team.aliens.dms.android.network.outing.model.ApplyOutingRequest -import java.text.SimpleDateFormat import java.util.UUID import javax.inject.Inject @@ -22,16 +21,16 @@ class OutingRepositoryImpl @Inject constructor( override suspend fun applyOuting( date: LocalDate, - startTime: LocalDateTime, - endTime: LocalDateTime, + startTime: LocalTime, + endTime: LocalTime, type: String, reason: String?, companionIds: List ): OutingApplicationId = outingNetworkDataSource.applyOuting( req = ApplyOutingRequest( date = date.format(DateTimeFormatter.ISO_LOCAL_DATE), - startTime = startTime.format(DateTimeFormatter.ofPattern("hh:mm:00")), - endTime = endTime.format(DateTimeFormatter.ofPattern("hh:mm:00")), + startTime = startTime.toString(), + endTime = endTime.toString(), type = type, reason = reason, companionIds = companionIds, diff --git a/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingApplicationScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingApplicationScreen.kt index 3d93257c3..ef3ae8acb 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingApplicationScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingApplicationScreen.kt @@ -54,6 +54,7 @@ import com.ramcosta.composedestinations.annotation.Destination import kotlinx.coroutines.launch import org.threeten.bp.DayOfWeek import org.threeten.bp.LocalDateTime +import org.threeten.bp.LocalTime import team.aliens.dms.android.core.designsystem.AlertDialog import team.aliens.dms.android.core.designsystem.Button import team.aliens.dms.android.core.designsystem.DmsTheme @@ -107,11 +108,7 @@ fun OutingApplicationScreen( onClick = { viewModel.postIntent( OutingIntent.UpdateOutingStartTime( - value = LocalDateTime.of( - // TODO: 죄송합니다.. - 2006, - 5, - 8, + value = LocalTime.of( startTimePickerState.hour, startTimePickerState.minute, ), @@ -139,14 +136,10 @@ fun OutingApplicationScreen( onClick = { viewModel.postIntent( OutingIntent.UpdateOutingEndTime( - value = LocalDateTime.of( - // TODO: 죄송합니다.. - 2006, - 5, - 8, + value = LocalTime.of( endTimePickerState.hour, endTimePickerState.minute, - ), + ) ) ) onChangeShouldShowEndTimePicker(false) @@ -336,10 +329,10 @@ fun OutingApplicationScreen( modifier = Modifier.endPadding(), text = stringResource( id = R.string.format_date_yyyy_mm_dd_day_of_week, - uiState.capturedNow.year, - uiState.capturedNow.month.value, - uiState.capturedNow.dayOfMonth, - uiState.capturedNow.dayOfWeek.text, + uiState.outingDate.year, + uiState.outingDate.month.value, + uiState.outingDate.dayOfMonth, + uiState.outingDate.dayOfWeek.text, ), ) } From 0db2260cc41775369446d96d7c9ef09aa3ffbe57 Mon Sep 17 00:00:00 2001 From: uiel Date: Wed, 12 Jun 2024 21:25:12 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=99=B8?= =?UTF-8?q?=EC=B6=9C=20=EC=9D=BC=EC=9E=90=20=EC=B2=98=EB=A6=AC=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/feature/outing/OutingViewModel.kt | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingViewModel.kt b/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingViewModel.kt index d2bafdec4..221aa87bc 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingViewModel.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/outing/OutingViewModel.kt @@ -4,7 +4,8 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import org.threeten.bp.LocalDateTime +import org.threeten.bp.LocalDate +import org.threeten.bp.LocalTime import team.aliens.dms.android.core.ui.mvi.BaseMviViewModel import team.aliens.dms.android.core.ui.mvi.Intent import team.aliens.dms.android.core.ui.mvi.SideEffect @@ -15,6 +16,7 @@ import team.aliens.dms.android.data.outing.repository.OutingRepository import team.aliens.dms.android.data.student.model.Student import team.aliens.dms.android.data.student.repository.StudentRepository import team.aliens.dms.android.shared.date.util.now +import team.aliens.dms.android.shared.date.util.timeNow import team.aliens.dms.android.shared.date.util.today import java.util.UUID import javax.inject.Inject @@ -31,6 +33,7 @@ class OutingViewModel @Inject constructor( fetchCurrentAppliedOutingApplication() fetchOutingTypes() fetchStudents() + fetchOutingDate() } override fun processIntent(intent: OutingIntent) { @@ -96,6 +99,15 @@ class OutingViewModel @Inject constructor( } } + private fun fetchOutingDate() { + val captureOutingDate: LocalDate = stateFlow.value.outingDate + if (now.hour >= 20) { + reduce( + newState = stateFlow.value.copy(outingDate = captureOutingDate.plusDays(1)) + ) + } + } + private fun fetchOutingTypes() = viewModelScope.launch(Dispatchers.IO) { runCatching { outingRepository.fetchOutingTypes(null) @@ -120,14 +132,13 @@ class OutingViewModel @Inject constructor( ), ) - private fun updateOutingStartTime(value: LocalDateTime) = reduce( + private fun updateOutingStartTime(value: LocalTime) = reduce( newState = stateFlow.value.copy( selectedOutingStartTime = value, ), ) - - private fun updateOutingEndTime(value: LocalDateTime) = reduce( + private fun updateOutingEndTime(value: LocalTime) = reduce( newState = stateFlow.value.copy( selectedOutingEndTime = value, ), @@ -143,7 +154,7 @@ class OutingViewModel @Inject constructor( viewModelScope.launch(Dispatchers.IO) { runCatching { outingRepository.applyOuting( - date = capturedState.capturedNow.toLocalDate(), + date = capturedState.outingDate, startTime = capturedState.selectedOutingStartTime, endTime = capturedState.selectedOutingEndTime, type = capturedState.selectedOutingType, @@ -157,7 +168,7 @@ class OutingViewModel @Inject constructor( ), ) postSideEffect(OutingSideEffect.OutingApplicationSuccess(applicationId)) - }.onSuccess { + }.onFailure { postSideEffect(OutingSideEffect.OutingApplicationTimeError) } } @@ -202,9 +213,9 @@ data class OutingUiState( val outingTypes: List?, val selectedOutingType: String?, val reason: String, - val capturedNow: LocalDateTime, - val selectedOutingStartTime: LocalDateTime, - val selectedOutingEndTime: LocalDateTime, + val outingDate: LocalDate, + val selectedOutingStartTime: LocalTime, + val selectedOutingEndTime: LocalTime, val companionIds: List, val students: List?, val selectedStudents: List, @@ -212,17 +223,16 @@ data class OutingUiState( ) : UiState() { companion object { fun initial(): OutingUiState { - val capturedNow = now return OutingUiState( outingApplicationTime = null, currentAppliedOutingApplication = null, outingTypes = null, selectedOutingType = null, reason = "", - capturedNow = capturedNow, + outingDate = today, // TODO: remove hard-coded string resources from viewmodel - selectedOutingEndTime = now, - selectedOutingStartTime = now, + selectedOutingEndTime = timeNow, + selectedOutingStartTime = timeNow, companionIds = emptyList(), students = null, selectedStudents = emptyList(), @@ -236,8 +246,8 @@ sealed class OutingIntent : Intent() { data object CancelCurrentApplication : OutingIntent() class UpdateSelectedOutingType(val value: String) : OutingIntent() class UpdateReason(val value: String) : OutingIntent() - class UpdateOutingStartTime(val value: LocalDateTime) : OutingIntent() - class UpdateOutingEndTime(val value: LocalDateTime) : OutingIntent() + class UpdateOutingStartTime(val value: LocalTime) : OutingIntent() + class UpdateOutingEndTime(val value: LocalTime) : OutingIntent() data object ApplyOuting : OutingIntent() class SelectStudent( val student: Student, From 09f74c8b6e0725d2f2e354ce3541926adf8a39f4 Mon Sep 17 00:00:00 2001 From: uielPark Date: Thu, 13 Jun 2024 16:22:00 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B2=84?= =?UTF-8?q?=EC=A0=84=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6faca4d95..346a70ab7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,8 +17,8 @@ android { minSdk = libs.versions.minSdk.get().toInt() targetSdk = libs.versions.targetSdk.get().toInt() - versionCode = 13 - versionName = "1.3.4" + versionCode = 14 + versionName = "1.3.5" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" }