diff --git a/clients/tablet/core/ui/build.gradle.kts b/clients/tablet/core/ui/build.gradle.kts index 0b70ba248cdba4297b68035aeb57c4e7fdf86d2e..3e7671809ccd832159075017d4ae85d1913dfb97 100644 --- a/clients/tablet/core/ui/build.gradle.kts +++ b/clients/tablet/core/ui/build.gradle.kts @@ -10,6 +10,7 @@ kotlin { implementation(libs.decompose.compose.jetbrains) implementation(libs.essenty.lifecycle) implementation(libs.essenty.state.keeper) + api(libs.kotlinx.datetime) } } } diff --git a/clients/tablet/core/ui/src/androidMain/kotlin/band/effective/office/tablet/core/ui/util/DateFormatter.android.kt b/clients/tablet/core/ui/src/androidMain/kotlin/band/effective/office/tablet/core/ui/util/DateFormatter.android.kt new file mode 100644 index 0000000000000000000000000000000000000000..b2ebeb9d11c3b36cbe9ba1f5442a7fef0cc76dae --- /dev/null +++ b/clients/tablet/core/ui/src/androidMain/kotlin/band/effective/office/tablet/core/ui/util/DateFormatter.android.kt @@ -0,0 +1,11 @@ +package band.effective.office.tablet.core.ui.utils + +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.toJavaLocalDateTime +import java.time.format.DateTimeFormatter +import java.util.Locale + +actual fun LocalDateTime.toLocalisedString(pattern: String): String { + val formatter = DateTimeFormatter.ofPattern(pattern, Locale.getDefault()) + return this.toJavaLocalDateTime().format(formatter) +} \ No newline at end of file diff --git a/clients/tablet/core/ui/src/commonMain/composeResources/values-ru/strings_ru.xml b/clients/tablet/core/ui/src/commonMain/composeResources/values-ru/strings_ru.xml new file mode 100644 index 0000000000000000000000000000000000000000..3ccdf63f76759e4c30816f2c672b21b69629f637 --- /dev/null +++ b/clients/tablet/core/ui/src/commonMain/composeResources/values-ru/strings_ru.xml @@ -0,0 +1,36 @@ + + + Нет соединения с сервером + Перезагрузите приложение + Перезагрузить приложение + Когда + На сколько + Организатор + ${date} с ${time} + - 15 мин + + 30 мин + мин + ч + Выберите организатора + Неверный организатор, попробуйте еще раз + Занять с + Подтвердить + Нет подключения к интернету + Забронирована до %1$s + Отменить бронь + Свободных нет + Через %1$s мин освободится %2$s. Пока что попробуйте найти тихое место в офисе + Вас кто-то опередил + Попробуйте занять другую переговорку, либо выберите другое время брони + Это время уже занято + %1$s, %2$s — %3$s + На главную + Вы заняли %1$s + Отмена + Загрузка слота на время: %1$s - %2$s + Свободно %1$s мин + Занято %1$s + %1$s брони + Слот загружается + Ошибка. Повторите попытку позже + \ No newline at end of file diff --git a/clients/tablet/core/ui/src/commonMain/composeResources/values/strings.xml b/clients/tablet/core/ui/src/commonMain/composeResources/values/strings.xml index 3ccdf63f76759e4c30816f2c672b21b69629f637..c661b9cf13c08d18752c18609e52da8faf41110b 100644 --- a/clients/tablet/core/ui/src/commonMain/composeResources/values/strings.xml +++ b/clients/tablet/core/ui/src/commonMain/composeResources/values/strings.xml @@ -1,36 +1,36 @@ - Нет соединения с сервером - Перезагрузите приложение - Перезагрузить приложение - Когда - На сколько - Организатор - ${date} с ${time} - - 15 мин - + 30 мин - мин - ч - Выберите организатора - Неверный организатор, попробуйте еще раз - Занять с - Подтвердить - Нет подключения к интернету - Забронирована до %1$s - Отменить бронь - Свободных нет - Через %1$s мин освободится %2$s. Пока что попробуйте найти тихое место в офисе - Вас кто-то опередил - Попробуйте занять другую переговорку, либо выберите другое время брони - Это время уже занято + No server connection + Restart the app + Restart app + When + Duration + Organizer + ${date} at ${time} + - 15 min + + 30 min + min + h + Select organizer + Invalid organizer, try again + Book from + Confirm + No internet connection + Booked until %1$s + Cancel booking + No free rooms + In %1$s min, %2$s will be free. For now, try finding a quiet place in the office + Someone booked it before you + Try booking another meeting room or choose a different time + This time is already booked %1$s, %2$s — %3$s - На главную - Вы заняли %1$s - Отмена - Загрузка слота на время: %1$s - %2$s - Свободно %1$s мин - Занято %1$s - %1$s брони - Слот загружается - Ошибка. Повторите попытку позже + Back to main + You booked %1$s + Cancel + Loading slot for time: %1$s - %2$s + Free for %1$s min + Booked by %1$s + %1$s bookings + Slot is loading + Error. Try again later \ No newline at end of file diff --git a/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/date/DateTimeView.kt b/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/date/DateTimeView.kt index 14e96ef835d7d798b3911dafe4ed563258c489c0..7af3ec7d9b8d7960ca065f7214d5a3078ea5c670 100644 --- a/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/date/DateTimeView.kt +++ b/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/date/DateTimeView.kt @@ -40,6 +40,7 @@ import kotlin.time.ExperimentalTime import kotlinx.datetime.LocalDateTime import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.stringResource +import band.effective.office.tablet.core.ui.utils.DateDisplayMapper @OptIn(ExperimentalTime::class) @Composable @@ -122,7 +123,10 @@ private fun RowScope.SelectedDate( contentPadding = PaddingValues(0.dp) ) { AnimatedContent( - targetState = displayedFormat.format(selectDate), + targetState = DateDisplayMapper.map( + selectDate = selectDate, + currentDate = currentDate + ), transitionSpec = { slideIntoContainer(slideDirection) + fadeIn() with slideOutOfContainer(slideDirection.opposite()) + fadeOut() diff --git a/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateDisplayMapper.kt b/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateDisplayMapper.kt new file mode 100644 index 0000000000000000000000000000000000000000..5590bec78758e9cc39d5b7c6792fc5e10f6fe120 --- /dev/null +++ b/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateDisplayMapper.kt @@ -0,0 +1,20 @@ +package band.effective.office.tablet.core.ui.utils + + +import kotlinx.datetime.LocalDateTime + +object DateDisplayMapper { + + private const val FUTURE_DATE_FORMAT = "d MMMM" + private const val DEFAULT_DATE_FORMAT = "HH:mm, d MMMM" + + fun map(selectDate: LocalDateTime, currentDate: LocalDateTime?): String { + val isFutureDate = currentDate != null && selectDate.date > currentDate.date + val pattern = if (isFutureDate) FUTURE_DATE_FORMAT else DEFAULT_DATE_FORMAT + return selectDate.toLocalisedString(pattern) + } + + fun formatForPicker(date: LocalDateTime): String { + return date.toLocalisedString(FUTURE_DATE_FORMAT) + } +} \ No newline at end of file diff --git a/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.kt b/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.kt new file mode 100644 index 0000000000000000000000000000000000000000..d6a5e1f1465b6d38e89a59878daf62453e1984b6 --- /dev/null +++ b/clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.kt @@ -0,0 +1,6 @@ +package band.effective.office.tablet.core.ui.utils + +import kotlinx.datetime.LocalDateTime + +@OptIn(kotlinx.datetime.format.FormatStringsInDatetimeFormats::class) +expect fun LocalDateTime.toLocalisedString(pattern: String): String diff --git a/clients/tablet/core/ui/src/iosMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.ios.kt b/clients/tablet/core/ui/src/iosMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.ios.kt new file mode 100644 index 0000000000000000000000000000000000000000..cb4e9add813420b3b9c190b4f7c22cde43582ad4 --- /dev/null +++ b/clients/tablet/core/ui/src/iosMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.ios.kt @@ -0,0 +1,23 @@ +package band.effective.office.tablet.core.ui.utils + +import kotlinx.datetime.LocalDateTime +import platform.Foundation.NSDate +import platform.Foundation.NSDateFormatter +import platform.Foundation.NSLocale +import platform.Foundation.currentLocale + + +import kotlinx.datetime.toNSDateComponents +import platform.Foundation.* + +actual fun LocalDateTime.toLocalisedString(pattern: String): String { + val dateFormatter = NSDateFormatter() + dateFormatter.dateFormat = pattern + dateFormatter.locale = NSLocale.currentLocale + + val calendar = NSCalendar.currentCalendar + val dateComponents = toNSDateComponents() + + val date = calendar.dateFromComponents(dateComponents) ?: NSDate() + return dateFormatter.stringFromDate(date) +} \ No newline at end of file diff --git a/clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values-ru/strings_ru.xml b/clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values-ru/strings_ru.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a9ea279d8c9619fad921f25819631fbe634bb07 --- /dev/null +++ b/clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values-ru/strings_ru.xml @@ -0,0 +1,12 @@ + + + Занять %1$s + Изменить бронь + Занять c %1$s до %2$s + Изменить + Удалить бронь + Произошла ошибка + Ошибка, выбрана неправильная дата + Ошибка при создании события + Ошибка при удалении события + diff --git a/clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values/strings.xml b/clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values/strings.xml index 9e4c2290b2cf798069d28a2170bb654a04164f4f..989bb565c16d761193a283849860216340e44524 100644 --- a/clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values/strings.xml +++ b/clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values/strings.xml @@ -1,12 +1,12 @@ - Занять %1$s - Изменить бронь - Занять c %1$s до %2$s - Изменить - Удалить бронь - Произошла ошибка - Ошибка, выбрана неправильная дата + Book %1$s + Edit booking + Book from %1$s to %2$s + Update + Delete booking + An error occurred + Error, incorrect date selected Error creating event - Error deleting event" + Error deleting event \ No newline at end of file diff --git a/clients/tablet/feature/bookingEditor/src/commonMain/kotlin/band/effective/office/tablet/feature/bookingEditor/presentation/datetimepicker/DateTimePickerModalView.kt b/clients/tablet/feature/bookingEditor/src/commonMain/kotlin/band/effective/office/tablet/feature/bookingEditor/presentation/datetimepicker/DateTimePickerModalView.kt index 62c63d4195e6ca1c104669662ea7800fb3c53d15..98a2a784113a088853cef78c8e3934806833cc21 100644 --- a/clients/tablet/feature/bookingEditor/src/commonMain/kotlin/band/effective/office/tablet/feature/bookingEditor/presentation/datetimepicker/DateTimePickerModalView.kt +++ b/clients/tablet/feature/bookingEditor/src/commonMain/kotlin/band/effective/office/tablet/feature/bookingEditor/presentation/datetimepicker/DateTimePickerModalView.kt @@ -24,11 +24,11 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties -import band.effective.office.tablet.core.domain.util.toFormattedString import band.effective.office.tablet.core.ui.common.CrossButtonView import band.effective.office.tablet.core.ui.theme.LocalCustomColorsPalette import band.effective.office.tablet.core.ui.theme.header8 import band.effective.office.tablet.core.ui.time_booked +import band.effective.office.tablet.core.ui.utils.DateDisplayMapper import band.effective.office.tablet.feature.bookingEditor.presentation.datetimepicker.components.DatePickerView import band.effective.office.tablet.feature.bookingEditor.presentation.datetimepicker.components.TimePickerView import kotlinx.datetime.LocalDate @@ -114,7 +114,7 @@ fun DateTimePickerModalView( ) { Text( text = when (enableDateButton) { - true -> "${currentDate.dayOfMonth} ${currentDate.month.name} ${currentDate.toFormattedString("HH:mm")}" + true -> DateDisplayMapper.formatForPicker(currentDate) false -> stringResource(band.effective.office.tablet.core.ui.Res.string.time_booked) }, style = header8, diff --git a/clients/tablet/feature/main/src/commonMain/composeResources/values-ru/strings_ru.xml b/clients/tablet/feature/main/src/commonMain/composeResources/values-ru/strings_ru.xml new file mode 100644 index 0000000000000000000000000000000000000000..bed24afc7c0287bcb05d113b470f9d7c937405be --- /dev/null +++ b/clients/tablet/feature/main/src/commonMain/composeResources/values-ru/strings_ru.xml @@ -0,0 +1,52 @@ + + + Занято до %1$s + · До конца %1$s + Свободна до %1$s + · До начала %1$s + Освободить + TV + USB + Розетка + Розетки + Розеток + час + часа + часов + минута + минуты + минут + Занять + Занять %1$s + До конца + Смотреть другие переговорки + на сегодня + %1$s с %2$s + %1$s мин + Занятое время + Занятое время + Выберите организатора + В это время будет другая бронь + Нет подключения к интернету + Нет соединения с сервером + Перезагрузите приложение + Перезагрузить приложение + Выход + Выбрать %1$s + Сейчас свободна + Данные брони могут быть неактуальны + %1$s мин + Занять любую переговорку на: + Освободить переговорку? + Попробовать ещё раз + Освободить + с %1$s до %2$s + Занять %2$s? + Когда + На сколько + Организатор + %1$s мин + %1$sч %2$sмин + Занять %1$s + Это время уже занято + \ No newline at end of file diff --git a/clients/tablet/feature/main/src/commonMain/composeResources/values/strings.xml b/clients/tablet/feature/main/src/commonMain/composeResources/values/strings.xml index bed24afc7c0287bcb05d113b470f9d7c937405be..ec4b48f3a5bfda9d45d8af82e7f51a620a6df741 100644 --- a/clients/tablet/feature/main/src/commonMain/composeResources/values/strings.xml +++ b/clients/tablet/feature/main/src/commonMain/composeResources/values/strings.xml @@ -1,52 +1,52 @@ - Занято до %1$s - · До конца %1$s - Свободна до %1$s - · До начала %1$s - Освободить + Booked until %1$s + · Until %1$s + Free until %1$s + · Until start %1$s + Release TV USB - Розетка - Розетки - Розеток - час - часа - часов - минута - минуты - минут - Занять - Занять %1$s - До конца - Смотреть другие переговорки - на сегодня - %1$s с %2$s - %1$s мин - Занятое время - Занятое время - Выберите организатора - В это время будет другая бронь - Нет подключения к интернету - Нет соединения с сервером - Перезагрузите приложение - Перезагрузить приложение - Выход - Выбрать %1$s - Сейчас свободна - Данные брони могут быть неактуальны - %1$s мин - Занять любую переговорку на: - Освободить переговорку? - Попробовать ещё раз - Освободить - с %1$s до %2$s - Занять %2$s? - Когда - На сколько - Организатор - %1$s мин - %1$sч %2$sмин - Занять %1$s - Это время уже занято + Socket + Sockets + Sockets + hour + hours + hours + minute + minutes + minutes + Book + Book %1$s + Until end + View other meeting rooms + for today + %1$s at %2$s + %1$s min + Booked time + Booked time + Select an organizer + Another booking is scheduled at this time + No internet connection + No server connection + Restart the app + Restart app + Exit + Choose %1$s + Free now + Booking data may be outdated + %1$s min + Book any meeting room for: + Release the meeting room? + Try again + Release + from %1$s to %2$s + Book %2$s? + When + Duration + Organizer + %1$s min + %1$s h %2$s min + Book %1$s + This time is already booked \ No newline at end of file diff --git a/clients/tablet/feature/main/src/commonMain/kotlin/band/effective/office/tablet/feature/main/presentation/main/MainComponent.kt b/clients/tablet/feature/main/src/commonMain/kotlin/band/effective/office/tablet/feature/main/presentation/main/MainComponent.kt index 9439e74324f6c1635d30f8ddebef5a4bbde5df1d..2d293d84c52985c90d4bddb845c3d5702a9800ef 100644 --- a/clients/tablet/feature/main/src/commonMain/kotlin/band/effective/office/tablet/feature/main/presentation/main/MainComponent.kt +++ b/clients/tablet/feature/main/src/commonMain/kotlin/band/effective/office/tablet/feature/main/presentation/main/MainComponent.kt @@ -337,20 +337,31 @@ class MainComponent( */ private fun updateStateWithRoomsResult(roomsResult: RoomsResult) { mutableState.update { - it.copy( - isLoad = false, - isData = roomsResult.isSuccess, - isError = !roomsResult.isSuccess, - roomList = roomsResult.roomList, - indexSelectRoom = roomsResult.indexSelectRoom, - timeToNextEvent = getTimeToNextEventUseCase( - state.value.roomList, - state.value.indexSelectRoom - ), - ) + if (roomsResult.roomList.isEmpty()) { + it.copy( + isLoad = false, + isData = false, + isError = true, + roomList = listOf(RoomInfo.defaultValue), + indexSelectRoom = 0, + timeToNextEvent = 0 + ) + } else { + val selectedRoom = roomsResult.roomList[roomsResult.indexSelectRoom.coerceIn(0, roomsResult.roomList.size - 1)] + updateComponents(selectedRoom, it.selectedDate) + it.copy( + isLoad = false, + isData = roomsResult.isSuccess, + isError = !roomsResult.isSuccess, + roomList = roomsResult.roomList, + indexSelectRoom = roomsResult.indexSelectRoom, + timeToNextEvent = getTimeToNextEventUseCase( + rooms = roomsResult.roomList, + selectedRoomIndex = roomsResult.indexSelectRoom + ) + ) + } } - val selectedRoom = roomsResult.roomList[roomsResult.indexSelectRoom] - updateComponents(selectedRoom, state.value.selectedDate) } /** diff --git a/clients/tablet/feature/settings/src/commonMain/composeResources/values-ru/strings_ru.xml b/clients/tablet/feature/settings/src/commonMain/composeResources/values-ru/strings_ru.xml new file mode 100644 index 0000000000000000000000000000000000000000..45c0da64618a195eaad61e644867da1707a63007 --- /dev/null +++ b/clients/tablet/feature/settings/src/commonMain/composeResources/values-ru/strings_ru.xml @@ -0,0 +1,6 @@ + + + Выход + Переговорки + Выбрать ${nameRoom} + \ No newline at end of file diff --git a/clients/tablet/feature/settings/src/commonMain/composeResources/values/strings.xml b/clients/tablet/feature/settings/src/commonMain/composeResources/values/strings.xml index 45c0da64618a195eaad61e644867da1707a63007..3f37dbb1417e5b787582b954da8ce9ec3decaca8 100644 --- a/clients/tablet/feature/settings/src/commonMain/composeResources/values/strings.xml +++ b/clients/tablet/feature/settings/src/commonMain/composeResources/values/strings.xml @@ -1,6 +1,6 @@ - Выход - Переговорки - Выбрать ${nameRoom} + Exit + Meeting Rooms + Choose ${nameRoom} \ No newline at end of file diff --git a/iosApp/iosApp/Info.plist b/iosApp/iosApp/Info.plist index 11845e1da7e0b58bbd6e684ba65da1e31ec829ae..bb19ebf6a4a3338d7cf1566b32de08fa60bf4a9d 100644 --- a/iosApp/iosApp/Info.plist +++ b/iosApp/iosApp/Info.plist @@ -4,5 +4,12 @@ CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion + en + CFBundleLocalizations + + en + ru +