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..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 @@ -6,19 +6,30 @@ 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.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 (isTodayDay3()) { + FloorLevel.Ground + } else { + FloorLevel.Basement + }, + ) private val floorMapSideEventListUiState = FloorMapSideEventListUiState( sideEvents = SideEvents, ) @@ -57,6 +68,15 @@ class FloorMapScreenViewModel @Inject constructor( ) } + 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")) && + currentInTokyo < Day3.end.toLocalDateTime(TimeZone.of("Asia/Tokyo")) + } fun onClickFloorLevelSwitcher(floorLevel: FloorLevel) { floorLevelStateFlow.value = floorLevel }