From 99317e266e924880faf9d0609e4c0ad94a6a3b2a Mon Sep 17 00:00:00 2001 From: todayama_r <13657682+Corvus400@users.noreply.github.com> Date: Fri, 8 Sep 2023 23:52:56 +0900 Subject: [PATCH 1/4] :recycle: Day3 shows the 1st floor and the rest show the basement. --- .../floormap/FloorMapScreenViewModel.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt index 84095c0c0..774b43b7b 100644 --- a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt +++ b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt @@ -6,19 +6,31 @@ import io.github.droidkaigi.confsched2023.floormap.FloorMapContentUiState.LargeF import io.github.droidkaigi.confsched2023.floormap.FloorMapContentUiState.SmallFloorMapContentUiState import io.github.droidkaigi.confsched2023.floormap.section.FloorMapSideEventListUiState import io.github.droidkaigi.confsched2023.floormap.section.FloorMapUiState +import io.github.droidkaigi.confsched2023.model.DroidKaigi2023Day.Day3 import io.github.droidkaigi.confsched2023.model.FloorLevel import io.github.droidkaigi.confsched2023.model.SideEvents import io.github.droidkaigi.confsched2023.ui.UserMessageStateHolder import io.github.droidkaigi.confsched2023.ui.buildUiState import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.datetime.Clock +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.TimeZone +import kotlinx.datetime.toInstant +import kotlinx.datetime.toLocalDateTime import javax.inject.Inject @HiltViewModel class FloorMapScreenViewModel @Inject constructor( val userMessageStateHolder: UserMessageStateHolder, ) : ViewModel(), UserMessageStateHolder by userMessageStateHolder { - private val floorLevelStateFlow = MutableStateFlow(FloorLevel.Basement) + private val floorLevelStateFlow = MutableStateFlow( + if (Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).isTodayDay3()) { + FloorLevel.Ground + } else { + FloorLevel.Basement + }, + ) private val floorMapSideEventListUiState = FloorMapSideEventListUiState( sideEvents = SideEvents, ) @@ -33,6 +45,14 @@ class FloorMapScreenViewModel @Inject constructor( FloorMapUiState.of(floorLevel) } + private fun LocalDateTime.isTodayDay3(): Boolean { + val currentInTokyo = this.toInstant(TimeZone.currentSystemDefault()).toLocalDateTime( + TimeZone.of("Asia/Tokyo"), + ) + return currentInTokyo >= Day3.start.toLocalDateTime(TimeZone.of("Asia/Tokyo")) && + currentInTokyo < Day3.end.toLocalDateTime(TimeZone.of("Asia/Tokyo")) + } + val uiState = buildUiState( floorLevelStateFlow, floorMapUiStateFlow, From 6eb113d440f3dd6ae7dd7d444f56dd912a3630dc Mon Sep 17 00:00:00 2001 From: todayama_r <13657682+Corvus400@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:06:04 +0900 Subject: [PATCH 2/4] :wrench: ./gradlew detekt --auto-correct --- .../floormap/FloorMapScreenViewModel.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt index 774b43b7b..cc6cd9906 100644 --- a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt +++ b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt @@ -45,14 +45,6 @@ class FloorMapScreenViewModel @Inject constructor( FloorMapUiState.of(floorLevel) } - private fun LocalDateTime.isTodayDay3(): Boolean { - val currentInTokyo = this.toInstant(TimeZone.currentSystemDefault()).toLocalDateTime( - TimeZone.of("Asia/Tokyo"), - ) - return currentInTokyo >= Day3.start.toLocalDateTime(TimeZone.of("Asia/Tokyo")) && - currentInTokyo < Day3.end.toLocalDateTime(TimeZone.of("Asia/Tokyo")) - } - val uiState = buildUiState( floorLevelStateFlow, floorMapUiStateFlow, @@ -77,6 +69,13 @@ class FloorMapScreenViewModel @Inject constructor( ) } + private fun LocalDateTime.isTodayDay3(): Boolean { + val currentInTokyo = this.toInstant(TimeZone.currentSystemDefault()).toLocalDateTime( + TimeZone.of("Asia/Tokyo"), + ) + return currentInTokyo >= Day3.start.toLocalDateTime(TimeZone.of("Asia/Tokyo")) && + currentInTokyo < Day3.end.toLocalDateTime(TimeZone.of("Asia/Tokyo")) + } fun onClickFloorLevelSwitcher(floorLevel: FloorLevel) { floorLevelStateFlow.value = floorLevel } From bd94055917cdc605489ada6ca94cff8a5b4597af Mon Sep 17 00:00:00 2001 From: todayama_r <13657682+Corvus400@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:16:00 +0900 Subject: [PATCH 3/4] :wrench: Correct redundant descriptions. --- .../confsched2023/floormap/FloorMapScreenViewModel.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt index cc6cd9906..024ee3833 100644 --- a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt +++ b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt @@ -25,7 +25,7 @@ class FloorMapScreenViewModel @Inject constructor( val userMessageStateHolder: UserMessageStateHolder, ) : ViewModel(), UserMessageStateHolder by userMessageStateHolder { private val floorLevelStateFlow = MutableStateFlow( - if (Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).isTodayDay3()) { + if (isTodayDay3()) { FloorLevel.Ground } else { FloorLevel.Basement @@ -69,8 +69,10 @@ class FloorMapScreenViewModel @Inject constructor( ) } - private fun LocalDateTime.isTodayDay3(): Boolean { - val currentInTokyo = this.toInstant(TimeZone.currentSystemDefault()).toLocalDateTime( + private fun isTodayDay3(): Boolean { + val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) + + val currentInTokyo = now.toInstant(TimeZone.currentSystemDefault()).toLocalDateTime( TimeZone.of("Asia/Tokyo"), ) return currentInTokyo >= Day3.start.toLocalDateTime(TimeZone.of("Asia/Tokyo")) && From a6f3e834bca77d872af4ac34b16bb547184bd026 Mon Sep 17 00:00:00 2001 From: todayama_r <13657682+Corvus400@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:16:12 +0900 Subject: [PATCH 4/4] :wrench: ./gradlew detekt --auto-correct --- .../droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt index 024ee3833..fefb17ed7 100644 --- a/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt +++ b/feature/floor-map/src/main/java/io/github/droidkaigi/confsched2023/floormap/FloorMapScreenViewModel.kt @@ -14,7 +14,6 @@ import io.github.droidkaigi.confsched2023.ui.buildUiState import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.datetime.Clock -import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone import kotlinx.datetime.toInstant import kotlinx.datetime.toLocalDateTime