From 9e56b9b40fe43b094946c0ecdccd52c799e73304 Mon Sep 17 00:00:00 2001 From: easyhz Date: Fri, 19 Jul 2024 18:23:34 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20creation=20=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/OrganizationSideEffect.kt | 2 ++ .../screen/organization/OrganizationScreen.kt | 17 +++++++++++++---- .../organization/OrganizationViewModel.kt | 8 +++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/organization/OrganizationSideEffect.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/organization/OrganizationSideEffect.kt index 21c281b2..5aef5e21 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/organization/OrganizationSideEffect.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/contract/organization/OrganizationSideEffect.kt @@ -3,4 +3,6 @@ package com.easyhz.noffice.feature.organization.contract.organization import com.easyhz.noffice.core.common.base.UiSideEffect sealed class OrganizationSideEffect: UiSideEffect() { + + data object NavigateToCreation: OrganizationSideEffect() } \ No newline at end of file diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationScreen.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationScreen.kt index e69b9e08..b8e09d20 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationScreen.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationScreen.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.easyhz.noffice.core.common.util.collectInSideEffectWithLifecycle import com.easyhz.noffice.core.design_system.R import com.easyhz.noffice.core.design_system.component.button.IconMediumButton import com.easyhz.noffice.core.design_system.component.exception.ExceptionView @@ -21,17 +22,19 @@ import com.easyhz.noffice.core.design_system.component.topBar.HomeTopBar import com.easyhz.noffice.core.design_system.extension.screenHorizonPadding import com.easyhz.noffice.core.design_system.util.exception.ExceptionType import com.easyhz.noffice.feature.organization.component.organization.OrganizationItem +import com.easyhz.noffice.feature.organization.contract.organization.OrganizationIntent +import com.easyhz.noffice.feature.organization.contract.organization.OrganizationSideEffect import com.easyhz.noffice.feature.organization.util.OrganizationTopBarMenu @Composable fun OrganizationScreen( modifier: Modifier = Modifier, - viewModel: OrganizationViewModel = hiltViewModel() + viewModel: OrganizationViewModel = hiltViewModel(), + navigateToCreation: () -> Unit ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() NofficeScaffold( - modifier = modifier, topBar = { HomeTopBar( tabs = enumValues(), @@ -48,7 +51,7 @@ fun OrganizationScreen( ) } Column( - modifier = Modifier + modifier = modifier .padding(top = it.calculateTopPadding()) .screenHorizonPadding() ) { @@ -57,7 +60,7 @@ fun OrganizationScreen( text = stringResource(id = R.string.organization_new), iconId = R.drawable.ic_plus ) { - + viewModel.postIntent(OrganizationIntent.ClickOrganizationCreation) } LazyColumn( modifier = Modifier.fillMaxSize() @@ -75,4 +78,10 @@ fun OrganizationScreen( } } + + viewModel.sideEffect.collectInSideEffectWithLifecycle {sideEffect -> + when(sideEffect) { + is OrganizationSideEffect.NavigateToCreation -> { navigateToCreation() } + } + } } \ No newline at end of file diff --git a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationViewModel.kt b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationViewModel.kt index 3737379e..e5cdea6d 100644 --- a/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationViewModel.kt +++ b/feature/organization/src/main/java/com/easyhz/noffice/feature/organization/screen/organization/OrganizationViewModel.kt @@ -14,6 +14,12 @@ class OrganizationViewModel @Inject constructor( initialState = OrganizationState.init() ) { override fun handleIntent(intent: OrganizationIntent) { - TODO("Not yet implemented") + when(intent) { + is OrganizationIntent.ClickOrganizationCreation -> { onClickOrganizationCreation() } + } + } + + private fun onClickOrganizationCreation() { + postSideEffect { OrganizationSideEffect.NavigateToCreation } } } \ No newline at end of file