From 922c9c6e74cbd8b0d41e7463cf58aab354a1795c Mon Sep 17 00:00:00 2001 From: Leci Date: Mon, 10 Jul 2023 21:51:29 +0600 Subject: [PATCH 01/13] Added file ProfileEditStore.kt in the screen "Profile" --- .../ui/profile/store/ProfileEditStore.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt new file mode 100644 index 00000000..3fd5294a --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt @@ -0,0 +1,22 @@ +package band.effective.office.elevator.ui.profile.store + +import com.arkivanov.mvikotlin.core.store.Store + +interface ProfileEditStore : Store{ + sealed interface Intent { + object BackInProfileClicked : Intent + object SaveChangeClicked : Intent + } + + data class User( + val username: String?, + val post:String?, + val phoneNumber:String?, + val telegram: String? + ) + + sealed interface Label { + object ReturnedInProfile : Label + object SavedChange : Intent + } +} \ No newline at end of file -- GitLab From 4bcc1d6d839b9c7ebba5d5fe10fabbd0d2463954 Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 11 Jul 2023 09:43:41 +0600 Subject: [PATCH 02/13] Added file ProfileEditStoreFactory.kt for the screen "Edit Profile" --- .../profile/store/ProfileEditStoreFactory.kt | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStoreFactory.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStoreFactory.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStoreFactory.kt new file mode 100644 index 00000000..edbfd41f --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStoreFactory.kt @@ -0,0 +1,84 @@ +package band.effective.office.elevator.ui.profile.store + +import com.arkivanov.mvikotlin.core.store.Reducer +import com.arkivanov.mvikotlin.core.store.Store +import com.arkivanov.mvikotlin.core.store.StoreFactory +import com.arkivanov.mvikotlin.core.utils.ExperimentalMviKotlinApi +import com.arkivanov.mvikotlin.extensions.coroutines.CoroutineExecutor +import com.arkivanov.mvikotlin.extensions.coroutines.coroutineBootstrapper +import org.koin.core.component.KoinComponent + +internal class ProfileEditStoreFactory( + private val storeFactory: StoreFactory +) : KoinComponent { + @OptIn(ExperimentalMviKotlinApi::class) + fun create(): ProfileEditStore = + object : ProfileEditStore, + Store + by storeFactory.create( + name = "ProfileEditStore", + initialState = ProfileEditStore.User( + username = null, + telegram = null, + post = null, + phoneNumber = null + ), + bootstrapper = coroutineBootstrapper { + dispatch(ProfileEditStoreFactory.Action.FetchUserInfo) + }, + executorFactory = ::ExecutorImpl, + reducer = ProfileEditStoreFactory.ReducerImpl + ) {} + + private sealed interface Action { + object FetchUserInfo : Action + } + + private sealed interface Msg { + data class ProfileData(val user: ProfileEditStore.User) : Msg + } + + private inner class ExecutorImpl : + CoroutineExecutor() { + override fun executeIntent( + intent: ProfileEditStore.Intent, + getState: () -> ProfileEditStore.User + ) { + when (intent) { + ProfileEditStore.Intent.BackInProfileClicked -> doReturnProfile() + ProfileEditStore.Intent.SaveChangeClicked -> doSaveChange() + else -> {} + } + } + + override fun executeAction(action: Action, getState: () -> ProfileEditStore.User) { + when (action) { + Action.FetchUserInfo -> fetchUserInfo() + } + } + + private fun fetchUserInfo() { + TODO("Not yet implemented") + } + + private fun doSaveChange() { + TODO("Not yet implemented") + } + + private fun doReturnProfile() { + TODO("Not yet implemented") + } + } + + private object ReducerImpl : Reducer { + override fun ProfileEditStore.User.reduce(message: Msg): ProfileEditStore.User = + when (message) { + is Msg.ProfileData -> ProfileEditStore.User( + username = null, + telegram = null, + post = null, + phoneNumber = null, + ) + } + } +} \ No newline at end of file -- GitLab From b2e2a40f63b347d0f71025fca1036e0671f3d52e Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 11 Jul 2023 09:57:27 +0600 Subject: [PATCH 03/13] Updated file ProfileEditStoreFactory.kt and ProfileEditStore.kt for the screen "Edit Profile" --- .../ui/profile/store/ProfileEditStore.kt | 2 +- .../profile/store/ProfileEditStoreFactory.kt | 40 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt index 3fd5294a..a43b29ac 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt @@ -17,6 +17,6 @@ interface ProfileEditStore : Store + Store by storeFactory.create( name = "ProfileEditStore", - initialState = ProfileEditStore.User( + initialState = User( username = null, telegram = null, post = null, phoneNumber = null ), bootstrapper = coroutineBootstrapper { - dispatch(ProfileEditStoreFactory.Action.FetchUserInfo) + dispatch(Action.FetchUserInfo) }, executorFactory = ::ExecutorImpl, - reducer = ProfileEditStoreFactory.ReducerImpl + reducer = ReducerImpl ) {} private sealed interface Action { @@ -35,23 +36,24 @@ internal class ProfileEditStoreFactory( } private sealed interface Msg { - data class ProfileData(val user: ProfileEditStore.User) : Msg + data class ProfileData(val user: User) : Msg } private inner class ExecutorImpl : - CoroutineExecutor() { + CoroutineExecutor() { override fun executeIntent( - intent: ProfileEditStore.Intent, - getState: () -> ProfileEditStore.User + intent: Intent, + getState: () -> User ) { when (intent) { - ProfileEditStore.Intent.BackInProfileClicked -> doReturnProfile() - ProfileEditStore.Intent.SaveChangeClicked -> doSaveChange() - else -> {} + Intent.BackInProfileClicked -> doReturnProfile() + Intent.SaveChangeClicked -> doSaveChange() } } - - override fun executeAction(action: Action, getState: () -> ProfileEditStore.User) { + private fun doSaveChange() { + publish(Label.SavedChange) + } + override fun executeAction(action: Action, getState: () -> User) { when (action) { Action.FetchUserInfo -> fetchUserInfo() } @@ -61,19 +63,17 @@ internal class ProfileEditStoreFactory( TODO("Not yet implemented") } - private fun doSaveChange() { - TODO("Not yet implemented") - } + private fun doReturnProfile() { - TODO("Not yet implemented") + publish(Label.ReturnedInProfile) } } - private object ReducerImpl : Reducer { - override fun ProfileEditStore.User.reduce(message: Msg): ProfileEditStore.User = + private object ReducerImpl : Reducer { + override fun User.reduce(message: Msg): User = when (message) { - is Msg.ProfileData -> ProfileEditStore.User( + is Msg.ProfileData -> User( username = null, telegram = null, post = null, -- GitLab From c26ded4329747f3053050588a3520a69b62b6725 Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 11 Jul 2023 10:12:37 +0600 Subject: [PATCH 04/13] Changed project structures for the screens "Profile" and "Edit Profile" --- .../office/elevator/ui/booking/BookingComponent.kt | 8 -------- .../band/effective/office/elevator/ui/content/Content.kt | 4 +--- .../office/elevator/ui/content/ContentComponent.kt | 2 +- .../ui/profile/editProfile/ProfileEditComponent.kt | 4 ++++ .../profile/{ => editProfile}/store/ProfileEditStore.kt | 6 +++--- .../{ => editProfile}/store/ProfileEditStoreFactory.kt | 6 +++--- .../ui/profile/{ => mainProfile}/ProfileComponent.kt | 6 +++--- .../ui/profile/{ => mainProfile}/ProfileScreen.kt | 4 ++-- .../ui/profile/{ => mainProfile}/store/ProfileStore.kt | 2 +- .../{ => mainProfile}/store/ProfileStoreFactory.kt | 4 ++-- 10 files changed, 20 insertions(+), 26 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt rename composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/{ => editProfile}/store/ProfileEditStore.kt (65%) rename composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/{ => editProfile}/store/ProfileEditStoreFactory.kt (91%) rename composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/{ => mainProfile}/ProfileComponent.kt (83%) rename composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/{ => mainProfile}/ProfileScreen.kt (98%) rename composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/{ => mainProfile}/store/ProfileStore.kt (87%) rename composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/{ => mainProfile}/store/ProfileStoreFactory.kt (95%) 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 f38f26a5..aa9b636d 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 @@ -1,15 +1,7 @@ package band.effective.office.elevator.ui.booking -import band.effective.office.elevator.ui.profile.store.ProfileStore -import band.effective.office.elevator.ui.profile.store.ProfileStoreFactory import com.arkivanov.decompose.ComponentContext -import com.arkivanov.mvikotlin.core.instancekeeper.getStore import com.arkivanov.mvikotlin.core.store.StoreFactory -import com.arkivanov.mvikotlin.extensions.coroutines.labels -import com.arkivanov.mvikotlin.extensions.coroutines.stateFlow -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.StateFlow class BookingComponent( componentContext: ComponentContext, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt index 4893f6cc..b4f040f6 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt @@ -4,14 +4,12 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding import androidx.compose.material.BottomNavigation -import androidx.compose.material.MaterialTheme import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import band.effective.office.elevator.components.TabNavigationItem -import band.effective.office.elevator.lightGray import band.effective.office.elevator.navigation.BookingTab import band.effective.office.elevator.navigation.EmployeesTab import band.effective.office.elevator.navigation.MainTab @@ -19,7 +17,7 @@ import band.effective.office.elevator.navigation.ProfileTab import band.effective.office.elevator.ui.booking.BookingScreen import band.effective.office.elevator.ui.employee.EmployeeScreen import band.effective.office.elevator.ui.main.MainScreen -import band.effective.office.elevator.ui.profile.ProfileScreen +import band.effective.office.elevator.ui.profile.mainProfile.ProfileScreen import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.Direction import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.StackAnimation 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 9ed96e65..b134b1ff 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 @@ -3,7 +3,7 @@ package band.effective.office.elevator.ui.content import band.effective.office.elevator.ui.booking.BookingComponent import band.effective.office.elevator.ui.employee.EmployeeComponent import band.effective.office.elevator.ui.main.MainComponent -import band.effective.office.elevator.ui.profile.ProfileComponent +import band.effective.office.elevator.ui.profile.mainProfile.ProfileComponent import com.arkivanov.decompose.ComponentContext import com.arkivanov.decompose.router.stack.ChildStack import com.arkivanov.decompose.router.stack.StackNavigation diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt new file mode 100644 index 00000000..ad99a1ee --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt @@ -0,0 +1,4 @@ +package band.effective.office.elevator.ui.profile.editProfile + +class ProfileEditComponent { +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStore.kt similarity index 65% rename from composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt rename to composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStore.kt index a43b29ac..18d80fe4 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileEditStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStore.kt @@ -1,8 +1,8 @@ -package band.effective.office.elevator.ui.profile.store +package band.effective.office.elevator.ui.profile.editProfile.store import com.arkivanov.mvikotlin.core.store.Store -interface ProfileEditStore : Store{ +interface ProfileEditStore : Store{ sealed interface Intent { object BackInProfileClicked : Intent object SaveChangeClicked : Intent @@ -17,6 +17,6 @@ interface ProfileEditStore : Store() { + CoroutineExecutor() { override fun executeIntent( intent: Intent, getState: () -> User diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileComponent.kt similarity index 83% rename from composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt rename to composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileComponent.kt index 31371be7..391c7522 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileComponent.kt @@ -1,7 +1,7 @@ -package band.effective.office.elevator.ui.profile +package band.effective.office.elevator.ui.profile.mainProfile -import band.effective.office.elevator.ui.profile.store.ProfileStore -import band.effective.office.elevator.ui.profile.store.ProfileStoreFactory +import band.effective.office.elevator.ui.profile.mainProfile.store.ProfileStore +import band.effective.office.elevator.ui.profile.mainProfile.store.ProfileStoreFactory import com.arkivanov.decompose.ComponentContext import com.arkivanov.mvikotlin.core.instancekeeper.getStore import com.arkivanov.mvikotlin.core.store.StoreFactory diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt similarity index 98% rename from composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileScreen.kt rename to composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt index 1fa43ab5..4c18e874 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt @@ -1,4 +1,4 @@ -package band.effective.office.elevator.ui.profile +package band.effective.office.elevator.ui.profile.mainProfile import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image @@ -38,7 +38,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import band.effective.office.elevator.MainRes -import band.effective.office.elevator.ui.profile.store.ProfileStore +import band.effective.office.elevator.ui.profile.mainProfile.store.ProfileStore import com.seiko.imageloader.model.ImageRequest import com.seiko.imageloader.rememberAsyncImagePainter import dev.icerock.moko.resources.ImageResource diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStore.kt similarity index 87% rename from composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileStore.kt rename to composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStore.kt index 4026f5aa..4aff8e8f 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStore.kt @@ -1,4 +1,4 @@ -package band.effective.office.elevator.ui.profile.store +package band.effective.office.elevator.ui.profile.mainProfile.store import com.arkivanov.mvikotlin.core.store.Store diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileStoreFactory.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStoreFactory.kt similarity index 95% rename from composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileStoreFactory.kt rename to composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStoreFactory.kt index bd3254db..6e4f4b34 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/store/ProfileStoreFactory.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStoreFactory.kt @@ -1,9 +1,9 @@ -package band.effective.office.elevator.ui.profile.store +package band.effective.office.elevator.ui.profile.mainProfile.store import band.effective.office.elevator.data.ApiResponse import band.effective.office.elevator.domain.GoogleSignIn import band.effective.office.elevator.domain.models.GoogleAccount -import band.effective.office.elevator.ui.profile.store.ProfileStore.* +import band.effective.office.elevator.ui.profile.mainProfile.store.ProfileStore.* import com.arkivanov.mvikotlin.core.store.Reducer import com.arkivanov.mvikotlin.core.store.Store import com.arkivanov.mvikotlin.core.store.StoreFactory -- GitLab From ef13db781af76b83daae1e1fa0fe7264c475d503 Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 11 Jul 2023 10:36:08 +0600 Subject: [PATCH 05/13] Added component for the screen "Edit Profile" --- .../editProfile/ProfileEditComponent.kt | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt index ad99a1ee..c0de53c5 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt @@ -1,4 +1,40 @@ package band.effective.office.elevator.ui.profile.editProfile -class ProfileEditComponent { +import band.effective.office.elevator.ui.profile.editProfile.store.ProfileEditStore +import band.effective.office.elevator.ui.profile.editProfile.store.ProfileEditStoreFactory +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.mvikotlin.core.instancekeeper.getStore +import com.arkivanov.mvikotlin.core.store.StoreFactory +import com.arkivanov.mvikotlin.core.utils.ExperimentalMviKotlinApi +import com.arkivanov.mvikotlin.extensions.coroutines.labels +import com.arkivanov.mvikotlin.extensions.coroutines.stateFlow +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.StateFlow + +class ProfileEditComponent ( + componentContext: ComponentContext, + storeFactory: StoreFactory, + private val output: (Output) -> Unit) : ComponentContext by componentContext { + + private val profileEditStore = instanceKeeper.getStore { + ProfileEditStoreFactory( + storeFactory = storeFactory + ).create() + } + + @OptIn(ExperimentalMviKotlinApi::class) + val user: StateFlow = profileEditStore.stateFlow + + val label: Flow = profileEditStore.labels + + fun onEvent(event:ProfileEditStore.Intent){ + profileEditStore.accept(event) + } + + fun onOutput(output: Output){ + output(output) + } + sealed interface Output { + object OpenProfileFlow:Output + } } \ No newline at end of file -- GitLab From 74a13400347b44f61a888f3b838353e638fd56c9 Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 11 Jul 2023 16:31:48 +0600 Subject: [PATCH 06/13] Created file with Jetpack Compose and added strings resources for the screen "Edit Profile" --- .../profile/editProfile/ProfileEditScreen.kt | 65 +++++++++++++++++++ .../resources/MR/base/strings_ru.xml | 9 ++- .../commonMain/resources/MR/en/strings_en.xml | 8 ++- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt new file mode 100644 index 00000000..f61ba512 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt @@ -0,0 +1,65 @@ +package band.effective.office.elevator.ui.profile.editProfile + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import band.effective.office.elevator.ui.profile.editProfile.store.ProfileEditStore +import band.effective.office.elevator.ui.profile.mainProfile.ProfileComponent + +@Composable +fun ProfileEditScreen(component: ProfileEditComponent){ + val user by component.user.collectAsState() + + LaunchedEffect(component){ + component.label.collect{ label-> + when(label){ + ProfileEditStore.Label.ReturnedInProfile -> component.onOutput(ProfileEditComponent.Output.OpenProfileFlow) + ProfileEditStore.Label.SavedChange -> {} + } + } + } + + ProfileEditScreenContent( + username = user.username, + post = user.post, + telegram = user.telegram, + phoneNumber = user.phoneNumber + ) +} + +@Composable +private fun ProfileEditScreenContent( + username: String?, + post: String?, + telegram: String?, + phoneNumber: String? +) { + Column ( + modifier = Modifier.fillMaxSize().padding(top = 48.dp), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Top + ){ + ProfileEditHeader() + } +} + +@Composable +fun ProfileEditHeader() { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth() + ){ + + } +} diff --git a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml index d6161090..47f6f58b 100644 --- a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml +++ b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml @@ -37,6 +37,13 @@ Выход - Телефон + Телефон Telegram + + + Данные профиля + Фамилия и Имя + Должность + Номер телефона + Номер телефона diff --git a/composeApp/src/commonMain/resources/MR/en/strings_en.xml b/composeApp/src/commonMain/resources/MR/en/strings_en.xml index 12d489c9..7af053f7 100644 --- a/composeApp/src/commonMain/resources/MR/en/strings_en.xml +++ b/composeApp/src/commonMain/resources/MR/en/strings_en.xml @@ -30,6 +30,12 @@ Exit - Phone number + Phone number Telegram + + + Profile Data + Last name and First name + Post + Telephone number -- GitLab From c089c22f4db284b687f4c501ee66e31ddaf952f3 Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 11 Jul 2023 16:32:43 +0600 Subject: [PATCH 07/13] Added images resources for the screen "Edit Profile" --- composeApp/src/commonMain/resources/MR/images/back_button.svg | 3 +++ composeApp/src/commonMain/resources/MR/images/clear_icon.svg | 3 +++ .../src/commonMain/resources/MR/images/mask_commercial_at.svg | 3 +++ composeApp/src/commonMain/resources/MR/images/mask_number.svg | 3 +++ composeApp/src/commonMain/resources/MR/images/person_icon.svg | 3 +++ composeApp/src/commonMain/resources/MR/images/symbols_work.svg | 3 +++ 6 files changed, 18 insertions(+) create mode 100644 composeApp/src/commonMain/resources/MR/images/back_button.svg create mode 100644 composeApp/src/commonMain/resources/MR/images/clear_icon.svg create mode 100644 composeApp/src/commonMain/resources/MR/images/mask_commercial_at.svg create mode 100644 composeApp/src/commonMain/resources/MR/images/mask_number.svg create mode 100644 composeApp/src/commonMain/resources/MR/images/person_icon.svg create mode 100644 composeApp/src/commonMain/resources/MR/images/symbols_work.svg diff --git a/composeApp/src/commonMain/resources/MR/images/back_button.svg b/composeApp/src/commonMain/resources/MR/images/back_button.svg new file mode 100644 index 00000000..5a163615 --- /dev/null +++ b/composeApp/src/commonMain/resources/MR/images/back_button.svg @@ -0,0 +1,3 @@ + + + diff --git a/composeApp/src/commonMain/resources/MR/images/clear_icon.svg b/composeApp/src/commonMain/resources/MR/images/clear_icon.svg new file mode 100644 index 00000000..3ec11b40 --- /dev/null +++ b/composeApp/src/commonMain/resources/MR/images/clear_icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/composeApp/src/commonMain/resources/MR/images/mask_commercial_at.svg b/composeApp/src/commonMain/resources/MR/images/mask_commercial_at.svg new file mode 100644 index 00000000..80f75b8e --- /dev/null +++ b/composeApp/src/commonMain/resources/MR/images/mask_commercial_at.svg @@ -0,0 +1,3 @@ + + + diff --git a/composeApp/src/commonMain/resources/MR/images/mask_number.svg b/composeApp/src/commonMain/resources/MR/images/mask_number.svg new file mode 100644 index 00000000..bc9ecf52 --- /dev/null +++ b/composeApp/src/commonMain/resources/MR/images/mask_number.svg @@ -0,0 +1,3 @@ + + + diff --git a/composeApp/src/commonMain/resources/MR/images/person_icon.svg b/composeApp/src/commonMain/resources/MR/images/person_icon.svg new file mode 100644 index 00000000..f0525e13 --- /dev/null +++ b/composeApp/src/commonMain/resources/MR/images/person_icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/composeApp/src/commonMain/resources/MR/images/symbols_work.svg b/composeApp/src/commonMain/resources/MR/images/symbols_work.svg new file mode 100644 index 00000000..4264454b --- /dev/null +++ b/composeApp/src/commonMain/resources/MR/images/symbols_work.svg @@ -0,0 +1,3 @@ + + + -- GitLab From 9fd0f5d4250cb8d6167faadd17027b2ceadba2ba Mon Sep 17 00:00:00 2001 From: Leci Date: Tue, 11 Jul 2023 20:37:04 +0600 Subject: [PATCH 08/13] Created main view screen "Edit Profile" and added all strings resources --- .../profile/editProfile/ProfileEditScreen.kt | 161 +++++++++++++++++- .../resources/MR/base/strings_ru.xml | 2 +- .../commonMain/resources/MR/en/strings_en.xml | 1 + 3 files changed, 161 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt index f61ba512..6148a254 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt @@ -3,24 +3,51 @@ package band.effective.office.elevator.ui.profile.editProfile import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Button +import androidx.compose.material.Divider +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.OutlinedButton +import androidx.compose.material.OutlinedTextField import androidx.compose.material.Text +import androidx.compose.material.TextFieldDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import band.effective.office.elevator.MainRes import band.effective.office.elevator.ui.profile.editProfile.store.ProfileEditStore -import band.effective.office.elevator.ui.profile.mainProfile.ProfileComponent +import dev.icerock.moko.resources.ImageResource +import dev.icerock.moko.resources.StringResource +import dev.icerock.moko.resources.compose.painterResource +import dev.icerock.moko.resources.compose.stringResource +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext @Composable fun ProfileEditScreen(component: ProfileEditComponent){ val user by component.user.collectAsState() + LaunchedEffect(component){ component.label.collect{ label-> when(label){ @@ -51,15 +78,145 @@ private fun ProfileEditScreenContent( verticalArrangement = Arrangement.Top ){ ProfileEditHeader() + + var listPrepared by remember { + mutableStateOf(false) + } + + LaunchedEffect(Unit){ + withContext(Dispatchers.Default){ + fieldsList.clear() + prepareFieldsData(username,post,telegram,phoneNumber) + listPrepared = true + } + } + + if(listPrepared){ + LazyColumn(modifier = Modifier.fillMaxSize().padding(top= 28.dp)){ + items(fieldsList){item-> + FieldsItemStyle(item = item) + } + } + } + Spacer(modifier = Modifier.weight(.1f)) + OutlinedButton( + onClick = {}, + shape = RoundedCornerShape(40.dp), + ){ + Text( + text = stringResource(MainRes.strings.save), + style = TextStyle( + fontSize = 16.sp, + color = Color.White, + fontWeight = FontWeight.Bold + ), + modifier = Modifier.padding(vertical = 10.dp) + ) + } + } +} + +@Composable +private fun FieldsItemStyle(item:FieldsData){ + var itemText by remember { mutableStateOf(item.value) } + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.padding(horizontal = 16.dp).padding(top = 16.dp).fillMaxWidth() + ) { + Text(stringResource(item.title), modifier = Modifier.padding(bottom = 8.dp), style = TextStyle( + fontSize = 16.sp, + color = Color.Black + ) + ) + itemText?.let { it -> + OutlinedTextField( + value = it, + modifier = Modifier.padding(vertical = 12.dp, horizontal = 16.dp), + onValueChange = {itemText = it}, + shape = RoundedCornerShape(12.dp), + singleLine = true, + textStyle = TextStyle( + fontSize = 16.sp, + + ), + leadingIcon = { + Icon( + painter= painterResource(item.icon), + contentDescription = null, + ) + Divider(modifier = Modifier.padding(horizontal = 16.dp).fillMaxHeight(), thickness = 1.dp) + }, + trailingIcon = { + Icon( + painter = painterResource(MainRes.images.clear_icon), + contentDescription = null, + ) + }, + colors = TextFieldDefaults.outlinedTextFieldColors( + textColor = Color(0x80000000), + leadingIconColor = Color(0x66000000), + trailingIconColor = Color(0x66000000) + ) + ) + } } } +private fun prepareFieldsData(username: String?, post: String?, telegram: String?, phoneNumber: String?) { + + fieldsList.add( + FieldsData( + icon = MainRes.images.person_icon, + title = MainRes.strings.last_name_and_first_name, + value = username, + ) + ) + fieldsList.add( + FieldsData( + icon = MainRes.images.symbols_work, + title = MainRes.strings.post, + value = post, + ) + ) + fieldsList.add( + FieldsData( + icon = MainRes.images.mask_number, + title = MainRes.strings.phone_number, + value = phoneNumber, + ) + ) + fieldsList.add( + FieldsData( + icon = MainRes.images.icon_telegram, + title = MainRes.strings.telegram, + value = telegram, + ) + ) +} + +private val fieldsList: ArrayList = ArrayList() +private data class FieldsData(val title:StringResource,val icon:ImageResource,val value: String?) + @Composable fun ProfileEditHeader() { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth() ){ - + IconButton(onClick = {}){ + Icon( + painter = painterResource(MainRes.images.back_button), + contentDescription = null, + tint = Color.Black + ) + } + Text( + text = stringResource(MainRes.strings.profile_data), + style = TextStyle( + fontSize = 20.sp, color = Color.Black, + fontWeight = FontWeight.Bold + ), + modifier = Modifier.padding(start = 16.dp) + ) } } diff --git a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml index 47f6f58b..f93703b8 100644 --- a/composeApp/src/commonMain/resources/MR/base/strings_ru.xml +++ b/composeApp/src/commonMain/resources/MR/base/strings_ru.xml @@ -44,6 +44,6 @@ Данные профиля Фамилия и Имя Должность - Номер телефона Номер телефона + Сохранить diff --git a/composeApp/src/commonMain/resources/MR/en/strings_en.xml b/composeApp/src/commonMain/resources/MR/en/strings_en.xml index 7af053f7..66da5a8f 100644 --- a/composeApp/src/commonMain/resources/MR/en/strings_en.xml +++ b/composeApp/src/commonMain/resources/MR/en/strings_en.xml @@ -38,4 +38,5 @@ Last name and First name Post Telephone number + Save -- GitLab From 508db2150279e4d8ce1a5dac6f9ec995c542d541 Mon Sep 17 00:00:00 2001 From: Leci Date: Wed, 12 Jul 2023 20:41:51 +0600 Subject: [PATCH 09/13] Added transaction from screen "Profile" to screen "Edit Profile" --- .../office/elevator/ui/content/Content.kt | 5 +- .../elevator/ui/content/ContentComponent.kt | 9 +-- .../office/elevator/ui/profile/Profile.kt | 18 +++++ .../elevator/ui/profile/ProfileComponent.kt | 80 +++++++++++++++++++ .../editProfile/ProfileEditComponent.kt | 6 +- .../profile/editProfile/ProfileEditScreen.kt | 9 --- .../store/ProfileEditStoreFactory.kt | 1 - ...leComponent.kt => MainProfileComponent.kt} | 7 +- .../ui/profile/mainProfile/ProfileScreen.kt | 21 ++--- .../profile/mainProfile/store/ProfileStore.kt | 2 + .../mainProfile/store/ProfileStoreFactory.kt | 5 ++ 11 files changed, 128 insertions(+), 35 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt create mode 100644 composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt rename composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/{ProfileComponent.kt => MainProfileComponent.kt} (92%) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt index b4f040f6..b7cefee2 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/content/Content.kt @@ -17,6 +17,7 @@ import band.effective.office.elevator.navigation.ProfileTab import band.effective.office.elevator.ui.booking.BookingScreen import band.effective.office.elevator.ui.employee.EmployeeScreen import band.effective.office.elevator.ui.main.MainScreen +import band.effective.office.elevator.ui.profile.Profile import band.effective.office.elevator.ui.profile.mainProfile.ProfileScreen import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.Direction @@ -26,6 +27,8 @@ import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.isEn import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.slide import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import com.arkivanov.decompose.router.children.children +import com.arkivanov.decompose.router.stack.childStack @Composable fun Content (component: ContentComponent) { @@ -42,7 +45,7 @@ fun Content (component: ContentComponent) { ) { when (val child = it.instance) { is ContentComponent.Child.Main -> MainScreen(child.component) - is ContentComponent.Child.Profile -> ProfileScreen(child.component) + is ContentComponent.Child.Profile -> Profile(child.component) is ContentComponent.Child.Booking -> BookingScreen(child.component) is ContentComponent.Child.Employee -> EmployeeScreen(child.component) } 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 b134b1ff..82860027 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 @@ -3,7 +3,7 @@ package band.effective.office.elevator.ui.content import band.effective.office.elevator.ui.booking.BookingComponent import band.effective.office.elevator.ui.employee.EmployeeComponent import band.effective.office.elevator.ui.main.MainComponent -import band.effective.office.elevator.ui.profile.mainProfile.ProfileComponent +import band.effective.office.elevator.ui.profile.ProfileComponent import com.arkivanov.decompose.ComponentContext import com.arkivanov.decompose.router.stack.ChildStack import com.arkivanov.decompose.router.stack.StackNavigation @@ -35,7 +35,7 @@ class ContentComponent( ProfileComponent( componentContext, storeFactory, - ::profileOutput + openAuthorizationFlow ) ) is Config.Booking -> Child.Booking(BookingComponent(componentContext, storeFactory)) @@ -51,11 +51,6 @@ class ContentComponent( } } - private fun profileOutput(output: ProfileComponent.Output) { - when (output) { - ProfileComponent.Output.OpenAuthorizationFlow -> openAuthorizationFlow() - } - } sealed class Child { class Main(val component: MainComponent) : Child() diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt new file mode 100644 index 00000000..ac4863ea --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt @@ -0,0 +1,18 @@ +package band.effective.office.elevator.ui.profile + +import androidx.compose.runtime.Composable +import band.effective.office.elevator.ui.profile.editProfile.ProfileEditScreen +import band.effective.office.elevator.ui.profile.mainProfile.ProfileScreen +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children + +@Composable +fun Profile (component: ProfileComponent){ + Children( + stack = component.childStack + ){ + when(val child = it.instance){ + is ProfileComponent.Child.MainProfileChild -> ProfileScreen(child.component) + is ProfileComponent.Child.EditProfileChild -> ProfileEditScreen(child.component) + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt new file mode 100644 index 00000000..a703a249 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt @@ -0,0 +1,80 @@ +package band.effective.office.elevator.ui.profile + +import band.effective.office.elevator.ui.profile.editProfile.ProfileEditComponent +import band.effective.office.elevator.ui.profile.mainProfile.MainProfileComponent +import band.effective.office.elevator.ui.profile.mainProfile.store.ProfileStore +import band.effective.office.elevator.ui.profile.mainProfile.store.ProfileStoreFactory +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.router.stack.StackNavigation +import com.arkivanov.decompose.router.stack.bringToFront +import com.arkivanov.decompose.router.stack.childStack +import com.arkivanov.decompose.router.stack.replaceAll +import com.arkivanov.decompose.value.Value +import com.arkivanov.essenty.parcelable.Parcelable +import com.arkivanov.essenty.parcelable.Parcelize +import com.arkivanov.mvikotlin.core.instancekeeper.getStore +import com.arkivanov.mvikotlin.core.store.StoreFactory +import com.arkivanov.mvikotlin.extensions.coroutines.labels +import com.arkivanov.mvikotlin.extensions.coroutines.stateFlow +import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.StateFlow + +class ProfileComponent( + componentContext: ComponentContext, + private val storeFactory: StoreFactory, + private val openAuthorizationFlow: () -> Unit +) : + ComponentContext by componentContext { + + private val navigation = StackNavigation() + + private val stack = childStack( + source = navigation, + initialStack = { listOf(Config.MainProfile) }, + childFactory = ::child, + handleBackButton = true + ) + + val childStack: Value> = stack + + private fun child(config: Config, componentContext: ComponentContext):Child = + when(config){ + is Config.MainProfile -> Child.MainProfileChild( + MainProfileComponent( + componentContext, + storeFactory, + ::mainProfileOutput, + ) + ) + is Config.EditProfile -> Child.EditProfileChild( + ProfileEditComponent( + componentContext, + storeFactory, + ) + ) + } + + private fun mainProfileOutput(output: MainProfileComponent.Output) { + when(output){ + MainProfileComponent.Output.OpenAuthorizationFlow -> openAuthorizationFlow() + MainProfileComponent.Output.OpenEditProfile -> navigation.bringToFront(Config.EditProfile) + } + } + + + sealed class Child{ + class MainProfileChild(val component: MainProfileComponent) : Child() + class EditProfileChild(val component: ProfileEditComponent): Child() + } + + sealed class Config: Parcelable{ + @Parcelize + object MainProfile: Config() + + @Parcelize + object EditProfile: Config() + } +} diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt index c0de53c5..f8e3f613 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt @@ -13,8 +13,7 @@ import kotlinx.coroutines.flow.StateFlow class ProfileEditComponent ( componentContext: ComponentContext, - storeFactory: StoreFactory, - private val output: (Output) -> Unit) : ComponentContext by componentContext { + storeFactory: StoreFactory) : ComponentContext by componentContext { private val profileEditStore = instanceKeeper.getStore { ProfileEditStoreFactory( @@ -31,9 +30,6 @@ class ProfileEditComponent ( profileEditStore.accept(event) } - fun onOutput(output: Output){ - output(output) - } sealed interface Output { object OpenProfileFlow:Output } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt index 6148a254..f287c822 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt @@ -48,15 +48,6 @@ fun ProfileEditScreen(component: ProfileEditComponent){ val user by component.user.collectAsState() - LaunchedEffect(component){ - component.label.collect{ label-> - when(label){ - ProfileEditStore.Label.ReturnedInProfile -> component.onOutput(ProfileEditComponent.Output.OpenProfileFlow) - ProfileEditStore.Label.SavedChange -> {} - } - } - } - ProfileEditScreenContent( username = user.username, post = user.post, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStoreFactory.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStoreFactory.kt index d0671f33..35a3bc6b 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStoreFactory.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStoreFactory.kt @@ -60,7 +60,6 @@ internal class ProfileEditStoreFactory( } private fun fetchUserInfo() { - TODO("Not yet implemented") } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/MainProfileComponent.kt similarity index 92% rename from composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileComponent.kt rename to composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/MainProfileComponent.kt index 391c7522..6edef52a 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/MainProfileComponent.kt @@ -11,7 +11,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow -class ProfileComponent( +class MainProfileComponent( componentContext: ComponentContext, storeFactory: StoreFactory, private val output: (Output) -> Unit @@ -33,12 +33,13 @@ class ProfileComponent( profileStore.accept(event) } - fun onOutput(output: Output) { + fun onOutput(output: Output){ output(output) } sealed interface Output { object OpenAuthorizationFlow : Output + object OpenEditProfile: Output } -} +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt index 4c18e874..526e27a4 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt @@ -50,13 +50,14 @@ import kotlinx.coroutines.withContext @Composable -fun ProfileScreen(component: ProfileComponent) { +fun ProfileScreen(component: MainProfileComponent) { val user by component.user.collectAsState() - LaunchedEffect(component) { + LaunchedEffect(component){ component.label.collect { label -> - when (label) { - ProfileStore.Label.OnSignedOut -> component.onOutput(ProfileComponent.Output.OpenAuthorizationFlow) + when(label){ + ProfileStore.Label.OnSignedOut -> component.onOutput(MainProfileComponent.Output.OpenAuthorizationFlow) + ProfileStore.Label.OnClickedEdit -> component.onOutput(MainProfileComponent.Output.OpenEditProfile) } } } @@ -67,7 +68,8 @@ fun ProfileScreen(component: ProfileComponent) { post = user.post, telegram = user.telegram, phoneNumber = user.phoneNumber, - onSignOut = { component.onEvent(ProfileStore.Intent.SignOutClicked) } + onSignOut = { component.onEvent(ProfileStore.Intent.SignOutClicked) }, + onEditProfile = {component.onEvent(ProfileStore.Intent.EditProfileClicked)} ) } @@ -78,7 +80,8 @@ internal fun ProfileScreenContent( post: String?, telegram: String?, phoneNumber: String?, - onSignOut: () -> Unit + onSignOut: () -> Unit, + onEditProfile: ()-> Unit ) { Column( modifier = Modifier.fillMaxSize().padding(top = 48.dp), @@ -103,7 +106,7 @@ internal fun ProfileScreenContent( .fillMaxSize().padding(top = 24.dp) ) { items(optionsList) { item -> - OptionsItemStyle(item = item) + OptionsItemStyle(item = item, onEditProfile) } } } @@ -199,7 +202,7 @@ private fun ProfileHeader(onSignOut: () -> Unit) { } @Composable -private fun OptionsItemStyle(item: OptionsData) { +private fun OptionsItemStyle(item: OptionsData, onEditProfile: () -> Unit) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier .padding(horizontal = 16.dp).fillMaxWidth() @@ -227,7 +230,7 @@ private fun OptionsItemStyle(item: OptionsData) { ) ) } - IconButton(onClick = {}) { + IconButton(onClick = onEditProfile) { Icon( painter = painterResource(MainRes.images.next), contentDescription = null, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStore.kt index 4aff8e8f..60f84562 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/store/ProfileStore.kt @@ -6,6 +6,7 @@ interface ProfileStore : Store User) { when (intent) { Intent.SignOutClicked -> doSignOut() + Intent.EditProfileClicked -> doTransaction() } } + private fun doTransaction(){ + publish(Label.OnClickedEdit) + } + private fun doSignOut() { signInClient.signOut() publish(Label.OnSignedOut) -- GitLab From 2a075de846401089b423f0d9326c022f985d1022 Mon Sep 17 00:00:00 2001 From: Leci Date: Wed, 12 Jul 2023 20:57:42 +0600 Subject: [PATCH 10/13] Added transaction from screen "Edit Profile" to screen "Profile" --- .../elevator/ui/profile/ProfileComponent.kt | 7 ++++++ .../editProfile/ProfileEditComponent.kt | 7 +++++- .../profile/editProfile/ProfileEditScreen.kt | 22 ++++++++++++------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt index a703a249..b96612e1 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt @@ -53,10 +53,17 @@ class ProfileComponent( ProfileEditComponent( componentContext, storeFactory, + ::editProfileOutput, ) ) } + private fun editProfileOutput(output: ProfileEditComponent.Output) { + when(output){ + ProfileEditComponent.Output.OpenProfileFlow -> navigation.replaceAll(Config.MainProfile) + } + } + private fun mainProfileOutput(output: MainProfileComponent.Output) { when(output){ MainProfileComponent.Output.OpenAuthorizationFlow -> openAuthorizationFlow() diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt index f8e3f613..b346312b 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditComponent.kt @@ -13,7 +13,9 @@ import kotlinx.coroutines.flow.StateFlow class ProfileEditComponent ( componentContext: ComponentContext, - storeFactory: StoreFactory) : ComponentContext by componentContext { + storeFactory: StoreFactory, + private val output: (Output) -> Unit + ) : ComponentContext by componentContext { private val profileEditStore = instanceKeeper.getStore { ProfileEditStoreFactory( @@ -29,6 +31,9 @@ class ProfileEditComponent ( fun onEvent(event:ProfileEditStore.Intent){ profileEditStore.accept(event) } + fun onOutput(output: Output){ + output(output) + } sealed interface Output { object OpenProfileFlow:Output diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt index f287c822..b4990212 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt @@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Button import androidx.compose.material.Divider import androidx.compose.material.Icon import androidx.compose.material.IconButton @@ -30,7 +29,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -47,13 +45,20 @@ import kotlinx.coroutines.withContext fun ProfileEditScreen(component: ProfileEditComponent){ val user by component.user.collectAsState() - + LaunchedEffect(component){ + component.label.collect{label-> + when(label){ + ProfileEditStore.Label.ReturnedInProfile ->component.onOutput(ProfileEditComponent.Output.OpenProfileFlow) + else-> {} + } + } + } ProfileEditScreenContent( username = user.username, post = user.post, telegram = user.telegram, phoneNumber = user.phoneNumber - ) + ) { component.onEvent(ProfileEditStore.Intent.BackInProfileClicked) } } @Composable @@ -61,14 +66,15 @@ private fun ProfileEditScreenContent( username: String?, post: String?, telegram: String?, - phoneNumber: String? + phoneNumber: String?, + onReturnToProfile: () -> Unit ) { Column ( modifier = Modifier.fillMaxSize().padding(top = 48.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top ){ - ProfileEditHeader() + ProfileEditHeader(onReturnToProfile) var listPrepared by remember { mutableStateOf(false) @@ -189,12 +195,12 @@ private val fieldsList: ArrayList = ArrayList() private data class FieldsData(val title:StringResource,val icon:ImageResource,val value: String?) @Composable -fun ProfileEditHeader() { +fun ProfileEditHeader(onReturnToProfile: () -> Unit) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth() ){ - IconButton(onClick = {}){ + IconButton(onClick = onReturnToProfile){ Icon( painter = painterResource(MainRes.images.back_button), contentDescription = null, -- GitLab From d616993b3465f04c38c4eb8a4455a33eec18bd67 Mon Sep 17 00:00:00 2001 From: Leci Date: Wed, 12 Jul 2023 20:59:25 +0600 Subject: [PATCH 11/13] Added animation for transactions between "Edit Profile" and "Profile" --- .../band/effective/office/elevator/ui/profile/Profile.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt index ac4863ea..74876170 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/Profile.kt @@ -4,11 +4,16 @@ import androidx.compose.runtime.Composable import band.effective.office.elevator.ui.profile.editProfile.ProfileEditScreen import band.effective.office.elevator.ui.profile.mainProfile.ProfileScreen import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.fade +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.plus +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.scale +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation @Composable fun Profile (component: ProfileComponent){ Children( - stack = component.childStack + stack = component.childStack, + animation = stackAnimation(fade() + scale()), ){ when(val child = it.instance){ is ProfileComponent.Child.MainProfileChild -> ProfileScreen(child.component) -- GitLab From 44ab9d9ed567be369939bee9917d421d3049cb5e Mon Sep 17 00:00:00 2001 From: Leci Date: Wed, 12 Jul 2023 23:20:04 +0600 Subject: [PATCH 12/13] Updated view the screen "Edit Profile" --- .../profile/editProfile/ProfileEditScreen.kt | 53 +++++++------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt index b4990212..8aaaaa41 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt @@ -4,17 +4,14 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Divider import androidx.compose.material.Icon import androidx.compose.material.IconButton -import androidx.compose.material.OutlinedButton import androidx.compose.material.OutlinedTextField import androidx.compose.material.Text import androidx.compose.material.TextFieldDefaults @@ -33,6 +30,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import band.effective.office.elevator.MainRes +import band.effective.office.elevator.components.EffectiveButton import band.effective.office.elevator.ui.profile.editProfile.store.ProfileEditStore import dev.icerock.moko.resources.ImageResource import dev.icerock.moko.resources.StringResource @@ -70,7 +68,7 @@ private fun ProfileEditScreenContent( onReturnToProfile: () -> Unit ) { Column ( - modifier = Modifier.fillMaxSize().padding(top = 48.dp), + modifier = Modifier.fillMaxSize().padding(top = 48.dp).padding(horizontal = 16.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top ){ @@ -89,46 +87,34 @@ private fun ProfileEditScreenContent( } if(listPrepared){ - LazyColumn(modifier = Modifier.fillMaxSize().padding(top= 28.dp)){ + LazyColumn(modifier = Modifier.padding(top= 28.dp)){ items(fieldsList){item-> FieldsItemStyle(item = item) } } } Spacer(modifier = Modifier.weight(.1f)) - OutlinedButton( + EffectiveButton( onClick = {}, - shape = RoundedCornerShape(40.dp), - ){ - Text( - text = stringResource(MainRes.strings.save), - style = TextStyle( - fontSize = 16.sp, - color = Color.White, - fontWeight = FontWeight.Bold - ), - modifier = Modifier.padding(vertical = 10.dp) - ) - } + buttonText = stringResource(MainRes.strings.save), + modifier = Modifier.fillMaxWidth().padding(bottom = 16.dp) + ) } } @Composable private fun FieldsItemStyle(item:FieldsData){ - var itemText by remember { mutableStateOf(item.value) } - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.padding(horizontal = 16.dp).padding(top = 16.dp).fillMaxWidth() + var itemText by remember { mutableStateOf("ii") } + Column( + modifier = Modifier.padding(top = 16.dp).fillMaxWidth() ) { Text(stringResource(item.title), modifier = Modifier.padding(bottom = 8.dp), style = TextStyle( fontSize = 16.sp, - color = Color.Black - ) - ) + color = Color.Black)) itemText?.let { it -> OutlinedTextField( value = it, - modifier = Modifier.padding(vertical = 12.dp, horizontal = 16.dp), + modifier = Modifier.fillMaxWidth(), onValueChange = {itemText = it}, shape = RoundedCornerShape(12.dp), singleLine = true, @@ -137,11 +123,10 @@ private fun FieldsItemStyle(item:FieldsData){ ), leadingIcon = { - Icon( - painter= painterResource(item.icon), - contentDescription = null, - ) - Divider(modifier = Modifier.padding(horizontal = 16.dp).fillMaxHeight(), thickness = 1.dp) + Icon( + painter= painterResource(item.icon), + contentDescription = null, + ) }, trailingIcon = { Icon( @@ -163,7 +148,7 @@ private fun prepareFieldsData(username: String?, post: String?, telegram: String fieldsList.add( FieldsData( - icon = MainRes.images.person_icon, + icon = MainRes.images.person_ic, title = MainRes.strings.last_name_and_first_name, value = username, ) @@ -184,7 +169,7 @@ private fun prepareFieldsData(username: String?, post: String?, telegram: String ) fieldsList.add( FieldsData( - icon = MainRes.images.icon_telegram, + icon = MainRes.images.mask_commercial_at, title = MainRes.strings.telegram, value = telegram, ) @@ -198,7 +183,7 @@ private data class FieldsData(val title:StringResource,val icon:ImageResource,va fun ProfileEditHeader(onReturnToProfile: () -> Unit) { Row( verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth() + modifier = Modifier.fillMaxWidth() ){ IconButton(onClick = onReturnToProfile){ Icon( -- GitLab From 838aea0c864165ea27fb31447868a9541bc2b591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D1=81=D1=8F?= Date: Thu, 13 Jul 2023 14:10:45 +0300 Subject: [PATCH 13/13] [~] refactor code --- .../elevator/components/EffectiveButton.kt | 3 +-- .../elevator/ui/profile/ProfileComponent.kt | 4 +--- .../profile/editProfile/ProfileEditScreen.kt | 10 ++++----- .../editProfile/store/ProfileEditStore.kt | 2 +- .../store/ProfileEditStoreFactory.kt | 4 ++-- .../mainProfile/MainProfileComponent.kt | 6 +----- .../ui/profile/mainProfile/ProfileScreen.kt | 21 ++++++++++++------- .../MR/images/edit_profile_image.svg | 12 ++--------- 8 files changed, 27 insertions(+), 35 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/components/EffectiveButton.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/components/EffectiveButton.kt index af55640e..097fe93b 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/components/EffectiveButton.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/components/EffectiveButton.kt @@ -31,8 +31,7 @@ fun EffectiveButton( ) { Text( text = buttonText, - fontFamily = MaterialTheme.typography.button.fontFamily, - fontSize = 15.sp, + style = MaterialTheme.typography.button, modifier = Modifier.padding(vertical = 10.dp) ) } diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt index b96612e1..12a2afca 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/ProfileComponent.kt @@ -25,8 +25,7 @@ import kotlinx.coroutines.flow.StateFlow class ProfileComponent( componentContext: ComponentContext, private val storeFactory: StoreFactory, - private val openAuthorizationFlow: () -> Unit -) : + private val openAuthorizationFlow: () -> Unit) : ComponentContext by componentContext { private val navigation = StackNavigation() @@ -71,7 +70,6 @@ class ProfileComponent( } } - sealed class Child{ class MainProfileChild(val component: MainProfileComponent) : Child() class EditProfileChild(val component: ProfileEditComponent): Child() diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt index 8aaaaa41..150afdcf 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/ProfileEditScreen.kt @@ -52,7 +52,7 @@ fun ProfileEditScreen(component: ProfileEditComponent){ } } ProfileEditScreenContent( - username = user.username, + userName = user.userName, post = user.post, telegram = user.telegram, phoneNumber = user.phoneNumber @@ -61,7 +61,7 @@ fun ProfileEditScreen(component: ProfileEditComponent){ @Composable private fun ProfileEditScreenContent( - username: String?, + userName: String?, post: String?, telegram: String?, phoneNumber: String?, @@ -81,7 +81,7 @@ private fun ProfileEditScreenContent( LaunchedEffect(Unit){ withContext(Dispatchers.Default){ fieldsList.clear() - prepareFieldsData(username,post,telegram,phoneNumber) + prepareFieldsData("Петров Иван","Android-разработчик","petrov","89654561232") listPrepared = true } } @@ -104,7 +104,7 @@ private fun ProfileEditScreenContent( @Composable private fun FieldsItemStyle(item:FieldsData){ - var itemText by remember { mutableStateOf("ii") } + var itemText by remember { mutableStateOf(item.value) } Column( modifier = Modifier.padding(top = 16.dp).fillMaxWidth() ) { @@ -176,7 +176,7 @@ private fun prepareFieldsData(username: String?, post: String?, telegram: String ) } -private val fieldsList: ArrayList = ArrayList() +private val fieldsList: ArrayList = ArrayList() //TODO("Added in fun ProfileEditScreenContent") private data class FieldsData(val title:StringResource,val icon:ImageResource,val value: String?) @Composable diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStore.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStore.kt index 18d80fe4..cca4d96f 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStore.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/editProfile/store/ProfileEditStore.kt @@ -9,7 +9,7 @@ interface ProfileEditStore : Store User( - username = null, + userName = null, telegram = null, post = null, phoneNumber = null, diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/MainProfileComponent.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/MainProfileComponent.kt index 6edef52a..f80e9205 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/MainProfileComponent.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/MainProfileComponent.kt @@ -14,8 +14,7 @@ import kotlinx.coroutines.flow.StateFlow class MainProfileComponent( componentContext: ComponentContext, storeFactory: StoreFactory, - private val output: (Output) -> Unit -) : + private val output: (Output) -> Unit) : ComponentContext by componentContext { private val profileStore = instanceKeeper.getStore { @@ -28,15 +27,12 @@ class MainProfileComponent( val user: StateFlow = profileStore.stateFlow val label: Flow = profileStore.labels - fun onEvent(event: ProfileStore.Intent) { profileStore.accept(event) } - fun onOutput(output: Output){ output(output) } - sealed interface Output { object OpenAuthorizationFlow : Output object OpenEditProfile: Output diff --git a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt index 526e27a4..acde2cb8 100644 --- a/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt +++ b/composeApp/src/commonMain/kotlin/band/effective/office/elevator/ui/profile/mainProfile/ProfileScreen.kt @@ -9,12 +9,15 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Button import androidx.compose.material.Divider import androidx.compose.material.Icon import androidx.compose.material.IconButton @@ -89,7 +92,7 @@ internal fun ProfileScreenContent( verticalArrangement = Arrangement.Top ) { ProfileHeader(onSignOut) - ProfileInfoAboutUser(imageUrl, username, post) + ProfileInfoAboutUser(imageUrl, username, post, onEditProfile) var listPrepared by remember { mutableStateOf(false) } @@ -114,7 +117,7 @@ internal fun ProfileScreenContent( } @Composable -fun ProfileInfoAboutUser(imageUrl: String?, username: String?, post: String?) { +fun ProfileInfoAboutUser(imageUrl: String?, username: String?, post: String?, onEditProfile: ()-> Unit) { imageUrl?.let { url -> val request = remember(url) { ImageRequest { @@ -135,11 +138,15 @@ fun ProfileInfoAboutUser(imageUrl: String?, username: String?, post: String?) { contentDescription = null, ) } - Image( - modifier = Modifier.size(24.dp).align(Alignment.TopEnd), - painter = painterResource(MainRes.images.edit_profile_image), - contentDescription = null, - ) + Button(onClick = onEditProfile, + shape = CircleShape, + modifier = Modifier.size(24.dp).align(Alignment.TopEnd)){ + Image( + painter = painterResource(MainRes.images.edit_profile_image), + contentDescription = null, + contentScale = ContentScale.Fit + ) + } } } username?.let { diff --git a/composeApp/src/commonMain/resources/MR/images/edit_profile_image.svg b/composeApp/src/commonMain/resources/MR/images/edit_profile_image.svg index 004e5775..3707765c 100644 --- a/composeApp/src/commonMain/resources/MR/images/edit_profile_image.svg +++ b/composeApp/src/commonMain/resources/MR/images/edit_profile_image.svg @@ -1,11 +1,3 @@ - - - - - - - - - - + + -- GitLab