From 5a230f024354437705181ecd3f948ff0dc708e34 Mon Sep 17 00:00:00 2001 From: KrugarValdes Date: Thu, 24 Jul 2025 19:00:35 +0600 Subject: [PATCH 1/3] feat: Add localization for Russian and English --- .../util/LocalDateTimeFormatter.android.kt | 11 +++ .../domain/util/LocalDateTimeFormatter.kt | 2 + .../domain/util/LocalDateTimeFormatter.ios.kt | 23 +++++ clients/tablet/core/ui/build.gradle.kts | 1 + .../composeResources/values-ru/strings_ru.xml | 36 +++++++ .../composeResources/values/strings.xml | 64 ++++++------- .../tablet/core/ui/date/DateTimeView.kt | 5 +- .../composeResources/values-ru/strings_ru.xml | 12 +++ .../composeResources/values/strings.xml | 16 ++-- .../datetimepicker/DateTimePickerModalView.kt | 3 +- .../composeResources/values-ru/strings_ru.xml | 52 ++++++++++ .../composeResources/values/strings.xml | 94 +++++++++---------- .../main/presentation/main/MainComponent.kt | 37 +++++--- .../composeResources/values-ru/strings_ru.xml | 6 ++ .../composeResources/values/strings.xml | 6 +- iosApp/iosApp/Info.plist | 7 ++ 16 files changed, 270 insertions(+), 105 deletions(-) create mode 100644 clients/tablet/core/domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt create mode 100644 clients/tablet/core/domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt create mode 100644 clients/tablet/core/ui/src/commonMain/composeResources/values-ru/strings_ru.xml create mode 100644 clients/tablet/feature/bookingEditor/src/commonMain/composeResources/values-ru/strings_ru.xml create mode 100644 clients/tablet/feature/main/src/commonMain/composeResources/values-ru/strings_ru.xml create mode 100644 clients/tablet/feature/settings/src/commonMain/composeResources/values-ru/strings_ru.xml diff --git a/clients/tablet/core/domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt b/clients/tablet/core/domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt new file mode 100644 index 00000000..d614e0b3 --- /dev/null +++ b/clients/tablet/core/domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt @@ -0,0 +1,11 @@ +package band.effective.office.tablet.core.domain.util + +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/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt b/clients/tablet/core/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt index c5bcf5ee..b51af2f0 100644 --- a/clients/tablet/core/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt +++ b/clients/tablet/core/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt @@ -30,3 +30,5 @@ fun LocalTime.toFormattedString(pattern: String): String { } return formatter.format(this) } + +expect fun LocalDateTime.toLocalisedString(pattern: String): String diff --git a/clients/tablet/core/domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt b/clients/tablet/core/domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt new file mode 100644 index 00000000..032e8b6f --- /dev/null +++ b/clients/tablet/core/domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt @@ -0,0 +1,23 @@ +package band.effective.office.tablet.core.domain.util + +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/core/ui/build.gradle.kts b/clients/tablet/core/ui/build.gradle.kts index 0b70ba24..786444db 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) + implementation(project(":clients:tablet:core:domain")) } } } 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 00000000..3ccdf63f --- /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 3ccdf63f..c661b9cf 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 14e96ef8..415c797b 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.domain.util.toLocalisedString @OptIn(ExperimentalTime::class) @Composable @@ -122,7 +123,9 @@ private fun RowScope.SelectedDate( contentPadding = PaddingValues(0.dp) ) { AnimatedContent( - targetState = displayedFormat.format(selectDate), + targetState = if (currentDate != null && selectDate.date > currentDate.date) + selectDate.toLocalisedString("d MMMM HH:mm") + else selectDate.toLocalisedString("HH:mm d MMMM"), transitionSpec = { slideIntoContainer(slideDirection) + fadeIn() with slideOutOfContainer(slideDirection.opposite()) + fadeOut() 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 00000000..ae0b7bcd --- /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 + Изменить + Удалить бронь + Произошла ошибка + Ошибка, выбрана неправильная дата + Ошибка при создании события + Ошибка при удалении события + \ No newline at end of file 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 c73b265e..989bb565 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 62c63d41..611461f4 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 @@ -25,6 +25,7 @@ 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.domain.util.toLocalisedString 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 @@ -114,7 +115,7 @@ fun DateTimePickerModalView( ) { Text( text = when (enableDateButton) { - true -> "${currentDate.dayOfMonth} ${currentDate.month.name} ${currentDate.toFormattedString("HH:mm")}" + true -> currentDate.toLocalisedString("d MMMM HH:mm") 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 00000000..bed24afc --- /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 bed24afc..ec4b48f3 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 9439e743..2d293d84 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 00000000..45c0da64 --- /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 45c0da64..3f37dbb1 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 11845e1d..bb19ebf6 100644 --- a/iosApp/iosApp/Info.plist +++ b/iosApp/iosApp/Info.plist @@ -4,5 +4,12 @@ CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion + en + CFBundleLocalizations + + en + ru + -- GitLab From 49761238b59466fd0bb3c289cd0a9b7a334fa068 Mon Sep 17 00:00:00 2001 From: KrugarValdes Date: Mon, 28 Jul 2025 19:57:29 +0600 Subject: [PATCH 2/3] refactor: Improve date localization and formatting --- .../domain/util/LocalDateTimeFormatter.kt | 2 -- clients/tablet/core/ui/build.gradle.kts | 2 +- .../core/ui/util/DateFormatter.android.kt} | 2 +- .../tablet/core/ui/date/DateTimeView.kt | 9 +++++---- .../tablet/core/ui/utils/DateDisplayMapper.kt | 20 +++++++++++++++++++ .../tablet/core/ui/utils/DateFormatter.kt | 6 ++++++ .../core/ui/utils/DateFormatter.ios.kt} | 2 +- .../datetimepicker/DateTimePickerModalView.kt | 5 ++--- 8 files changed, 36 insertions(+), 12 deletions(-) rename clients/tablet/core/{domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt => ui/src/androidMain/kotlin/band/effective/office/tablet/core/ui/util/DateFormatter.android.kt} (86%) create mode 100644 clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateDisplayMapper.kt create mode 100644 clients/tablet/core/ui/src/commonMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.kt rename clients/tablet/core/{domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt => ui/src/iosMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.ios.kt} (92%) diff --git a/clients/tablet/core/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt b/clients/tablet/core/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt index b51af2f0..c5bcf5ee 100644 --- a/clients/tablet/core/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt +++ b/clients/tablet/core/domain/src/commonMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.kt @@ -30,5 +30,3 @@ fun LocalTime.toFormattedString(pattern: String): String { } return formatter.format(this) } - -expect fun LocalDateTime.toLocalisedString(pattern: String): String diff --git a/clients/tablet/core/ui/build.gradle.kts b/clients/tablet/core/ui/build.gradle.kts index 786444db..3e767180 100644 --- a/clients/tablet/core/ui/build.gradle.kts +++ b/clients/tablet/core/ui/build.gradle.kts @@ -10,7 +10,7 @@ kotlin { implementation(libs.decompose.compose.jetbrains) implementation(libs.essenty.lifecycle) implementation(libs.essenty.state.keeper) - implementation(project(":clients:tablet:core:domain")) + api(libs.kotlinx.datetime) } } } diff --git a/clients/tablet/core/domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt b/clients/tablet/core/ui/src/androidMain/kotlin/band/effective/office/tablet/core/ui/util/DateFormatter.android.kt similarity index 86% rename from clients/tablet/core/domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt rename to clients/tablet/core/ui/src/androidMain/kotlin/band/effective/office/tablet/core/ui/util/DateFormatter.android.kt index d614e0b3..b2ebeb9d 100644 --- a/clients/tablet/core/domain/src/androidMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.android.kt +++ b/clients/tablet/core/ui/src/androidMain/kotlin/band/effective/office/tablet/core/ui/util/DateFormatter.android.kt @@ -1,4 +1,4 @@ -package band.effective.office.tablet.core.domain.util +package band.effective.office.tablet.core.ui.utils import kotlinx.datetime.LocalDateTime import kotlinx.datetime.toJavaLocalDateTime 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 415c797b..7af3ec7d 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,7 +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.domain.util.toLocalisedString +import band.effective.office.tablet.core.ui.utils.DateDisplayMapper @OptIn(ExperimentalTime::class) @Composable @@ -123,9 +123,10 @@ private fun RowScope.SelectedDate( contentPadding = PaddingValues(0.dp) ) { AnimatedContent( - targetState = if (currentDate != null && selectDate.date > currentDate.date) - selectDate.toLocalisedString("d MMMM HH:mm") - else selectDate.toLocalisedString("HH:mm d MMMM"), + 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 00000000..5590bec7 --- /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 00000000..d6a5e1f1 --- /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/domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt b/clients/tablet/core/ui/src/iosMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.ios.kt similarity index 92% rename from clients/tablet/core/domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt rename to clients/tablet/core/ui/src/iosMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.ios.kt index 032e8b6f..cb4e9add 100644 --- a/clients/tablet/core/domain/src/iosMain/kotlin/band/effective/office/tablet/core/domain/util/LocalDateTimeFormatter.ios.kt +++ b/clients/tablet/core/ui/src/iosMain/kotlin/band/effective/office/tablet/core/ui/utils/DateFormatter.ios.kt @@ -1,4 +1,4 @@ -package band.effective.office.tablet.core.domain.util +package band.effective.office.tablet.core.ui.utils import kotlinx.datetime.LocalDateTime import platform.Foundation.NSDate 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 611461f4..98a2a784 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,12 +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.domain.util.toLocalisedString 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 @@ -115,7 +114,7 @@ fun DateTimePickerModalView( ) { Text( text = when (enableDateButton) { - true -> currentDate.toLocalisedString("d MMMM HH:mm") + true -> DateDisplayMapper.formatForPicker(currentDate) false -> stringResource(band.effective.office.tablet.core.ui.Res.string.time_booked) }, style = header8, -- GitLab From 8a87b9bdbbea48e53c794a9f1913630faf59c295 Mon Sep 17 00:00:00 2001 From: "Vitaly.Smirnov" <54392170+KrugarValdes@users.noreply.github.com> Date: Tue, 29 Jul 2025 14:14:13 +0600 Subject: [PATCH 3/3] Update strings_ru.xml --- .../src/commonMain/composeResources/values-ru/strings_ru.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index ae0b7bcd..2a9ea279 100644 --- 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 @@ -1,7 +1,7 @@ Занять %1$s - Измененить бронь + Изменить бронь Занять c %1$s до %2$s Изменить Удалить бронь @@ -9,4 +9,4 @@ Ошибка, выбрана неправильная дата Ошибка при создании события Ошибка при удалении события - \ No newline at end of file + -- GitLab