Skip to content

Commit

Permalink
feat: navigateToHome 추가 #20
Browse files Browse the repository at this point in the history
  • Loading branch information
easyhz committed Jul 20, 2024
1 parent 8c4ce4e commit 8e95702
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 1 addition & 5 deletions app/src/main/java/com/easyhz/noffice/NofficeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ internal fun NavGraphBuilder.organizationScreen(
popExitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.End, tween(DURATION)) }
) {
OrganizationCreationScreen(
navigateToInvitation = navigateToInvitation
navigateToInvitation = navigateToInvitation,
navigateToHome = navigateToHome
)
}
composable<OrganizationInvitation>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand All @@ -94,6 +94,10 @@ class OrganizationCreationViewModel @Inject constructor(
reduce { copy(promotionCode = "") }
}

private fun onNavigateToHome() {
postSideEffect { CreationSideEffect.NavigateToHome }
}

// TODO: 서버 통신 로직 추가
private fun onNavigateToInvitation() {
postSideEffect {
Expand Down

0 comments on commit 8e95702

Please sign in to comment.