From 94c7bbda0cb09f8686338b0e3c3a8545b9fbe93f Mon Sep 17 00:00:00 2001 From: Artem Gruzdev Date: Tue, 8 Aug 2023 14:33:25 +0600 Subject: [PATCH 01/19] [~] save commit --- .../domain/models/CreatingBookModel.kt | 32 ++++- .../elevator/ui/booking/BookingScreen.kt | 15 +- .../booking/components/modals/ChooseZone.kt | 131 ++++++++---------- .../ui/booking/models/WorkSpaceZone.kt | 3 + .../elevator/ui/booking/store/BookingStore.kt | 53 ++++++- .../ui/booking/store/BookingStoreFactory.kt | 28 ++-- 6 files changed, 170 insertions(+), 92 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/WorkSpaceZone.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt index e0511a13..0c9626d9 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt @@ -1,9 +1,39 @@ package band.effective.office.elevator.domain.models +import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime data class CreatingBookModel( val workSpaceId: String, val dateOfStart: LocalDateTime, - val dateOfEnd: LocalDateTime + val dateOfEnd: LocalDateTime, + val bookingPeriod: BookingPeriod, + val typeOfEndPeriod: TypeEndPeriodBooking ) + +sealed class BookingPeriod(val durationPeriod: Int) { + data class Month(val monthPeriod: Int) : BookingPeriod(monthPeriod) + + data class Year(val yearPeriod: Int) : BookingPeriod(yearPeriod) + + data class Week(val weekPeriod: Int, val selectedDayOfWeek: List) : + BookingPeriod(weekPeriod) + + object NoPeriod : BookingPeriod(0) +} + +sealed interface TypeEndPeriodBooking{ + object Never : TypeEndPeriodBooking + + data class DatePeriodEnd(val date: LocalDate) : TypeEndPeriodBooking + + data class CountRepeat(val count: Int) : TypeEndPeriodBooking +} +enum class DayOfWeek { + Monday, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday +} diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 97af9b7e..9ec2b257 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -37,6 +37,7 @@ import band.effective.office.elevator.ui.booking.components.modals.BookingRepeat import band.effective.office.elevator.ui.booking.components.modals.BookingSuccess import band.effective.office.elevator.ui.booking.components.modals.ChooseZone import band.effective.office.elevator.ui.booking.models.BottomSheetNames +import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import band.effective.office.elevator.ui.booking.store.BookingStore import band.effective.office.elevator.utils.Stack @@ -66,8 +67,13 @@ fun BookingScreen(bookingComponent: BookingComponent) { bottomSheetContentState = showChooseZone ) { ChooseZone( - true, - onClickCloseChoseZone = { bookingComponent.onEvent(BookingStore.Intent.CloseChooseZone) } + sheetTile = stringResource( + if (state.workSpacesType == WorkSpaceType.WORK_PLACE) MainRes.strings.selection_zones + else MainRes.strings.selection_rooms + ), + workSpacecZone = state.workSpacecZone, + onClickCloseChoseZone = { bookingComponent.onEvent(BookingStore.Intent.CloseChooseZone) }, + onClickConfirmSelectedZone = {} ) }, BottomSheetNames.BOOK_ACCEPT.name to BottomSheetItem( @@ -185,7 +191,6 @@ fun BookingScreen(bookingComponent: BookingComponent) { ) } -@OptIn(ExperimentalMaterialApi::class) @Composable private fun BookingScreenContent( workSpaces: List, @@ -239,8 +244,8 @@ private fun BookingScreenContent( onClickOpenBookAccept = onClickOpenBookAccept, onClickOpenBookPeriod = onClickOpenBookPeriod, onClickOpenChoseZone = onClickOpenChoseZone, - onClickExpandedMap = {isExpandedCard = !isExpandedCard}, - onClickExpandedOption = { isExpandedOptions = !isExpandedOptions} + onClickExpandedMap = { isExpandedCard = !isExpandedCard }, + onClickExpandedOption = { isExpandedOptions = !isExpandedOptions } ) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt index 77781f13..6472c019 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt @@ -2,15 +2,23 @@ package band.effective.office.elevator.ui.booking.components.modals import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid +import androidx.compose.foundation.lazy.grid.items +import androidx.compose.foundation.lazy.grid.itemsIndexed import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults @@ -39,39 +47,35 @@ import band.effective.office.elevator.MainRes import band.effective.office.elevator.textInBorderGray import band.effective.office.elevator.textInBorderPurple import band.effective.office.elevator.theme_light_primary_color -import dev.icerock.moko.resources.StringResource +import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import dev.icerock.moko.resources.compose.stringResource @Composable -fun ChooseZone(zone: Boolean, onClickCloseChoseZone: () -> Unit) { - val highZonesNames = listOf( - MainRes.strings.sirius_zone, - MainRes.strings.antares_zone, - MainRes.strings.mars_zone - ) - val lowZonesNames = listOf( - MainRes.strings.cassiopeia_zone, - MainRes.strings.arrakis_zone - ) - val highRoomsNames = listOf( - MainRes.strings.moon_room, - MainRes.strings.sun_room, - MainRes.strings.mercury_room, - MainRes.strings.pluto_room - ) - val lowRoomsNames = listOf( - MainRes.strings.pluto_room - ) - val highListNames: List - val lowListNames: List - if (zone) { - highListNames = highZonesNames - lowListNames = lowZonesNames - } else { - highListNames = highRoomsNames - lowListNames = lowRoomsNames +fun ChooseZone( + sheetTile: String, + workSpacecZone: List, + onClickCloseChoseZone: () -> Unit, + onClickConfirmSelectedZone: (List) -> Unit +) { + val selectedZones: MutableList = mutableListOf() + selectedZones.addAll(workSpacecZone) + + val maxCountItemInRow = 3 + + val currentIndex = 0 + + val list: MutableList> = mutableListOf() + + while (currentIndex < workSpacecZone.size) { + list. } - Column(modifier = Modifier.fillMaxWidth().background(Color.White)) { + + + + Column(modifier = Modifier + .fillMaxWidth() + .background(Color.White) + ) { Spacer(modifier = Modifier.padding(vertical = 10.dp)) Divider( modifier = Modifier @@ -99,10 +103,7 @@ fun ChooseZone(zone: Boolean, onClickCloseChoseZone: () -> Unit) { ) } Text( - text = stringResource( - if (zone) MainRes.strings.selection_zones - else MainRes.strings.selection_rooms - ), + text = sheetTile, style = MaterialTheme.typography.subtitle1, fontSize = 20.sp, fontWeight = FontWeight(600), @@ -118,26 +119,12 @@ fun ChooseZone(zone: Boolean, onClickCloseChoseZone: () -> Unit) { color = ExtendedTheme.colors._66x ) ) - Column( - modifier = Modifier.padding( - top = 16.dp, - bottom = 6.dp, - start = 16.dp - ).fillMaxWidth() - ) { - LazyRow { - items(highListNames) { highListName -> - WorkingZones(highListName) - } - } - LazyRow { - items(lowListNames) { lowListName -> - WorkingZones(lowListName) - } - } + Column { + } + Button( - onClick = onClickCloseChoseZone, + onClick = { onClickConfirmSelectedZone(selectedZones) }, modifier = Modifier.align(alignment = Alignment.CenterHorizontally) .fillMaxWidth() .height(60.dp) @@ -156,39 +143,39 @@ fun ChooseZone(zone: Boolean, onClickCloseChoseZone: () -> Unit) { } @Composable -fun WorkingZones(text: StringResource) { - var isExpanded by remember { mutableStateOf(false) } +fun WorkingZones( + modifier: Modifier = Modifier, + workSpaceZone: WorkSpaceZone, + onClickZone: (WorkSpaceZone) -> Unit, +) { Button( - onClick = { isExpanded = !isExpanded }, + onClick = { onClickZone(workSpaceZone) }, colors = ButtonDefaults.buttonColors(theme_light_primary_color), - modifier = Modifier - .padding(end = 10.dp) - .fillMaxWidth(fraction = 0.5f), + modifier = modifier + .padding(end = 10.dp), border = BorderStroke( width = 1.dp, - color = if (!isExpanded) textInBorderPurple else textInBorderGray + color = if (workSpaceZone.isSelected) textInBorderPurple else textInBorderGray ), shape = RoundedCornerShape(12.dp), elevation = ButtonDefaults.elevation(0.dp, 2.dp, 0.dp) ) { - Row { + if (workSpaceZone.isSelected) { Icon( imageVector = Icons.Rounded.Done, tint = textInBorderPurple, - modifier = Modifier.size( - if (!isExpanded) 20.dp - else 0.dp - ) + modifier = Modifier + .size(20.dp) .align(Alignment.CenterVertically), contentDescription = "galochka" ) - Text( - text = stringResource(text), - fontSize = 16.sp, - fontWeight = FontWeight(500), - color = if (!isExpanded) textInBorderPurple - else textInBorderGray - ) } + Text( + text = workSpaceZone.name, + fontSize = 16.sp, + fontWeight = FontWeight(500), + color = if (workSpaceZone.isSelected) textInBorderPurple + else textInBorderGray + ) } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/WorkSpaceZone.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/WorkSpaceZone.kt new file mode 100644 index 00000000..587b83aa --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/WorkSpaceZone.kt @@ -0,0 +1,3 @@ +package band.effective.office.elevator.ui.booking.models + +data class WorkSpaceZone(val isSelected: Boolean, val name: String ) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index e3c2d169..4bc226d3 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -1,8 +1,16 @@ package band.effective.office.elevator.ui.booking.store +import band.effective.office.elevator.domain.models.BookingPeriod +import band.effective.office.elevator.domain.models.CreatingBookModel +import band.effective.office.elevator.domain.models.TypeEndPeriodBooking +import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI +import band.effective.office.elevator.ui.booking.models.WorkSpaceZone +import band.effective.office.elevator.utils.getCurrentDate import com.arkivanov.mvikotlin.core.store.Store +import com.commandiron.wheel_picker_compose.utils.getCurrentTime import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime interface BookingStore: Store { @@ -21,22 +29,40 @@ interface BookingStore: Store) : Intent data class ApplyDate(val date: LocalDate?) : Intent data class ShowPlace(val type:String): Intent } data class State( val workSpaces : List, - val currentDate: LocalDate - ) + val creatingBookModel: CreatingBookModel, + val currentDate: LocalDate, + val workSpacesType: WorkSpaceType, + val workSpacecZone: List + ){ + companion object { + val initState = State( + workSpaces = listOf(), + currentDate = getCurrentDate(), + creatingBookModel = CreatingBookModel( + workSpaceId = "", + dateOfStart = LocalDateTime(getCurrentDate(), getCurrentTime()), + dateOfEnd = LocalDateTime(getCurrentDate(), getCurrentTime()), + bookingPeriod = BookingPeriod.NoPeriod, + typeOfEndPeriod = TypeEndPeriodBooking.Never + ), + workSpacesType = WorkSpaceType.WORK_PLACE, + workSpacecZone = allBookingZone + ) + } + } sealed interface Label{ object OpenChooseZone : Label @@ -57,4 +83,21 @@ interface BookingStore: Store by storeFactory.create( name = "BookingStore", - initialState = BookingStore.State( - workSpaces = listOf(), - currentDate = getCurrentDate() - ), + initialState = BookingStore.State.initState, executorFactory = ::ExecutorImpl, - reducer = ReducerImpl, + reducer = ReducerImpl ) {} private sealed interface Msg { + data class BeginningBookingTime(val time: LocalTime) + data class BeginningBookingDate(val date: LocalDate) + data class EndBookingTime(val time: LocalTime) + data class EndBookingDate(val date: LocalDate) data class TypeList(val type: String) : Msg data class DateBooking(val date: LocalDate) : Msg data class TimeBooking(val time: LocalTime) : Msg + + data class ChangeSelectedWorkSpacesZone(val workSpacesZone: List) : Msg } private inner class ExecutorImpl : @@ -171,16 +175,22 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen publish(BookingStore.Label.OpenBookPeriod) } } + + is BookingStore.Intent.ChangeSelectedWorkSpacesZone -> { + dispatch(Msg.ChangeSelectedWorkSpacesZone(intent.workSpaceZone)) + } } } - - } private object ReducerImpl : Reducer { override fun BookingStore.State.reduce(msg: Msg): BookingStore.State { - TODO("Not yet implemented") + return when(msg) { + is Msg.ChangeSelectedWorkSpacesZone -> copy(workSpacecZone = msg.workSpacesZone) + is Msg.DateBooking -> TODO() + is Msg.TimeBooking -> TODO() + is Msg.TypeList -> TODO() + } } - } } \ No newline at end of file -- GitLab From 53e4e2cfb4f5282d9d1c4ae1c3f28bd54c8dc414 Mon Sep 17 00:00:00 2001 From: Artem Gruzdev Date: Wed, 9 Aug 2023 08:34:26 +0300 Subject: [PATCH 02/19] [~] chang design Booking Period bottomSheet --- .../elevator/ui/booking/BookingScreen.kt | 16 ++-- .../booking/components/HorizontalGridItems.kt | 55 ++++++++++++ .../components/modals/BookingPeriod.kt | 23 ++--- .../booking/components/modals/ChooseZone.kt | 55 ++++++++---- .../ui/booking/components/modals/TimeLine.kt | 88 ++++++++++++++----- .../elevator/ui/booking/store/BookingStore.kt | 4 +- .../ui/booking/store/BookingStoreFactory.kt | 3 +- 7 files changed, 176 insertions(+), 68 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/HorizontalGridItems.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 9ec2b257..bfb3c1a4 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -71,9 +71,15 @@ fun BookingScreen(bookingComponent: BookingComponent) { if (state.workSpacesType == WorkSpaceType.WORK_PLACE) MainRes.strings.selection_zones else MainRes.strings.selection_rooms ), - workSpacecZone = state.workSpacecZone, + workSpacecZone = state.workSpacesZone, onClickCloseChoseZone = { bookingComponent.onEvent(BookingStore.Intent.CloseChooseZone) }, - onClickConfirmSelectedZone = {} + onClickConfirmSelectedZone = { + bookingComponent.onEvent( + BookingStore.Intent.ChangeSelectedWorkSpacesZone( + it + ) + ) + } ) }, BottomSheetNames.BOOK_ACCEPT.name to BottomSheetItem( @@ -90,14 +96,12 @@ fun BookingScreen(bookingComponent: BookingComponent) { BookingPeriod( startDate = "Чт, 27 июл. 2023 г.", startTime = "10:30", - finishDate = "Чт, 27 июл. 2023 г.", finishTime = "15:30", repeatBooking = "Бронирование не повторяется", - false, + switchChecked = false, closeClick = { bookingComponent.onEvent(BookingStore.Intent.CloseBookPeriod) }, - onSwitchChange = { false }, + onSelectAllDay = { false }, bookStartDate = { bookingComponent.onEvent(BookingStore.Intent.OpenCalendar) }, - bookFinishDate = { bookingComponent.onEvent(BookingStore.Intent.OpenCalendar) }, bookStartTime = { bookingComponent.onEvent(BookingStore.Intent.OpenTimeModal) }, bookFinishTime = { bookingComponent.onEvent(BookingStore.Intent.OpenTimeModal) }, bookingRepeat = { bookingComponent.onEvent(BookingStore.Intent.OpenRepeatDialog) }, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/HorizontalGridItems.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/HorizontalGridItems.kt new file mode 100644 index 00000000..6055ca69 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/HorizontalGridItems.kt @@ -0,0 +1,55 @@ +package band.effective.office.elevator.ui.booking.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import band.effective.office.elevator.ui.booking.components.modals.WorkingZones + +@Composable +fun HorizontalGirdItems( + countItemsInRow: Int, + modifier: Modifier = Modifier, + listItems: List, + verticalPaddingContent: Dp = 0.dp, + horizontalPaddingContent: Dp = 0.dp, + content: @Composable RowScope.(T, Int, Int) -> Unit +) { + var currentIndex = 0 + val list: MutableList> = mutableListOf() + + while (currentIndex < listItems.size) { + val endIndex = + if (currentIndex + countItemsInRow > listItems.size) + listItems.size + else currentIndex + countItemsInRow + + list.add( + listItems.subList(currentIndex, endIndex) + ) + + currentIndex += countItemsInRow + } + + LazyColumn( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(verticalPaddingContent), + ) { + itemsIndexed(list){columnIndex, row -> + Row( + horizontalArrangement = Arrangement.spacedBy(horizontalPaddingContent) + ) { + row.forEachIndexed{ rowIndex, item -> + content(item, columnIndex, rowIndex) + } + } + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt index 297c6e06..3727c32a 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt @@ -43,15 +43,13 @@ import dev.icerock.moko.resources.compose.stringResource fun BookingPeriod( startDate: String, startTime: String, - finishDate: String, finishTime: String, repeatBooking: String, switchChecked: Boolean, closeClick: () -> Unit, - onSwitchChange: (Boolean) -> Unit, + onSelectAllDay: (Boolean) -> Unit, bookStartDate: () -> Unit, bookStartTime: () -> Unit, - bookFinishDate: () -> Unit, bookFinishTime: () -> Unit, bookingRepeat: () -> Unit, onClickSearchSuitableOptions: () -> Unit @@ -162,7 +160,7 @@ fun BookingPeriod( Switch( checked = switchChecked, - onCheckedChange = onSwitchChange, + onCheckedChange = onSelectAllDay, colors = SwitchDefaults.colors( checkedThumbColor = MaterialTheme.colors.primary, uncheckedThumbColor = ExtendedTheme.colors.switchColor, @@ -175,19 +173,12 @@ fun BookingPeriod( //Start booking date TimeLine( date = startDate, - time = startTime, - elevation = elevation, + statTime = startTime, + endTime = finishTime, onPickDate = bookStartDate, - onPickTime = bookStartTime, - ) - - //Finish booking date - TimeLine( - date = finishDate, - time = finishTime, - elevation = elevation, - onPickDate = bookFinishDate, - onPickTime = bookFinishTime + onPickStartTime = bookStartTime, + selectTimeActive = !switchChecked, + onPickEndTime = bookFinishTime, ) //Book period diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt index 6472c019..add7811e 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/ChooseZone.kt @@ -15,10 +15,12 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.itemsIndexed +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults @@ -47,6 +49,7 @@ import band.effective.office.elevator.MainRes import band.effective.office.elevator.textInBorderGray import band.effective.office.elevator.textInBorderPurple import band.effective.office.elevator.theme_light_primary_color +import band.effective.office.elevator.ui.booking.components.HorizontalGirdItems import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import dev.icerock.moko.resources.compose.stringResource @@ -60,19 +63,8 @@ fun ChooseZone( val selectedZones: MutableList = mutableListOf() selectedZones.addAll(workSpacecZone) - val maxCountItemInRow = 3 - - val currentIndex = 0 - - val list: MutableList> = mutableListOf() - - while (currentIndex < workSpacecZone.size) { - list. - } - - - - Column(modifier = Modifier + Column( + modifier = Modifier .fillMaxWidth() .background(Color.White) ) { @@ -119,12 +111,32 @@ fun ChooseZone( color = ExtendedTheme.colors._66x ) ) - Column { + Spacer(modifier = Modifier.height(16.dp)) + + HorizontalGirdItems( + modifier = Modifier.align(Alignment.CenterHorizontally), + countItemsInRow = 3, + listItems = workSpacecZone, + horizontalPaddingContent = 12.dp, + verticalPaddingContent = 12.dp + ) { workSpaceZone, columnIndex, rowIndex -> + val currentIndex = 3 * columnIndex + rowIndex + //TODO(Artem Gruzdev) refactor this code + WorkingZones( + workSpaceZone = workSpaceZone, + onClickZone = { workSpaceZone1 -> + val isSelected = !workSpaceZone.isSelected + selectedZones[currentIndex] = workSpaceZone.copy(isSelected = isSelected) + } + ) } Button( - onClick = { onClickConfirmSelectedZone(selectedZones) }, + onClick = { + onClickConfirmSelectedZone(selectedZones) + onClickCloseChoseZone() + }, modifier = Modifier.align(alignment = Alignment.CenterHorizontally) .fillMaxWidth() .height(60.dp) @@ -148,19 +160,24 @@ fun WorkingZones( workSpaceZone: WorkSpaceZone, onClickZone: (WorkSpaceZone) -> Unit, ) { + var isSelected by remember { mutableStateOf(workSpaceZone.isSelected) } + Button( - onClick = { onClickZone(workSpaceZone) }, + onClick = { + isSelected = !isSelected + onClickZone(workSpaceZone) + }, colors = ButtonDefaults.buttonColors(theme_light_primary_color), modifier = modifier .padding(end = 10.dp), border = BorderStroke( width = 1.dp, - color = if (workSpaceZone.isSelected) textInBorderPurple else textInBorderGray + color = if (isSelected) textInBorderPurple else textInBorderGray ), shape = RoundedCornerShape(12.dp), elevation = ButtonDefaults.elevation(0.dp, 2.dp, 0.dp) ) { - if (workSpaceZone.isSelected) { + if (isSelected) { Icon( imageVector = Icons.Rounded.Done, tint = textInBorderPurple, @@ -174,7 +191,7 @@ fun WorkingZones( text = workSpaceZone.name, fontSize = 16.sp, fontWeight = FontWeight(500), - color = if (workSpaceZone.isSelected) textInBorderPurple + color = if (isSelected) textInBorderPurple else textInBorderGray ) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/TimeLine.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/TimeLine.kt index 4aa37c0e..3fffb857 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/TimeLine.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/TimeLine.kt @@ -1,9 +1,11 @@ package band.effective.office.elevator.ui.booking.components.modals +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight @@ -11,37 +13,62 @@ import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.MaterialTheme import androidx.compose.material.ButtonElevation +import androidx.compose.material3.Divider import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.rotate import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp +import band.effective.office.elevator.common.compose.components.GrayText @Composable fun TimeLine( date: String, - time: String, - elevation: ButtonElevation, + statTime: String, + endTime: String, + selectTimeActive: Boolean, onPickDate: () -> Unit, - onPickTime: () -> Unit + onPickStartTime: () -> Unit, + onPickEndTime: () -> Unit ) { Row( - horizontalArrangement = Arrangement.Start, + horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.fillMaxWidth().wrapContentHeight() - .padding(start = 54.dp, end = 16.dp, top = 16.dp, bottom = 16.dp) + modifier = Modifier + .fillMaxWidth() + .padding(start = 30.dp, end = 16.dp, top = 16.dp, bottom = 16.dp) ) { - Button( - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = elevation, - onClick = onPickDate - ) { + + Text( + text = date, + modifier = Modifier.clickable { onPickDate() }, + style = MaterialTheme.typography.button.copy( + fontWeight = FontWeight( + weight = 400 + ), + color = Color.Black + ) + ) + + Spacer(modifier = Modifier.width(24.dp)) + + if (selectTimeActive) { Text( - text = date, + text = statTime, + modifier = Modifier.clickable { if (selectTimeActive) onPickStartTime() }, + style = MaterialTheme.typography.button.copy( + fontWeight = FontWeight( + weight = 400 + ), + color = Color.Black + ) + ) + } else { + GrayText( + text = statTime, style = MaterialTheme.typography.button.copy( fontWeight = FontWeight( weight = 400 @@ -49,17 +76,32 @@ fun TimeLine( color = Color.Black ) ) - Spacer(modifier = Modifier.width(width = 10.dp)) } - Button( - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = elevation, - onClick = onPickTime - ) { + + Spacer(modifier = Modifier.width(12.dp)) + + Divider( + thickness = 1.dp, + modifier = Modifier.width(11.dp), + color = Color.Black + ) + + Spacer(modifier = Modifier.width(12.dp)) + + if (selectTimeActive) { Text( - text = time, + text = endTime, + modifier = Modifier.clickable { if (selectTimeActive) onPickEndTime() }, + style = MaterialTheme.typography.button.copy( + fontWeight = FontWeight( + weight = 400 + ), + color = Color.Black + ) + ) + } else { + GrayText( + text = endTime, style = MaterialTheme.typography.button.copy( fontWeight = FontWeight( weight = 400 diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index 4bc226d3..759f8b68 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -45,7 +45,7 @@ interface BookingStore: Store + val workSpacesZone: List ){ companion object { val initState = State( @@ -59,7 +59,7 @@ interface BookingStore: Store { override fun BookingStore.State.reduce(msg: Msg): BookingStore.State { return when(msg) { - is Msg.ChangeSelectedWorkSpacesZone -> copy(workSpacecZone = msg.workSpacesZone) + is Msg.ChangeSelectedWorkSpacesZone -> copy(workSpacesZone = msg.workSpacesZone) is Msg.DateBooking -> TODO() is Msg.TimeBooking -> TODO() is Msg.TypeList -> TODO() -- GitLab From c2440dd28e425decc590e7d9991fe09e252ec3a5 Mon Sep 17 00:00:00 2001 From: Slava Date: Tue, 15 Aug 2023 12:44:52 +0600 Subject: [PATCH 03/19] Choose zone [+] added init state [~] refactoring code [+] changing with room type leads to changing with lists --- .../elevator/ui/booking/BookingScreen.kt | 88 +++++++++++++++++-- .../components/BookingMainContentScreen.kt | 7 +- .../ui/booking/components/OptionMenu.kt | 11 ++- .../elevator/ui/booking/store/BookingStore.kt | 59 ++++++++++++- .../ui/booking/store/BookingStoreFactory.kt | 43 ++++++++- .../office/elevator/ui/models/TypesList.kt | 4 +- 6 files changed, 197 insertions(+), 15 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index bfb3c1a4..699cb7f2 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -29,6 +29,7 @@ import band.effective.office.elevator.components.TimePickerModal import band.effective.office.elevator.components.bottomSheet.BottomSheetItem import band.effective.office.elevator.components.bottomSheet.MultiBottomSheetController import band.effective.office.elevator.components.bottomSheet.rememberMultiBottomSheetController +import band.effective.office.elevator.expects.showToast import band.effective.office.elevator.ui.booking.components.BookingMainContentScreen import band.effective.office.elevator.ui.booking.components.modals.BookAccept import band.effective.office.elevator.ui.booking.components.modals.BookingPeriod @@ -39,6 +40,7 @@ import band.effective.office.elevator.ui.booking.components.modals.ChooseZone import band.effective.office.elevator.ui.booking.models.BottomSheetNames import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI +import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import band.effective.office.elevator.ui.booking.store.BookingStore import band.effective.office.elevator.utils.Stack import band.effective.office.elevator.utils.isScrollingDown @@ -53,10 +55,74 @@ fun BookingScreen(bookingComponent: BookingComponent) { val state by bookingComponent.state.collectAsState() - var showChooseZone = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) - var showBookPeriod = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) - var showBookAccept = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) - var showBookRepeat = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) + val showChooseZone = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) + val showBookPeriod = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) + val showBookAccept = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) + val showBookRepeat = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden) + + val workSpacesUI = listOf( + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.cassiopeia_zone), + workSpaceType = WorkSpaceType.MEETING_ROOM + ), + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.arrakis_zone), + workSpaceType = WorkSpaceType.MEETING_ROOM + ), + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.mars_zone), + workSpaceType = WorkSpaceType.MEETING_ROOM + ), + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.antares_zone), + workSpaceType = WorkSpaceType.MEETING_ROOM + ), + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.sirius_zone), + workSpaceType = WorkSpaceType.MEETING_ROOM + ), + + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.moon_room), + workSpaceType = WorkSpaceType.WORK_PLACE + ), + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.sun_room), + workSpaceType = WorkSpaceType.WORK_PLACE + ), + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.mercury_room), + workSpaceType = WorkSpaceType.WORK_PLACE + ), + WorkSpaceUI( + workSpaceId = "", + workSpaceName = stringResource(MainRes.strings.pluto_room), + workSpaceType = WorkSpaceType.WORK_PLACE + ) + ) + + val allBookingZone = listOf( + WorkSpaceZone(name = stringResource(MainRes.strings.sirius_zone), isSelected = true), + WorkSpaceZone(name = stringResource(MainRes.strings.antares_zone), isSelected = true), + WorkSpaceZone(name = stringResource(MainRes.strings.mars_zone), isSelected = true), + WorkSpaceZone(name = stringResource(MainRes.strings.cassiopeia_zone), isSelected = true), + WorkSpaceZone(name = stringResource(MainRes.strings.arrakis_zone), isSelected = true), + ) + + val allMeetingRooms = listOf( + WorkSpaceZone(name = stringResource(MainRes.strings.moon_room), isSelected = true), + WorkSpaceZone(name = stringResource(MainRes.strings.sun_room), isSelected = true), + WorkSpaceZone(name = stringResource(MainRes.strings.mercury_room), isSelected = true), + WorkSpaceZone(name = stringResource(MainRes.strings.pluto_room), isSelected = true), + ) val stackRemember: Stack by remember { mutableStateOf(stackOf()) } @@ -191,6 +257,16 @@ fun BookingScreen(bookingComponent: BookingComponent) { date = date ) ) + }, + onClickChangeZone = { type -> + with(if (type == WorkSpaceType.MEETING_ROOM) allBookingZone else allMeetingRooms) { + bookingComponent.onEvent( + BookingStore.Intent.ChangeSelectedWorkSpacesZone( + workSpaceZone = this@with + ) + ) + bookingComponent.onEvent(BookingStore.Intent.ChangeWorkSpacesUI(workSpaces = workSpacesUI.filter { workSpaceUI -> workSpaceUI.workSpaceType == type })) + } } ) } @@ -214,6 +290,7 @@ private fun BookingScreenContent( onClickCloseTimeModal: () -> Unit, onClickSelectTime: (LocalTime) -> Unit, onClickOpenBookRepeat: () -> Unit, + onClickChangeZone: (WorkSpaceType) -> Unit ) { val scrollState = rememberLazyListState() val scrollIsDown = scrollState.isScrollingDown() @@ -249,7 +326,8 @@ private fun BookingScreenContent( onClickOpenBookPeriod = onClickOpenBookPeriod, onClickOpenChoseZone = onClickOpenChoseZone, onClickExpandedMap = { isExpandedCard = !isExpandedCard }, - onClickExpandedOption = { isExpandedOptions = !isExpandedOptions } + onClickExpandedOption = { isExpandedOptions = !isExpandedOptions }, + onClickChangeZone = onClickChangeZone ) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt index 801de2d2..7b1b1f7e 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt @@ -35,6 +35,7 @@ import band.effective.office.elevator.borderPurple import band.effective.office.elevator.components.TitlePage import band.effective.office.elevator.textGrayColor import band.effective.office.elevator.textInBorderPurple +import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource @@ -51,7 +52,8 @@ fun BookingMainContentScreen( onClickOpenBookPeriod: () -> Unit, onClickOpenChoseZone: () -> Unit, onClickExpandedMap: () -> Unit, - onClickExpandedOption: () -> Unit + onClickExpandedOption: () -> Unit, + onClickChangeZone: (WorkSpaceType) -> Unit ) { Scaffold( topBar = { @@ -84,7 +86,8 @@ fun BookingMainContentScreen( OptionMenu( isExpandedCard = isExpandedCard, isExpandedOptions = isExpandedOptions, - onClickOpenBookPeriod = onClickOpenBookPeriod + onClickOpenBookPeriod = onClickOpenBookPeriod, + onClickChangeZone = onClickChangeZone ) } Box( diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt index dfbabb63..50c18531 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import band.effective.office.elevator.MainRes +import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.models.TypesList import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource @@ -34,7 +35,8 @@ import dev.icerock.moko.resources.compose.stringResource fun OptionMenu( isExpandedCard: Boolean, isExpandedOptions: Boolean, - onClickOpenBookPeriod: () -> Unit + onClickOpenBookPeriod: () -> Unit, + onClickChangeZone: (WorkSpaceType) -> Unit ) { Column { AnimatedVisibility(visible = isExpandedCard) { @@ -69,11 +71,13 @@ fun OptionMenu( val types = listOf( TypesList( name = MainRes.strings.workplace, - icon = MainRes.images.table_icon + icon = MainRes.images.table_icon, + type = WorkSpaceType.WORK_PLACE ), TypesList( name = MainRes.strings.meeting_room, - icon = MainRes.images.icon_meet + icon = MainRes.images.icon_meet, + type = WorkSpaceType.MEETING_ROOM ) ) val selectedType = remember { mutableStateOf(types[0]) } @@ -97,6 +101,7 @@ fun OptionMenu( selected = selected, onClick = { selectedType.value = type + onClickChangeZone(type.type) } ) ) { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index 759f8b68..1d02a842 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -1,5 +1,6 @@ package band.effective.office.elevator.ui.booking.store +import band.effective.office.elevator.MainRes import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.domain.models.CreatingBookModel import band.effective.office.elevator.domain.models.TypeEndPeriodBooking @@ -9,6 +10,7 @@ import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import band.effective.office.elevator.utils.getCurrentDate import com.arkivanov.mvikotlin.core.store.Store import com.commandiron.wheel_picker_compose.utils.getCurrentTime +import dev.icerock.moko.resources.compose.stringResource import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -37,7 +39,10 @@ interface BookingStore: Store) : Intent data class ApplyDate(val date: LocalDate?) : Intent - data class ShowPlace(val type:String): Intent + data class ShowPlace(val type: String): Intent + + data class ChangeWorkSpacesUI(val workSpaces: List) : Intent + data class ChangeType(val type : WorkSpaceType) : Intent } data class State( @@ -49,7 +54,7 @@ interface BookingStore: Store by storeFactory.create( name = "BookingStore", initialState = BookingStore.State.initState, + bootstrapper = coroutineBootstrapper { + launch { + dispatch(Action.InitWorkSpaces) + } + }, executorFactory = ::ExecutorImpl, reducer = ReducerImpl ) {} @@ -33,10 +41,16 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen data class TimeBooking(val time: LocalTime) : Msg data class ChangeSelectedWorkSpacesZone(val workSpacesZone: List) : Msg + + data class ChangeWorkSpacesUI(val workSpacesUI: List) : Msg + } + + private sealed interface Action { + object InitWorkSpaces : Action } private inner class ExecutorImpl : - CoroutineExecutor() { + CoroutineExecutor() { override fun executeIntent( intent: BookingStore.Intent, getState: () -> BookingStore.State @@ -178,17 +192,42 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is BookingStore.Intent.ChangeSelectedWorkSpacesZone -> { dispatch(Msg.ChangeSelectedWorkSpacesZone(intent.workSpaceZone)) } + + is BookingStore.Intent.ChangeWorkSpacesUI -> { + intent.workSpaces.forEachIndexed { index1, workSpaceUI -> + getState().workSpacesZone.forEachIndexed { index2, workSpaceZone -> + intent.workSpaces.filter { workSpaceUI -> workSpaceUI.workSpaceName == workSpaceZone.name } + } + } + dispatch(Msg.ChangeWorkSpacesUI(workSpacesUI = intent.workSpaces)) + } + + is BookingStore.Intent.ChangeType -> { + + } + } + } + + override fun executeAction(action: Action, getState: () -> BookingStore.State) = + when (action) { + Action.InitWorkSpaces -> initList(getState()) + } + + private fun initList(state: BookingStore.State) { + scope.launch { + dispatch(Msg.ChangeWorkSpacesUI(workSpacesUI = state.workSpaces.filter { workSpaceUI -> workSpaceUI.workSpaceType == WorkSpaceType.WORK_PLACE })) } } } private object ReducerImpl : Reducer { override fun BookingStore.State.reduce(msg: Msg): BookingStore.State { - return when(msg) { + return when (msg) { is Msg.ChangeSelectedWorkSpacesZone -> copy(workSpacesZone = msg.workSpacesZone) is Msg.DateBooking -> TODO() is Msg.TimeBooking -> TODO() is Msg.TypeList -> TODO() + is Msg.ChangeWorkSpacesUI -> copy(workSpaces = msg.workSpacesUI) } } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/models/TypesList.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/models/TypesList.kt index 3df350c1..b9c49705 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/models/TypesList.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/models/TypesList.kt @@ -1,9 +1,11 @@ package band.effective.office.elevator.ui.models +import band.effective.office.elevator.ui.booking.models.WorkSpaceType import dev.icerock.moko.resources.ImageResource import dev.icerock.moko.resources.StringResource data class TypesList( val name: StringResource, - val icon: ImageResource + val icon: ImageResource, + val type: WorkSpaceType = WorkSpaceType.WORK_PLACE ) -- GitLab From 92732e61cb1b3ec76a18e283cb7f09890f71690f Mon Sep 17 00:00:00 2001 From: Slava Date: Tue, 15 Aug 2023 13:41:17 +0600 Subject: [PATCH 04/19] Navigation + stated changing [+] added changing selected in calendar time and date functions [+] added navigation from BookingSuccess.kt to MainTab [~] simple code refactoring --- .../elevator/ui/booking/BookingComponent.kt | 10 ++++++++++ .../office/elevator/ui/booking/BookingScreen.kt | 2 +- .../booking/components/modals/BookingSuccess.kt | 17 +++++++---------- .../elevator/ui/booking/store/BookingStore.kt | 8 ++++++-- .../ui/booking/store/BookingStoreFactory.kt | 4 ++-- .../elevator/ui/content/ContentComponent.kt | 8 +++++++- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingComponent.kt index 36adf10a..14b59144 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingComponent.kt @@ -2,6 +2,7 @@ package band.effective.office.elevator.ui.booking import band.effective.office.elevator.ui.booking.store.BookingStore import band.effective.office.elevator.ui.booking.store.BookingStoreFactory +import band.effective.office.elevator.ui.main.MainComponent import com.arkivanov.decompose.ComponentContext import com.arkivanov.mvikotlin.core.instancekeeper.getStore import com.arkivanov.mvikotlin.core.store.StoreFactory @@ -14,6 +15,7 @@ import kotlinx.coroutines.flow.StateFlow class BookingComponent( componentContext: ComponentContext, storeFactory: StoreFactory, + private val output: (BookingComponent.Output) -> Unit ) : ComponentContext by componentContext { @@ -30,4 +32,12 @@ class BookingComponent( fun onEvent(event: BookingStore.Intent) { bookingStore.accept(event) } + + fun onOutput(output: BookingComponent.Output) { + output(output) + } + + sealed class Output { + object OpenMainTab : Output() + } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 699cb7f2..5a1bae9d 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -249,7 +249,7 @@ fun BookingScreen(bookingComponent: BookingComponent) { onClickCloseCalendar = { bookingComponent.onEvent(BookingStore.Intent.CloseCalendar) }, onClickOpenChoseZone = { bookingComponent.onEvent(BookingStore.Intent.OpenChooseZone) }, onClickOpenBookPeriod = { bookingComponent.onEvent(BookingStore.Intent.OpenBookPeriod) }, - onClickMainScreen = {}, + onClickMainScreen = { bookingComponent.onOutput(BookingComponent.Output.OpenMainTab) }, onClickOpenBookAccept = { bookingComponent.onEvent(BookingStore.Intent.OpenBookAccept) }, onClickApplyDate = { date: LocalDate? -> bookingComponent.onEvent( diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt index c6792a1b..090150f1 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt @@ -55,12 +55,11 @@ fun BookingSuccess(onMain: () -> Unit, close: () -> Unit, modifier: Modifier) { text = stringResource( resource = MainRes.strings.place_booked, ), - style = MaterialTheme.typography.h6.merge( - other = TextStyle( - fontWeight = FontWeight( - weight = 500 - ) - ) + style = MaterialTheme.typography.h6.copy( + fontWeight = FontWeight( + weight = 500 + ), + color = Color.Black ), textAlign = TextAlign.Center ) @@ -69,10 +68,8 @@ fun BookingSuccess(onMain: () -> Unit, close: () -> Unit, modifier: Modifier) { text = stringResource( resource = MainRes.strings.good_working_day, ), - style = MaterialTheme.typography.body1.merge( - other = TextStyle( - color = ExtendedTheme.colors._66x - ) + style = MaterialTheme.typography.body1.copy( + color = ExtendedTheme.colors._66x ), textAlign = TextAlign.Center ) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index 1d02a842..b1d3aa4f 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -50,7 +50,9 @@ interface BookingStore: Store + val workSpacesZone: List, + val selectedDate: LocalDate, + val selectedTime: LocalTime ){ companion object { val initState = State( @@ -64,7 +66,9 @@ interface BookingStore: Store copy(workSpacesZone = msg.workSpacesZone) - is Msg.DateBooking -> TODO() - is Msg.TimeBooking -> TODO() + is Msg.DateBooking -> copy(selectedDate = msg.date) + is Msg.TimeBooking -> copy(selectedTime = msg.time) is Msg.TypeList -> TODO() is Msg.ChangeWorkSpacesUI -> copy(workSpaces = msg.workSpacesUI) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt index d09eb551..1239eb2e 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt @@ -39,10 +39,16 @@ class ContentComponent( openAuthorizationFlow ) ) - is Config.Booking -> Child.Booking(BookingComponent(componentContext, storeFactory)) + is Config.Booking -> Child.Booking(BookingComponent(componentContext, storeFactory, ::bookingOutput)) is Config.Employee -> Child.Employee(FullEmployeeComponent(componentContext, storeFactory)) } + private fun bookingOutput(output: BookingComponent.Output){ + when(output){ + BookingComponent.Output.OpenMainTab -> navigation.bringToFront(Config.MainScreen) + } + } + fun onOutput(output: Output) { when (output) { Output.OpenMainTab -> navigation.bringToFront(Config.MainScreen) -- GitLab From d38bd2d8690b7a931bbb201bb0cc535b2175aa30 Mon Sep 17 00:00:00 2001 From: Slava Date: Tue, 15 Aug 2023 15:39:56 +0600 Subject: [PATCH 05/19] Booking domain [+] created two more use cases to change and create booking [+] created booking interactor --- .../elevator/domain/di/DomainModuleDI.kt | 11 +++++ .../domain/entity/BookingInteractor.kt | 46 +++++++++++++++++++ .../domain/useCase/ChangeBookingUseCase.kt | 13 ++++++ .../domain/useCase/CreateBookingUseCase.kt | 11 +++++ .../ui/main/store/MainStoreFactory.kt | 12 +++-- 5 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/ChangeBookingUseCase.kt create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/CreateBookingUseCase.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt index 6e0001cf..92fd5d62 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt @@ -6,7 +6,10 @@ import band.effective.office.elevator.data.repository.UserProfileRepositoryImpl import band.effective.office.elevator.domain.repository.BookingRepository import band.effective.office.elevator.domain.repository.OfficeElevatorRepository import band.effective.office.elevator.domain.entity.AuthorizationEntity +import band.effective.office.elevator.domain.entity.BookingInteractor import band.effective.office.elevator.domain.repository.UserProfileRepository +import band.effective.office.elevator.domain.useCase.ChangeBookingUseCase +import band.effective.office.elevator.domain.useCase.CreateBookingUseCase import band.effective.office.elevator.domain.useCase.ElevatorCallUseCase import band.effective.office.elevator.domain.useCase.EmployeeUseCase import band.effective.office.elevator.domain.useCase.GetBookingsUseCase @@ -28,4 +31,12 @@ internal val domainModuleDI = module { PushUserDataUseCase(get()) ) } + single { + BookingInteractor( + getBookingsUseCase = GetBookingsUseCase(repository = get()), + changeBookingUseCase = ChangeBookingUseCase(repository = get()), + createBookingUseCase = CreateBookingUseCase(repository = get()) + ) + } + } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt new file mode 100644 index 00000000..55981a3e --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt @@ -0,0 +1,46 @@ +package band.effective.office.elevator.domain.entity + +import band.effective.office.elevator.domain.models.BookingInfo +import band.effective.office.elevator.domain.models.CreatingBookModel +import band.effective.office.elevator.domain.useCase.ChangeBookingUseCase +import band.effective.office.elevator.domain.useCase.CreateBookingUseCase +import band.effective.office.elevator.domain.useCase.GetBookingsUseCase +import band.effective.office.elevator.ui.models.ReservedSeat +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.StateFlow +import kotlinx.datetime.LocalDate + +class BookingInteractor( + private val getBookingsUseCase: GetBookingsUseCase, + private val changeBookingUseCase: ChangeBookingUseCase, + private val createBookingUseCase: CreateBookingUseCase +) { + suspend fun getForUser(coroutineScope: CoroutineScope): StateFlow> { + val bookingsForUser: StateFlow> = + getBookingsUseCase.getBookingsForUser(coroutineScope) + return bookingsForUser + } + + suspend fun getByDate( + date: LocalDate, + coroutineScope: CoroutineScope + ): StateFlow> { + val bookingsByDate: StateFlow> = + getBookingsUseCase.getBookingsByDate(date = date, coroutineScope = coroutineScope) + return bookingsByDate + } + + suspend fun change(coroutineScope: CoroutineScope, bookingInfo: BookingInfo) { + changeBookingUseCase.execute( + coroutineScope = coroutineScope, + bookingInfo = bookingInfo + ) + } + + suspend fun create(coroutineScope: CoroutineScope, creatingBookModel: CreatingBookModel) { + createBookingUseCase.execute( + coroutineScope = coroutineScope, + creatingBookModel = creatingBookModel + ) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/ChangeBookingUseCase.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/ChangeBookingUseCase.kt new file mode 100644 index 00000000..ffa3e154 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/ChangeBookingUseCase.kt @@ -0,0 +1,13 @@ +package band.effective.office.elevator.domain.useCase + +import band.effective.office.elevator.domain.models.BookingInfo +import band.effective.office.elevator.domain.repository.BookingRepository +import kotlinx.coroutines.CoroutineScope + +class ChangeBookingUseCase( + private val repository: BookingRepository +) { + suspend fun execute(coroutineScope: CoroutineScope, bookingInfo: BookingInfo) { + repository.changeBooking(bookingInfo = bookingInfo) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/CreateBookingUseCase.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/CreateBookingUseCase.kt new file mode 100644 index 00000000..df195fd2 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/useCase/CreateBookingUseCase.kt @@ -0,0 +1,11 @@ +package band.effective.office.elevator.domain.useCase + +import band.effective.office.elevator.domain.models.CreatingBookModel +import band.effective.office.elevator.domain.repository.BookingRepository +import kotlinx.coroutines.CoroutineScope + +class CreateBookingUseCase(private val repository: BookingRepository) { + suspend fun execute(coroutineScope: CoroutineScope, creatingBookModel: CreatingBookModel) { + repository.createBook(bookingInfo = creatingBookModel) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt index 2ed956c9..ada69d5c 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt @@ -2,6 +2,7 @@ package band.effective.office.elevator.ui.main.store import band.effective.office.elevator.MainRes import band.effective.office.elevator.data.ApiResponse +import band.effective.office.elevator.domain.entity.BookingInteractor import band.effective.office.elevator.domain.useCase.ElevatorCallUseCase import band.effective.office.elevator.domain.useCase.GetBookingsUseCase import band.effective.office.elevator.ui.models.ElevatorState @@ -29,7 +30,8 @@ internal class MainStoreFactory( ) : KoinComponent { private val elevatorUseCase: ElevatorCallUseCase by inject() - private val bookingsUseCase: GetBookingsUseCase by inject() +// private val bookingsUseCase: GetBookingsUseCase by inject() + private val bookingInteractor: BookingInteractor by inject() @OptIn(ExperimentalMviKotlinApi::class) fun create(): MainStore = @@ -151,8 +153,8 @@ internal class MainStoreFactory( fun getBookingsForUserByDate(date: LocalDate) { scope.launch(Dispatchers.IO) { - bookingsUseCase - .getBookingsByDate(date = date, coroutineScope = this) + bookingInteractor + .getByDate(date = date, coroutineScope = this) .collect { bookings -> withContext(Dispatchers.Main) { dispatch(Msg.UpdateSeatsReservation(reservedSeats = bookings)) @@ -163,8 +165,8 @@ internal class MainStoreFactory( fun changeBookingsByDate(date: LocalDate) { scope.launch(Dispatchers.IO) { - bookingsUseCase - .getBookingsByDate(date = date, coroutineScope = this) + bookingInteractor + .getByDate(date = date, coroutineScope = this) .collect { bookings -> withContext(Dispatchers.Main) { dispatch( -- GitLab From db0047c38b71fca93be514435fa6234f0291ae6a Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 15 Aug 2023 07:32:49 -0700 Subject: [PATCH 06/19] [~] updated modal window "Booking Repeat" Signed-off-by: effective --- .../components/modals/BookingRepeat.kt | 629 +++++++++--------- .../resources/MR/base/strings_ru.xml | 2 - .../commonMain/resources/MR/en/strings_en.xml | 2 - 3 files changed, 304 insertions(+), 329 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt index fcd56a19..74c33922 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt @@ -3,6 +3,7 @@ package band.effective.office.elevator.ui.booking.components.modals import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -17,8 +18,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentWidth -import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid -import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells +import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults @@ -49,24 +49,23 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import band.effective.office.elevator.ExtendedTheme +import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes -import band.effective.office.elevator.components.PrimaryButton +import band.effective.office.elevator.components.EffectiveButton +import band.effective.office.elevator.components.Elevation import band.effective.office.elevator.textInBorderGray -import band.effective.office.elevator.textInBorderPurple -import band.effective.office.elevator.theme_light_primary_color import dev.icerock.moko.resources.compose.stringResource @OptIn(ExperimentalFoundationApi::class) @Composable fun BookingRepeat( backButtonClicked: () -> Unit, - dropDownClick: () -> Unit, + dropDownClick: (Int) -> Unit, confirmBooking: () -> Unit, onSelected: () -> Unit, onDaySelected: (Int) -> Unit ) { + val selected1 = remember { mutableStateOf(true) } @@ -77,160 +76,142 @@ fun BookingRepeat( mutableStateOf(false) } - val elevation = ButtonDefaults.elevation( - defaultElevation = 0.dp, - pressedElevation = 0.dp, - disabledElevation = 0.dp, - hoveredElevation = 0.dp, - focusedElevation = 0.dp - ) - - val weekNames = listOf( - MainRes.strings.Monday, - MainRes.strings.Tuesday, - MainRes.strings.Wednesday, - MainRes.strings.Thursday, - MainRes.strings.Friday, - MainRes.strings.Saturday, - MainRes.strings.Sunday, - ) + val isExpandedContextMenu = remember { mutableStateOf(false) } - val dropDownList = listOf( - stringResource(MainRes.strings.week), - stringResource(MainRes.strings.month) - ) + Column( + verticalArrangement = Arrangement.Top, + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight() + .background( + color = Color.White, + shape = RoundedCornerShape( + topStart = 16.dp, + topEnd = 16.dp, + bottomEnd = 0.dp, + bottomStart = 0.dp + ) + ) + .padding(bottom = 16.dp) + ) { + Spacer(modifier = Modifier.height(height = 8.dp)) + Divider( + modifier = Modifier + .fillMaxWidth(fraction = .3f) + .height(height = 4.dp) + .background( + color = ExtendedThemeColors.colors.dividerColor, + shape = RoundedCornerShape(size = 16.dp) + ) + .padding( + bottom = 8.dp, + top = 8.dp + ) + ) - Box { - Column( - verticalArrangement = Arrangement.Top, - horizontalAlignment = Alignment.CenterHorizontally, + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, modifier = Modifier .fillMaxWidth() .wrapContentHeight() - .background( - color = Color.White, - shape = RoundedCornerShape( - topStart = 16.dp, - topEnd = 16.dp, - bottomEnd = 0.dp, - bottomStart = 0.dp - ) - ) - .padding(bottom = 16.dp) + .padding(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 16.dp) ) { - Spacer(modifier = Modifier.height(height = 8.dp)) - Divider( - modifier = Modifier - .fillMaxWidth(fraction = .3f) - .height(height = 4.dp) - .background( - color = ExtendedTheme.colors.dividerColor, - shape = RoundedCornerShape(size = 16.dp) - ) - .padding( - bottom = 8.dp, - top = 8.dp - ) + IconButton( + onClick = backButtonClicked, + ) { + Icon( + imageVector = Icons.Default.ArrowBack, + contentDescription = "back button" + ) + } + Text( + text = stringResource(resource = MainRes.strings.booking_repeat), + style = MaterialTheme.typography.h6.copy(fontWeight = FontWeight(500)), + textAlign = TextAlign.Center ) + } + + Divider( + modifier = Modifier + .fillMaxWidth(fraction = 1.0f) + .height(height = 1.dp) + .background( + color = ExtendedThemeColors.colors._66x + ) + ) + Column( + modifier = Modifier + ) { Row( horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), verticalAlignment = Alignment.CenterVertically, modifier = Modifier .fillMaxWidth() - .wrapContentHeight() - .padding(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 16.dp) + .padding(start = 54.dp, end = 16.dp, top = 16.dp) ) { - IconButton( - onClick = backButtonClicked, - ) { - Icon( - imageVector = Icons.Default.ArrowBack, - contentDescription = "back button" - ) - } Text( - text = stringResource(resource = MainRes.strings.booking_repeat), - style = MaterialTheme.typography.h6.copy(fontWeight = FontWeight(500)), - textAlign = TextAlign.Center + text = stringResource(resource = MainRes.strings.booking_repeat_in), + style = MaterialTheme.typography.button.copy(fontWeight = FontWeight(400)) ) } - Divider( - modifier = Modifier - .fillMaxWidth(fraction = 1.0f) - .height(height = 1.dp) - .background( - color = ExtendedTheme.colors._66x - ) - ) - - Column( + Row( + horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, modifier = Modifier + .wrapContentWidth() + .padding(start = 54.dp, end = 16.dp) ) { - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 16.dp) - ) { - Text( - text = stringResource(resource = MainRes.strings.booking_repeat_in), - style = MaterialTheme.typography.button.copy(fontWeight = FontWeight(400)) - ) - } + OutlinedTextField( + value = "1", + onValueChange = { - Row( - horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, + }, + shape = RoundedCornerShape(8.dp), modifier = Modifier - .wrapContentWidth() - .padding(start = 54.dp, end = 16.dp) - ) { - OutlinedTextField( - value = "1", - onValueChange = { - - }, - shape = RoundedCornerShape(8.dp), - modifier = Modifier - .padding(top = 12.dp, bottom = 12.dp) - .weight(.3f) - ) - OutlinedTextField( - enabled = false, - readOnly = true, - value = dropDownList[0], - onValueChange = { + .padding(top = 12.dp, bottom = 12.dp) + .weight(.3f) + ) + OutlinedTextField( + enabled = false, + readOnly = true, + value = stringResource(MainRes.strings.week), + onValueChange = { - }, - shape = RoundedCornerShape(8.dp), - colors = TextFieldDefaults.outlinedTextFieldColors( - disabledTextColor = LocalContentColor.current.copy(LocalContentAlpha.current) - ), - modifier = Modifier - .padding( - start = 16.dp, - top = 12.dp, - end = 12.dp, - bottom = 12.dp - ) - .weight(.7f), - trailingIcon = { - IconButton( - onClick = dropDownClick - ) { - Image( - imageVector = Icons.Default.ArrowDropDown, - contentDescription = "drop down", - contentScale = ContentScale.None - ) + }, + shape = RoundedCornerShape(8.dp), + colors = TextFieldDefaults.outlinedTextFieldColors( + disabledTextColor = LocalContentColor.current.copy(LocalContentAlpha.current) + ), + modifier = Modifier + .padding( + start = 16.dp, + top = 12.dp, + end = 12.dp, + bottom = 12.dp + ) + .weight(.7f), + trailingIcon = { + IconButton( + onClick = + { + isExpandedContextMenu.value = !isExpandedContextMenu.value } + ) { + Image( + modifier = Modifier, + imageVector = Icons.Default.ArrowDropDown, + contentDescription = "drop down", + contentScale = ContentScale.None + ) } - ) - } - + } + ) + } + Column { Row( horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), verticalAlignment = Alignment.CenterVertically, @@ -240,223 +221,221 @@ fun BookingRepeat( ) { Text( text = stringResource(MainRes.strings.when_repeat), - style = MaterialTheme.typography.button.copy(fontWeight = FontWeight(weight = 400)) + style = MaterialTheme.typography.button.copy( + fontWeight = FontWeight( + weight = 400 + ) + ) ) } - - LazyVerticalStaggeredGrid( - columns = StaggeredGridCells.Fixed(count = 4), - verticalItemSpacing = 12.dp, - horizontalArrangement = Arrangement.spacedBy(12.dp), - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 16.dp, bottom = 16.dp), - content = { - items(weekNames.size) { index -> - var isExpanded by remember { mutableStateOf(false) } - Button( - onClick = { - isExpanded = !isExpanded - }.also { onDaySelected(index) }, - colors = ButtonDefaults.buttonColors(theme_light_primary_color), - contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp), - modifier = Modifier - .wrapContentWidth(), - border = BorderStroke( - width = 1.dp, - color = if (isExpanded) textInBorderPurple else textInBorderGray - ), - shape = RoundedCornerShape(12.dp), - elevation = ButtonDefaults.elevation(0.dp, 2.dp, 0.dp) - ) { - Row { - androidx.compose.material.Icon( - imageVector = Icons.Rounded.Done, - tint = textInBorderPurple, - modifier = Modifier.size( - if (isExpanded) 20.dp - else 0.dp - ) - .align(Alignment.CenterVertically), - contentDescription = "done button" - ) - androidx.compose.material.Text( - text = stringResource(weekNames[index]), - style = MaterialTheme.typography.body2.copy( - color = if (isExpanded) textInBorderPurple - else textInBorderGray - ), + val listDaysOfWeek = listOf( + MainRes.strings.Monday, + MainRes.strings.Tuesday, + MainRes.strings.Wednesday, + MainRes.strings.Thursday, + MainRes.strings.Friday + ) + LazyRow (modifier = Modifier.padding(start = 54.dp, end = 16.dp, top = 16.dp)){ + items(listDaysOfWeek) { days -> + var isExpanded by remember { mutableStateOf(false) } + Button( + onClick = { + isExpanded = !isExpanded + }, + contentPadding = PaddingValues( + horizontal = 12.dp, + vertical = 6.dp + ), + colors = ButtonDefaults.buttonColors( + backgroundColor = ExtendedThemeColors.colors.whiteColor + ), + modifier = Modifier + .wrapContentWidth().padding(end = 12.dp), + border = BorderStroke( + width = 1.dp, + color = if (isExpanded) + ExtendedThemeColors.colors.purple_heart_800 + else textInBorderGray + ), + shape = RoundedCornerShape(12.dp), + elevation = ButtonDefaults.elevation(0.dp, 2.dp, 0.dp) + ) { + Row { + Icon( + imageVector = Icons.Rounded.Done, + tint = ExtendedThemeColors.colors.purple_heart_800, + modifier = Modifier.size( + if (isExpanded) 20.dp + else 0.dp ) - } + .align(Alignment.CenterVertically), + contentDescription = "done button" + ) } + Text( + text = stringResource(days), + style = MaterialTheme.typography.body2.copy( + color = if (isExpanded) ExtendedThemeColors.colors.purple_heart_800 + else textInBorderGray + ), + ) } } - ) + } + } + Divider( + modifier = Modifier + .fillMaxWidth(fraction = 1.0f) + .height(height = 1.dp) + .background( + color = ExtendedThemeColors.colors._66x + ) + ) - Divider( - modifier = Modifier - .fillMaxWidth(fraction = 1.0f) - .height(height = 1.dp) - .background( - color = ExtendedTheme.colors._66x + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 16.dp) + ) { + Text( + text = stringResource(MainRes.strings.book_finish), + style = MaterialTheme.typography.button.copy( + fontWeight = FontWeight( + weight = 400 ) + ), + textAlign = TextAlign.Start ) + } - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 16.dp, bottom = 8.dp) - ) { - Text( - text = stringResource(MainRes.strings.book_finish), - style = MaterialTheme.typography.button.copy(fontWeight = FontWeight(weight = 400)), - textAlign = TextAlign.Start - ) - } - - Row( - horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 16.dp) + Row( + horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 8.dp) + ) { + Button( + colors = ButtonDefaults.buttonColors( + backgroundColor = Color.Transparent + ), + elevation = Elevation(), + modifier = Modifier.fillMaxWidth().wrapContentHeight(), + onClick = { + selected1.value = !selected1.value + selected2.value = false + selected3.value = false + }.also { onSelected() }, + contentPadding = PaddingValues(all = 0.dp) ) { - Button( - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = ButtonDefaults.elevation( - defaultElevation = 0.dp, - pressedElevation = 0.dp, - disabledElevation = 0.dp, - hoveredElevation = 0.dp, - focusedElevation = 0.dp - ), - modifier = Modifier.fillMaxWidth().wrapContentHeight(), - onClick = { - selected1.value = !selected1.value - selected2.value = false - selected3.value = false - }.also { onSelected() }, - contentPadding = PaddingValues(all = 0.dp) + Row( + horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, ) { - Row( - horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, - ) { - RadioButton( - enabled = false, - selected = selected1.value, - onClick = { }, - colors = RadioButtonDefaults.colors( - disabledSelectedColor = MaterialTheme.colors.primary, - disabledUnselectedColor = Color.Black - ) + RadioButton( + enabled = false, + selected = selected1.value, + onClick = { }, + colors = RadioButtonDefaults.colors( + disabledSelectedColor = MaterialTheme.colors.primary, + disabledUnselectedColor = Color.Black ) - Text( - text = stringResource(MainRes.strings.never), - style = MaterialTheme.typography.button.copy( - color = ExtendedTheme.colors.radioTextColor, - fontWeight = FontWeight(400) - ), - modifier = Modifier.fillMaxWidth().wrapContentHeight() - ) - } + ) + Text( + text = stringResource(MainRes.strings.never), + style = MaterialTheme.typography.button.copy( + color = ExtendedThemeColors.colors.radioTextColor, + fontWeight = FontWeight(400) + ), + modifier = Modifier.fillMaxWidth().wrapContentHeight() + ) } } + } - Row( - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 8.dp) - ) { - RadioButton(selected = selected2.value, onClick = { - selected2.value = !selected2.value - selected1.value = false - selected3.value = false - }.also { onSelected() }) - - Spacer(modifier = Modifier.width(width = 16.dp)) - - OutlinedTextField( - value = "01.01.2023", - onValueChange = { + Row( + horizontalArrangement = Arrangement.Start, + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 6.dp) + ) { + RadioButton(selected = selected2.value, onClick = { + selected2.value = !selected2.value + selected1.value = false + selected3.value = false + }.also { onSelected() }) - }, - shape = RoundedCornerShape(8.dp), - modifier = Modifier - .padding(top = 12.dp, bottom = 12.dp) - .weight(0.4f) - ) + Spacer(modifier = Modifier.width(width = 16.dp)) - Spacer(modifier = Modifier.width(width = 48.dp)) - } + OutlinedTextField( + value = "01.01.2023", + onValueChange = { - Row( - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically, + }, + shape = RoundedCornerShape(8.dp), modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 8.dp, bottom = 8.dp) - ) { - RadioButton(selected = selected3.value, onClick = { - selected3.value = !selected3.value - selected1.value = false - selected2.value = false - }.also { onSelected() }) - Text( - text = stringResource(MainRes.strings.booking_1), - style = MaterialTheme.typography.button.copy( - color = ExtendedTheme.colors.radioTextColor, - fontWeight = FontWeight(400) - ), - modifier = Modifier.wrapContentWidth() - ) - Spacer(modifier = Modifier.width(width = 16.dp)) + .padding(top = 12.dp, bottom = 12.dp) + .weight(0.4f) + ) - OutlinedTextField( - value = "1", - onValueChange = { + Spacer(modifier = Modifier.width(width = 48.dp)) + } - }, - shape = RoundedCornerShape(8.dp), - modifier = Modifier - .padding(top = 12.dp, bottom = 12.dp) - .weight(weight = 0.1f) - ) + Row( + horizontalArrangement = Arrangement.Start, + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 8.dp, bottom = 8.dp) + ) { + RadioButton(selected = selected3.value, onClick = { + selected3.value = !selected3.value + selected1.value = false + selected2.value = false + }.also { onSelected() }) + Text( + text = stringResource(MainRes.strings.booking_1), + style = MaterialTheme.typography.button.copy( + color = ExtendedThemeColors.colors.radioTextColor, + fontWeight = FontWeight(400) + ), + modifier = Modifier.wrapContentWidth() + ) + Spacer(modifier = Modifier.width(width = 16.dp)) - Spacer(modifier = Modifier.width(width = 16.dp)) + OutlinedTextField( + value = "1", + onValueChange = { - Text( - text = stringResource(MainRes.strings.booking_2), - style = MaterialTheme.typography.button.copy( - color = ExtendedTheme.colors.radioTextColor, - fontWeight = FontWeight(400) - ), - modifier = Modifier.wrapContentWidth().wrapContentHeight() - ) + }, + shape = RoundedCornerShape(8.dp), + modifier = Modifier + .padding(top = 12.dp, bottom = 12.dp) + .weight(weight = 0.1f) + ) - Spacer(modifier = Modifier.width(width = 48.dp)) - } + Spacer(modifier = Modifier.width(width = 16.dp)) - PrimaryButton( - text = stringResource(MainRes.strings.confirm_booking), - cornerValue = 40.dp, - modifier = Modifier.padding(horizontal = 16.dp), - contentTextSize = 16.sp, - paddingValues = PaddingValues(all = 10.dp), - elevation = elevation, - colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.primary + Text( + text = stringResource(MainRes.strings.booking_2), + style = MaterialTheme.typography.button.copy( + color = ExtendedThemeColors.colors.radioTextColor, + fontWeight = FontWeight(400) ), - border = null, - onButtonClick = confirmBooking + modifier = Modifier.wrapContentWidth().wrapContentHeight() ) + + Spacer(modifier = Modifier.width(width = 48.dp)) } + + EffectiveButton( + buttonText = stringResource(MainRes.strings.confirm_booking), + onClick = confirmBooking, + modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), + ) } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml index a350e560..fadfbf68 100644 --- a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml +++ b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml @@ -74,8 +74,6 @@ Ср Чт Пт - Сб - Вс Занять с Занять до diff --git a/composeApp/src/commonMain/resources/MR/en/strings_en.xml b/composeApp/src/commonMain/resources/MR/en/strings_en.xml index 4f62fb09..cfdf62a5 100644 --- a/composeApp/src/commonMain/resources/MR/en/strings_en.xml +++ b/composeApp/src/commonMain/resources/MR/en/strings_en.xml @@ -77,8 +77,6 @@ Wed Thu Fri - Sat - Sun Take from Take before -- GitLab From f0d0da12a71ff4db42b565db37b0ca464008f056 Mon Sep 17 00:00:00 2001 From: Slava Date: Wed, 16 Aug 2023 01:49:33 +0600 Subject: [PATCH 07/19] Booking period modal [+] created functionality to change date and time on whole booking screen [~] simple code refactoring to change this stated --- .../domain/entity/BookingInteractor.kt | 7 +- .../elevator/ui/booking/BookingScreen.kt | 67 +++++++++++++------ .../components/BookingMainContentScreen.kt | 21 +++--- .../ui/booking/components/OptionMenu.kt | 7 +- .../components/modals/BookingPeriod.kt | 2 +- .../components/modals/BookingSuccess.kt | 37 +++------- .../elevator/ui/booking/store/BookingStore.kt | 32 ++++++--- .../ui/booking/store/BookingStoreFactory.kt | 50 +++++++++++--- .../elevator/ui/content/ContentComponent.kt | 12 +++- .../ui/main/store/MainStoreFactory.kt | 11 ++- .../office/elevator/utils/ConvertDate.kt | 19 ++++++ 11 files changed, 175 insertions(+), 90 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/utils/ConvertDate.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt index 55981a3e..22ef0ab6 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt @@ -15,18 +15,19 @@ class BookingInteractor( private val changeBookingUseCase: ChangeBookingUseCase, private val createBookingUseCase: CreateBookingUseCase ) { - suspend fun getForUser(coroutineScope: CoroutineScope): StateFlow> { + suspend fun getForUser(ownerId:String, coroutineScope: CoroutineScope): StateFlow> { val bookingsForUser: StateFlow> = - getBookingsUseCase.getBookingsForUser(coroutineScope) + getBookingsUseCase.getBookingsForUser(ownerId = ownerId, coroutineScope = coroutineScope) return bookingsForUser } suspend fun getByDate( + ownerId: String, date: LocalDate, coroutineScope: CoroutineScope ): StateFlow> { val bookingsByDate: StateFlow> = - getBookingsUseCase.getBookingsByDate(date = date, coroutineScope = coroutineScope) + getBookingsUseCase.getBookingsByDate(ownerId = ownerId, date = date, coroutineScope = coroutineScope) return bookingsByDate } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 593eac60..15f12d59 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -29,7 +29,6 @@ import band.effective.office.elevator.components.TimePickerModal import band.effective.office.elevator.components.bottomSheet.BottomSheetItem import band.effective.office.elevator.components.bottomSheet.MultiBottomSheetController import band.effective.office.elevator.components.bottomSheet.rememberMultiBottomSheetController -import band.effective.office.elevator.expects.showToast import band.effective.office.elevator.ui.booking.components.BookingMainContentScreen import band.effective.office.elevator.ui.booking.components.modals.BookAccept import band.effective.office.elevator.ui.booking.components.modals.BookingPeriod @@ -42,6 +41,7 @@ import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import band.effective.office.elevator.ui.booking.store.BookingStore +import band.effective.office.elevator.utils.NumToMonth import band.effective.office.elevator.utils.Stack import band.effective.office.elevator.utils.isScrollingDown import band.effective.office.elevator.utils.stackOf @@ -160,16 +160,36 @@ fun BookingScreen(bookingComponent: BookingComponent) { bottomSheetContentState = showBookPeriod ) { BookingPeriod( - startDate = "Чт, 27 июл. 2023 г.", - startTime = "10:30", - finishTime = "15:30", + startDate = "${state.selectedStartDate.dayOfMonth} ${NumToMonth(month = state.selectedStartDate.monthNumber)} ${state.selectedStartDate.year}", + startTime = "${state.selectedStartTime.hour}:${state.selectedStartTime.minute}", + finishTime = "${state.selectedFinishTime.hour}:${state.selectedFinishTime.minute}", repeatBooking = "Бронирование не повторяется", - switchChecked = false, + switchChecked = state.wholeDay, closeClick = { bookingComponent.onEvent(BookingStore.Intent.CloseBookPeriod) }, - onSelectAllDay = { false }, + onSelectAllDay = { + bookingComponent.onEvent( + BookingStore.Intent.ChangeWholeDay( + wholeDay = !state.wholeDay + ) + ) + }, bookStartDate = { bookingComponent.onEvent(BookingStore.Intent.OpenCalendar) }, - bookStartTime = { bookingComponent.onEvent(BookingStore.Intent.OpenTimeModal) }, - bookFinishTime = { bookingComponent.onEvent(BookingStore.Intent.OpenTimeModal) }, + bookStartTime = { + bookingComponent.onEvent( + BookingStore.Intent.OpenStartTimeModal( + isStart = true, + time = state.selectedStartTime + ) + ) + }, + bookFinishTime = { + bookingComponent.onEvent( + BookingStore.Intent.OpenStartTimeModal( + isStart = false, + time = state.selectedStartTime + ) + ) + }, bookingRepeat = { bookingComponent.onEvent(BookingStore.Intent.OpenRepeatDialog) }, onClickSearchSuitableOptions = { bookingComponent.onEvent(BookingStore.Intent.SearchSuitableOptions) } ) @@ -217,13 +237,15 @@ fun BookingScreen(bookingComponent: BookingComponent) { is BookingStore.Label.CloseCalendar -> showCalendar = false is BookingStore.Label.OpenConfirmBooking -> showConfirm = true is BookingStore.Label.CloseConfirmBooking -> showConfirm = false - is BookingStore.Label.OpenTimeModal -> showTimePicker = true - is BookingStore.Label.CloseTimeModal -> showTimePicker = false + is BookingStore.Label.OpenStartTimeModal -> showTimePicker = true + is BookingStore.Label.CloseStartTimeModal -> showTimePicker = false is BookingStore.Label.OpenBookRepeat -> multiBottomSheetController.showSheet( BottomSheetNames.BOOK_REPEAT.name ) is BookingStore.Label.CloseBookRepeat -> multiBottomSheetController.closeCurrentSheet() + BookingStore.Label.OpenFinishTimeModal -> showTimePicker = true + BookingStore.Label.CloseFinishTimeModal -> showTimePicker = false } } } @@ -237,11 +259,12 @@ fun BookingScreen(bookingComponent: BookingComponent) { showTimePicker = showTimePicker, currentDate = state.currentDate, onClickOpenBookRepeat = { bookingComponent.onEvent(BookingStore.Intent.OpenBookRepeat) }, - onClickCloseTimeModal = { bookingComponent.onEvent(BookingStore.Intent.CloseTimeModal) }, + onClickCloseTimeModal = { bookingComponent.onEvent(BookingStore.Intent.CloseStartTimeModal) }, onClickSelectTime = { time: LocalTime -> bookingComponent.onEvent( BookingStore.Intent.ApplyTime( - time = time + time = time, + isStart = state.isStart ) ) }, @@ -267,7 +290,9 @@ fun BookingScreen(bookingComponent: BookingComponent) { ) bookingComponent.onEvent(BookingStore.Intent.ChangeWorkSpacesUI(workSpaces = workSpacesUI.filter { workSpaceUI -> workSpaceUI.workSpaceType == type })) } - } + }, + isStart = state.isStart, + date = state.selectedStartDate ) } @@ -290,7 +315,9 @@ private fun BookingScreenContent( onClickCloseTimeModal: () -> Unit, onClickSelectTime: (LocalTime) -> Unit, onClickOpenBookRepeat: () -> Unit, - onClickChangeZone: (WorkSpaceType) -> Unit + onClickChangeZone: (WorkSpaceType) -> Unit, + isStart: Boolean, + date: LocalDate ) { val scrollState = rememberLazyListState() val scrollIsDown = scrollState.isScrollingDown() @@ -326,7 +353,8 @@ private fun BookingScreenContent( onClickOpenChoseZone = onClickOpenChoseZone, onClickExpandedMap = { isExpandedCard = !isExpandedCard }, onClickExpandedOption = { isExpandedOptions = !isExpandedOptions }, - onClickChangeZone = onClickChangeZone + onClickChangeZone = onClickChangeZone, + date = date ) } @@ -347,12 +375,12 @@ private fun BookingScreenContent( if (showTimePicker) { TimePickerModal( - titleText = stringResource(timeTitle), + titleText = if (isStart) "Занять с" else "Занять до", modifier = Modifier.padding(horizontal = 16.dp) .clip(shape = RoundedCornerShape(16.dp)).background(Color.White) .align(Alignment.Center), onClickCansel = onClickCloseTimeModal, - onClickOk = onClickSelectTime + onClickOk = onClickSelectTime, ) } @@ -365,8 +393,3 @@ private fun BookingScreenContent( } } } - - - - - diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt index 7b1b1f7e..c4fbcde9 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt @@ -30,15 +30,16 @@ import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp +import band.effective.office.elevator.ExtendedColors.purple_heart_600 import band.effective.office.elevator.MainRes -import band.effective.office.elevator.borderPurple import band.effective.office.elevator.components.TitlePage -import band.effective.office.elevator.textGrayColor -import band.effective.office.elevator.textInBorderPurple import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource +import band.effective.office.elevator.ExtendedColors._66x +import band.effective.office.elevator.ExtendedColors.purple_heart_500 +import kotlinx.datetime.LocalDate @Composable fun BookingMainContentScreen( @@ -53,7 +54,8 @@ fun BookingMainContentScreen( onClickOpenChoseZone: () -> Unit, onClickExpandedMap: () -> Unit, onClickExpandedOption: () -> Unit, - onClickChangeZone: (WorkSpaceType) -> Unit + onClickChangeZone: (WorkSpaceType) -> Unit, + date: LocalDate ) { Scaffold( topBar = { @@ -87,7 +89,8 @@ fun BookingMainContentScreen( isExpandedCard = isExpandedCard, isExpandedOptions = isExpandedOptions, onClickOpenBookPeriod = onClickOpenBookPeriod, - onClickChangeZone = onClickChangeZone + onClickChangeZone = onClickChangeZone, + date = date ) } Box( @@ -101,11 +104,11 @@ fun BookingMainContentScreen( shape = CircleShape, border = BorderStroke( width = 1.dp, - color = textGrayColor + color = _66x ), colors = ButtonDefaults.buttonColors( backgroundColor = Color.White, - contentColor = textGrayColor + contentColor = _66x ), modifier = Modifier.size(40.dp) ) { @@ -143,14 +146,14 @@ fun BookingMainContentScreen( Row(verticalAlignment = Alignment.CenterVertically) { Icon( painter = painterResource(MainRes.images.icon_location), - tint = textInBorderPurple, + tint = purple_heart_500, contentDescription = null ) Text( modifier = Modifier.padding(start = 8.dp), text = stringResource(MainRes.strings.select_zones), style = MaterialTheme.typography.subtitle1.copy( - color = borderPurple, + color = purple_heart_600, fontWeight = FontWeight(400) ) ) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt index fd95b55d..2744d340 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt @@ -29,15 +29,18 @@ import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.models.TypesList +import band.effective.office.elevator.utils.NumToMonth import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource +import kotlinx.datetime.LocalDate @Composable fun OptionMenu( isExpandedCard: Boolean, isExpandedOptions: Boolean, onClickOpenBookPeriod: () -> Unit, - onClickChangeZone: (WorkSpaceType) -> Unit + onClickChangeZone: (WorkSpaceType) -> Unit, + date: LocalDate ) { Column { AnimatedVisibility(visible = isExpandedCard) { @@ -145,7 +148,7 @@ fun OptionMenu( ) } Text( - text = "Пт, 30 июня 12:00 — 14:00", //TODO(Olesia Shinkarenko): get from calendar + text = "${date.dayOfMonth} ${NumToMonth(month = date.monthNumber)} ${date.year}", modifier = Modifier.padding(start = 8.dp), style = MaterialTheme.typography.body2 ) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt index d8ee8403..d755a739 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt @@ -88,7 +88,7 @@ fun BookingPeriod( Row( horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), - verticalAlignment = Alignment.Top, + verticalAlignment = Alignment.CenterVertically, modifier = Modifier .fillMaxWidth() .wrapContentHeight() diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt index 090150f1..afddc2c4 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt @@ -23,8 +23,9 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import band.effective.office.elevator.ExtendedTheme +import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes -import band.effective.office.elevator.components.PrimaryButton +import band.effective.office.elevator.components.EffectiveButton import dev.icerock.moko.resources.compose.stringResource @Composable @@ -69,7 +70,7 @@ fun BookingSuccess(onMain: () -> Unit, close: () -> Unit, modifier: Modifier) { resource = MainRes.strings.good_working_day, ), style = MaterialTheme.typography.body1.copy( - color = ExtendedTheme.colors._66x + color = ExtendedThemeColors.colors._66x ), textAlign = TextAlign.Center ) @@ -79,33 +80,13 @@ fun BookingSuccess(onMain: () -> Unit, close: () -> Unit, modifier: Modifier) { verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top), horizontalAlignment = Alignment.Start, ) { - PrimaryButton( - text = stringResource(resource = MainRes.strings.move_to_main_from_booking), - cornerValue = 40.dp, - contentTextSize = 16.sp, - paddingValues = PaddingValues(all = 10.dp), - elevation = elevation, - colors = ButtonDefaults.buttonColors( - backgroundColor = Color(0xFFE85B0F), //TODO: Replace with material theme Color(0xFFE85B0F) - contentColor = Color.White - ), - onButtonClick = onMain + EffectiveButton( + buttonText = stringResource(resource = MainRes.strings.move_to_main_from_booking), + onClick = onMain ) - PrimaryButton( - text = stringResource(resource = MainRes.strings.close_booking), - cornerValue = 40.dp, - contentTextSize = 16.sp, - paddingValues = PaddingValues(horizontal = 16.dp, vertical = 10.dp), - elevation = elevation, - colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.background, - contentColor = ExtendedTheme.colors.trinidad_700 - ), - border = BorderStroke( - width = 2.dp, - color = ExtendedTheme.colors.trinidad_700 - ), - onButtonClick = close + EffectiveButton( + buttonText = stringResource(resource = MainRes.strings.close_booking), + onClick = close ) } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index b1d3aa4f..8b04bbf1 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -1,6 +1,5 @@ package band.effective.office.elevator.ui.booking.store -import band.effective.office.elevator.MainRes import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.domain.models.CreatingBookModel import band.effective.office.elevator.domain.models.TypeEndPeriodBooking @@ -10,7 +9,6 @@ import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import band.effective.office.elevator.utils.getCurrentDate import com.arkivanov.mvikotlin.core.store.Store import com.commandiron.wheel_picker_compose.utils.getCurrentTime -import dev.icerock.moko.resources.compose.stringResource import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime @@ -19,9 +17,11 @@ interface BookingStore: Store) : Intent data class ChangeType(val type : WorkSpaceType) : Intent + + data class ChangeWholeDay(val wholeDay: Boolean) : Intent } data class State( @@ -51,8 +53,11 @@ interface BookingStore: Store, - val selectedDate: LocalDate, - val selectedTime: LocalTime + val selectedStartDate: LocalDate, + val selectedStartTime: LocalTime, + val selectedFinishTime: LocalTime, + val wholeDay: Boolean, + val isStart: Boolean ){ companion object { val initState = State( @@ -67,8 +72,11 @@ interface BookingStore: Store) : Msg data class ChangeWorkSpacesUI(val workSpacesUI: List) : Msg + + data class WholeDay(val wholeDay: Boolean) : Msg + data class IsStartTimePicked(val isStart: Boolean) : Msg } private sealed interface Action { @@ -145,23 +149,26 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is BookingStore.Intent.ApplyTime -> { scope.launch { - publish(BookingStore.Label.CloseTimeModal) - intent.time?.let { newTime -> - dispatch(Msg.TimeBooking(newTime)) + if (intent.isStart) { + dispatch(Msg.BeginningBookingTime(intent.time)) + } else { + dispatch(Msg.EndBookingTime(intent.time)) } + publish(BookingStore.Label.CloseStartTimeModal) } } - is BookingStore.Intent.CloseTimeModal -> { + is BookingStore.Intent.CloseStartTimeModal -> { scope.launch { - publish(BookingStore.Label.CloseTimeModal) + publish(BookingStore.Label.CloseStartTimeModal) } } - is BookingStore.Intent.OpenTimeModal -> { + is BookingStore.Intent.OpenStartTimeModal -> { scope.launch { - publish(BookingStore.Label.OpenTimeModal) + dispatch(Msg.IsStartTimePicked(isStart = intent.isStart)) + publish(BookingStore.Label.OpenStartTimeModal) } } @@ -205,6 +212,23 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is BookingStore.Intent.ChangeType -> { } + + is BookingStore.Intent.ChangeWholeDay -> { + dispatch(Msg.WholeDay(wholeDay = intent.wholeDay)) + } + + BookingStore.Intent.OpenFinishTimeModal -> { + scope.launch { + publish(BookingStore.Label.OpenFinishTimeModal) + } + } + + BookingStore.Intent.CloseFinishTimeModal -> { + scope.launch { + publish(BookingStore.Label.CloseFinishTimeModal) + } + + } } } @@ -224,10 +248,14 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen override fun BookingStore.State.reduce(msg: Msg): BookingStore.State { return when (msg) { is Msg.ChangeSelectedWorkSpacesZone -> copy(workSpacesZone = msg.workSpacesZone) - is Msg.DateBooking -> copy(selectedDate = msg.date) - is Msg.TimeBooking -> copy(selectedTime = msg.time) + is Msg.DateBooking -> copy(selectedStartDate = msg.date) + is Msg.TimeBooking -> copy(selectedStartTime = msg.time) is Msg.TypeList -> TODO() is Msg.ChangeWorkSpacesUI -> copy(workSpaces = msg.workSpacesUI) + is Msg.WholeDay -> copy(wholeDay = msg.wholeDay) + is Msg.BeginningBookingTime -> copy(selectedStartTime = msg.time) + is Msg.EndBookingTime -> copy(selectedFinishTime = msg.time) + is Msg.IsStartTimePicked -> copy(isStart = msg.isStart) } } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt index 1239eb2e..0d4b97de 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/ContentComponent.kt @@ -31,7 +31,7 @@ class ContentComponent( val childStack: Value> = stack private fun child(config: Config, componentContext: ComponentContext): Child = when (config) { - is Config.MainScreen -> Child.Main(MainComponent(componentContext, storeFactory)) + is Config.MainScreen -> Child.Main(MainComponent(componentContext, storeFactory, ::mainOutput)) is Config.Profile -> Child.Profile( ProfileComponent( componentContext, @@ -49,6 +49,16 @@ class ContentComponent( } } + private fun mainOutput(output: MainComponent.Output) { + when(output){ + MainComponent.Output.DeleteBooking -> TODO() + MainComponent.Output.ExtendBooking -> TODO() + MainComponent.Output.OpenBookingScreen -> TODO() + MainComponent.Output.OpenMap -> TODO() + MainComponent.Output.RepeatBooking -> TODO() + } + } + fun onOutput(output: Output) { when (output) { Output.OpenMainTab -> navigation.bringToFront(Config.MainScreen) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt index ada69d5c..4b682064 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt @@ -101,6 +101,13 @@ internal class MainStoreFactory( changeBookingsByDate(date = newDate) } } + + MainStore.Intent.CloseFiltersBottomDialog -> TODO() + is MainStore.Intent.OnClickDeleteBooking -> TODO() + is MainStore.Intent.OnClickExtendBooking -> TODO() + is MainStore.Intent.OnClickRepeatBooking -> TODO() + MainStore.Intent.OnClickShowMap -> TODO() + MainStore.Intent.OpenFiltersBottomDialog -> TODO() } } @@ -154,7 +161,7 @@ internal class MainStoreFactory( fun getBookingsForUserByDate(date: LocalDate) { scope.launch(Dispatchers.IO) { bookingInteractor - .getByDate(date = date, coroutineScope = this) + .getByDate(ownerId = "", date = date, coroutineScope = this) .collect { bookings -> withContext(Dispatchers.Main) { dispatch(Msg.UpdateSeatsReservation(reservedSeats = bookings)) @@ -166,7 +173,7 @@ internal class MainStoreFactory( fun changeBookingsByDate(date: LocalDate) { scope.launch(Dispatchers.IO) { bookingInteractor - .getByDate(date = date, coroutineScope = this) + .getByDate(ownerId = "", date = date, coroutineScope = this) .collect { bookings -> withContext(Dispatchers.Main) { dispatch( diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/utils/ConvertDate.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/utils/ConvertDate.kt new file mode 100644 index 00000000..11032df8 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/utils/ConvertDate.kt @@ -0,0 +1,19 @@ +package band.effective.office.elevator.utils + +fun NumToMonth(month: Int): String { + return when(month) { + 1 -> "Янв." + 2 -> "Фев." + 3 -> "Мар." + 4 -> "Апр." + 5 -> "Май" + 6 -> "Июнь" + 7 -> "Июль" + 8 -> "Авг." + 9 -> "Сен." + 10 -> "Окт." + 11 -> "Ноя." + 12 -> "Дек." + else -> "Unknown" + } +} \ No newline at end of file -- GitLab From c42cf50cb351f322c38a2564f1953bd3a447bc25 Mon Sep 17 00:00:00 2001 From: Slava Date: Wed, 16 Aug 2023 14:16:32 +0600 Subject: [PATCH 08/19] Booking [+] created several more states [~] refactoring code [+] added domain logic to BookingStoreFactory --- .../elevator/ui/booking/BookingScreen.kt | 31 +- .../booking/components/modals/BookAccept.kt | 35 +- .../components/modals/BookingPeriod.kt | 8 +- .../components/modals/BookingRepeat.kt | 596 +++++++++--------- .../components/modals/BookingRepeatCard.kt | 23 +- .../components/modals/BookingRepeatElement.kt | 8 +- .../components/modals/BookingSuccess.kt | 7 - .../booking/components/modals/EditBooking.kt | 2 +- .../elevator/ui/booking/models/Frequency.kt | 15 + .../elevator/ui/booking/store/BookingStore.kt | 75 ++- .../ui/booking/store/BookingStoreFactory.kt | 66 +- 11 files changed, 498 insertions(+), 368 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 15f12d59..adf9e66e 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -29,6 +29,7 @@ import band.effective.office.elevator.components.TimePickerModal import band.effective.office.elevator.components.bottomSheet.BottomSheetItem import band.effective.office.elevator.components.bottomSheet.MultiBottomSheetController import band.effective.office.elevator.components.bottomSheet.rememberMultiBottomSheetController +import band.effective.office.elevator.domain.models.BookingInfo import band.effective.office.elevator.ui.booking.components.BookingMainContentScreen import band.effective.office.elevator.ui.booking.components.modals.BookAccept import band.effective.office.elevator.ui.booking.components.modals.BookingPeriod @@ -48,6 +49,7 @@ import band.effective.office.elevator.utils.stackOf import dev.icerock.moko.resources.compose.stringResource import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalTime +import kotlinx.datetime.atTime @OptIn(ExperimentalMaterialApi::class) @Composable @@ -153,7 +155,15 @@ fun BookingScreen(bookingComponent: BookingComponent) { ) { BookAccept( onClickCloseBookAccept = { bookingComponent.onEvent(BookingStore.Intent.CloseBookAccept) }, - confirmBooking = { bookingComponent.onEvent(BookingStore.Intent.OpenConfirmBooking) } + confirmBooking = { bookingComponent.onEvent(BookingStore.Intent.OpenConfirmBooking) }, + bookingInfo = BookingInfo( + id = "", + ownerId = "", + seatName = "", + dateOfStart = state.selectedStartDate.atTime(state.selectedStartTime), + dateOfEnd = state.selectedStartDate.atTime(state.selectedFinishTime) + ), + frequency = state.frequency ) }, BottomSheetNames.BOOK_PERIOD.name to BottomSheetItem( @@ -163,7 +173,7 @@ fun BookingScreen(bookingComponent: BookingComponent) { startDate = "${state.selectedStartDate.dayOfMonth} ${NumToMonth(month = state.selectedStartDate.monthNumber)} ${state.selectedStartDate.year}", startTime = "${state.selectedStartTime.hour}:${state.selectedStartTime.minute}", finishTime = "${state.selectedFinishTime.hour}:${state.selectedFinishTime.minute}", - repeatBooking = "Бронирование не повторяется", + repeatBooking = state.repeatBooking, switchChecked = state.wholeDay, closeClick = { bookingComponent.onEvent(BookingStore.Intent.CloseBookPeriod) }, onSelectAllDay = { @@ -190,8 +200,11 @@ fun BookingScreen(bookingComponent: BookingComponent) { ) ) }, - bookingRepeat = { bookingComponent.onEvent(BookingStore.Intent.OpenRepeatDialog) }, - onClickSearchSuitableOptions = { bookingComponent.onEvent(BookingStore.Intent.SearchSuitableOptions) } + bookingRepeat = { + bookingComponent.onEvent(BookingStore.Intent.OpenRepeatDialog) + }, + onClickSearchSuitableOptions = { bookingComponent.onEvent(BookingStore.Intent.SearchSuitableOptions) }, + frequency = state.frequency ) }, BottomSheetNames.BOOK_REPEAT.name to BottomSheetItem( @@ -200,7 +213,9 @@ fun BookingScreen(bookingComponent: BookingComponent) { BookingRepeat( backButtonClicked = { bookingComponent.onEvent(BookingStore.Intent.CloseBookRepeat) }, dropDownClick = {}, - confirmBooking = {}, + confirmBooking = { frequency -> + bookingComponent.onEvent(BookingStore.Intent.ChangeFrequency(frequency = frequency)) + }, onSelected = {}, onDaySelected = {} ) @@ -258,7 +273,9 @@ fun BookingScreen(bookingComponent: BookingComponent) { showConfirm = showConfirm, showTimePicker = showTimePicker, currentDate = state.currentDate, - onClickOpenBookRepeat = { bookingComponent.onEvent(BookingStore.Intent.OpenBookRepeat) }, + onClickOpenBookRepeat = { name -> + bookingComponent.onEvent(BookingStore.Intent.OpenBookRepeat(name = name)) + }, onClickCloseTimeModal = { bookingComponent.onEvent(BookingStore.Intent.CloseStartTimeModal) }, onClickSelectTime = { time: LocalTime -> bookingComponent.onEvent( @@ -314,7 +331,7 @@ private fun BookingScreenContent( showTimePicker: Boolean, onClickCloseTimeModal: () -> Unit, onClickSelectTime: (LocalTime) -> Unit, - onClickOpenBookRepeat: () -> Unit, + onClickOpenBookRepeat: (String) -> Unit, onClickChangeZone: (WorkSpaceType) -> Unit, isStart: Boolean, date: LocalDate diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt index 71709ce8..30be140e 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt @@ -26,20 +26,20 @@ import androidx.compose.ui.unit.sp import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes import band.effective.office.elevator.components.EffectiveButton +import band.effective.office.elevator.domain.models.BookingInfo import band.effective.office.elevator.textInBorderGray +import band.effective.office.elevator.ui.booking.models.Frequency import dev.icerock.moko.resources.compose.stringResource @Composable fun BookAccept( onClickCloseBookAccept: () -> Unit, confirmBooking: () -> Unit, -){ - val booking_place ="Cassipopeia | Table 1" - val frequency = "Every single day" - val startTime = "11:00" - val endTime = "19:00" - Box{ - Column (modifier = Modifier.fillMaxWidth().background(Color.White)){ + bookingInfo: BookingInfo, + frequency: Frequency +) { + Box { + Column(modifier = Modifier.fillMaxWidth().background(Color.White)) { Spacer(modifier = Modifier.padding(vertical = 10.dp)) Divider( modifier = Modifier @@ -55,7 +55,7 @@ fun BookAccept( ) ) - Row (modifier= Modifier.padding(top=10.dp, start = 16.dp, end = 16.dp)){ + Row(modifier = Modifier.padding(top = 10.dp, start = 16.dp, end = 16.dp)) { IconButton( onClick = onClickCloseBookAccept, modifier = Modifier @@ -67,9 +67,9 @@ fun BookAccept( tint = ExtendedThemeColors.colors.blackColor ) } - Column(modifier=Modifier.padding(horizontal = 5.dp)){ + Column(modifier = Modifier.padding(horizontal = 5.dp)) { Text( - text = booking_place, + text = bookingInfo.seatName, style = MaterialTheme.typography.subtitle1, fontSize = 20.sp, fontWeight = FontWeight(600), @@ -77,7 +77,20 @@ fun BookAccept( modifier = Modifier.padding(top = 10.dp, bottom = 5.dp) ) Text( - text = "$frequency $startTime-$endTime", + text = with(bookingInfo) { + "" + + "${frequency.toString()} ${dateOfStart.time.hour.toString()}:${ + with( + dateOfStart.time + ) { if (minute.toString().length < 2) "0$minute" else minute.toString() } + }-${dateOfEnd.time.hour.toString()}:${ + with( + dateOfStart.time + ) { + if (minute.toString().length < 2) "0$minute" else minute.toString() + } + }" + }, style = MaterialTheme.typography.subtitle1, fontSize = 16.sp, fontWeight = FontWeight(400), diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt index d755a739..84b3dcee 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt @@ -35,6 +35,7 @@ import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes import band.effective.office.elevator.components.EffectiveButton import band.effective.office.elevator.components.Elevation +import band.effective.office.elevator.ui.booking.models.Frequency import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource @@ -51,7 +52,8 @@ fun BookingPeriod( bookStartTime: () -> Unit, bookFinishTime: () -> Unit, bookingRepeat: () -> Unit, - onClickSearchSuitableOptions: () -> Unit + onClickSearchSuitableOptions: () -> Unit, + frequency: Frequency ) { Column( verticalArrangement = Arrangement.Top, @@ -100,7 +102,7 @@ fun BookingPeriod( Icon(imageVector = Icons.Default.Close, contentDescription = "close booking") } Text( - text = stringResource(resource = MainRes.strings.booking_period), + text = stringResource(MainRes.strings.booking_period), style = MaterialTheme.typography.h6.copy(fontWeight = FontWeight(500)) ) } @@ -195,7 +197,7 @@ fun BookingPeriod( contentDescription = "repeat booking date" ) Text( - text = repeatBooking, + text = frequency.toString().ifEmpty { repeatBooking }, style = MaterialTheme.typography.button.copy( fontWeight = FontWeight(weight = 400), color = Color.Black diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt index 2de3f8ae..2471b290 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeat.kt @@ -19,7 +19,10 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.LocalContentAlpha @@ -56,6 +59,7 @@ import band.effective.office.elevator.components.Elevation import band.effective.office.elevator.textInBorderGray import band.effective.office.elevator.components.EffectiveButton import band.effective.office.elevator.components.Elevation +import band.effective.office.elevator.ui.booking.models.Frequency import dev.icerock.moko.resources.compose.stringResource @OptIn(ExperimentalFoundationApi::class) @@ -63,9 +67,9 @@ import dev.icerock.moko.resources.compose.stringResource fun BookingRepeat( backButtonClicked: () -> Unit, dropDownClick: (Int) -> Unit, - confirmBooking: () -> Unit, + confirmBooking: (Frequency) -> Unit, onSelected: () -> Unit, - onDaySelected: (Int) -> Unit + onDaySelected: (Int) -> Unit, ) { val selected1 = remember { @@ -78,6 +82,8 @@ fun BookingRepeat( mutableStateOf(false) } + val list = mutableListOf>() + val isExpandedContextMenu = remember { mutableStateOf(false) } val weekNames = listOf( MainRes.strings.Monday, @@ -102,6 +108,8 @@ fun BookingRepeat( bottomStart = 0.dp ) ) + .height(height = 500.dp) + .verticalScroll(state = rememberScrollState()) .padding(bottom = 16.dp) ) { Spacer(modifier = Modifier.height(height = 8.dp)) @@ -118,128 +126,61 @@ fun BookingRepeat( top = 8.dp ) ) - val isExpandedContextMenu = remember { mutableStateOf(false) } + val isExpandedContextMenu = remember { mutableStateOf(false) } - Column( - verticalArrangement = Arrangement.Top, - horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier - .fillMaxWidth() - .wrapContentHeight() - .background( - color = Color.White, - shape = RoundedCornerShape( - topStart = 16.dp, - topEnd = 16.dp, - bottomEnd = 0.dp, - bottomStart = 0.dp - ) - ) - .padding(bottom = 16.dp) - ) { - Spacer(modifier = Modifier.height(height = 8.dp)) - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, + Column( + verticalArrangement = Arrangement.Top, + horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .fillMaxWidth() .wrapContentHeight() - .padding(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 16.dp) - ) { - IconButton( - onClick = backButtonClicked, - ) { - Icon( - imageVector = Icons.Default.ArrowBack, - contentDescription = "back button" - ) - } - Text( - text = stringResource(resource = MainRes.strings.booking_repeat), - style = MaterialTheme.typography.h6.copy(fontWeight = FontWeight(500)), - textAlign = TextAlign.Center - ) - } - - Divider( - modifier = Modifier - .fillMaxWidth(fraction = 1.0f) - .height(height = 1.dp) .background( - color = ExtendedThemeColors.colors._66x + color = Color.White, + shape = RoundedCornerShape( + topStart = 16.dp, + topEnd = 16.dp, + bottomEnd = 0.dp, + bottomStart = 0.dp + ) ) - ) - - Column( - modifier = Modifier + .padding(bottom = 16.dp) ) { + Spacer(modifier = Modifier.height(height = 8.dp)) Row( horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), verticalAlignment = Alignment.CenterVertically, modifier = Modifier .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 16.dp) + .wrapContentHeight() + .padding(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 16.dp) ) { + IconButton( + onClick = backButtonClicked, + ) { + Icon( + imageVector = Icons.Default.ArrowBack, + contentDescription = "back button" + ) + } Text( - text = stringResource(resource = MainRes.strings.booking_repeat_in), - style = MaterialTheme.typography.button.copy(fontWeight = FontWeight(400)) + text = stringResource(resource = MainRes.strings.booking_repeat), + style = MaterialTheme.typography.h6.copy(fontWeight = FontWeight(500)), + textAlign = TextAlign.Center ) } - Row( - horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, + Divider( modifier = Modifier - .wrapContentWidth() - .padding(start = 54.dp, end = 16.dp) - ) { - OutlinedTextField( - value = "1", - onValueChange = { - - }, - shape = RoundedCornerShape(8.dp), - modifier = Modifier - .padding(top = 12.dp, bottom = 12.dp) - .weight(.3f) - ) - OutlinedTextField( - enabled = false, - readOnly = true, - value = stringResource(MainRes.strings.week), - onValueChange = { + .fillMaxWidth(fraction = 1.0f) + .height(height = 1.dp) + .background( + color = ExtendedThemeColors.colors._66x + ) + ) - }, - shape = RoundedCornerShape(8.dp), - colors = TextFieldDefaults.outlinedTextFieldColors( - disabledTextColor = LocalContentColor.current.copy(LocalContentAlpha.current) - ), - modifier = Modifier - .padding( - start = 16.dp, - top = 12.dp, - end = 12.dp, - bottom = 12.dp - ) - .weight(.7f), - trailingIcon = { - IconButton( - onClick = - { - isExpandedContextMenu.value = !isExpandedContextMenu.value - } - ) { - Image( - modifier = Modifier, - imageVector = Icons.Default.ArrowDropDown, - contentDescription = "drop down", - contentScale = ContentScale.None - ) - } - } - ) - } - Column { + Column( + modifier = Modifier + ) { Row( horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), verticalAlignment = Alignment.CenterVertically, @@ -248,223 +189,296 @@ fun BookingRepeat( .padding(start = 54.dp, end = 16.dp, top = 16.dp) ) { Text( - text = stringResource(MainRes.strings.when_repeat), - style = MaterialTheme.typography.button.copy( - fontWeight = FontWeight( - weight = 400 + text = stringResource(resource = MainRes.strings.booking_repeat_in), + style = MaterialTheme.typography.button.copy(fontWeight = FontWeight(400)) + ) + } + + Row( + horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .wrapContentWidth() + .padding(start = 54.dp, end = 16.dp) + ) { + OutlinedTextField( + value = "1", + onValueChange = { + + }, + shape = RoundedCornerShape(8.dp), + modifier = Modifier + .padding(top = 12.dp, bottom = 12.dp) + .weight(.3f) + ) + OutlinedTextField( + enabled = false, + readOnly = true, + value = stringResource(MainRes.strings.week), + onValueChange = { + + }, + shape = RoundedCornerShape(8.dp), + colors = TextFieldDefaults.outlinedTextFieldColors( + disabledTextColor = LocalContentColor.current.copy(LocalContentAlpha.current) + ), + modifier = Modifier + .padding( + start = 16.dp, + top = 12.dp, + end = 12.dp, + bottom = 12.dp ) - ) + .weight(.7f), + trailingIcon = { + IconButton( + onClick = + { + isExpandedContextMenu.value = !isExpandedContextMenu.value + } + ) { + Image( + modifier = Modifier, + imageVector = Icons.Default.ArrowDropDown, + contentDescription = "drop down", + contentScale = ContentScale.None + ) + } + } ) } - val listDaysOfWeek = listOf( - MainRes.strings.Monday, - MainRes.strings.Tuesday, - MainRes.strings.Wednesday, - MainRes.strings.Thursday, - MainRes.strings.Friday - ) - LazyRow (modifier = Modifier.padding(start = 54.dp, end = 16.dp, top = 16.dp)){ - items(listDaysOfWeek) { days -> - var isExpanded by remember { mutableStateOf(false) } - Button( - onClick = { - isExpanded = !isExpanded - }, - contentPadding = PaddingValues( - horizontal = 12.dp, - vertical = 6.dp + Column { + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 16.dp) + ) { + Text( + text = stringResource(MainRes.strings.when_repeat), + style = MaterialTheme.typography.button.copy( + fontWeight = FontWeight( + weight = 400 + ) + ) + ) + } + val listDaysOfWeek = listOf( + MainRes.strings.Monday, + MainRes.strings.Tuesday, + MainRes.strings.Wednesday, + MainRes.strings.Thursday, + MainRes.strings.Friday + ) + + LazyRow(modifier = Modifier.padding(start = 54.dp, end = 16.dp, top = 16.dp)) { + itemsIndexed(listDaysOfWeek) { index, days -> + var isExpanded by remember { mutableStateOf(false) } + val name: String = stringResource(days) + Button( + onClick = { + isExpanded = !isExpanded + list.add(Pair(first = name, second = index)) + }, + contentPadding = PaddingValues( + horizontal = 12.dp, + vertical = 6.dp + ), + colors = ButtonDefaults.buttonColors( + backgroundColor = ExtendedThemeColors.colors.whiteColor + ), + modifier = Modifier + .wrapContentWidth().padding(end = 12.dp), + border = BorderStroke( + width = 1.dp, + color = if (isExpanded) + ExtendedThemeColors.colors.purple_heart_800 + else textInBorderGray + ), + shape = RoundedCornerShape(12.dp), + elevation = ButtonDefaults.elevation(0.dp, 2.dp, 0.dp) + ) { + Row { + Icon( + imageVector = Icons.Rounded.Done, + tint = ExtendedThemeColors.colors.purple_heart_800, + modifier = Modifier.size( + if (isExpanded) 20.dp + else 0.dp + ) + .align(Alignment.CenterVertically), + contentDescription = "done button" + ) + } + Text( + text = stringResource(days), + style = MaterialTheme.typography.body2.copy( + color = if (isExpanded) ExtendedThemeColors.colors.purple_heart_800 + else textInBorderGray + ), + ) + } + } + } + Divider( + modifier = Modifier + .fillMaxWidth(fraction = 1.0f) + .height(height = 1.dp) + .background( + color = ExtendedThemeColors.colors._66x + ) + ) + + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 16.dp) + ) { + Text( + text = stringResource(MainRes.strings.book_finish), + style = MaterialTheme.typography.button.copy( + fontWeight = FontWeight( + weight = 400 + ) ), + textAlign = TextAlign.Start + ) + } + + Row( + horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 8.dp) + ) { + Button( colors = ButtonDefaults.buttonColors( - backgroundColor = ExtendedThemeColors.colors.whiteColor - ), - modifier = Modifier - .wrapContentWidth().padding(end = 12.dp), - border = BorderStroke( - width = 1.dp, - color = if (isExpanded) - ExtendedThemeColors.colors.purple_heart_800 - else textInBorderGray + backgroundColor = Color.Transparent ), - shape = RoundedCornerShape(12.dp), - elevation = ButtonDefaults.elevation(0.dp, 2.dp, 0.dp) + elevation = Elevation(), + modifier = Modifier.fillMaxWidth().wrapContentHeight(), + onClick = { + selected1.value = !selected1.value + selected2.value = false + selected3.value = false + }.also { onSelected() }, + contentPadding = PaddingValues(all = 0.dp) ) { - Row { - Icon( - imageVector = Icons.Rounded.Done, - tint = ExtendedThemeColors.colors.purple_heart_800, - modifier = Modifier.size( - if (isExpanded) 20.dp - else 0.dp + Row( + horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), + verticalAlignment = Alignment.CenterVertically, + ) { + RadioButton( + enabled = false, + selected = selected1.value, + onClick = { }, + colors = RadioButtonDefaults.colors( + disabledSelectedColor = MaterialTheme.colors.primary, + disabledUnselectedColor = Color.Black ) - .align(Alignment.CenterVertically), - contentDescription = "done button" + ) + Text( + text = stringResource(MainRes.strings.never), + style = MaterialTheme.typography.button.copy( + color = ExtendedThemeColors.colors.radioTextColor, + fontWeight = FontWeight(400) + ), + modifier = Modifier.fillMaxWidth().wrapContentHeight() ) } - Text( - text = stringResource(days), - style = MaterialTheme.typography.body2.copy( - color = if (isExpanded) ExtendedThemeColors.colors.purple_heart_800 - else textInBorderGray - ), - ) } } - } - } - Divider( - modifier = Modifier - .fillMaxWidth(fraction = 1.0f) - .height(height = 1.dp) - .background( - color = ExtendedThemeColors.colors._66x - ) - ) - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 16.dp) - ) { - Text( - text = stringResource(MainRes.strings.book_finish), - style = MaterialTheme.typography.button.copy( - fontWeight = FontWeight( - weight = 400 + Row( + horizontalArrangement = Arrangement.Start, + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 6.dp) + ) { + RadioButton(selected = selected2.value, onClick = { + selected2.value = !selected2.value + selected1.value = false + selected3.value = false + }.also { onSelected() }) + + Spacer(modifier = Modifier.width(width = 16.dp)) + + OutlinedTextField( + value = "01.01.2023", + onValueChange = { + + }, + shape = RoundedCornerShape(8.dp), + modifier = Modifier + .padding(top = 12.dp, bottom = 12.dp) + .weight(0.4f) ) - ), - textAlign = TextAlign.Start - ) - } - Row( - horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 8.dp) - ) { - Button( - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = Elevation(), - modifier = Modifier.fillMaxWidth().wrapContentHeight(), - onClick = { - selected1.value = !selected1.value - selected2.value = false - selected3.value = false - }.also { onSelected() }, - contentPadding = PaddingValues(all = 0.dp) - ) { + Spacer(modifier = Modifier.width(width = 48.dp)) + } + Row( - horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.Start), + horizontalArrangement = Arrangement.Start, verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .padding(start = 54.dp, end = 16.dp, top = 8.dp, bottom = 8.dp) ) { - RadioButton( - enabled = false, - selected = selected1.value, - onClick = { }, - colors = RadioButtonDefaults.colors( - disabledSelectedColor = MaterialTheme.colors.primary, - disabledUnselectedColor = Color.Black - ) - ) + RadioButton(selected = selected3.value, onClick = { + selected3.value = !selected3.value + selected1.value = false + selected2.value = false + }.also { onSelected() }) Text( - text = stringResource(MainRes.strings.never), + text = stringResource(MainRes.strings.booking_1), style = MaterialTheme.typography.button.copy( color = ExtendedThemeColors.colors.radioTextColor, fontWeight = FontWeight(400) ), - modifier = Modifier.fillMaxWidth().wrapContentHeight() + modifier = Modifier.wrapContentWidth() ) - } - } - } - - Row( - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 6.dp) - ) { - RadioButton(selected = selected2.value, onClick = { - selected2.value = !selected2.value - selected1.value = false - selected3.value = false - }.also { onSelected() }) - - Spacer(modifier = Modifier.width(width = 16.dp)) + Spacer(modifier = Modifier.width(width = 16.dp)) - OutlinedTextField( - value = "01.01.2023", - onValueChange = { + OutlinedTextField( + value = "1", + onValueChange = { - }, - shape = RoundedCornerShape(8.dp), - modifier = Modifier - .padding(top = 12.dp, bottom = 12.dp) - .weight(0.4f) - ) - - Spacer(modifier = Modifier.width(width = 48.dp)) - } - - Row( - horizontalArrangement = Arrangement.Start, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .padding(start = 54.dp, end = 16.dp, top = 8.dp, bottom = 8.dp) - ) { - RadioButton(selected = selected3.value, onClick = { - selected3.value = !selected3.value - selected1.value = false - selected2.value = false - }.also { onSelected() }) - Text( - text = stringResource(MainRes.strings.booking_1), - style = MaterialTheme.typography.button.copy( - color = ExtendedThemeColors.colors.radioTextColor, - fontWeight = FontWeight(400) - ), - modifier = Modifier.wrapContentWidth() - ) - Spacer(modifier = Modifier.width(width = 16.dp)) - - OutlinedTextField( - value = "1", - onValueChange = { + }, + shape = RoundedCornerShape(8.dp), + modifier = Modifier + .padding(top = 12.dp, bottom = 12.dp) + .weight(weight = 0.1f) + ) - }, - shape = RoundedCornerShape(8.dp), - modifier = Modifier - .padding(top = 12.dp, bottom = 12.dp) - .weight(weight = 0.1f) - ) + Spacer(modifier = Modifier.width(width = 16.dp)) - Spacer(modifier = Modifier.width(width = 16.dp)) + Text( + text = stringResource(MainRes.strings.booking_2), + style = MaterialTheme.typography.button.copy( + color = ExtendedThemeColors.colors.radioTextColor, + fontWeight = FontWeight(400) + ), + modifier = Modifier.wrapContentWidth().wrapContentHeight() + ) - Text( - text = stringResource(MainRes.strings.booking_2), - style = MaterialTheme.typography.button.copy( - color = ExtendedThemeColors.colors.radioTextColor, - fontWeight = FontWeight(400) - ), - modifier = Modifier.wrapContentWidth().wrapContentHeight() - ) + Spacer(modifier = Modifier.width(width = 48.dp)) + } - Spacer(modifier = Modifier.width(width = 48.dp)) + EffectiveButton( + buttonText = stringResource(MainRes.strings.confirm_booking), + onClick = { + val frequency = Frequency(days = list.toList()) + confirmBooking(frequency) + }, + modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), + ) + } } - - EffectiveButton( - buttonText = stringResource(MainRes.strings.confirm_booking), - onClick = confirmBooking, - modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), - ) } } - } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt index ea9a0c14..7489420e 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt @@ -19,7 +19,7 @@ import band.effective.office.elevator.MainRes import dev.icerock.moko.resources.compose.stringResource @Composable -fun BookingRepeatCard(onSelected: () -> Unit, modifier: Modifier) { +fun BookingRepeatCard(onSelected: (String) -> Unit, modifier: Modifier) { val strings = listOf( MainRes.strings.do_not_repeat, MainRes.strings.every_work_day, @@ -36,16 +36,23 @@ fun BookingRepeatCard(onSelected: () -> Unit, modifier: Modifier) { .padding(all = 24.dp) .fillMaxWidth() .wrapContentHeight() - .background(color = ExtendedThemeColors.colors.whiteColor, shape = RoundedCornerShape(size = 16.dp)) + .background( + color = ExtendedThemeColors.colors.whiteColor, + shape = RoundedCornerShape(size = 16.dp) + ) ) { - strings.forEach { frequency -> + strings.forEachIndexed { index, stringResource -> + val name: String = stringResource(stringResource) + BookingRepeatElement( - selected = frequency == selectedOption, - bookingText = stringResource(frequency), - onSelect = { - onOptionSelected(frequency) + selected = stringResource == selectedOption, + bookingText = name, + onSelect = { it -> + onOptionSelected(stringResource) }, - onSelected = onSelected + onSelected = { + onSelected(it) + } ) } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt index b8040a50..30e1d302 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt @@ -27,8 +27,8 @@ import kotlinx.coroutines.launch fun BookingRepeatElement( selected: Boolean, bookingText: String, - onSelect: () -> Unit, - onSelected: () -> Unit + onSelect: (String) -> Unit, + onSelected: (String) -> Unit ) { val coroutineScope = rememberCoroutineScope() @@ -40,9 +40,9 @@ fun BookingRepeatElement( modifier = Modifier.fillMaxWidth().wrapContentHeight(), onClick = { coroutineScope.launch { - onSelect() + onSelect(bookingText) delay(100) - onSelected() + onSelected(bookingText) } } ) { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt index afddc2c4..cc3a1ca9 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt @@ -30,13 +30,6 @@ import dev.icerock.moko.resources.compose.stringResource @Composable fun BookingSuccess(onMain: () -> Unit, close: () -> Unit, modifier: Modifier) { - val elevation = ButtonDefaults.elevation( - defaultElevation = 0.dp, - pressedElevation = 0.dp, - disabledElevation = 0.dp, - hoveredElevation = 0.dp, - focusedElevation = 0.dp - ) Column( verticalArrangement = Arrangement.spacedBy(32.dp, Alignment.Top), diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt index 904f8676..dd3f85d3 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt @@ -232,7 +232,7 @@ fun EditBooking( } if (showRepeatDialog) { BookingRepeatCard( - onSelected = onClickCloseRepeatDialog, + onSelected = { onClickCloseRepeatDialog() }, modifier = Modifier ) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt new file mode 100644 index 00000000..42bacef5 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt @@ -0,0 +1,15 @@ +package band.effective.office.elevator.ui.booking.models + +class Frequency(private val days: List>) { + +// private fun replaceNumbersWithWeekdays(): List { +// val weekdays = listOf("Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс") +// return days.map { weekdays[it.second - 1] } +// } + + override fun toString(): String { +// val weekdays = replaceNumbersWithWeekdays() + val distinctWeekdays = days.distinct() + return distinctWeekdays.joinToString(", ") { it.first } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index 8b04bbf1..f97a547d 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -3,6 +3,7 @@ package band.effective.office.elevator.ui.booking.store import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.domain.models.CreatingBookModel import band.effective.office.elevator.domain.models.TypeEndPeriodBooking +import band.effective.office.elevator.ui.booking.models.Frequency import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import band.effective.office.elevator.ui.booking.models.WorkSpaceZone @@ -13,42 +14,46 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime -interface BookingStore: Store { +interface BookingStore : Store { sealed interface Intent { - object OpenChooseZone: Intent - data class OpenStartTimeModal(val isStart: Boolean, val time: LocalTime): Intent - object OpenFinishTimeModal: Intent - object CloseFinishTimeModal: Intent - object CloseStartTimeModal: Intent + object OpenChooseZone : Intent + data class OpenStartTimeModal(val isStart: Boolean, val time: LocalTime) : Intent + object OpenFinishTimeModal : Intent + object CloseFinishTimeModal : Intent + object CloseStartTimeModal : Intent data class ApplyTime(val isStart: Boolean, val time: LocalTime) : Intent - object CloseChooseZone: Intent + object CloseChooseZone : Intent object OpenRepeatDialog : Intent object CloseBookRepeat : Intent - object OpenBookRepeat : Intent - object OpenBookAccept: Intent - object CloseBookAccept: Intent - object OpenBookPeriod: Intent - object OpenConfirmBooking: Intent - object SearchSuitableOptions: Intent - object CloseBookPeriod: Intent + data class OpenBookRepeat(val name: String) : Intent + object OpenBookAccept : Intent + object CloseBookAccept : Intent + object OpenBookPeriod : Intent + object OpenConfirmBooking : Intent + object SearchSuitableOptions : Intent + object CloseBookPeriod : Intent object OpenCalendar : Intent object CloseCalendar : Intent - object OpenMainScreen: Intent - object CloseConfirmBooking: Intent + object OpenMainScreen : Intent + object CloseConfirmBooking : Intent data class ChangeSelectedWorkSpacesZone(val workSpaceZone: List) : Intent data class ApplyDate(val date: LocalDate?) : Intent - data class ShowPlace(val type: String): Intent + data class ShowPlace(val type: String) : Intent data class ChangeWorkSpacesUI(val workSpaces: List) : Intent - data class ChangeType(val type : WorkSpaceType) : Intent + data class ChangeType(val type: WorkSpaceType) : Intent data class ChangeWholeDay(val wholeDay: Boolean) : Intent + + data class ChangeFrequency(val frequency: Frequency) : Intent + + data class ChangeBookingRepeat(val bookingRepeat: String) : Intent } data class State( - val workSpaces : List, + val workSpaces: List, val creatingBookModel: CreatingBookModel, val currentDate: LocalDate, val workSpacesType: WorkSpaceType, @@ -57,8 +62,10 @@ interface BookingStore: Store { scope.launch { publish(BookingStore.Label.CloseChooseZone) + + scope.launch { + val list = getState().workSpacesZone.filter { it.isSelected == true } + .toMutableList() + val mListW = getState().workSpaces.toMutableList() + + val iteratorW = mListW.iterator() + while (iteratorW.hasNext()) { + val workSpaceUI = iteratorW.next() + val iteratorZ = list.iterator() + while (iteratorZ.hasNext()) { + val zone = iteratorZ.next() + if (workSpaceUI.workSpaceName != zone.name) { + iteratorW.remove() + break + } + } + } + dispatch(Msg.ChangeWorkSpacesUI(workSpacesUI = mListW.toList())) + } } } @@ -124,13 +154,25 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen scope.launch { publish(BookingStore.Label.CloseCalendar) intent.date?.let { newDate -> - dispatch(Msg.DateBooking(date = newDate)) + dispatch(Msg.BeginningBookingDate(date = newDate)) } } } is BookingStore.Intent.OpenConfirmBooking -> { scope.launch { + + bookingInteractor.create( + coroutineScope = this@launch, + creatingBookModel = CreatingBookModel( + workSpaceId = "", + dateOfStart = getState().selectedStartDate.atTime(getState().selectedStartTime), + dateOfEnd = getState().selectedStartDate.atTime(getState().selectedFinishTime), + bookingPeriod = BookingPeriod.NoPeriod, + typeOfEndPeriod = TypeEndPeriodBooking.Never + ) + ) + publish(BookingStore.Label.CloseBookAccept) publish(BookingStore.Label.OpenConfirmBooking) } @@ -185,6 +227,7 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen publish(BookingStore.Label.CloseBookPeriod) publish(BookingStore.Label.CloseRepeatDialog) publish(BookingStore.Label.OpenBookRepeat) + dispatch(Msg.ChangeBookingRepeat(bookingRepeat = intent.name)) } } @@ -201,6 +244,7 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen } is BookingStore.Intent.ChangeWorkSpacesUI -> { + val list = getState().workSpacesZone.filter { zone -> zone.isSelected == true } intent.workSpaces.forEachIndexed { index1, workSpaceUI -> getState().workSpacesZone.forEachIndexed { index2, workSpaceZone -> intent.workSpaces.filter { workSpaceUI -> workSpaceUI.workSpaceName == workSpaceZone.name } @@ -229,6 +273,19 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen } } + + is BookingStore.Intent.ChangeFrequency -> { + scope.launch { + dispatch(Msg.ChangeFrequency(frequency = intent.frequency)) + publish(BookingStore.Label.CloseBookRepeat) + } + } + + is BookingStore.Intent.ChangeBookingRepeat -> { + scope.launch { + dispatch(Msg.ChangeBookingRepeat(bookingRepeat = intent.bookingRepeat)) + } + } } } @@ -256,6 +313,9 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is Msg.BeginningBookingTime -> copy(selectedStartTime = msg.time) is Msg.EndBookingTime -> copy(selectedFinishTime = msg.time) is Msg.IsStartTimePicked -> copy(isStart = msg.isStart) + is Msg.BeginningBookingDate -> copy(selectedStartDate = msg.date) + is Msg.ChangeFrequency -> copy(frequency = msg.frequency) + is Msg.ChangeBookingRepeat -> copy(repeatBooking = msg.bookingRepeat) } } } -- GitLab From 7d3045ba8cce17964c1bbc38c344eee5838386eb Mon Sep 17 00:00:00 2001 From: Slava Date: Wed, 16 Aug 2023 16:36:05 +0600 Subject: [PATCH 09/19] Booking [+] created several more states [~] refactoring code [+] added domain logic to BookingStoreFactory [+] added logic to create new booking --- .../repository/MockBookingRepositoryImpl.kt | 3 +- .../domain/models/CreatingBookModel.kt | 2 + .../elevator/ui/booking/BookingScreen.kt | 17 ++++++--- .../components/modals/BookingRepeatCard.kt | 38 ++++++++++++------- .../components/modals/BookingRepeatElement.kt | 6 ++- .../booking/components/modals/EditBooking.kt | 4 +- .../elevator/ui/booking/models/Frequency.kt | 20 +++++++--- .../elevator/ui/booking/store/BookingStore.kt | 8 ++-- .../ui/booking/store/BookingStoreFactory.kt | 14 ++++++- 9 files changed, 78 insertions(+), 34 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt index 4bb52841..cac5d5f0 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt @@ -3,6 +3,7 @@ package band.effective.office.elevator.data.repository import band.effective.office.elevator.domain.repository.BookingRepository import band.effective.office.elevator.domain.models.BookingInfo import band.effective.office.elevator.domain.models.CreatingBookModel +import band.effective.office.elevator.expects.showToast import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO @@ -116,7 +117,7 @@ class MockBookingRepositoryImpl: BookingRepository { } override suspend fun createBook(bookingInfo: CreatingBookModel) { - TODO("Not yet implemented") + showToast(bookingInfo.toString()) } override suspend fun getBookingsForUser(ownerId:String): StateFlow> { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt index 0c9626d9..749b359b 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt @@ -16,6 +16,8 @@ sealed class BookingPeriod(val durationPeriod: Int) { data class Year(val yearPeriod: Int) : BookingPeriod(yearPeriod) + data class EveryWorkDay(val workPeriod: Int) : BookingPeriod(workPeriod) + data class Week(val weekPeriod: Int, val selectedDayOfWeek: List) : BookingPeriod(weekPeriod) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index adf9e66e..074c0de9 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -30,6 +30,7 @@ import band.effective.office.elevator.components.bottomSheet.BottomSheetItem import band.effective.office.elevator.components.bottomSheet.MultiBottomSheetController import band.effective.office.elevator.components.bottomSheet.rememberMultiBottomSheetController import band.effective.office.elevator.domain.models.BookingInfo +import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.ui.booking.components.BookingMainContentScreen import band.effective.office.elevator.ui.booking.components.modals.BookAccept import band.effective.office.elevator.ui.booking.components.modals.BookingPeriod @@ -38,6 +39,7 @@ import band.effective.office.elevator.ui.booking.components.modals.BookingRepeat import band.effective.office.elevator.ui.booking.components.modals.BookingSuccess import band.effective.office.elevator.ui.booking.components.modals.ChooseZone import band.effective.office.elevator.ui.booking.models.BottomSheetNames +import band.effective.office.elevator.ui.booking.models.Frequency import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import band.effective.office.elevator.ui.booking.models.WorkSpaceZone @@ -273,8 +275,8 @@ fun BookingScreen(bookingComponent: BookingComponent) { showConfirm = showConfirm, showTimePicker = showTimePicker, currentDate = state.currentDate, - onClickOpenBookRepeat = { name -> - bookingComponent.onEvent(BookingStore.Intent.OpenBookRepeat(name = name)) + onClickOpenBookRepeat = { pair -> + bookingComponent.onEvent(BookingStore.Intent.OpenBookRepeat(pair = pair)) }, onClickCloseTimeModal = { bookingComponent.onEvent(BookingStore.Intent.CloseStartTimeModal) }, onClickSelectTime = { time: LocalTime -> @@ -309,7 +311,8 @@ fun BookingScreen(bookingComponent: BookingComponent) { } }, isStart = state.isStart, - date = state.selectedStartDate + date = state.selectedStartDate, + frequency = state.frequency ) } @@ -331,10 +334,11 @@ private fun BookingScreenContent( showTimePicker: Boolean, onClickCloseTimeModal: () -> Unit, onClickSelectTime: (LocalTime) -> Unit, - onClickOpenBookRepeat: (String) -> Unit, + onClickOpenBookRepeat: (Pair) -> Unit, onClickChangeZone: (WorkSpaceType) -> Unit, isStart: Boolean, - date: LocalDate + date: LocalDate, + frequency: Frequency ) { val scrollState = rememberLazyListState() val scrollIsDown = scrollState.isScrollingDown() @@ -378,7 +382,8 @@ private fun BookingScreenContent( if (showRepeatDialog) { BookingRepeatCard( onSelected = onClickOpenBookRepeat, - modifier = Modifier.padding(horizontal = 16.dp).align(Alignment.Center) + modifier = Modifier.padding(horizontal = 16.dp).align(Alignment.Center), + frequency = frequency ) } if (showCalendar) { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt index 7489420e..c6ac17e3 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt @@ -12,21 +12,32 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes +import band.effective.office.elevator.domain.models.BookingPeriod +import band.effective.office.elevator.domain.models.DayOfWeek +import band.effective.office.elevator.ui.booking.models.Frequency import dev.icerock.moko.resources.compose.stringResource @Composable -fun BookingRepeatCard(onSelected: (String) -> Unit, modifier: Modifier) { +fun BookingRepeatCard( + onSelected: (Pair) -> Unit, + modifier: Modifier, + frequency: Frequency +) { + + val days: List = frequency.getDays() val strings = listOf( - MainRes.strings.do_not_repeat, - MainRes.strings.every_work_day, - MainRes.strings.every_week, - MainRes.strings.every_month, - MainRes.strings.another + Pair(first = MainRes.strings.do_not_repeat, second = BookingPeriod.NoPeriod), + Pair(first = MainRes.strings.every_work_day, second = BookingPeriod.EveryWorkDay(5)), + Pair(first = MainRes.strings.every_week, second = BookingPeriod.Week(7, days)), + Pair( + first = MainRes.strings.every_month, second = BookingPeriod.Year(365), + ), + Pair(first = MainRes.strings.another, second = 0) ) + val (selectedOption, onOptionSelected) = remember { mutableStateOf(strings[0]) } Column( @@ -41,18 +52,17 @@ fun BookingRepeatCard(onSelected: (String) -> Unit, modifier: Modifier) { shape = RoundedCornerShape(size = 16.dp) ) ) { - strings.forEachIndexed { index, stringResource -> - val name: String = stringResource(stringResource) + strings.forEachIndexed { index, pair -> + val name: String = stringResource(pair.first) BookingRepeatElement( - selected = stringResource == selectedOption, + selected = pair == selectedOption, bookingText = name, onSelect = { it -> - onOptionSelected(stringResource) + onOptionSelected(pair) }, - onSelected = { - onSelected(it) - } + onSelected = onSelected, + bookingPeriod = pair.second ) } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt index 30e1d302..7e046663 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.components.Elevation +import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.radioButtonColor import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -27,8 +28,9 @@ import kotlinx.coroutines.launch fun BookingRepeatElement( selected: Boolean, bookingText: String, + bookingPeriod: Any, onSelect: (String) -> Unit, - onSelected: (String) -> Unit + onSelected: (Pair) -> Unit ) { val coroutineScope = rememberCoroutineScope() @@ -42,7 +44,7 @@ fun BookingRepeatElement( coroutineScope.launch { onSelect(bookingText) delay(100) - onSelected(bookingText) + onSelected(Pair(first = bookingText, second = bookingPeriod) as Pair) } } ) { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt index dd3f85d3..f78ae1ca 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/EditBooking.kt @@ -38,6 +38,7 @@ import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes import band.effective.office.elevator.components.EffectiveButton import band.effective.office.elevator.components.Elevation +import band.effective.office.elevator.ui.booking.models.Frequency import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource @@ -233,7 +234,8 @@ fun EditBooking( if (showRepeatDialog) { BookingRepeatCard( onSelected = { onClickCloseRepeatDialog() }, - modifier = Modifier + modifier = Modifier, + frequency = Frequency(days = listOf()) ) } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt index 42bacef5..fcaa523d 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt @@ -1,14 +1,24 @@ package band.effective.office.elevator.ui.booking.models +import band.effective.office.elevator.domain.models.BookingPeriod +import band.effective.office.elevator.domain.models.DayOfWeek + class Frequency(private val days: List>) { -// private fun replaceNumbersWithWeekdays(): List { -// val weekdays = listOf("Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс") -// return days.map { weekdays[it.second - 1] } -// } + fun getDays(): List { + val list = listOf( + DayOfWeek.Monday, + DayOfWeek.Tuesday, + DayOfWeek.Wednesday, + DayOfWeek.Thursday, + DayOfWeek.Friday, + DayOfWeek.Saturday + ) + + return days.map { list[it.second] } + } override fun toString(): String { -// val weekdays = replaceNumbersWithWeekdays() val distinctWeekdays = days.distinct() return distinctWeekdays.joinToString(", ") { it.first } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index f97a547d..ed7fbfa9 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -26,7 +26,7 @@ interface BookingStore : Store) : Intent object OpenBookAccept : Intent object CloseBookAccept : Intent object OpenBookPeriod : Intent @@ -64,7 +64,8 @@ interface BookingStore : Store "Каждый рабочий день" + is BookingPeriod.Month -> "Каждый месяц" + BookingPeriod.NoPeriod -> "Без периода" + is BookingPeriod.Week -> "Каждую неделю" + is BookingPeriod.Year -> "Каждый год" + } + dispatch(Msg.ChangeBookingRepeat(bookingRepeat = name)) + dispatch(Msg.ChangeBookingPeriod(bookingPeriod = intent.pair.second)) } } @@ -316,6 +325,7 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is Msg.BeginningBookingDate -> copy(selectedStartDate = msg.date) is Msg.ChangeFrequency -> copy(frequency = msg.frequency) is Msg.ChangeBookingRepeat -> copy(repeatBooking = msg.bookingRepeat) + is Msg.ChangeBookingPeriod -> copy(bookingPeriod = msg.bookingPeriod) } } } -- GitLab From 5e5b143ecab8bad72e986f4869c3bd433d687e02 Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 14:53:26 +0600 Subject: [PATCH 10/19] Booking [+] created several more states [~] refactoring code [+] added logic to change types list on booking screen [+] added map [+] changing text, when you expand map --- .../elevator/domain/di/DomainModuleDI.kt | 4 + .../elevator/ui/booking/BookingScreen.kt | 19 ++- .../components/BookingMainContentScreen.kt | 11 +- .../ui/booking/components/OptionMenu.kt | 15 +- .../booking/components/OutlineButtonPurple.kt | 2 +- .../elevator/ui/booking/store/BookingStore.kt | 14 +- .../ui/booking/store/BookingStoreFactory.kt | 14 +- .../resources/MR/base/strings_ru.xml | 1 + .../commonMain/resources/MR/en/strings_en.xml | 2 +- .../resources/MR/images/super_map.svg | 134 ++++++++++++++++++ 10 files changed, 195 insertions(+), 21 deletions(-) create mode 100644 composeApp/src/commonMain/resources/MR/images/super_map.svg diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt index 92fd5d62..466ff6b6 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt @@ -1,5 +1,6 @@ package band.effective.office.elevator.domain.di +import band.effective.office.elevator.data.repository.EmployeeRepositoryImpl import band.effective.office.elevator.data.repository.MockBookingRepositoryImpl import band.effective.office.elevator.data.repository.OfficeElevatorRepositoryImpl import band.effective.office.elevator.data.repository.UserProfileRepositoryImpl @@ -7,6 +8,7 @@ import band.effective.office.elevator.domain.repository.BookingRepository import band.effective.office.elevator.domain.repository.OfficeElevatorRepository import band.effective.office.elevator.domain.entity.AuthorizationEntity import band.effective.office.elevator.domain.entity.BookingInteractor +import band.effective.office.elevator.domain.repository.EmployeeRepository import band.effective.office.elevator.domain.repository.UserProfileRepository import band.effective.office.elevator.domain.useCase.ChangeBookingUseCase import band.effective.office.elevator.domain.useCase.CreateBookingUseCase @@ -20,7 +22,9 @@ import org.koin.dsl.module internal val domainModuleDI = module { single { OfficeElevatorRepositoryImpl(get(), get()) } + single { EmployeeRepositoryImpl() } factory { EmployeeUseCase(repository = get()) } + single { GetBookingsUseCase(get()) } single { ElevatorCallUseCase(get()) } single { MockBookingRepositoryImpl() } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 074c0de9..b4f79528 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -44,6 +44,7 @@ import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import band.effective.office.elevator.ui.booking.store.BookingStore +import band.effective.office.elevator.ui.models.TypesList import band.effective.office.elevator.utils.NumToMonth import band.effective.office.elevator.utils.Stack import band.effective.office.elevator.utils.isScrollingDown @@ -312,7 +313,15 @@ fun BookingScreen(bookingComponent: BookingComponent) { }, isStart = state.isStart, date = state.selectedStartDate, - frequency = state.frequency + frequency = state.frequency, + onClickChangeSelectedType = { + bookingComponent.onEvent( + BookingStore.Intent.ChangeSelectedType( + selectedType = it + ) + ) + }, + selectedTypesList = state.selectedType ) } @@ -338,7 +347,9 @@ private fun BookingScreenContent( onClickChangeZone: (WorkSpaceType) -> Unit, isStart: Boolean, date: LocalDate, - frequency: Frequency + frequency: Frequency, + onClickChangeSelectedType: (TypesList) -> Unit, + selectedTypesList: TypesList ) { val scrollState = rememberLazyListState() val scrollIsDown = scrollState.isScrollingDown() @@ -375,7 +386,9 @@ private fun BookingScreenContent( onClickExpandedMap = { isExpandedCard = !isExpandedCard }, onClickExpandedOption = { isExpandedOptions = !isExpandedOptions }, onClickChangeZone = onClickChangeZone, - date = date + date = date, + onClickChangeSelectedType = onClickChangeSelectedType, + selectedTypesList = selectedTypesList ) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt index c4fbcde9..b0e62f6a 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt @@ -39,6 +39,7 @@ import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource import band.effective.office.elevator.ExtendedColors._66x import band.effective.office.elevator.ExtendedColors.purple_heart_500 +import band.effective.office.elevator.ui.models.TypesList import kotlinx.datetime.LocalDate @Composable @@ -55,7 +56,9 @@ fun BookingMainContentScreen( onClickExpandedMap: () -> Unit, onClickExpandedOption: () -> Unit, onClickChangeZone: (WorkSpaceType) -> Unit, - date: LocalDate + date: LocalDate, + onClickChangeSelectedType: (TypesList) -> Unit, + selectedTypesList: TypesList ) { Scaffold( topBar = { @@ -81,7 +84,7 @@ fun BookingMainContentScreen( onClick = onClickExpandedMap, icon1 = MainRes.images.icon_map, icon2 = MainRes.images.back_button, - title = MainRes.strings.show_map, + title = if (isExpandedCard) MainRes.strings.hide_map else MainRes.strings.show_map, rotate = iconRotationStateCard ) } @@ -90,7 +93,9 @@ fun BookingMainContentScreen( isExpandedOptions = isExpandedOptions, onClickOpenBookPeriod = onClickOpenBookPeriod, onClickChangeZone = onClickChangeZone, - date = date + date = date, + onClickChangeSelectedType = onClickChangeSelectedType, + selectedTypesList = selectedTypesList ) } Box( diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt index 2744d340..fe708257 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OptionMenu.kt @@ -40,13 +40,15 @@ fun OptionMenu( isExpandedOptions: Boolean, onClickOpenBookPeriod: () -> Unit, onClickChangeZone: (WorkSpaceType) -> Unit, - date: LocalDate + date: LocalDate, + onClickChangeSelectedType: (TypesList) -> Unit, + selectedTypesList: TypesList ) { Column { AnimatedVisibility(visible = isExpandedCard) { Column( modifier = Modifier.fillMaxWidth().padding(top = 16.dp) - .background(MaterialTheme.colors.onBackground) + .background(color = Color.White) ) { Row( horizontalArrangement = Arrangement.Center, @@ -54,13 +56,11 @@ fun OptionMenu( ) { Image( modifier = Modifier.padding(vertical = 20.dp), - painter = painterResource(MainRes.images.icon_map), //TODO(Olesia Shinkarenko): replace map - contentDescription = null + painter = painterResource(MainRes.images.super_map), + contentDescription = "office map" ) } } - - } AnimatedVisibility(visible = isExpandedOptions) { @@ -86,7 +86,7 @@ fun OptionMenu( type = WorkSpaceType.MEETING_ROOM ) ) - val selectedType = remember { mutableStateOf(types[0]) } + val selectedType = remember { mutableStateOf(selectedTypesList) } types.forEach { type -> val selected = selectedType.value == type @@ -108,6 +108,7 @@ fun OptionMenu( onClick = { selectedType.value = type onClickChangeZone(type.type) + onClickChangeSelectedType(selectedType.value) } ) ) { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OutlineButtonPurple.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OutlineButtonPurple.kt index 66d1c092..a3a7fca4 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OutlineButtonPurple.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/OutlineButtonPurple.kt @@ -45,7 +45,7 @@ fun OutlineButtonPurple( ) Text( modifier = Modifier.padding(start = 8.dp), - text = stringResource(title), + text = stringResource(title) , color = ExtendedThemeColors.colors.purple_heart_800, style = MaterialTheme.typography.body2 ) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index ed7fbfa9..a61aa566 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -1,5 +1,6 @@ package band.effective.office.elevator.ui.booking.store +import band.effective.office.elevator.MainRes import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.domain.models.CreatingBookModel import band.effective.office.elevator.domain.models.TypeEndPeriodBooking @@ -7,6 +8,7 @@ import band.effective.office.elevator.ui.booking.models.Frequency import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import band.effective.office.elevator.ui.booking.models.WorkSpaceZone +import band.effective.office.elevator.ui.models.TypesList import band.effective.office.elevator.utils.getCurrentDate import com.arkivanov.mvikotlin.core.store.Store import com.commandiron.wheel_picker_compose.utils.getCurrentTime @@ -50,6 +52,8 @@ interface BookingStore : Store dispatch( - Msg.TypeList( - type = intent.type + Msg.SelectedTypeList( + type = TypesList(name = MainRes.strings.app_name, icon = MainRes.images.table_icon, type = WorkSpaceType.WORK_PLACE) ) ) @@ -295,6 +297,10 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen dispatch(Msg.ChangeBookingRepeat(bookingRepeat = intent.bookingRepeat)) } } + + is BookingStore.Intent.ChangeSelectedType -> { + dispatch(Msg.SelectedTypeList(type = intent.selectedType)) + } } } @@ -316,7 +322,7 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is Msg.ChangeSelectedWorkSpacesZone -> copy(workSpacesZone = msg.workSpacesZone) is Msg.DateBooking -> copy(selectedStartDate = msg.date) is Msg.TimeBooking -> copy(selectedStartTime = msg.time) - is Msg.TypeList -> TODO() + is Msg.SelectedTypeList -> copy(selectedType = msg.type) is Msg.ChangeWorkSpacesUI -> copy(workSpaces = msg.workSpacesUI) is Msg.WholeDay -> copy(wholeDay = msg.wholeDay) is Msg.BeginningBookingTime -> copy(selectedStartTime = msg.time) diff --git a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml index 3bf2eb7a..06567619 100644 --- a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml +++ b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml @@ -113,6 +113,7 @@ Каждую неделю Каждый месяц Другое + Скрыть карту diff --git a/composeApp/src/commonMain/resources/MR/en/strings_en.xml b/composeApp/src/commonMain/resources/MR/en/strings_en.xml index 7f027474..eadd4c7e 100644 --- a/composeApp/src/commonMain/resources/MR/en/strings_en.xml +++ b/composeApp/src/commonMain/resources/MR/en/strings_en.xml @@ -52,7 +52,7 @@ Every week Every month Other - + Hide map Place reserved diff --git a/composeApp/src/commonMain/resources/MR/images/super_map.svg b/composeApp/src/commonMain/resources/MR/images/super_map.svg new file mode 100644 index 00000000..cb30e3bc --- /dev/null +++ b/composeApp/src/commonMain/resources/MR/images/super_map.svg @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- GitLab From b24a2cc4002f4b984e2a254f0f72719265dcc62b Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 15:20:40 +0600 Subject: [PATCH 11/19] Booking [+] created several more states [~] refactoring code [+] added logic to change booking info when you click on booking item --- .../elevator/ui/booking/BookingScreen.kt | 18 ++++++----- .../ui/booking/components/BookingCard.kt | 4 +-- .../ui/booking/components/BookingList.kt | 2 +- .../components/BookingMainContentScreen.kt | 2 +- .../elevator/ui/booking/store/BookingStore.kt | 15 +++++++-- .../ui/booking/store/BookingStoreFactory.kt | 31 +++++++++++++++++-- 6 files changed, 56 insertions(+), 16 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index b4f79528..2e20ca44 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -160,9 +160,9 @@ fun BookingScreen(bookingComponent: BookingComponent) { onClickCloseBookAccept = { bookingComponent.onEvent(BookingStore.Intent.CloseBookAccept) }, confirmBooking = { bookingComponent.onEvent(BookingStore.Intent.OpenConfirmBooking) }, bookingInfo = BookingInfo( - id = "", + id = state.bookingInfo.id, ownerId = "", - seatName = "", + seatName = state.bookingInfo.seatName, dateOfStart = state.selectedStartDate.atTime(state.selectedStartTime), dateOfEnd = state.selectedStartDate.atTime(state.selectedFinishTime) ), @@ -246,9 +246,11 @@ fun BookingScreen(bookingComponent: BookingComponent) { is BookingStore.Label.CloseBookPeriod -> multiBottomSheetController.closeCurrentSheet() is BookingStore.Label.OpenRepeatDialog -> showRepeatDialog = true is BookingStore.Label.CloseRepeatDialog -> showRepeatDialog = false - is BookingStore.Label.OpenBookAccept -> multiBottomSheetController.showSheet( - BottomSheetNames.BOOK_ACCEPT.name - ) + is BookingStore.Label.OpenBookAccept -> { + multiBottomSheetController.showSheet( + BottomSheetNames.BOOK_ACCEPT.name + ) + } is BookingStore.Label.CloseBookAccept -> multiBottomSheetController.closeCurrentSheet() is BookingStore.Label.OpenCalendar -> showCalendar = true @@ -293,7 +295,9 @@ fun BookingScreen(bookingComponent: BookingComponent) { onClickOpenChoseZone = { bookingComponent.onEvent(BookingStore.Intent.OpenChooseZone) }, onClickOpenBookPeriod = { bookingComponent.onEvent(BookingStore.Intent.OpenBookPeriod) }, onClickMainScreen = { bookingComponent.onOutput(BookingComponent.Output.OpenMainTab) }, - onClickOpenBookAccept = { bookingComponent.onEvent(BookingStore.Intent.OpenBookAccept) }, + onClickOpenBookAccept = { workSpacesUI -> + bookingComponent.onEvent(BookingStore.Intent.OpenBookAccept(value = workSpacesUI)) + }, onClickApplyDate = { date: LocalDate? -> bookingComponent.onEvent( BookingStore.Intent.ApplyDate( @@ -332,7 +336,7 @@ private fun BookingScreenContent( onClickOpenBookPeriod: () -> Unit, onClickOpenChoseZone: () -> Unit, showRepeatDialog: Boolean, - onClickOpenBookAccept: (String) -> Unit, + onClickOpenBookAccept: (WorkSpaceUI) -> Unit, onClickCloseCalendar: () -> Unit, showCalendar: Boolean, onClickApplyDate: (LocalDate?) -> Unit, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingCard.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingCard.kt index 9b53e503..5834b236 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingCard.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingCard.kt @@ -26,11 +26,11 @@ import band.effective.office.elevator.ui.booking.models.WorkSpaceUI import dev.icerock.moko.resources.compose.painterResource @Composable -fun BookingCard(workSpace: WorkSpaceUI, onClickOpenBookAccept: (String) -> Unit) { +fun BookingCard(workSpace: WorkSpaceUI, onClickOpenBookAccept: (WorkSpaceUI) -> Unit) { Column( modifier = Modifier .padding(bottom = 16.dp) - .clickable { onClickOpenBookAccept(workSpace.workSpaceId) } + .clickable { onClickOpenBookAccept(workSpace) } ) { Box( modifier = Modifier diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingList.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingList.kt index 1cdd0cd0..f5a7037f 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingList.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingList.kt @@ -15,7 +15,7 @@ import band.effective.office.elevator.ui.booking.models.WorkSpaceUI fun WorkSpaceList( scrollState: LazyListState, workSpaces: List, - onClickOpenBookAccept: (String) -> Unit + onClickOpenBookAccept: (WorkSpaceUI) -> Unit ) { LazyColumn( modifier = Modifier.background(MaterialTheme.colors.onBackground) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt index b0e62f6a..77551797 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/BookingMainContentScreen.kt @@ -50,7 +50,7 @@ fun BookingMainContentScreen( isExpandedOptions: Boolean, iconRotationStateCard: Float, iconRotationStateOptions: Float, - onClickOpenBookAccept: (String) -> Unit, + onClickOpenBookAccept: (WorkSpaceUI) -> Unit, onClickOpenBookPeriod: () -> Unit, onClickOpenChoseZone: () -> Unit, onClickExpandedMap: () -> Unit, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index a61aa566..79a947b4 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -1,6 +1,7 @@ package band.effective.office.elevator.ui.booking.store import band.effective.office.elevator.MainRes +import band.effective.office.elevator.domain.models.BookingInfo import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.domain.models.CreatingBookModel import band.effective.office.elevator.domain.models.TypeEndPeriodBooking @@ -29,7 +30,7 @@ interface BookingStore : Store) : Intent - object OpenBookAccept : Intent + data class OpenBookAccept(val value: WorkSpaceUI) : Intent object CloseBookAccept : Intent object OpenBookPeriod : Intent object OpenConfirmBooking : Intent @@ -70,7 +71,8 @@ interface BookingStore : Store dispatch( Msg.SelectedTypeList( - type = TypesList(name = MainRes.strings.app_name, icon = MainRes.images.table_icon, type = WorkSpaceType.WORK_PLACE) + type = TypesList( + name = MainRes.strings.app_name, + icon = MainRes.images.table_icon, + type = WorkSpaceType.WORK_PLACE + ) ) ) @@ -131,7 +138,26 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is BookingStore.Intent.OpenBookAccept -> { scope.launch { - publish(BookingStore.Label.OpenBookAccept) + publish(BookingStore.Label.OpenBookAccept(value = intent.value)) + with(intent.value) { + dispatch( + Msg.ChangeWorkingUI( + bookingInfo = BookingInfo( + id = workSpaceId, + ownerId = "", + seatName = workSpaceName, + dateOfEnd = LocalDateTime( + date = getState().selectedStartDate, + time = getState().selectedFinishTime + ), + dateOfStart = LocalDateTime( + date = getState().selectedStartDate, + time = getState().selectedStartTime + ) + ) + ) + ) + } } } @@ -332,6 +358,7 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is Msg.ChangeFrequency -> copy(frequency = msg.frequency) is Msg.ChangeBookingRepeat -> copy(repeatBooking = msg.bookingRepeat) is Msg.ChangeBookingPeriod -> copy(bookingPeriod = msg.bookingPeriod) + is Msg.ChangeWorkingUI -> copy(bookingInfo = msg.bookingInfo) } } } -- GitLab From 791d71d01c604ff0a61d1f7d0865f29c1b37add6 Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 15:46:21 +0600 Subject: [PATCH 12/19] Booking [~] refactoring code --- .../repository/MockBookingRepositoryImpl.kt | 2 +- .../booking/components/modals/BookAccept.kt | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt index cac5d5f0..a3dec7ce 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/data/repository/MockBookingRepositoryImpl.kt @@ -117,7 +117,7 @@ class MockBookingRepositoryImpl: BookingRepository { } override suspend fun createBook(bookingInfo: CreatingBookModel) { - showToast(bookingInfo.toString()) +// showToast(bookingInfo.toString()) } override suspend fun getBookingsForUser(ownerId:String): StateFlow> { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt index 30be140e..f3ac5b0b 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookAccept.kt @@ -29,6 +29,7 @@ import band.effective.office.elevator.components.EffectiveButton import band.effective.office.elevator.domain.models.BookingInfo import band.effective.office.elevator.textInBorderGray import band.effective.office.elevator.ui.booking.models.Frequency +import band.effective.office.elevator.utils.NumToMonth import dev.icerock.moko.resources.compose.stringResource @Composable @@ -78,18 +79,17 @@ fun BookAccept( ) Text( text = with(bookingInfo) { - "" + - "${frequency.toString()} ${dateOfStart.time.hour.toString()}:${ - with( - dateOfStart.time - ) { if (minute.toString().length < 2) "0$minute" else minute.toString() } - }-${dateOfEnd.time.hour.toString()}:${ - with( - dateOfStart.time - ) { - if (minute.toString().length < 2) "0$minute" else minute.toString() - } - }" + "${frequency.toString()} ${dateOfStart.date.dayOfMonth} " + NumToMonth(dateOfStart.date.monthNumber)+ " ${dateOfStart.time.hour.toString()}:${ + with( + dateOfStart.time + ) { if (minute.toString().length < 2) "0$minute" else minute.toString() } + } - ${dateOfEnd.time.hour.toString()}:${ + with( + dateOfStart.time + ) { + if (minute.toString().length < 2) "0$minute" else minute.toString() + } + }" }, style = MaterialTheme.typography.subtitle1, fontSize = 16.sp, -- GitLab From a893440a0cc6134db76b2b45892e54986d687bf0 Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 15:52:40 +0600 Subject: [PATCH 13/19] Booking: BookingSuccess.kt [~] refactoring code according design --- .../components/modals/BookingSuccess.kt | 93 ++++++++++--------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt index cc3a1ca9..f2f69b4d 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt @@ -3,8 +3,10 @@ package band.effective.office.elevator.ui.booking.components.modals import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight @@ -31,56 +33,59 @@ import dev.icerock.moko.resources.compose.stringResource @Composable fun BookingSuccess(onMain: () -> Unit, close: () -> Unit, modifier: Modifier) { - Column( - verticalArrangement = Arrangement.spacedBy(32.dp, Alignment.Top), - horizontalAlignment = Alignment.CenterHorizontally, - modifier = modifier - .fillMaxWidth() - .wrapContentHeight() - .clip(shape = RoundedCornerShape(size = 16.dp)) - .background(color = Color.White) - .padding(start = 16.dp, top = 24.dp, end = 16.dp, bottom = 24.dp) - ) { + Box(modifier = Modifier.background(color = ExtendedThemeColors.colors._66x).fillMaxSize()) { Column( - verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.Top), + verticalArrangement = Arrangement.spacedBy(32.dp, Alignment.Top), horizontalAlignment = Alignment.CenterHorizontally, + modifier = modifier + .fillMaxWidth() + .wrapContentHeight() + .align(alignment = Alignment.Center) + .clip(shape = RoundedCornerShape(size = 16.dp)) + .background(color = Color.White) + .padding(start = 16.dp, top = 24.dp, end = 16.dp, bottom = 24.dp) ) { - Text( - text = stringResource( - resource = MainRes.strings.place_booked, - ), - style = MaterialTheme.typography.h6.copy( - fontWeight = FontWeight( - weight = 500 + Column( + verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.Top), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text( + text = stringResource( + resource = MainRes.strings.place_booked, ), - color = Color.Black - ), - textAlign = TextAlign.Center - ) + style = MaterialTheme.typography.h6.copy( + fontWeight = FontWeight( + weight = 500 + ), + color = Color.Black + ), + textAlign = TextAlign.Center + ) - Text( - text = stringResource( - resource = MainRes.strings.good_working_day, - ), - style = MaterialTheme.typography.body1.copy( - color = ExtendedThemeColors.colors._66x - ), - textAlign = TextAlign.Center - ) - } + Text( + text = stringResource( + resource = MainRes.strings.good_working_day, + ), + style = MaterialTheme.typography.body1.copy( + color = ExtendedThemeColors.colors._66x + ), + textAlign = TextAlign.Center + ) + } - Column( - verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top), - horizontalAlignment = Alignment.Start, - ) { - EffectiveButton( - buttonText = stringResource(resource = MainRes.strings.move_to_main_from_booking), - onClick = onMain - ) - EffectiveButton( - buttonText = stringResource(resource = MainRes.strings.close_booking), - onClick = close - ) + Column( + verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + EffectiveButton( + buttonText = stringResource(resource = MainRes.strings.move_to_main_from_booking), + onClick = onMain + ) + EffectiveButton( + buttonText = stringResource(resource = MainRes.strings.close_booking), + onClick = close + ) + } } } } \ No newline at end of file -- GitLab From 846a1e3128a87b20feea0feddedd66160a6051e6 Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 16:50:12 +0600 Subject: [PATCH 14/19] Added use cases in domain module DI [~] refactoring code --- .../band/effective/office/elevator/domain/di/DomainModuleDI.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt index 466ff6b6..2785b567 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt @@ -10,6 +10,7 @@ import band.effective.office.elevator.domain.entity.AuthorizationEntity import band.effective.office.elevator.domain.entity.BookingInteractor import band.effective.office.elevator.domain.repository.EmployeeRepository import band.effective.office.elevator.domain.repository.UserProfileRepository +import band.effective.office.elevator.domain.useCase.AboutEmployeeUseCase import band.effective.office.elevator.domain.useCase.ChangeBookingUseCase import band.effective.office.elevator.domain.useCase.CreateBookingUseCase import band.effective.office.elevator.domain.useCase.ElevatorCallUseCase @@ -24,6 +25,7 @@ internal val domainModuleDI = module { single { EmployeeRepositoryImpl() } factory { EmployeeUseCase(repository = get()) } + factory { AboutEmployeeUseCase(repository = get()) } single { GetBookingsUseCase(get()) } single { ElevatorCallUseCase(get()) } -- GitLab From 768236587629ce35d4a5b25dcd44b9cdd3dc9661 Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 17:11:11 +0600 Subject: [PATCH 15/19] Time picker [+] added step 5 in minute list --- .../wheel_picker_compose/core/DefaultWheelTimePicker.kt | 2 +- .../commandiron/wheel_picker_compose/core/WheelPicker.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt index 1b58fce8..fa99ce7e 100644 --- a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt +++ b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt @@ -58,7 +58,7 @@ internal fun DefaultWheelTimePicker( ) } - val minutes = (0..59).map { + val minutes = (0..59 step 5).map { Minute( text = it.toString().padStart(2, '0'), value = it, diff --git a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt index 3e6f2a0e..a0de310b 100644 --- a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt +++ b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt @@ -46,9 +46,9 @@ internal fun WheelPicker( LaunchedEffect(isScrollInProgress, count) { if(!isScrollInProgress) { - onScrollFinished(calculateSnappedItemIndex(lazyListState, rowCount))?.let { - lazyListState.scrollToItem(it) - } +// onScrollFinished(calculateSnappedItemIndex(lazyListState, rowCount))?.let { +// lazyListState.scrollToItem(it) +// } } } -- GitLab From 579257e785375b6b9dd5ccb731f360537744c7ee Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 17:15:51 +0600 Subject: [PATCH 16/19] [~] simple code refactoring --- .../elevator/ui/booking/components/modals/BookingPeriod.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt index 84b3dcee..4a4b4ff4 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingPeriod.kt @@ -168,7 +168,7 @@ fun BookingPeriod( //Start booking date TimeLine( date = startDate, - statTime = startTime, + statTime = startTime.padStart(2, '0'), endTime = finishTime, onPickDate = bookStartDate, onPickStartTime = bookStartTime, -- GitLab From 86d62e3c4a74505e2b8eb9d61614b7c6f1df3945 Mon Sep 17 00:00:00 2001 From: Slava Date: Thu, 17 Aug 2023 17:30:58 +0600 Subject: [PATCH 17/19] [~] simple code refactoring --- .../elevator/ui/booking/BookingScreen.kt | 2 + .../core/DefaultWheelTimePicker.kt | 87 ++++++++++--------- .../wheel_picker_compose/core/WheelPicker.kt | 6 +- 3 files changed, 51 insertions(+), 44 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 2e20ca44..8ecbba38 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -31,6 +31,7 @@ import band.effective.office.elevator.components.bottomSheet.MultiBottomSheetCon import band.effective.office.elevator.components.bottomSheet.rememberMultiBottomSheetController import band.effective.office.elevator.domain.models.BookingInfo import band.effective.office.elevator.domain.models.BookingPeriod +import band.effective.office.elevator.expects.showToast import band.effective.office.elevator.ui.booking.components.BookingMainContentScreen import band.effective.office.elevator.ui.booking.components.modals.BookAccept import band.effective.office.elevator.ui.booking.components.modals.BookingPeriod @@ -283,6 +284,7 @@ fun BookingScreen(bookingComponent: BookingComponent) { }, onClickCloseTimeModal = { bookingComponent.onEvent(BookingStore.Intent.CloseStartTimeModal) }, onClickSelectTime = { time: LocalTime -> + showToast(time.minute.toString()) bookingComponent.onEvent( BookingStore.Intent.ApplyTime( time = time, diff --git a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt index fa99ce7e..abfe03e6 100644 --- a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt +++ b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/DefaultWheelTimePicker.kt @@ -38,7 +38,7 @@ internal fun DefaultWheelTimePicker( textStyle: TextStyle = MaterialTheme.typography.titleMedium, textColor: Color = LocalContentColor.current, selectorProperties: SelectorProperties = WheelPickerDefaults.selectorProperties(), - onSnappedTime : (snappedTime: SnappedTime, timeFormat: TimeFormat) -> Int? = { _,_ -> null }, + onSnappedTime: (snappedTime: SnappedTime, timeFormat: TimeFormat) -> Int? = { _, _ -> null }, ) { var snappedTime by remember { mutableStateOf(startTime.truncatedToMinute()) } @@ -62,7 +62,7 @@ internal fun DefaultWheelTimePicker( Minute( text = it.toString().padStart(2, '0'), value = it, - index = it + index = it.div(5) ) } @@ -85,10 +85,10 @@ internal fun DefaultWheelTimePicker( ) } - Box(modifier = modifier, contentAlignment = Alignment.Center){ - if(selectorProperties.enabled().value){ + Box(modifier = modifier, contentAlignment = Alignment.Center) { + if (selectorProperties.enabled().value) { Surface( - modifier = Modifier.size(size.width,size.height / rowCount), + modifier = Modifier.size(size.width, size.height / rowCount), shape = selectorProperties.shape().value, color = selectorProperties.color().value, border = selectorProperties.border().value @@ -98,22 +98,22 @@ internal fun DefaultWheelTimePicker( //Hour WheelTextPicker( size = DpSize( - width = size.width / if(timeFormat == TimeFormat.HOUR_24) 2 else 3, + width = size.width / if (timeFormat == TimeFormat.HOUR_24) 2 else 3, height = size.height ), - texts = if(timeFormat == TimeFormat.HOUR_24) hours.map { it.text } else amPmHours.map { it.text }, + texts = if (timeFormat == TimeFormat.HOUR_24) hours.map { it.text } else amPmHours.map { it.text }, rowCount = rowCount, style = textStyle, color = textColor, - startIndex = if(timeFormat == TimeFormat.HOUR_24) { + startIndex = if (timeFormat == TimeFormat.HOUR_24) { hours.find { it.value == startTime.hour }?.index ?: 0 - } else amPmHours.find { it.value == localTimeToAmPmHour(startTime) }?.index ?: 0, + } else amPmHours.find { it.value == localTimeToAmPmHour(startTime) }?.index ?: 0, selectorProperties = WheelPickerDefaults.selectorProperties( enabled = false ), onScrollFinished = { snappedIndex -> - val newHour = if(timeFormat == TimeFormat.HOUR_24) { + val newHour = if (timeFormat == TimeFormat.HOUR_24) { hours.find { it.index == snappedIndex }?.value } else { amPmHourToHour24( @@ -127,14 +127,14 @@ internal fun DefaultWheelTimePicker( val newTime = snappedTime.withHour(newHour) - if(!newTime.isBefore(minTime) && !newTime.isAfter(maxTime)) { + if (!newTime.isBefore(minTime) && !newTime.isAfter(maxTime)) { snappedTime = newTime } - val newIndex = if(timeFormat == TimeFormat.HOUR_24) { + val newIndex = if (timeFormat == TimeFormat.HOUR_24) { hours.find { it.value == snappedTime.hour }?.index } else { - amPmHours.find { it.value == localTimeToAmPmHour(snappedTime)}?.index + amPmHours.find { it.value == localTimeToAmPmHour(snappedTime) }?.index } newIndex?.let { @@ -148,17 +148,17 @@ internal fun DefaultWheelTimePicker( } } - return@WheelTextPicker if(timeFormat == TimeFormat.HOUR_24) { + return@WheelTextPicker if (timeFormat == TimeFormat.HOUR_24) { hours.find { it.value == snappedTime.hour }?.index } else { - amPmHours.find { it.value == localTimeToAmPmHour(snappedTime)}?.index + amPmHours.find { it.value == localTimeToAmPmHour(snappedTime) }?.index } } ) //Minute WheelTextPicker( size = DpSize( - width = size.width / if(timeFormat == TimeFormat.HOUR_24) 2 else 3, + width = size.width / if (timeFormat == TimeFormat.HOUR_24) 2 else 3, height = size.height ), texts = minutes.map { it.text }, @@ -173,11 +173,12 @@ internal fun DefaultWheelTimePicker( val newMinute = minutes.find { it.index == snappedIndex }?.value - val newHour = if(timeFormat == TimeFormat.HOUR_24) { + val newHour = if (timeFormat == TimeFormat.HOUR_24) { hours.find { it.value == snappedTime.hour }?.value } else { amPmHourToHour24( - amPmHours.find { it.value == localTimeToAmPmHour(snappedTime) }?.value ?: 0, + amPmHours.find { it.value == localTimeToAmPmHour(snappedTime) }?.value + ?: 0, snappedTime.minute, snappedAmPm.value ) @@ -187,7 +188,7 @@ internal fun DefaultWheelTimePicker( newHour?.let { val newTime = snappedTime.withMinute(newMinute).withHour(newHour) - if(!newTime.isBefore(minTime) && !newTime.isAfter(maxTime)) { + if (!newTime.isBefore(minTime) && !newTime.isAfter(maxTime)) { snappedTime = newTime } @@ -209,7 +210,7 @@ internal fun DefaultWheelTimePicker( } ) //AM_PM - if(timeFormat == TimeFormat.AM_PM) { + if (timeFormat == TimeFormat.AM_PM) { WheelTextPicker( size = DpSize( width = size.width / 3, @@ -219,14 +220,15 @@ internal fun DefaultWheelTimePicker( rowCount = rowCount, style = textStyle, color = textColor, - startIndex = amPms.find { it.value == amPmValueFromTime(startTime) }?.index ?:0, + startIndex = amPms.find { it.value == amPmValueFromTime(startTime) }?.index + ?: 0, selectorProperties = WheelPickerDefaults.selectorProperties( enabled = false ), onScrollFinished = { snappedIndex -> - val newAmPm = amPms.find { - if(snappedIndex == 2) { + val newAmPm = amPms.find { + if (snappedIndex == 2) { it.index == 1 } else { it.index == snappedIndex @@ -240,7 +242,8 @@ internal fun DefaultWheelTimePicker( val newMinute = minutes.find { it.value == snappedTime.minute }?.value val newHour = amPmHourToHour24( - amPmHours.find { it.value == localTimeToAmPmHour(snappedTime) }?.value ?: 0, + amPmHours.find { it.value == localTimeToAmPmHour(snappedTime) }?.value + ?: 0, snappedTime.minute, snappedAmPm.value ) @@ -248,7 +251,7 @@ internal fun DefaultWheelTimePicker( newMinute?.let { val newTime = snappedTime.withMinute(newMinute).withHour(newHour) - if(!newTime.isBefore(minTime) && !newTime.isAfter(maxTime)) { + if (!newTime.isBefore(minTime) && !newTime.isAfter(maxTime)) { snappedTime = newTime } @@ -303,6 +306,7 @@ private data class Hour( val value: Int, val index: Int ) + private data class AmPmHour( val text: String, val value: Int, @@ -311,41 +315,41 @@ private data class AmPmHour( internal fun localTimeToAmPmHour(localTime: LocalTime): Int { - if( + if ( isBetween( localTime, - LocalTime.of(0,0), - LocalTime.of(0,59) + LocalTime.of(0, 0), + LocalTime.of(0, 59) ) ) { return localTime.hour + 12 } - if( + if ( isBetween( localTime, - LocalTime.of(1,0), - LocalTime.of(11,59) + LocalTime.of(1, 0), + LocalTime.of(11, 59) ) ) { return localTime.hour } - if( + if ( isBetween( localTime, - LocalTime.of(12,0), - LocalTime.of(12,59) + LocalTime.of(12, 0), + LocalTime.of(12, 59) ) ) { return localTime.hour } - if( + if ( isBetween( localTime, - LocalTime.of(13,0), - LocalTime.of(23,59) + LocalTime.of(13, 0), + LocalTime.of(23, 59) ) ) { return localTime.hour - 12 @@ -360,16 +364,17 @@ private fun isBetween(localTime: LocalTime, startTime: LocalTime, endTime: Local private fun amPmHourToHour24(amPmHour: Int, amPmMinute: Int, amPmValue: AmPmValue): Int { - return when(amPmValue) { + return when (amPmValue) { AmPmValue.AM -> { - if(amPmHour == 12 && amPmMinute <= 59) { + if (amPmHour == 12 && amPmMinute <= 59) { 0 } else { amPmHour } } + AmPmValue.PM -> { - if(amPmHour == 12 && amPmMinute <= 59) { + if (amPmHour == 12 && amPmMinute <= 59) { amPmHour } else { amPmHour + 12 @@ -395,7 +400,7 @@ internal enum class AmPmValue { } private fun amPmValueFromTime(time: LocalTime): AmPmValue { - return if(time.hour > 11) AmPmValue.PM else AmPmValue.AM + return if (time.hour > 11) AmPmValue.PM else AmPmValue.AM } diff --git a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt index a0de310b..3e6f2a0e 100644 --- a/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt +++ b/wheel-picker-compose/src/commonMain/kotlin/com/commandiron/wheel_picker_compose/core/WheelPicker.kt @@ -46,9 +46,9 @@ internal fun WheelPicker( LaunchedEffect(isScrollInProgress, count) { if(!isScrollInProgress) { -// onScrollFinished(calculateSnappedItemIndex(lazyListState, rowCount))?.let { -// lazyListState.scrollToItem(it) -// } + onScrollFinished(calculateSnappedItemIndex(lazyListState, rowCount))?.let { + lazyListState.scrollToItem(it) + } } } -- GitLab From a79e9ef04e052488faf77db8e212b4fe6da69770 Mon Sep 17 00:00:00 2001 From: Artem Gruzdev Date: Thu, 17 Aug 2023 19:25:32 +0400 Subject: [PATCH 18/19] [~] update ktore version --- .../buildSrc/src/main/kotlin/Dependencies.kt | 2 +- composeApp/build.gradle.kts | 2 +- composeApp/composeApp.podspec | 2 +- .../elevator/domain/di/DomainModuleDI.kt | 14 ++-- iosApp/Podfile.lock | 4 +- .../Local Podspecs/composeApp.podspec.json | 2 +- iosApp/Pods/Manifest.lock | 4 +- iosApp/Pods/Pods.xcodeproj/project.pbxproj | 57 +++++++++----- iosApp/iosApp.xcodeproj/project.pbxproj | 74 +++++++++---------- iosApp/iosApp/Info.plist | 4 +- 10 files changed, 89 insertions(+), 76 deletions(-) diff --git a/buildSrc/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/buildSrc/src/main/kotlin/Dependencies.kt index c6dc742f..45554dea 100644 --- a/buildSrc/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/buildSrc/src/main/kotlin/Dependencies.kt @@ -14,7 +14,7 @@ object Dependencies { const val buildConfig = "3.1.0" const val kotlinxCoroutines = "1.7.1" const val kotlinCorutinesMultiplatform = "1.6.1-native-mt" - const val ktor = "2.3.1" + const val ktor = "2.3.2" const val composeIcons = "1.1.0" const val kotlinxSerialization = "1.5.1" const val kotlinxDatetime = "0.4.0" diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 20409fcc..eb9bc216 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -26,7 +26,7 @@ kotlin { val iosSimulatorArm64 = iosSimulatorArm64() cocoapods { - version = "1.0.0" + version = "2.0.0" summary = "Compose application framework" homepage = "https://github.com/Radch-enko" ios.deploymentTarget = "11.0" diff --git a/composeApp/composeApp.podspec b/composeApp/composeApp.podspec index a0b5dec1..66383bd0 100644 --- a/composeApp/composeApp.podspec +++ b/composeApp/composeApp.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'composeApp' - spec.version = '1.0.0' + spec.version = '2.0.0' spec.homepage = 'https://github.com/Radch-enko' spec.source = { :http=> ''} spec.authors = '' diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt index 22142907..08ed3e43 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt @@ -1,17 +1,13 @@ package band.effective.office.elevator.domain.di -import band.effective.office.elevator.data.MockBookingRepositoryImpl -import band.effective.office.elevator.data.OfficeElevatorRepositoryImpl -import band.effective.office.elevator.domain.BookingRepository +import band.effective.office.elevator.data.repository.EmployeeRepositoryImpl +import band.effective.office.elevator.data.repository.MockBookingRepositoryImpl +import band.effective.office.elevator.data.repository.OfficeElevatorRepositoryImpl import band.effective.office.elevator.data.repository.UserProfileRepositoryImpl -import band.effective.office.elevator.domain.OfficeElevatorRepository -import band.effective.office.elevator.data.ProfileRepositoryImpl -import band.effective.office.elevator.domain.ProfileRepository -import band.effective.office.elevator.domain.usecase.EmployeeUseCase -import band.effective.office.elevator.domain.useCase.ElevatorCallUseCase -import band.effective.office.elevator.domain.useCase.GetBookingsUseCase import band.effective.office.elevator.domain.entity.AuthorizationEntity +import band.effective.office.elevator.domain.repository.BookingRepository import band.effective.office.elevator.domain.repository.EmployeeRepository +import band.effective.office.elevator.domain.repository.OfficeElevatorRepository import band.effective.office.elevator.domain.repository.UserProfileRepository import band.effective.office.elevator.domain.useCase.AboutEmployeeUseCase import band.effective.office.elevator.domain.useCase.ElevatorCallUseCase diff --git a/iosApp/Podfile.lock b/iosApp/Podfile.lock index 4f42a6c5..10f96c04 100644 --- a/iosApp/Podfile.lock +++ b/iosApp/Podfile.lock @@ -5,7 +5,7 @@ PODS: - AppAuth/Core (1.6.2) - AppAuth/ExternalUserAgent (1.6.2): - AppAuth/Core - - composeApp (1.0.0): + - composeApp (2.0.0): - GoogleSignIn - GoogleSignIn (7.0.0): - AppAuth (~> 1.5) @@ -37,7 +37,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570 - composeApp: c9320403aea46d1edd74b689602b3b896e9921ec + composeApp: a1edab20faaec8401fc3b7c185faec0bac7df6be GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842 GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72 diff --git a/iosApp/Pods/Local Podspecs/composeApp.podspec.json b/iosApp/Pods/Local Podspecs/composeApp.podspec.json index 030c9481..d6d3a886 100644 --- a/iosApp/Pods/Local Podspecs/composeApp.podspec.json +++ b/iosApp/Pods/Local Podspecs/composeApp.podspec.json @@ -1,6 +1,6 @@ { "name": "composeApp", - "version": "1.0.0", + "version": "2.0.0", "homepage": "https://github.com/Radch-enko", "source": { "http": "" diff --git a/iosApp/Pods/Manifest.lock b/iosApp/Pods/Manifest.lock index 4f42a6c5..10f96c04 100644 --- a/iosApp/Pods/Manifest.lock +++ b/iosApp/Pods/Manifest.lock @@ -5,7 +5,7 @@ PODS: - AppAuth/Core (1.6.2) - AppAuth/ExternalUserAgent (1.6.2): - AppAuth/Core - - composeApp (1.0.0): + - composeApp (2.0.0): - GoogleSignIn - GoogleSignIn (7.0.0): - AppAuth (~> 1.5) @@ -37,7 +37,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570 - composeApp: c9320403aea46d1edd74b689602b3b896e9921ec + composeApp: a1edab20faaec8401fc3b7c185faec0bac7df6be GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842 GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72 diff --git a/iosApp/Pods/Pods.xcodeproj/project.pbxproj b/iosApp/Pods/Pods.xcodeproj/project.pbxproj index 3e7e1a0e..5b91255c 100644 --- a/iosApp/Pods/Pods.xcodeproj/project.pbxproj +++ b/iosApp/Pods/Pods.xcodeproj/project.pbxproj @@ -1915,24 +1915,6 @@ }; name = Debug; }; - 67E3EE5ADFF5140990DBF1D4C4BE47E6 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 096A6188A17BF3596C45A1CA21DE88CA /* composeApp.release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CLANG_ENABLE_OBJC_WEAK = NO; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; 67E9E8FAE28D5D2AAA42A505C1665534 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 43D230156786D7BF27524F67A89E77BD /* sqlite3.debug.xcconfig */; @@ -2196,6 +2178,23 @@ }; name = Debug; }; + 9FA184A50112DBCC8B401DA2417C3FC1 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 143DC92D92785A65F2D61940588F8633 /* composeApp.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_OBJC_WEAK = NO; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; ACC628E3E41F703E9390BEECA9E86A9E /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = C7B6AF4C78A838C667B10A14E4C217E3 /* GTMAppAuth.debug.xcconfig */; @@ -2265,6 +2264,24 @@ }; name = Release; }; + BB5CE3866944923E616F12F112F50D20 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 096A6188A17BF3596C45A1CA21DE88CA /* composeApp.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_OBJC_WEAK = NO; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; D1A26247852E9D0C9FEBB5C970FF2A62 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 783646D566B91DF5CC7D0D9BBF315D19 /* GoogleSignIn.debug.xcconfig */; @@ -2420,8 +2437,8 @@ BDDD9F5B8AC230B87C62C2594173958B /* Build configuration list for PBXAggregateTarget "composeApp" */ = { isa = XCConfigurationList; buildConfigurations = ( - DB9CAFC27F6824D854A8A6E3CAD1D6C9 /* Debug */, - 859E8832FC0E6D15F8B017733E248186 /* Release */, + 9FA184A50112DBCC8B401DA2417C3FC1 /* Debug */, + BB5CE3866944923E616F12F112F50D20 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj index 6bf64766..efede7b0 100644 --- a/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -10,9 +10,9 @@ 8353E90C2A2F991D008864CD /* ComposeControllerToSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8353E90B2A2F991D008864CD /* ComposeControllerToSwiftUI.swift */; }; 8353E90E2A2F998D008864CD /* LifecycleHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8353E90D2A2F998D008864CD /* LifecycleHolder.swift */; }; 83EE76A62A0CAD2F00C22CA2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A93A954129CC810D00F8E227 /* Preview Assets.xcassets */; }; - 936DC71E579D551C18B27BC1 /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F460AC6B7F13C738251A7649 /* Pods_iosApp.framework */; }; A93A953B29CC810C00F8E227 /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93A953A29CC810C00F8E227 /* iosApp.swift */; }; A93A953F29CC810D00F8E227 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A93A953E29CC810D00F8E227 /* Assets.xcassets */; }; + CC0B9C7171848D01B8647E25 /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 64DE1D0D3E14721661BC7419 /* Pods_iosApp.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -37,7 +37,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 1827569E0AB67A938D63CF60 /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = ""; }; + 425FD6D203E60E3536513341 /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = ""; }; + 64DE1D0D3E14721661BC7419 /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 68B90E629CA4F16CEC02F6C7 /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = ""; }; 8353E90B2A2F991D008864CD /* ComposeControllerToSwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeControllerToSwiftUI.swift; sourceTree = ""; }; 8353E90D2A2F998D008864CD /* LifecycleHolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LifecycleHolder.swift; sourceTree = ""; }; 8391E6E32A06C560000AAEE7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -45,8 +47,6 @@ A93A953A29CC810C00F8E227 /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; }; A93A953E29CC810D00F8E227 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; A93A954129CC810D00F8E227 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - EC6A94A9C4EAEFB47CDC8DFC /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = ""; }; - F460AC6B7F13C738251A7649 /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,7 +54,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 936DC71E579D551C18B27BC1 /* Pods_iosApp.framework in Frameworks */, + CC0B9C7171848D01B8647E25 /* Pods_iosApp.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -64,8 +64,8 @@ 979913F6AE5D271756D4649D /* Pods */ = { isa = PBXGroup; children = ( - 1827569E0AB67A938D63CF60 /* Pods-iosApp.debug.xcconfig */, - EC6A94A9C4EAEFB47CDC8DFC /* Pods-iosApp.release.xcconfig */, + 68B90E629CA4F16CEC02F6C7 /* Pods-iosApp.debug.xcconfig */, + 425FD6D203E60E3536513341 /* Pods-iosApp.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -76,7 +76,7 @@ A93A953929CC810C00F8E227 /* iosApp */, A93A953829CC810C00F8E227 /* Products */, 979913F6AE5D271756D4649D /* Pods */, - C9E4D17461014272DBBCEEEB /* Frameworks */, + F3A533A982C75825543B0EC4 /* Frameworks */, ); sourceTree = ""; }; @@ -109,10 +109,10 @@ path = "Preview Content"; sourceTree = ""; }; - C9E4D17461014272DBBCEEEB /* Frameworks */ = { + F3A533A982C75825543B0EC4 /* Frameworks */ = { isa = PBXGroup; children = ( - F460AC6B7F13C738251A7649 /* Pods_iosApp.framework */, + 64DE1D0D3E14721661BC7419 /* Pods_iosApp.framework */, ); name = Frameworks; sourceTree = ""; @@ -124,14 +124,14 @@ isa = PBXNativeTarget; buildConfigurationList = A93A954529CC810D00F8E227 /* Build configuration list for PBXNativeTarget "iosApp" */; buildPhases = ( - D6083C08AE4609EF0C53CE7D /* [CP] Check Pods Manifest.lock */, + 54F2C73DF791A3403E389EB9 /* [CP] Check Pods Manifest.lock */, A93A953329CC810C00F8E227 /* Sources */, A93A953429CC810C00F8E227 /* Frameworks */, A93A953529CC810C00F8E227 /* Resources */, - 507007E4C951FE5AC1F98EBB /* [CP] Embed Pods Frameworks */, AC69DB4C2A6FC5EB00D52FEA /* CopyFiles */, AC69DB4D2A6FC72300D52FEA /* CopyFiles */, AC69DB4E2A6FC73200D52FEA /* copy moko resource */, + FA6CB0C4AA3D0EE0EE53414A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -187,21 +187,26 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 507007E4C951FE5AC1F98EBB /* [CP] Embed Pods Frameworks */ = { + 54F2C73DF791A3403E389EB9 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-iosApp-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; AC69DB4E2A6FC73200D52FEA /* copy moko resource */ = { @@ -222,26 +227,21 @@ shellPath = /bin/sh; shellScript = "\"$SRCROOT/../gradlew\" -p \"$SRCROOT/../\" :composeApp:copyFrameworkResourcesToApp \\\n -Pmoko.resources.BUILT_PRODUCTS_DIR=\"$BUILT_PRODUCTS_DIR\" \\\n -Pmoko.resources.CONTENTS_FOLDER_PATH=\"$CONTENTS_FOLDER_PATH\" \\\n -Pkotlin.native.cocoapods.platform=\"$PLATFORM_NAME\" \\\n -Pkotlin.native.cocoapods.archs=\"$ARCHS\" \\\n -Pkotlin.native.cocoapods.configuration=\"$CONFIGURATION\" \n"; }; - D6083C08AE4609EF0C53CE7D /* [CP] Check Pods Manifest.lock */ = { + FA6CB0C4AA3D0EE0EE53414A /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-iosApp-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -376,14 +376,14 @@ }; A93A954629CC810D00F8E227 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 1827569E0AB67A938D63CF60 /* Pods-iosApp.debug.xcconfig */; + baseConfigurationReference = 68B90E629CA4F16CEC02F6C7 /* Pods-iosApp.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - DEVELOPMENT_TEAM = 3HXPZFA9AN; + DEVELOPMENT_TEAM = JVX7U43WRX; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iosApp/Info.plist; @@ -391,14 +391,14 @@ INFOPLIST_KEY_LSApplicationCategoryType = ""; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIRequiredDeviceCapabilities = armv7; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = band.effective.office.elevator.iosApp; PRODUCT_NAME = "Office Elevator"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -409,7 +409,7 @@ }; A93A954729CC810D00F8E227 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = EC6A94A9C4EAEFB47CDC8DFC /* Pods-iosApp.release.xcconfig */; + baseConfigurationReference = 425FD6D203E60E3536513341 /* Pods-iosApp.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -417,7 +417,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - DEVELOPMENT_TEAM = 3HXPZFA9AN; + DEVELOPMENT_TEAM = JVX7U43WRX; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iosApp/Info.plist; @@ -425,14 +425,14 @@ INFOPLIST_KEY_LSApplicationCategoryType = ""; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIRequiredDeviceCapabilities = armv7; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 2.0; PRODUCT_BUNDLE_IDENTIFIER = band.effective.office.elevator.iosApp; PRODUCT_NAME = "Office Elevator"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/iosApp/iosApp/Info.plist b/iosApp/iosApp/Info.plist index d59d5889..e442925a 100644 --- a/iosApp/iosApp/Info.plist +++ b/iosApp/iosApp/Info.plist @@ -13,14 +13,14 @@ UIApplicationSceneManifest - UISceneConfigurations - New item UIApplicationSupportsMultipleScenes UIApplicationSupportsTabbedSceneCollection + UISceneConfigurations + UILaunchScreen -- GitLab From 15c6e5cfcb2c70fbf328beba0dbb83ed64b29ba0 Mon Sep 17 00:00:00 2001 From: Artem Gruzdev Date: Thu, 17 Aug 2023 21:27:08 +0400 Subject: [PATCH 19/19] [~] fix after merge --- .../elevator/domain/di/DomainModuleDI.kt | 4 +- .../domain/entity/BookingInteractor.kt | 13 +- .../domain/models/CreatingBookModel.kt | 14 +-- .../elevator/ui/booking/BookingScreen.kt | 12 +- .../components/modals/BookingRepeatCard.kt | 12 +- .../components/modals/BookingRepeatElement.kt | 7 +- .../components/modals/BookingSuccess.kt | 53 ++++---- .../elevator/ui/booking/models/Frequency.kt | 1 - .../elevator/ui/booking/store/BookingStore.kt | 10 +- .../ui/booking/store/BookingStoreFactory.kt | 20 +-- .../aboutEmployee/models/BookingsFilter.kt | 3 +- .../ui/main/store/MainStoreFactory.kt | 43 +++++-- iosApp/Pods/Pods.xcodeproj/project.pbxproj | 114 +++++++++--------- 13 files changed, 170 insertions(+), 136 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt index 819042b4..23cc25d5 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/di/DomainModuleDI.kt @@ -24,8 +24,8 @@ internal val domainModuleDI = module { single { OfficeElevatorRepositoryImpl(get(), get()) } single { EmployeeRepositoryImpl() } - factory { EmployeeUseCase(repository = get()) } - factory { AboutEmployeeUseCase(repository = get()) } + single { EmployeeUseCase(repository = get()) } + single { AboutEmployeeUseCase(repository = get()) } single { GetBookingsUseCase(get()) } single { ElevatorCallUseCase(get()) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt index 22ef0ab6..aaf7bad3 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/entity/BookingInteractor.kt @@ -5,6 +5,7 @@ import band.effective.office.elevator.domain.models.CreatingBookModel import band.effective.office.elevator.domain.useCase.ChangeBookingUseCase import band.effective.office.elevator.domain.useCase.CreateBookingUseCase import band.effective.office.elevator.domain.useCase.GetBookingsUseCase +import band.effective.office.elevator.ui.employee.aboutEmployee.models.BookingsFilter import band.effective.office.elevator.ui.models.ReservedSeat import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.StateFlow @@ -17,7 +18,11 @@ class BookingInteractor( ) { suspend fun getForUser(ownerId:String, coroutineScope: CoroutineScope): StateFlow> { val bookingsForUser: StateFlow> = - getBookingsUseCase.getBookingsForUser(ownerId = ownerId, coroutineScope = coroutineScope) + getBookingsUseCase.getBookingsForUser( + ownerId = ownerId, + coroutineScope = coroutineScope, + bookingsFilter = BookingsFilter(meetRoom = true, workPlace = true) + ) return bookingsForUser } @@ -27,7 +32,11 @@ class BookingInteractor( coroutineScope: CoroutineScope ): StateFlow> { val bookingsByDate: StateFlow> = - getBookingsUseCase.getBookingsByDate(ownerId = ownerId, date = date, coroutineScope = coroutineScope) + getBookingsUseCase.getBookingsByDate( + ownerId = ownerId, date = date, + coroutineScope = coroutineScope, + bookingsFilter = BookingsFilter(meetRoom = true, workPlace = true) + ) return bookingsByDate } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt index 749b359b..fbbd227d 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/domain/models/CreatingBookModel.kt @@ -7,21 +7,21 @@ data class CreatingBookModel( val workSpaceId: String, val dateOfStart: LocalDateTime, val dateOfEnd: LocalDateTime, - val bookingPeriod: BookingPeriod, + val bookingPeriodUI: BookingPeriodUI, val typeOfEndPeriod: TypeEndPeriodBooking ) -sealed class BookingPeriod(val durationPeriod: Int) { - data class Month(val monthPeriod: Int) : BookingPeriod(monthPeriod) +sealed class BookingPeriodUI(val durationPeriod: Int) { + data class Month(val monthPeriod: Int) : BookingPeriodUI(monthPeriod) - data class Year(val yearPeriod: Int) : BookingPeriod(yearPeriod) + data class Year(val yearPeriod: Int) : BookingPeriodUI(yearPeriod) - data class EveryWorkDay(val workPeriod: Int) : BookingPeriod(workPeriod) + data class EveryWorkDay(val workPeriod: Int) : BookingPeriodUI(workPeriod) data class Week(val weekPeriod: Int, val selectedDayOfWeek: List) : - BookingPeriod(weekPeriod) + BookingPeriodUI(weekPeriod) - object NoPeriod : BookingPeriod(0) + object NoPeriod : BookingPeriodUI(0) } sealed interface TypeEndPeriodBooking{ diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt index 26e24bec..31e4e312 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/BookingScreen.kt @@ -29,6 +29,9 @@ import band.effective.office.elevator.components.TimePickerModal import band.effective.office.elevator.components.bottomSheet.BottomSheetItem import band.effective.office.elevator.components.bottomSheet.MultiBottomSheetController import band.effective.office.elevator.components.bottomSheet.rememberMultiBottomSheetController +import band.effective.office.elevator.domain.models.BookingInfo +import band.effective.office.elevator.domain.models.BookingPeriodUI +import band.effective.office.elevator.expects.showToast import band.effective.office.elevator.ui.booking.components.BookingMainContentScreen import band.effective.office.elevator.ui.booking.components.modals.BookAccept import band.effective.office.elevator.ui.booking.components.modals.BookingPeriod @@ -37,14 +40,21 @@ import band.effective.office.elevator.ui.booking.components.modals.BookingRepeat import band.effective.office.elevator.ui.booking.components.modals.BookingSuccess import band.effective.office.elevator.ui.booking.components.modals.ChooseZone import band.effective.office.elevator.ui.booking.models.BottomSheetNames +import band.effective.office.elevator.ui.booking.models.Frequency +import band.effective.office.elevator.ui.booking.models.WorkSpaceType import band.effective.office.elevator.ui.booking.models.WorkSpaceUI +import band.effective.office.elevator.ui.booking.models.WorkSpaceZone import band.effective.office.elevator.ui.booking.store.BookingStore +import band.effective.office.elevator.ui.models.TypesList +import band.effective.office.elevator.utils.NumToMonth import band.effective.office.elevator.utils.Stack import band.effective.office.elevator.utils.isScrollingDown import band.effective.office.elevator.utils.stackOf import dev.icerock.moko.resources.compose.stringResource +import effective.office.modalcustomdialog.Dialog import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalTime +import kotlinx.datetime.atTime @OptIn(ExperimentalMaterialApi::class) @Composable @@ -341,7 +351,7 @@ private fun BookingScreenContent( showTimePicker: Boolean, onClickCloseTimeModal: () -> Unit, onClickSelectTime: (LocalTime) -> Unit, - onClickOpenBookRepeat: (Pair) -> Unit, + onClickOpenBookRepeat: (Pair) -> Unit, onClickChangeZone: (WorkSpaceType) -> Unit, isStart: Boolean, date: LocalDate, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt index c6ac17e3..646d8124 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatCard.kt @@ -15,25 +15,25 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.MainRes -import band.effective.office.elevator.domain.models.BookingPeriod +import band.effective.office.elevator.domain.models.BookingPeriodUI import band.effective.office.elevator.domain.models.DayOfWeek import band.effective.office.elevator.ui.booking.models.Frequency import dev.icerock.moko.resources.compose.stringResource @Composable fun BookingRepeatCard( - onSelected: (Pair) -> Unit, + onSelected: (Pair) -> Unit, modifier: Modifier, frequency: Frequency ) { val days: List = frequency.getDays() val strings = listOf( - Pair(first = MainRes.strings.do_not_repeat, second = BookingPeriod.NoPeriod), - Pair(first = MainRes.strings.every_work_day, second = BookingPeriod.EveryWorkDay(5)), - Pair(first = MainRes.strings.every_week, second = BookingPeriod.Week(7, days)), + Pair(first = MainRes.strings.do_not_repeat, second = BookingPeriodUI.NoPeriod), + Pair(first = MainRes.strings.every_work_day, second = BookingPeriodUI.EveryWorkDay(5)), + Pair(first = MainRes.strings.every_week, second = BookingPeriodUI.Week(7, days)), Pair( - first = MainRes.strings.every_month, second = BookingPeriod.Year(365), + first = MainRes.strings.every_month, second = BookingPeriodUI.Year(365), ), Pair(first = MainRes.strings.another, second = 0) ) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt index 7e046663..9b04a87e 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingRepeatElement.kt @@ -14,12 +14,11 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import band.effective.office.elevator.ExtendedThemeColors import band.effective.office.elevator.components.Elevation -import band.effective.office.elevator.domain.models.BookingPeriod +import band.effective.office.elevator.domain.models.BookingPeriodUI import band.effective.office.elevator.radioButtonColor import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -30,7 +29,7 @@ fun BookingRepeatElement( bookingText: String, bookingPeriod: Any, onSelect: (String) -> Unit, - onSelected: (Pair) -> Unit + onSelected: (Pair) -> Unit ) { val coroutineScope = rememberCoroutineScope() @@ -44,7 +43,7 @@ fun BookingRepeatElement( coroutineScope.launch { onSelect(bookingText) delay(100) - onSelected(Pair(first = bookingText, second = bookingPeriod) as Pair) + onSelected(Pair(first = bookingText, second = bookingPeriod) as Pair) } } ) { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt index c2711ae8..93986dd9 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/components/modals/BookingSuccess.kt @@ -57,33 +57,32 @@ fun BookingSuccess(onMain: () -> Unit, close: () -> Unit, modifier: Modifier) { ), color = Color.Black ), - textAlign = TextAlign.Center - ) - - Text( - text = stringResource( - resource = MainRes.strings.good_working_day, - ), - style = MaterialTheme.typography.body1.copy( - color = ExtendedThemeColors.colors._66x - ), - textAlign = TextAlign.Center - ) - } + ), + textAlign = TextAlign.Center + ) + Text( + text = stringResource( + resource = MainRes.strings.good_working_day, + ), + style = MaterialTheme.typography.body1.copy( + color = ExtendedThemeColors.colors._66x + ), + textAlign = TextAlign.Center + ) + } - Column( - verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - EffectiveButton( - buttonText = stringResource(resource = MainRes.strings.move_to_main_from_booking), - onClick = onMain - ) - EffectiveButton( - buttonText = stringResource(resource = MainRes.strings.close_booking), - onClick = close - ) - } + Column( + verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + EffectiveButton( + buttonText = stringResource(resource = MainRes.strings.move_to_main_from_booking), + onClick = onMain + ) + EffectiveButton( + buttonText = stringResource(resource = MainRes.strings.close_booking), + onClick = close + ) } } -} \ No newline at end of file +} diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt index fcaa523d..6ca19c0d 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/models/Frequency.kt @@ -1,6 +1,5 @@ package band.effective.office.elevator.ui.booking.models -import band.effective.office.elevator.domain.models.BookingPeriod import band.effective.office.elevator.domain.models.DayOfWeek class Frequency(private val days: List>) { diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt index 79a947b4..3f66acaa 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/booking/store/BookingStore.kt @@ -2,7 +2,7 @@ package band.effective.office.elevator.ui.booking.store import band.effective.office.elevator.MainRes import band.effective.office.elevator.domain.models.BookingInfo -import band.effective.office.elevator.domain.models.BookingPeriod +import band.effective.office.elevator.domain.models.BookingPeriodUI import band.effective.office.elevator.domain.models.CreatingBookModel import band.effective.office.elevator.domain.models.TypeEndPeriodBooking import band.effective.office.elevator.ui.booking.models.Frequency @@ -29,7 +29,7 @@ interface BookingStore : Store) : Intent + data class OpenBookRepeat(val pair: Pair) : Intent data class OpenBookAccept(val value: WorkSpaceUI) : Intent object CloseBookAccept : Intent object OpenBookPeriod : Intent @@ -70,7 +70,7 @@ interface BookingStore : Store "Каждый рабочий день" - is BookingPeriod.Month -> "Каждый месяц" - BookingPeriod.NoPeriod -> "Без периода" - is BookingPeriod.Week -> "Каждую неделю" - is BookingPeriod.Year -> "Каждый год" + is BookingPeriodUI.EveryWorkDay -> "Каждый рабочий день" + is BookingPeriodUI.Month -> "Каждый месяц" + BookingPeriodUI.NoPeriod -> "Без периода" + is BookingPeriodUI.Week -> "Каждую неделю" + is BookingPeriodUI.Year -> "Каждый год" } dispatch(Msg.ChangeBookingRepeat(bookingRepeat = name)) - dispatch(Msg.ChangeBookingPeriod(bookingPeriod = intent.pair.second)) + dispatch(Msg.ChangeBookingPeriod(bookingPeriodUI = intent.pair.second)) } } @@ -357,7 +357,7 @@ class BookingStoreFactory(private val storeFactory: StoreFactory) : KoinComponen is Msg.BeginningBookingDate -> copy(selectedStartDate = msg.date) is Msg.ChangeFrequency -> copy(frequency = msg.frequency) is Msg.ChangeBookingRepeat -> copy(repeatBooking = msg.bookingRepeat) - is Msg.ChangeBookingPeriod -> copy(bookingPeriod = msg.bookingPeriod) + is Msg.ChangeBookingPeriod -> copy(bookingPeriodUI = msg.bookingPeriodUI) is Msg.ChangeWorkingUI -> copy(bookingInfo = msg.bookingInfo) } } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/employee/aboutEmployee/models/BookingsFilter.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/employee/aboutEmployee/models/BookingsFilter.kt index 534bc3c9..2247d3a5 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/employee/aboutEmployee/models/BookingsFilter.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/employee/aboutEmployee/models/BookingsFilter.kt @@ -2,4 +2,5 @@ package band.effective.office.elevator.ui.employee.aboutEmployee.models data class BookingsFilter( val meetRoom: Boolean, - val workPlace: Boolean) + val workPlace: Boolean +) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt index d6ac2252..8c18ec8a 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/main/store/MainStoreFactory.kt @@ -32,8 +32,12 @@ internal class MainStoreFactory( ) : KoinComponent { private val elevatorUseCase: ElevatorCallUseCase by inject() -// private val bookingsUseCase: GetBookingsUseCase by inject() + + // private val bookingsUseCase: GetBookingsUseCase by inject() private val bookingInteractor: BookingInteractor by inject() + private var recentDate = LocalDate(2023, 8, 16) + private var filtration = BookingsFilter(meetRoom = true, workPlace = true) + private var updatedList = false @OptIn(ExperimentalMviKotlinApi::class) fun create(): MainStore = @@ -93,6 +97,7 @@ internal class MainStoreFactory( publish(MainStore.Label.CloseCalendar) } } + MainStore.Intent.OnClickOpenCalendar -> { scope.launch { publish(MainStore.Label.OpenCalendar) @@ -110,12 +115,15 @@ internal class MainStoreFactory( MainStore.Intent.OnClickShowMap -> { showToast("map") } + is MainStore.Intent.OnClickDeleteBooking -> { showToast("delete") } + is MainStore.Intent.OnClickExtendBooking -> { showToast("extend") } + is MainStore.Intent.OnClickRepeatBooking -> { showToast("repeat") } @@ -129,11 +137,17 @@ internal class MainStoreFactory( is MainStore.Intent.CloseFiltersBottomDialog -> { scope.launch { publish(MainStore.Label.CloseFiltersBottomDialog) - intent.bookingsFilter.let {bookingsFilter -> - if(updatedList){ - changeBookingsByDate(date=recentDate, bookingsFilter = bookingsFilter) - }else{ - getBookingsForUserByDate(date = getCurrentDate(), bookingsFilter = bookingsFilter) + intent.bookingsFilter.let { bookingsFilter -> + if (updatedList) { + changeBookingsByDate( + date = recentDate, + bookingsFilter = bookingsFilter + ) + } else { + getBookingsForUserByDate( + date = getCurrentDate(), + bookingsFilter = bookingsFilter + ) } } } @@ -143,7 +157,10 @@ internal class MainStoreFactory( override fun executeAction(action: Action, getState: () -> MainStore.State) { when (action) { - is Action.LoadBookings -> getBookingsForUserByDate(date = action.date, bookingsFilter = filtration) + is Action.LoadBookings -> getBookingsForUserByDate( + date = action.date, + bookingsFilter = filtration + ) } } @@ -189,10 +206,10 @@ internal class MainStoreFactory( } fun getBookingsForUserByDate(date: LocalDate, bookingsFilter: BookingsFilter) { - if(recentDate!=date) - recentDate=date + if (recentDate != date) + recentDate = date else - filtration=bookingsFilter + filtration = bookingsFilter scope.launch(Dispatchers.IO) { bookingInteractor @@ -206,10 +223,10 @@ internal class MainStoreFactory( } fun changeBookingsByDate(date: LocalDate, bookingsFilter: BookingsFilter) { - if(recentDate!=date) - recentDate=date + if (recentDate != date) + recentDate = date else - filtration=bookingsFilter + filtration = bookingsFilter scope.launch(Dispatchers.IO) { bookingInteractor diff --git a/iosApp/Pods/Pods.xcodeproj/project.pbxproj b/iosApp/Pods/Pods.xcodeproj/project.pbxproj index 6d7ea41d..5b91255c 100644 --- a/iosApp/Pods/Pods.xcodeproj/project.pbxproj +++ b/iosApp/Pods/Pods.xcodeproj/project.pbxproj @@ -1819,57 +1819,6 @@ }; name = Debug; }; - 19FC68DAC5F9A9970578F956EA2B1C27 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 43D230156786D7BF27524F67A89E77BD /* sqlite3.debug.xcconfig */; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/sqlite3/sqlite3-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/sqlite3/sqlite3-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - MODULEMAP_FILE = "Target Support Files/sqlite3/sqlite3.modulemap"; - PRODUCT_MODULE_NAME = sqlite3; - PRODUCT_NAME = sqlite3; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = ""; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 1D72C9DE68E999C98AB062E183E8B5FF /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 143DC92D92785A65F2D61940588F8633 /* composeApp.debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CLANG_ENABLE_OBJC_WEAK = NO; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; 280CBEAB0354DDBC341510E41B3F1D36 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1964,7 +1913,7 @@ VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; - name = Release; + name = Debug; }; 67E9E8FAE28D5D2AAA42A505C1665534 /* Debug */ = { isa = XCBuildConfiguration; @@ -2229,7 +2178,24 @@ }; name = Debug; }; - A47D72EEE9EC9BA1946C4A7D59FD0227 /* Debug */ = { + 9FA184A50112DBCC8B401DA2417C3FC1 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 143DC92D92785A65F2D61940588F8633 /* composeApp.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_OBJC_WEAK = NO; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + ACC628E3E41F703E9390BEECA9E86A9E /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = C7B6AF4C78A838C667B10A14E4C217E3 /* GTMAppAuth.debug.xcconfig */; buildSettings = { @@ -2298,11 +2264,45 @@ }; name = Release; }; - CAD506797A15FD305F3EC04A9EA81F5E /* Release */ = { + BB5CE3866944923E616F12F112F50D20 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 37D6B131A186B8B6C52A60D09B0A996F /* GoogleSignIn.release.xcconfig */; + baseConfigurationReference = 096A6188A17BF3596C45A1CA21DE88CA /* composeApp.release.xcconfig */; buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CLANG_ENABLE_OBJC_WEAK = NO; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + D1A26247852E9D0C9FEBB5C970FF2A62 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 783646D566B91DF5CC7D0D9BBF315D19 /* GoogleSignIn.debug.xcconfig */; + buildSettings = { + CODE_SIGNING_ALLOWED = NO; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/GoogleSignIn"; + IBSC_MODULE = GoogleSignIn; + INFOPLIST_FILE = "Target Support Files/GoogleSignIn/ResourceBundle-GoogleSignIn-GoogleSignIn-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + PRODUCT_NAME = GoogleSignIn; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + WRAPPER_EXTENSION = bundle; + }; + name = Debug; + }; + DB9CAFC27F6824D854A8A6E3CAD1D6C9 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FD1C773EDF2460206B706BDBDB245402 /* AppAuth.debug.xcconfig */; + buildSettings = { "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; @@ -2437,8 +2437,8 @@ BDDD9F5B8AC230B87C62C2594173958B /* Build configuration list for PBXAggregateTarget "composeApp" */ = { isa = XCConfigurationList; buildConfigurations = ( - 61B25A52857AA65D403905F0CC6BD68E /* Debug */, - 48C4116A3161C0DA7989A1E88F6DCA29 /* Release */, + 9FA184A50112DBCC8B401DA2417C3FC1 /* Debug */, + BB5CE3866944923E616F12F112F50D20 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; -- GitLab