From 8e957028518dcf356b602e5cab8c006611306832 Mon Sep 17 00:00:00 2001 From: easyhz Date: Sat, 20 Jul 2024 17:06:14 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20navigateToHome=20=EC=B6=94=EA=B0=80=20#?= =?UTF-8?q?20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/easyhz/noffice/NofficeApp.kt | 6 +----- .../organization/OrganizationNavigation.kt | 3 ++- .../screen/creation/OrganizationCreationScreen.kt | 4 +++- .../screen/creation/OrganizationCreationViewModel.kt | 12 ++++++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/easyhz/noffice/NofficeApp.kt b/app/src/main/java/com/easyhz/noffice/NofficeApp.kt index b1663a01..a0ff9ba6 100644 --- a/app/src/main/java/com/easyhz/noffice/NofficeApp.kt +++ b/app/src/main/java/com/easyhz/noffice/NofficeApp.kt @@ -21,7 +21,6 @@ import com.easyhz.noffice.navigation.home.screen.Home import com.easyhz.noffice.navigation.organization.navigateToOrganizationCreation import com.easyhz.noffice.navigation.organization.navigateToOrganizationInvitation import com.easyhz.noffice.navigation.organization.organizationScreen -import com.easyhz.noffice.navigation.organization.screen.OrganizationInvitation import com.easyhz.noffice.navigation.rememberNofficeNavController import com.easyhz.noffice.navigation.sign.signScreen import com.easyhz.noffice.navigation.util.BOTTOM_BAR_DURATION @@ -85,11 +84,8 @@ fun NofficeApp() { navigateToHome = { val navOptions = navOptions { popUpTo(navController.graph.id) { - saveState = true - inclusive = false + inclusive = true } - launchSingleTop = true - restoreState = true } navController.navigateToHome(navOptions) } diff --git a/app/src/main/java/com/easyhz/noffice/navigation/organization/OrganizationNavigation.kt b/app/src/main/java/com/easyhz/noffice/navigation/organization/OrganizationNavigation.kt index 5d9be9d0..0a949556 100644 --- a/app/src/main/java/com/easyhz/noffice/navigation/organization/OrganizationNavigation.kt +++ b/app/src/main/java/com/easyhz/noffice/navigation/organization/OrganizationNavigation.kt @@ -36,7 +36,8 @@ internal fun NavGraphBuilder.organizationScreen( popExitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.End, tween(DURATION)) } ) { OrganizationCreationScreen( - navigateToInvitation = navigateToInvitation + navigateToInvitation = navigateToInvitation, + navigateToHome = navigateToHome ) } composable( diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt index 1a88d100..6f56de1b 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationScreen.kt @@ -44,7 +44,8 @@ import com.easyhz.noffice.feature.organization.util.creation.CreationStep fun OrganizationCreationScreen( modifier: Modifier = Modifier, viewModel: OrganizationCreationViewModel = hiltViewModel(), - navigateToInvitation: (String, String) -> Unit + navigateToInvitation: (String, String) -> Unit, + navigateToHome: () -> Unit ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() val focusManager = LocalFocusManager.current @@ -108,6 +109,7 @@ fun OrganizationCreationScreen( is CreationSideEffect.NavigateToGallery -> { galleryLauncher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) } + is CreationSideEffect.NavigateToHome -> { navigateToHome() } is CreationSideEffect.NavigateToInvitation -> { navigateToInvitation(sideEffect.invitationUrl, sideEffect.imageUrl) } diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt index 7439eb00..1beddefd 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/creation/OrganizationCreationViewModel.kt @@ -36,7 +36,7 @@ class OrganizationCreationViewModel @Inject constructor( private fun onClickBackButton() { currentState.step.currentStep.beforeStep()?.let { beforeStep -> reduce { updateStep(currentStep = beforeStep) } - } // TODO NAVIGATE TO BACK + } ?: onNavigateToHome() } private fun onClickNextButton() { @@ -73,13 +73,13 @@ class OrganizationCreationViewModel @Inject constructor( } private fun onClickImageView() { + if (!currentState.isEnabledGallery) return postSideEffect { CreationSideEffect.NavigateToGallery } + reduce { copy(isEnabledGallery = false) } } private fun onPickImage(uri: Uri?) { - uri?.let { - reduce { copy(organizationImage = it) } - } + reduce { copy(organizationImage = uri ?: Uri.EMPTY, isEnabledGallery = true) } } private fun onChangeEndDate(date: LocalDate) { @@ -94,6 +94,10 @@ class OrganizationCreationViewModel @Inject constructor( reduce { copy(promotionCode = "") } } + private fun onNavigateToHome() { + postSideEffect { CreationSideEffect.NavigateToHome } + } + // TODO: 서버 통신 로직 추가 private fun onNavigateToInvitation() { postSideEffect {