From 6517b267d3a05c1fc9e08c3662fec97b509a14de Mon Sep 17 00:00:00 2001 From: jinukeu Date: Wed, 31 Jan 2024 12:27:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B0=9B=EC=9D=80=20=EB=B4=89=ED=88=AC?= =?UTF-8?q?=20=ED=8E=B8=EC=A7=91=20ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/susu/core/ui/util/Date.kt | 4 +- .../susu/feature/navigator/MainNavigator.kt | 6 +- .../ReceivedEnvelopeDetailScreen.kt | 11 +- .../ReceivedEnvelopeEditContract.kt | 23 ++ .../ReceivedEnvelopeEditScreen.kt | 210 ++++++++++++------ .../ReceivedEnvelopeEditViewModel.kt | 53 +++++ .../received/navigation/ReceivedNavigation.kt | 15 +- 7 files changed, 236 insertions(+), 86 deletions(-) create mode 100644 feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditContract.kt create mode 100644 feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditViewModel.kt diff --git a/core/ui/src/main/java/com/susu/core/ui/util/Date.kt b/core/ui/src/main/java/com/susu/core/ui/util/Date.kt index a9973a8e..024825cb 100644 --- a/core/ui/src/main/java/com/susu/core/ui/util/Date.kt +++ b/core/ui/src/main/java/com/susu/core/ui/util/Date.kt @@ -18,8 +18,8 @@ fun LocalDateTime.to_yyyy_dot_MM_dot_dd(): String { * 2023년 11월 25일 */ @Suppress("detekt:FunctionNaming") -fun LocalDateTime.to_yyyy_korYear_MM_korMonth_dd_korDay(): String { - val formatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일") +fun LocalDateTime.to_yyyy_korYear_M_korMonth_d_korDay(): String { + val formatter = DateTimeFormatter.ofPattern("yyyy년 M월 d일") return this.format(formatter) } diff --git a/feature/navigator/src/main/java/com/susu/feature/navigator/MainNavigator.kt b/feature/navigator/src/main/java/com/susu/feature/navigator/MainNavigator.kt index b2cb8055..3573806f 100644 --- a/feature/navigator/src/main/java/com/susu/feature/navigator/MainNavigator.kt +++ b/feature/navigator/src/main/java/com/susu/feature/navigator/MainNavigator.kt @@ -60,7 +60,7 @@ internal class MainNavigator( ReceivedRoute.ledgerSearchRoute, ReceivedRoute.ledgerFilterRoute("{${ReceivedRoute.FILTER_ARGUMENT_NAME}}"), ReceivedRoute.envelopeDetailRoute("{${ReceivedRoute.ENVELOPE_ARGUMENT_NAME}}"), - ReceivedRoute.envelopeEditRoute, + ReceivedRoute.envelopeEditRoute("{${ReceivedRoute.ENVELOPE_ARGUMENT_NAME}}"), SentRoute.sentEnvelopeRoute, SentRoute.sentEnvelopeDetailRoute, SentRoute.sentEnvelopeEditRoute, @@ -172,8 +172,8 @@ internal class MainNavigator( navController.navigateReceivedEnvelopeDetail(envelope) } - fun navigateReceivedEnvelopeEdit() { - navController.navigateReceivedEnvelopeEdit() + fun navigateReceivedEnvelopeEdit(envelope: Envelope) { + navController.navigateReceivedEnvelopeEdit(envelope) } fun navigateVoteAdd() { diff --git a/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt b/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt index 7d3c47d1..84bbaa1f 100644 --- a/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt +++ b/feature/received/src/main/java/com/susu/feature/received/envelopedetail/ReceivedEnvelopeDetailScreen.kt @@ -25,12 +25,13 @@ import com.susu.core.designsystem.component.appbar.icon.DeleteText import com.susu.core.designsystem.component.appbar.icon.EditText import com.susu.core.designsystem.theme.Gray100 import com.susu.core.designsystem.theme.SusuTheme +import com.susu.core.model.Envelope import com.susu.core.ui.DialogToken import com.susu.core.ui.SnackbarToken import com.susu.core.ui.extension.collectWithLifecycle import com.susu.core.ui.extension.toMoneyFormat import com.susu.core.ui.util.to_yyyy_dot_MM_dot_dd -import com.susu.core.ui.util.to_yyyy_korYear_MM_korMonth_dd_korDay +import com.susu.core.ui.util.to_yyyy_korYear_M_korMonth_d_korDay import com.susu.feature.received.R import com.susu.feature.received.envelopedetail.component.DetailItem import kotlinx.datetime.toJavaLocalDateTime @@ -40,7 +41,7 @@ fun ReceivedEnvelopeDetailRoute( viewModel: ReceivedEnvelopeDetailViewModel = hiltViewModel(), popBackStackWithDeleteReceivedEnvelopeId: (Long) -> Unit, popBackStackWithReceivedEnvelope: (String) -> Unit, - navigateReceivedEnvelopeEdit: () -> Unit, + navigateReceivedEnvelopeEdit: (Envelope) -> Unit, handleException: (Throwable, () -> Unit) -> Unit, onShowSnackbar: (SnackbarToken) -> Unit, onShowDialog: (DialogToken) -> Unit, @@ -50,7 +51,7 @@ fun ReceivedEnvelopeDetailRoute( viewModel.sideEffect.collectWithLifecycle { sideEffect -> when (sideEffect) { is ReceivedEnvelopeDetailSideEffect.HandleException -> handleException(sideEffect.throwable, sideEffect.retry) - is ReceivedEnvelopeDetailSideEffect.NavigateReceivedEnvelopeEdit -> TODO() + is ReceivedEnvelopeDetailSideEffect.NavigateReceivedEnvelopeEdit -> navigateReceivedEnvelopeEdit(sideEffect.envelope) is ReceivedEnvelopeDetailSideEffect.PopBackStackWithDeleteReceivedEnvelopeId -> popBackStackWithDeleteReceivedEnvelopeId( sideEffect.envelopeId, ) @@ -84,7 +85,7 @@ fun ReceivedEnvelopeDetailRoute( ReceivedEnvelopeDetailScreen( uiState = uiState, - onClickEdit = navigateReceivedEnvelopeEdit, + onClickEdit = viewModel::navigateEnvelopeEdit, onClickDelete = viewModel::showDeleteDialog, onClickBackIcon = viewModel::popBackStackWithEnvelope, ) @@ -151,7 +152,7 @@ fun ReceivedEnvelopeDetailScreen( ) DetailItem( categoryText = stringResource(com.susu.core.ui.R.string.word_date), - contentText = uiState.envelope.handedOverAt.toJavaLocalDateTime().to_yyyy_korYear_MM_korMonth_dd_korDay(), + contentText = uiState.envelope.handedOverAt.toJavaLocalDateTime().to_yyyy_korYear_M_korMonth_d_korDay(), isEmptyContent = false, ) DetailItem( diff --git a/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditContract.kt b/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditContract.kt new file mode 100644 index 00000000..3785dd52 --- /dev/null +++ b/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditContract.kt @@ -0,0 +1,23 @@ +package com.susu.feature.received.envelopeedit + +import com.susu.core.model.Envelope +import com.susu.core.model.Relationship +import com.susu.core.ui.base.SideEffect +import com.susu.core.ui.base.UiState +import com.susu.feature.received.envelopeadd.content.relationship.RelationShipSideEffect +import kotlinx.collections.immutable.PersistentList +import kotlinx.collections.immutable.persistentListOf + +data class ReceivedEnvelopeEditState( + val envelope: Envelope = Envelope(), + val relationshipConfig: PersistentList = persistentListOf(Relationship()), + val showCustomRelationButton: Boolean = false, + val showDateBottomSheet: Boolean = false, + val isRelationSaved: Boolean = false, +) : UiState { +} + +sealed interface ReceivedEnvelopeEditSideEffect : SideEffect { + data object PopBackStack : ReceivedEnvelopeEditSideEffect + data class HandleException(val throwable: Throwable, val retry: () -> Unit) : ReceivedEnvelopeEditSideEffect +} diff --git a/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditScreen.kt b/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditScreen.kt index fef75fea..cf78aad1 100644 --- a/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditScreen.kt +++ b/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditScreen.kt @@ -12,20 +12,29 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.susu.core.designsystem.component.appbar.SusuDefaultAppBar import com.susu.core.designsystem.component.appbar.icon.BackIcon +import com.susu.core.designsystem.component.bottomsheet.datepicker.SusuDatePickerBottomSheet +import com.susu.core.designsystem.component.bottomsheet.datepicker.SusuLimitDatePickerBottomSheet import com.susu.core.designsystem.component.button.AddConditionButton import com.susu.core.designsystem.component.button.FilledButtonColor import com.susu.core.designsystem.component.button.MediumButtonStyle @@ -33,36 +42,79 @@ import com.susu.core.designsystem.component.button.SmallButtonStyle import com.susu.core.designsystem.component.button.SusuFilledButton import com.susu.core.designsystem.component.textfield.SusuBasicTextField import com.susu.core.designsystem.component.textfield.SusuPriceTextField +import com.susu.core.designsystem.component.textfieldbutton.SusuTextFieldWrapContentButton +import com.susu.core.designsystem.component.textfieldbutton.TextFieldButtonColor +import com.susu.core.designsystem.component.textfieldbutton.style.SmallTextFieldButtonStyle import com.susu.core.designsystem.theme.Gray30 import com.susu.core.designsystem.theme.Gray40 import com.susu.core.designsystem.theme.Gray70 +import com.susu.core.designsystem.theme.Gray80 import com.susu.core.designsystem.theme.SusuTheme +import com.susu.core.model.Relationship +import com.susu.core.ui.extension.collectWithLifecycle +import com.susu.core.ui.extension.susuClickable +import com.susu.core.ui.util.AnnotatedText import com.susu.feature.received.R import com.susu.feature.received.envelopeedit.component.EditDetailItem @Composable fun ReceivedEnvelopeEditRoute( - @Suppress("detekt:UnusedParameter") + viewModel: ReceivedEnvelopeEditViewModel = hiltViewModel(), popBackStack: () -> Unit, + handleException: (Throwable, () -> Unit) -> Unit, ) { - ReceivedEnvelopeEditScreen() + val uiState = viewModel.uiState.collectAsStateWithLifecycle().value + + val focusRequester = remember { FocusRequester() } + val scope = rememberCoroutineScope() + + viewModel.sideEffect.collectWithLifecycle { sideEffect -> + when (sideEffect) { + is ReceivedEnvelopeEditSideEffect.HandleException -> handleException( + sideEffect.throwable, + sideEffect.retry, + ) + + ReceivedEnvelopeEditSideEffect.PopBackStack -> popBackStack() + } + } + + LaunchedEffect(key1 = Unit) { + viewModel.initData() + } + + + ReceivedEnvelopeEditScreen( + uiState = uiState, + focusRequester = focusRequester, + onClickBackIcon = viewModel::popBackStack, + ) } +@OptIn(ExperimentalMaterial3Api::class) @Composable fun ReceivedEnvelopeEditScreen( - modifier: Modifier = Modifier, + uiState: ReceivedEnvelopeEditState = ReceivedEnvelopeEditState(), + focusRequester: FocusRequester = remember { FocusRequester() }, onClickBackIcon: () -> Unit = {}, onClickSave: () -> Unit = {}, + onTextChangeMoney: (String) -> Unit = {}, + onTextChangeName: (String) -> Unit = {}, + onClickRelation: (Relationship) -> Unit = {}, + onClickCustomRelationClear: () -> Unit = {}, + onClickCustomRelationClose: () -> Unit = {}, + onClickRelationInnerButton: () -> Unit = {}, + onClickAddConditionButton: () -> Unit = {}, + onClickDate: () -> Unit = {}, + onClickHasVisited: (Boolean) -> Unit = {}, + onTextChangeGift: (String) -> Unit = {}, + onTextChangePhoneNumber: (String) -> Unit = {}, + onTextChangeMemo: (String) -> Unit = {}, + onDismissDateBottomSheet: (Int, Int, Int) -> Unit = { _, _, _ -> }, + onItemSelectedDateBottomSheet: (Int, Int, Int) -> Unit = { _, _, _ -> }, ) { - // TODO: 수정 필요 - var money by remember { mutableStateOf(150000) } - var name by remember { mutableStateOf("김철수") } - var present by remember { mutableStateOf("") } - var phone by remember { mutableStateOf("") } - var memo by remember { mutableStateOf("") } - Box( - modifier = modifier + modifier = Modifier .fillMaxSize() .background(SusuTheme.colorScheme.background10), ) { @@ -75,7 +127,7 @@ fun ReceivedEnvelopeEditScreen( }, ) Column( - modifier = modifier + modifier = Modifier .verticalScroll(rememberScrollState()) .weight(1f) .padding( @@ -85,59 +137,67 @@ fun ReceivedEnvelopeEditScreen( ), ) { SusuPriceTextField( - text = money.toString(), - onTextChange = { money = it.toInt() }, + text = uiState.envelope.amount.toString(), + onTextChange = onTextChangeMoney, textStyle = SusuTheme.typography.title_xxl, - modifier = modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), ) - Spacer(modifier = modifier.size(SusuTheme.spacing.spacing_m)) + Spacer(modifier = Modifier.size(SusuTheme.spacing.spacing_m)) EditDetailItem( categoryText = stringResource(R.string.received_envelope_edit_screen_name), categoryTextAlign = Alignment.CenterVertically, ) { SusuBasicTextField( - text = name, - onTextChange = { name = it }, + text = uiState.envelope.friend.name, + onTextChange = onTextChangeName, placeholder = stringResource(R.string.received_envelope_edit_screen_name_placeholder), placeholderColor = Gray30, textStyle = SusuTheme.typography.title_s, - modifier = modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), ) } EditDetailItem( categoryText = stringResource(R.string.received_envelope_edit_screen_relationship), categoryTextAlign = Alignment.Top, ) { - SusuFilledButton( - color = FilledButtonColor.Orange, - style = SmallButtonStyle.height32, - text = "친구", - isActive = true, - onClick = {}, - ) - SusuFilledButton( - color = FilledButtonColor.Orange, - style = SmallButtonStyle.height32, - text = "가족", - isActive = false, - onClick = {}, - ) - SusuFilledButton( - color = FilledButtonColor.Orange, - style = SmallButtonStyle.height32, - text = "친척", - isActive = false, - onClick = {}, - ) - SusuFilledButton( - color = FilledButtonColor.Orange, - style = SmallButtonStyle.height32, - text = "동료", - isActive = false, - onClick = {}, - ) - AddConditionButton( - onClick = {}, + uiState.relationshipConfig.dropLast(1).forEach { + SusuFilledButton( + color = FilledButtonColor.Orange, + style = SmallButtonStyle.height32, + text = it.relation, + isActive = it == uiState.envelope.relationship, + onClick = { onClickRelation(it) }, + ) + } + + if (uiState.showCustomRelationButton) { + SusuTextFieldWrapContentButton( + focusRequester = focusRequester, + onTextChange = {}, + color = TextFieldButtonColor.Orange, + style = SmallTextFieldButtonStyle.height32, + text = uiState.envelope.relationship.customRelation ?: "", + isFocused = uiState.relationshipConfig.last().id == uiState.envelope.relationship.id, + isSaved = uiState.isRelationSaved, + onClickClearIcon = onClickCustomRelationClear, + onClickCloseIcon = onClickCustomRelationClose, + onClickFilledButton = onClickRelationInnerButton, + onClickButton = { onClickRelation(uiState.relationshipConfig.last()) }, + ) + } else { + AddConditionButton(onClick = onClickAddConditionButton) + } + } + EditDetailItem(categoryText = stringResource(id = com.susu.core.ui.R.string.word_date), categoryTextAlign = Alignment.Top) { + Text( + modifier = Modifier.susuClickable(rippleEnabled = false, onClick = onClickDate), + text = stringResource( + R.string.ledger_add_screen_date, + uiState.envelope.handedOverAt.year, + uiState.envelope.handedOverAt.month.value, + uiState.envelope.handedOverAt.dayOfMonth, + ), + style = SusuTheme.typography.title_m, ) } EditDetailItem( @@ -148,68 +208,78 @@ fun ReceivedEnvelopeEditScreen( color = FilledButtonColor.Orange, style = SmallButtonStyle.height32, text = stringResource(com.susu.core.ui.R.string.word_yes), - isActive = true, - onClick = {}, - modifier = modifier.weight(1f), + isActive = uiState.envelope.hasVisited == true, + onClick = { onClickHasVisited(true) }, + modifier = Modifier.weight(1f), ) SusuFilledButton( color = FilledButtonColor.Orange, style = SmallButtonStyle.height32, text = stringResource(com.susu.core.ui.R.string.word_no), - isActive = false, - onClick = {}, - modifier = modifier.weight(1f), + isActive = uiState.envelope.hasVisited == false, + onClick = { onClickHasVisited(false) }, + modifier = Modifier.weight(1f), ) } EditDetailItem( categoryText = stringResource(R.string.received_envelope_edit_screen_present), - categoryTextColor = if (present.isNotEmpty()) Gray70 else Gray40, + categoryTextColor = if (!uiState.envelope.gift.isNullOrEmpty()) Gray70 else Gray40, categoryTextAlign = Alignment.CenterVertically, ) { SusuBasicTextField( - text = present, - onTextChange = { present = it }, + text = uiState.envelope.gift ?: "", + onTextChange = onTextChangeGift, placeholder = stringResource(R.string.received_envelope_edit_screen_present_placeholder), placeholderColor = Gray30, textStyle = SusuTheme.typography.title_s, - modifier = modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), ) } EditDetailItem( categoryText = stringResource(com.susu.core.ui.R.string.word_phone_number), - categoryTextColor = if (phone.isNotEmpty()) Gray70 else Gray40, + categoryTextColor = if (uiState.envelope.friend.phoneNumber.isNotEmpty()) Gray70 else Gray40, categoryTextAlign = Alignment.CenterVertically, ) { SusuBasicTextField( - text = phone, - onTextChange = { phone = it }, + text = uiState.envelope.friend.phoneNumber, + onTextChange = onTextChangePhoneNumber, placeholder = stringResource(R.string.received_envelope_edit_screen_phone_number_placeholder), placeholderColor = Gray30, textStyle = SusuTheme.typography.title_s, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), - modifier = modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), ) } EditDetailItem( categoryText = stringResource(com.susu.core.ui.R.string.word_memo), - categoryTextColor = if (memo.isNotEmpty()) Gray70 else Gray40, + categoryTextColor = if (!uiState.envelope.memo.isNullOrEmpty()) Gray70 else Gray40, categoryTextAlign = Alignment.Top, ) { SusuBasicTextField( - text = memo, - onTextChange = { memo = it }, + text = uiState.envelope.memo ?: "", + onTextChange = onTextChangeMemo, placeholder = stringResource(R.string.received_envelope_edit_screen_memo_placeholder), placeholderColor = Gray30, textStyle = SusuTheme.typography.title_s, - maxLines = 2, - modifier = modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), ) } - Spacer(modifier = modifier.size(240.dp)) + Spacer(modifier = Modifier.size(240.dp)) + } + + if (uiState.showDateBottomSheet) { + SusuDatePickerBottomSheet( + initialYear = uiState.envelope.handedOverAt.year, + initialMonth = uiState.envelope.handedOverAt.month.value, + initialDay = uiState.envelope.handedOverAt.dayOfMonth, + maximumContainerHeight = 346.dp, + onDismissRequest = onDismissDateBottomSheet, + onItemSelected = onItemSelectedDateBottomSheet, + ) } SusuFilledButton( - modifier = modifier + modifier = Modifier .fillMaxWidth() .imePadding(), color = FilledButtonColor.Black, diff --git a/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditViewModel.kt b/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditViewModel.kt new file mode 100644 index 00000000..dae702d6 --- /dev/null +++ b/feature/received/src/main/java/com/susu/feature/received/envelopeedit/ReceivedEnvelopeEditViewModel.kt @@ -0,0 +1,53 @@ +package com.susu.feature.received.envelopeedit + +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.viewModelScope +import com.susu.core.model.Envelope +import com.susu.core.ui.base.BaseViewModel +import com.susu.core.ui.extension.decodeFromUri +import com.susu.core.ui.extension.encodeToUri +import com.susu.domain.usecase.envelope.DeleteEnvelopeUseCase +import com.susu.domain.usecase.envelope.GetEnvelopeUseCase +import com.susu.domain.usecase.envelope.GetRelationShipConfigListUseCase +import com.susu.feature.received.navigation.ReceivedRoute +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.collections.immutable.toPersistentList +import kotlinx.coroutines.launch +import kotlinx.serialization.json.Json +import timber.log.Timber +import javax.inject.Inject + +@HiltViewModel +class ReceivedEnvelopeEditViewModel @Inject constructor( + private val getRelationShipConfigListUseCase: GetRelationShipConfigListUseCase, + savedStateHandle: SavedStateHandle, +) : BaseViewModel( + ReceivedEnvelopeEditState(), +) { + private val argument = savedStateHandle.get(ReceivedRoute.ENVELOPE_ARGUMENT_NAME)!! + + private var isFirstVisited: Boolean = true + + fun initData() = viewModelScope.launch { + if (isFirstVisited.not()) return@launch + isFirstVisited = false + + val envelope = Json.decodeFromUri(argument) + + getRelationShipConfigListUseCase() + .onSuccess { + intent { + copy( + envelope = envelope, + relationshipConfig = it.toPersistentList(), + showCustomRelationButton = it.last().id == envelope.relationship.id, + isRelationSaved = it.last().id == envelope.relationship.id, + ) + } + } + } + + + fun popBackStack() = postSideEffect(ReceivedEnvelopeEditSideEffect.PopBackStack) + +} diff --git a/feature/received/src/main/java/com/susu/feature/received/navigation/ReceivedNavigation.kt b/feature/received/src/main/java/com/susu/feature/received/navigation/ReceivedNavigation.kt index fe87b0de..b9117123 100644 --- a/feature/received/src/main/java/com/susu/feature/received/navigation/ReceivedNavigation.kt +++ b/feature/received/src/main/java/com/susu/feature/received/navigation/ReceivedNavigation.kt @@ -56,8 +56,8 @@ fun NavController.navigateReceivedEnvelopeDetail(envelope: Envelope) { navigate(ReceivedRoute.envelopeDetailRoute(Json.encodeToUri(envelope))) } -fun NavController.navigateReceivedEnvelopeEdit() { - navigate(ReceivedRoute.envelopeEditRoute) +fun NavController.navigateReceivedEnvelopeEdit(envelope: Envelope) { + navigate(ReceivedRoute.envelopeEditRoute(Json.encodeToUri(envelope))) } @Suppress("detekt:LongMethod") @@ -74,7 +74,7 @@ fun NavGraphBuilder.receivedNavGraph( navigateLedgerAdd: () -> Unit, navigateEnvelopAdd: (String, Long) -> Unit, navigateEnvelopeDetail: (Envelope) -> Unit, - navigateEnvelopeEdit: () -> Unit, + navigateEnvelopeEdit: (Envelope) -> Unit, popBackStackWithEnvelope: (String) -> Unit, popBackStackWithDeleteReceivedEnvelopeId: (Long) -> Unit, onShowSnackbar: (SnackbarToken) -> Unit, @@ -189,9 +189,12 @@ fun NavGraphBuilder.receivedNavGraph( } composable( - route = ReceivedRoute.envelopeEditRoute, + route = ReceivedRoute.envelopeEditRoute("{${ReceivedRoute.ENVELOPE_ARGUMENT_NAME}}"), ) { - ReceivedEnvelopeEditRoute(popBackStack = popBackStack) + ReceivedEnvelopeEditRoute( + popBackStack = popBackStack, + handleException = handleException, + ) } } @@ -213,5 +216,5 @@ object ReceivedRoute { fun envelopeAddRoute(categoryName: String, ledgerId: String) = "envelope-add/$categoryName/$ledgerId" fun envelopeDetailRoute(envelope: String) = "envelope-detail/$envelope" - const val envelopeEditRoute = "envelope-edit" // TODO 파라미터 넘기는 방식으로 수정해야함. + fun envelopeEditRoute(envelope: String) = "envelope-edit/$envelope" }