From 5c6fb8579905257170ad492fb0b9210c6566157a Mon Sep 17 00:00:00 2001 From: 0se0 <030ggong@gmail.com> Date: Tue, 8 Oct 2024 18:59:51 +0900 Subject: [PATCH] Feature #247: nickname, edit success --- .../com/hankki/feature/main/MainNavigator.kt | 13 +- .../com/hankki/feature/main/MainScreen.kt | 8 +- .../feature/storedetail/EditMenuRoute.kt | 143 +++++----- .../feature/storedetail/EditModRoute.kt | 92 +++++-- .../storedetail/EditModSucceedRoute.kt | 76 ++++++ .../feature/storedetail/StoreDetailRoute.kt | 1 + .../component/HankkiModTextField.kt | 12 +- .../storedetail/component/RollbackButton.kt | 48 ++++ .../navigation/navigateStoreDetail.kt | 59 +++- .../main/res/drawable/img_edit_completed.xml | 254 ++++++++++++++++++ 10 files changed, 611 insertions(+), 95 deletions(-) create mode 100644 feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModSucceedRoute.kt create mode 100644 feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/RollbackButton.kt create mode 100644 feature/storedetail/src/main/res/drawable/img_edit_completed.xml diff --git a/feature/main/src/main/java/com/hankki/feature/main/MainNavigator.kt b/feature/main/src/main/java/com/hankki/feature/main/MainNavigator.kt index 57f431df..b454db2f 100644 --- a/feature/main/src/main/java/com/hankki/feature/main/MainNavigator.kt +++ b/feature/main/src/main/java/com/hankki/feature/main/MainNavigator.kt @@ -165,17 +165,18 @@ internal class MainNavigator( currentDestination?.hasRoute(it::class) == true } && (currentTab?.showBottomSheet ?: true) - fun navigateToAddMenu(storeId: Long, navOptions: NavOptions? = null) { - navController.navigate("add_menu_route/$storeId", navOptions) + fun navigateToEditMenu(storeId: Long, navOptions: NavOptions? = null) { + navController.navigate("edit_menu_route/$storeId", navOptions) } - fun navigateToEditMenu(storeId: Long, navOptions: NavOptions? = null){ - navController.navigate("modify_menu_route/$storeId", navOptions) + fun navigateToEditMod(storeId: Long, menuId: Long, menuName: String, price: String) { + navController.navigate("edit_mod_route/$storeId/$menuId/$menuName/$price") } - fun navigateToEditMod(storeId: Long, menuId: Long, menuName: String, price: String) { - navController.navigate("modify_menu_route/$storeId/$menuId/$menuName/$price") + fun navigateToEditSuccess(storeId: Long) { + navController.navigate("edit_mod_success_route/$storeId") } + } @Composable diff --git a/feature/main/src/main/java/com/hankki/feature/main/MainScreen.kt b/feature/main/src/main/java/com/hankki/feature/main/MainScreen.kt index 5e6145fc..22e747ab 100644 --- a/feature/main/src/main/java/com/hankki/feature/main/MainScreen.kt +++ b/feature/main/src/main/java/com/hankki/feature/main/MainScreen.kt @@ -59,7 +59,6 @@ import com.hankki.core.designsystem.theme.HankkiTheme import com.hankki.core.designsystem.theme.HankkijogboTheme import com.hankki.core.designsystem.theme.Red500 import com.hankki.core.designsystem.theme.White -import com.hankki.core.designsystem.theme.hankkiTypography import com.hankki.feature.home.navigation.Home import com.hankki.feature.home.navigation.homeNavGraph import com.hankki.feature.login.navigation.Login @@ -293,13 +292,16 @@ internal fun MainScreen( } ) storeDetailNavGraph( + navController = navigator.navController, navigateUp = navigator::navigateUpIfNotHome, navigateToAddNewJogbo = navigator::navigateToNewJogbo, onShowSnackBar = onShowTextSnackBarWithButton, onShowTextSnackBar = onShowErrorSnackBar, - navigateToAddMenu = { storeId -> navigator.navigateToAddMenu(storeId) }, + navigateToAddMenu = { storeId -> navigator.navigateToEditMenu(storeId) }, navigateToEditMenu = { storeId-> navigator.navigateToEditMenu(storeId) }, - navigateToEditMod = { storeId, menuId, menuName, price -> navigator.navigateToEditMod(storeId, menuId, menuName, price) } + navigateToEditMod = { storeId, menuId, menuName, price -> navigator.navigateToEditMod(storeId, menuId, menuName, price) }, + navigateToEditSuccess = { storeId -> navigator.navigateToEditSuccess(storeId) }, + navigateToStoreDetail = { storeId -> navigator.navigateToStoreDetail(storeId) } ) } diff --git a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditMenuRoute.kt b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditMenuRoute.kt index 5ef05109..92d87d1c 100644 --- a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditMenuRoute.kt +++ b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditMenuRoute.kt @@ -26,6 +26,7 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.hankki.core.common.extension.noRippleClickable import com.hankki.core.common.utill.UiState +import com.hankki.core.designsystem.component.layout.BottomBlurLayout import com.hankki.core.designsystem.component.layout.HankkiLoadingScreen import com.hankki.core.designsystem.component.topappbar.HankkiTopBar import com.hankki.core.designsystem.theme.Gray700 @@ -72,84 +73,98 @@ fun EditMenuScreen( ) { var selectedMenu by remember { mutableStateOf(null) } - Column( + Box( modifier = Modifier .fillMaxSize() ) { Column( modifier = Modifier - .weight(0.9f) + .fillMaxSize() ) { - Spacer(modifier = Modifier.statusBarsPadding()) - HankkiTopBar( - leadingIcon = { - Icon( - painter = painterResource(com.hankki.core.designsystem.R.drawable.ic_arrow_left), - contentDescription = "뒤로가기", - modifier = Modifier - .offset(x = 6.dp, y = 2.dp) - .noRippleClickable(onClick = onNavigateUp), - tint = Gray700 - ) - } - ) + Column( + modifier = Modifier + .weight(0.9f) + ) { + Spacer(modifier = Modifier.statusBarsPadding()) + HankkiTopBar( + leadingIcon = { + Icon( + painter = painterResource(com.hankki.core.designsystem.R.drawable.ic_arrow_left), + contentDescription = "뒤로가기", + modifier = Modifier + .offset(x = 6.dp, y = 2.dp) + .noRippleClickable(onClick = onNavigateUp), + tint = Gray700 + ) + } + ) - Spacer(modifier = Modifier.padding(top = 18.dp)) - Text( - text = "어떤 메뉴를 편집할까요?", - style = HankkiTheme.typography.suitH2, - color = Gray900, - modifier = Modifier.padding(start = 22.dp) - ) + Spacer(modifier = Modifier.padding(top = 18.dp)) + Text( + text = "어떤 메뉴를 편집할까요?", + style = HankkiTheme.typography.suitH2, + color = Gray900, + modifier = Modifier.padding(start = 22.dp) + ) - when (storeDetailState) { - UiState.Loading -> { - Box( - modifier = Modifier - .fillMaxSize() - .background(White) - ) { - HankkiLoadingScreen(modifier = Modifier.align(Alignment.Center)) + when (storeDetailState) { + UiState.Loading -> { + Box( + modifier = Modifier + .fillMaxSize() + .background(White) + ) { + HankkiLoadingScreen(modifier = Modifier.align(Alignment.Center)) + } } - } - is UiState.Success -> { - menuItems.forEach { menuItem -> - MenuItemComponent( - menuItem = menuItem, - selectedMenu = selectedMenu?.name, - onMenuSelected = { - selectedMenu = menuItem - onMenuSelected(menuItem.name) - } - ) + is UiState.Success -> { + menuItems.forEach { menuItem -> + MenuItemComponent( + menuItem = menuItem, + selectedMenu = selectedMenu?.name, + onMenuSelected = { + selectedMenu = menuItem + onMenuSelected(menuItem.name) + } + ) + } } - } - UiState.Failure -> {} + UiState.Failure -> {} + } } - } - SegmentedButton( - option1 = "삭제하기", - option2 = "수정하기", - onOptionSelected = { selectedOption -> - if (selectedOption == "삭제하기") { - onDeleteMenuClick() - } else if (selectedOption == "수정하기") { - selectedMenu?.let { menu -> - onEditModClick(menu.id, menu.name, menu.price.toString()) + SegmentedButton( + option1 = "삭제하기", + option2 = "수정하기", + onOptionSelected = { selectedOption -> + if (selectedOption == "삭제하기") { + onDeleteMenuClick() + } else if (selectedOption == "수정하기") { + selectedMenu?.let { menu -> + onEditModClick(menu.id, menu.name, menu.price.toString()) + } } - } - }, - modifier = Modifier - .fillMaxWidth() - .weight(0.0675f) - ) - Spacer( - modifier = Modifier - .padding(bottom = 15.dp) - .navigationBarsPadding() - ) + }, + modifier = Modifier + .fillMaxWidth() + .weight(0.0675f) + ) + + Spacer( + modifier = Modifier + .padding(bottom = 15.dp) + .navigationBarsPadding() + ) + } + +// if (selectedMenu == null) { +// BottomBlurLayout( +// imageBlur = com.hankki.core.designsystem.R.drawable.img_white_gradient_bottom_middle, +// modifier = Modifier.align(Alignment.BottomCenter) +// ) +// } + } } diff --git a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModRoute.kt b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModRoute.kt index 325641c0..05d43330 100644 --- a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModRoute.kt +++ b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModRoute.kt @@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable 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.Modifier import androidx.compose.ui.focus.FocusManager @@ -30,16 +31,19 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.hankki.core.common.extension.noRippleClickable -import com.hankki.core.designsystem.component.button.HankkiButton import com.hankki.core.designsystem.component.button.HankkiExpandedButton +import com.hankki.core.designsystem.component.button.HankkiMediumButton import com.hankki.core.designsystem.component.topappbar.HankkiTopBar import com.hankki.core.designsystem.theme.Gray400 import com.hankki.core.designsystem.theme.Gray700 import com.hankki.core.designsystem.theme.Gray900 import com.hankki.core.designsystem.theme.HankkiTheme +import com.hankki.core.designsystem.theme.Red400 import com.hankki.core.designsystem.theme.Red500 import com.hankki.feature.storedetail.component.HankkiModMenuField import com.hankki.feature.storedetail.component.HankkiModPriceField +import com.hankki.feature.storedetail.component.RollbackButton +import kotlinx.coroutines.launch @Composable fun EditModRoute( @@ -49,19 +53,24 @@ fun EditModRoute( price: String, viewModel: StoreDetailViewModel = hiltViewModel(), onNavigateUp: () -> Unit, - onMenuUpdated: (String, String) -> Unit + onMenuUpdated: (String, String) -> Unit, + navigateToEditSuccess: (Long) -> Unit ) { var updatedMenuName by remember { mutableStateOf(menuName) } var updatedPrice by remember { mutableStateOf(price) } var isPriceValid by remember { mutableStateOf(true) } var isMenuFocused by remember { mutableStateOf(false) } + var isPriceFocused by remember { mutableStateOf(false) } val focusManager = LocalFocusManager.current + val coroutineScope = rememberCoroutineScope() ModifyMenuScreen( menuName = menuName, updatedMenuName = updatedMenuName, price = updatedPrice, + updatedPrice = updatedPrice, isMenuFocused = isMenuFocused, + isPriceFocused = isPriceFocused, onMenuNameChanged = { updatedMenuName = it }, onPriceChanged = { newPrice -> updatedPrice = newPrice @@ -71,12 +80,18 @@ fun EditModRoute( onNavigateUp = onNavigateUp, onSubmit = { if (isPriceValid) { - viewModel.updateMenu(storeId, menuId, updatedMenuName, updatedPrice.toInt()) - onMenuUpdated(updatedMenuName, updatedPrice) - onNavigateUp() + coroutineScope.launch { + val parsedPrice = updatedPrice.toIntOrNull() + if (parsedPrice != null && parsedPrice <= 8000) { + viewModel.updateMenu(storeId, menuId, updatedMenuName, parsedPrice) + onMenuUpdated(updatedMenuName, updatedPrice) + navigateToEditSuccess(storeId) + } + } } }, onMenuFocused = { isFocused -> isMenuFocused = isFocused }, + onPriceFocused = { isFocused -> isPriceFocused = isFocused }, focusManager = focusManager ) } @@ -87,17 +102,22 @@ fun ModifyMenuScreen( menuName: String, updatedMenuName: String, price: String, + updatedPrice: String, isMenuFocused: Boolean, + isPriceFocused: Boolean, onMenuNameChanged: (String) -> Unit, onPriceChanged: (String) -> Unit, isPriceValid: Boolean, onNavigateUp: () -> Unit, onSubmit: () -> Unit, onMenuFocused: (Boolean) -> Unit, + onPriceFocused: (Boolean) -> Unit, focusManager: FocusManager ) { val isVisibleIme = WindowInsets.isImeVisible - val focusManager = LocalFocusManager.current + val isSubmitEnabled = updatedMenuName.isNotBlank() && updatedPrice.isNotBlank() && isPriceValid + var showRestoreMenuNameButton by remember { mutableStateOf(false) } + var showRestorePriceButton by remember { mutableStateOf(false) } Column( modifier = Modifier @@ -156,36 +176,73 @@ fun ModifyMenuScreen( onMenuNameChanged("") } else { onMenuNameChanged(newValue) + showRestoreMenuNameButton = true } }, clearText = { onMenuNameChanged("") }, placeholder = "새로운 메뉴 이름", - onMenuFocused = onMenuFocused + onMenuFocused = { isFocused -> + onMenuFocused(isFocused) + if (!isFocused) { + showRestoreMenuNameButton = false + } + } ) - Spacer(modifier = Modifier.padding(top = 12.dp)) HankkiModPriceField( label = "가격", - priceValue = price, - onPriceValueChange = onPriceChanged, + priceValue = updatedPrice, + isFocused = isPriceFocused, + onPriceValueChange = { newValue -> + if (newValue.isEmpty()) { + onPriceChanged("") + } else { + onPriceChanged(newValue) + showRestorePriceButton = true + } + }, isError = !isPriceValid, errorMessage = "8000원 이하만 입력 가능합니다.", - clearText = { onPriceChanged("") } + clearText = { onPriceChanged("") }, + onPriceFocused = { isFocused -> + onPriceFocused(isFocused) + if (!isFocused) { + showRestorePriceButton = false + } + } ) Spacer(modifier = Modifier.weight(1f)) if (isVisibleIme) { + if (showRestoreMenuNameButton && updatedMenuName != menuName) { + RollbackButton( + text = "기존 메뉴이름 입력", + onClick = { onMenuNameChanged(menuName) } + ) + } + + if (showRestorePriceButton && updatedPrice != price) { + RollbackButton( + text = "기존 메뉴가격 입력", + onClick = { onPriceChanged(price) } + ) + } + + Spacer(modifier = Modifier.padding(top = 16.dp)) HankkiExpandedButton( modifier = Modifier .fillMaxWidth() .imePadding(), text = "적용", onClick = { - focusManager.clearFocus() + if (isSubmitEnabled) { + focusManager.clearFocus() + } }, enabled = isPriceValid, textStyle = HankkiTheme.typography.sub3, + backgroundColor = if (isSubmitEnabled) Red500 else Red400 ) } else { Text( @@ -195,17 +252,22 @@ fun ModifyMenuScreen( modifier = Modifier .padding(start = 36.dp, end = 35.dp, bottom = 12.dp) ) - HankkiButton( + HankkiMediumButton( modifier = Modifier .padding(horizontal = 22.dp) .fillMaxWidth() .navigationBarsPadding() .padding(bottom = 15.dp), text = "수정 완료", - onClick = onSubmit, + onClick = { + if (isSubmitEnabled) { + onSubmit() + } + }, enabled = isPriceValid, textStyle = HankkiTheme.typography.sub3, + backgroundColor = if (isSubmitEnabled) Red500 else Red400 ) } } -} \ No newline at end of file +} diff --git a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModSucceedRoute.kt b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModSucceedRoute.kt new file mode 100644 index 00000000..bd454d7e --- /dev/null +++ b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/EditModSucceedRoute.kt @@ -0,0 +1,76 @@ +package com.hankki.feature.storedetail + +import androidx.compose.foundation.layout.Column +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.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.NavController +import com.hankki.core.designsystem.component.button.HankkiMediumButton +import com.hankki.core.designsystem.theme.Gray900 +import com.hankki.core.designsystem.theme.HankkiTheme + +@Composable +fun EditModSucceedRoute( + storeId: Long, + viewModel: StoreDetailViewModel = hiltViewModel(), + onNavigateToEditMenu:() -> Unit, + onNavigateToStoreDetailRoute: () -> Unit +) { + val storeState by viewModel.storeState.collectAsStateWithLifecycle() + + LaunchedEffect(Unit) { + viewModel.fetchNickname() + } + + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp) + ) { + Spacer(modifier = Modifier.height(48.dp)) + Text( + text = "${storeState.nickname}님이 말씀해주신대로 메뉴 정보를 수정했어요!", + style = HankkiTheme.typography.suitH2, + color = Gray900, + modifier = Modifier.padding(start = 22.dp) + ) + Spacer(modifier = Modifier.height(32.dp)) + + Spacer(modifier = Modifier.weight(1f)) + HankkiMediumButton( + modifier = Modifier + .fillMaxWidth(), + text = "다른 메뉴도 수정하기", + onClick = { + onNavigateToEditMenu() + }, + enabled = true, + textStyle = HankkiTheme.typography.sub3 + ) + Spacer(modifier = Modifier.height(16.dp)) + HankkiMediumButton( + modifier = Modifier + .fillMaxWidth(), + text = "완료", + onClick = onNavigateToStoreDetailRoute, + enabled = true, + textStyle = HankkiTheme.typography.sub3 + ) + Spacer( + modifier = Modifier + .navigationBarsPadding() + .padding(bottom = 15.dp) + ) + } +} diff --git a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/StoreDetailRoute.kt b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/StoreDetailRoute.kt index 72b9e25c..86eec9f8 100644 --- a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/StoreDetailRoute.kt +++ b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/StoreDetailRoute.kt @@ -33,6 +33,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.NavController import coil.compose.AsyncImage import com.google.accompanist.systemuicontroller.rememberSystemUiController import com.hankki.core.common.amplitude.EventType diff --git a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/HankkiModTextField.kt b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/HankkiModTextField.kt index 903fdbef..595457cd 100644 --- a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/HankkiModTextField.kt +++ b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/HankkiModTextField.kt @@ -99,7 +99,6 @@ fun HankkiModMenuField( modifier = Modifier.weight(1f), contentAlignment = Alignment.CenterEnd ) { - innerTextField() if (menuValue.isEmpty() && isEditingMenu) { Text( text = placeholder, @@ -147,12 +146,20 @@ fun HankkiModPriceField( onPriceValueChange: (String) -> Unit, clearText: () -> Unit, isError: Boolean = false, + isFocused: Boolean, errorMessage: String = "유효하지 않은 가격입니다.", - warnRed: Color = WarnRed + warnRed: Color = WarnRed, + onPriceFocused: (Boolean) -> Unit ) { var isEditingPrice by remember { mutableStateOf(false) } val focusRequester = remember { FocusRequester() } + LaunchedEffect(isFocused) { + if (isFocused) { + focusRequester.requestFocus() + } + } + val borderColor = when { isError -> warnRed isEditingPrice -> Gray500 @@ -179,6 +186,7 @@ fun HankkiModPriceField( .focusRequester(focusRequester) .onFocusChanged { focusState -> isEditingPrice = focusState.isFocused + onPriceFocused(focusState.isFocused) }, textStyle = HankkiTheme.typography.body2.copy( color = if (isError) warnRed else Gray850, diff --git a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/RollbackButton.kt b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/RollbackButton.kt new file mode 100644 index 00000000..1f1bd608 --- /dev/null +++ b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/component/RollbackButton.kt @@ -0,0 +1,48 @@ +package com.hankki.feature.storedetail.component + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.hankki.core.common.extension.noRippleClickable +import com.hankki.core.designsystem.theme.Gray100 +import com.hankki.core.designsystem.theme.Gray600 +import com.hankki.core.designsystem.theme.HankkiTheme + +@Composable +fun RollbackButton( + text: String = "기존 메뉴이름 입력", + onClick: () -> Unit +) { + Box( + modifier = Modifier + .fillMaxWidth(), + contentAlignment = Alignment.Center + ) { + Text( + text = text, + style = HankkiTheme.typography.body6, + color = Gray600, + modifier = Modifier + .background(Gray100, shape = RoundedCornerShape(8.dp)) + .padding(horizontal = 12.dp, vertical = 8.dp) + .wrapContentSize() + .noRippleClickable(onClick = onClick) + ) + } +} + +@Preview(showBackground = true) +@Composable +fun PreviewRollbackButton() { + RollbackButton(onClick = { /* Do something */ }) +} + diff --git a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/navigation/navigateStoreDetail.kt b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/navigation/navigateStoreDetail.kt index 8df51c60..37b8c6ca 100644 --- a/feature/storedetail/src/main/java/com/hankki/feature/storedetail/navigation/navigateStoreDetail.kt +++ b/feature/storedetail/src/main/java/com/hankki/feature/storedetail/navigation/navigateStoreDetail.kt @@ -7,10 +7,12 @@ import androidx.navigation.NavOptions import androidx.navigation.NavType import androidx.navigation.compose.composable import androidx.navigation.navArgument +import androidx.navigation.navOptions import androidx.navigation.toRoute import com.hankki.core.navigation.MainTabRoute import com.hankki.feature.storedetail.EditMenuRoute import com.hankki.feature.storedetail.EditModRoute +import com.hankki.feature.storedetail.EditModSucceedRoute import com.hankki.feature.storedetail.StoreDetailRoute import com.hankki.feature.storedetail.StoreDetailViewModel import kotlinx.serialization.Serializable @@ -20,13 +22,16 @@ fun NavController.navigateStoreDetail(storeId: Long, navOptions: NavOptions?) { } fun NavGraphBuilder.storeDetailNavGraph( + navController: NavController, navigateUp: () -> Unit, navigateToAddNewJogbo: () -> Unit, onShowSnackBar: (String, Long) -> Unit, onShowTextSnackBar: (String) -> Unit, navigateToAddMenu: (Long) -> Unit, navigateToEditMenu: (Long) -> Unit, - navigateToEditMod: (Long, Long, String, String) -> Unit + navigateToStoreDetail: (Long) -> Unit, + navigateToEditMod: (Long, Long, String, String) -> Unit, + navigateToEditSuccess: (Long) -> Unit ) { composable { backStackEntry -> val items = backStackEntry.toRoute() @@ -42,7 +47,7 @@ fun NavGraphBuilder.storeDetailNavGraph( } composable( - route = "add_menu_route/{storeId}", + route = "edit_menu_route/{storeId}", arguments = listOf(navArgument("storeId") { type = NavType.LongType }) ) { backStackEntry -> val storeId = backStackEntry.arguments?.getLong("storeId") ?: 0L @@ -57,9 +62,8 @@ fun NavGraphBuilder.storeDetailNavGraph( ) } - composable( - route = "modify_menu_route/{storeId}/{menuId}/{menuName}/{price}", + route = "edit_mod_route/{storeId}/{menuId}/{menuName}/{price}", arguments = listOf( navArgument("storeId") { type = NavType.LongType }, navArgument("menuId") { type = NavType.LongType }, @@ -81,11 +85,56 @@ fun NavGraphBuilder.storeDetailNavGraph( onNavigateUp = navigateUp, onMenuUpdated = { updatedMenuName, updatedPrice -> viewModel.updateMenu(storeId, menuId, updatedMenuName, updatedPrice.toInt()) - } + navigateToEditSuccess(storeId) + }, + navigateToEditSuccess = navigateToEditSuccess ) } + composable( + route = "edit_mod_success_route/{storeId}", + arguments = listOf(navArgument("storeId") { type = NavType.LongType }) + ) { backStackEntry -> + val storeId = backStackEntry.arguments?.getLong("storeId") ?: 0L + EditModSucceedRoute( + storeId = storeId, + onNavigateToStoreDetailRoute = { + val options = navOptions { + popUpTo(navController.graph.startDestinationId) { + inclusive = true + } + launchSingleTop = true + } + navController.navigate("store_detail_route/$storeId", options) + }, + + onNavigateToEditMenu = { + val options = navOptions { + popUpTo(navController.graph.startDestinationId) { + inclusive = true + } + launchSingleTop = true + } + navController.navigate("edit_menu_route/$storeId", options) + } + ) + } + composable( + route = "store_detail_route/{storeId}", + arguments = listOf(navArgument("storeId") { type = NavType.LongType }) + ) { backStackEntry -> + val storeId = backStackEntry.arguments?.getLong("storeId") ?: 0L + StoreDetailRoute( + storeId = storeId, + navigateUp = navigateUp, + navigateToAddNewJogbo = navigateToAddNewJogbo, + onShowSnackBar = onShowSnackBar, + onShowTextSnackBar = onShowTextSnackBar, + onAddMenuClick = { navigateToAddMenu(storeId) }, + onEditMenuClick = { navigateToEditMenu(storeId) } + ) + } } @Serializable diff --git a/feature/storedetail/src/main/res/drawable/img_edit_completed.xml b/feature/storedetail/src/main/res/drawable/img_edit_completed.xml new file mode 100644 index 00000000..d38fab6e --- /dev/null +++ b/feature/storedetail/src/main/res/drawable/img_edit_completed.xml @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +