Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 사장님 가게 메뉴 등록 및 수정 네비게이션 구현 #397

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun StartInsertScreen(
.padding(top = 56.dp, start = 10.dp , bottom = 18.dp)
.width(40.dp)
.height(40.dp)
.clickable { onBackPressed }
.clickable { onBackPressed() }

) {
Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import `in`.koreatech.business.feature.store.modifyinfo.ModifyOperatingTimeScree
import `in`.koreatech.business.feature.store.storedetail.MyStoreDetailScreen
import `in`.koreatech.business.feature.store.storedetail.MyStoreDetailViewModel
import `in`.koreatech.business.navigation.MYSTORESCREEN
import `in`.koreatech.business.navigation.REGISTERSTORESCREEN
import `in`.koreatech.business.navigation.sharedHiltViewModel
import `in`.koreatech.business.navigation.toNavigateModifyMenuScreen
import `in`.koreatech.business.navigation.toNavigateRegisterMenuScreen

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.myStoreScreen(
Expand All @@ -37,7 +40,17 @@ fun NavGraphBuilder.myStoreScreen(
modifier = Modifier.fillMaxSize(),
navigateToModifyScreen = { navController.navigate(StoreRoute.MODIFY_INFO.name) },
viewModel = myStoreInfoViewModel,
modifyInfoViewModel = modifyInfoViewModel
modifyInfoViewModel = modifyInfoViewModel,
navigateToRegisterStoreScreen = {
navController.navigate(REGISTERSTORESCREEN)
},
navigateToRegisterMenuScreen = { storeId ->
navController.toNavigateRegisterMenuScreen(storeId)
},
navigateToModifyMenuScreen = {menuId ->
navController.toNavigateModifyMenuScreen(menuId)

}
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package `in`.koreatech.business.feature.store.storedetail

import android.annotation.SuppressLint
import android.util.Log
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -42,6 +43,7 @@ import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex
Expand Down Expand Up @@ -69,8 +71,10 @@ fun MyStoreDetailScreen(
navigateToLoginScreen: () -> Unit = {},
navigateToUploadEventScreen: () -> Unit = {},
navigateToModifyScreen: () -> Unit = {},
navigateToRegisterStoreScreen: () -> Unit = {},
navigateToManageMenuScreen: () -> Unit = {},
navigateToRegisterMenuScreen: () -> Unit = {},
navigateToRegisterMenuScreen: (Int) -> Unit = {},
navigateToModifyMenuScreen: (Int) -> Unit = {}
) {
val state = viewModel.collectAsState().value
val pagerState = rememberPagerState(0, 0f) { 2 }
Expand Down Expand Up @@ -98,6 +102,7 @@ fun MyStoreDetailScreen(
}
},
onDeleteEvent = viewModel::deleteEventAll,
onMenuItemClicked = viewModel::onModifyMenuClicked
)
}
viewModel.collectSideEffect {
Expand All @@ -108,18 +113,24 @@ fun MyStoreDetailScreen(
}

MyStoreDetailSideEffect.NavigateToUploadEventScreen -> navigateToUploadEventScreen()
MyStoreDetailSideEffect.NavigateToModifyScreen -> navigateToModifyScreen()
MyStoreDetailSideEffect.NavigateToManageMenuScreen -> {
navigateToManageMenuScreen()
MyStoreDetailSideEffect.NavigateToModifyScreen -> {
navigateToModifyScreen()
}
MyStoreDetailSideEffect.NavigateToRegisterStoreScreen -> navigateToRegisterStoreScreen()
MyStoreDetailSideEffect.NavigateToManageMenuScreen -> navigateToManageMenuScreen()

MyStoreDetailSideEffect.NavigateToRegisterMenuScreen -> {
navigateToRegisterMenuScreen()
navigateToRegisterMenuScreen(state.storeId)
}

is MyStoreDetailSideEffect.NavigateToModifyMenuScreen ->{
navigateToModifyMenuScreen(it.menuId)
}

MyStoreDetailSideEffect.ShowErrorModifyEventToast -> ToastUtil.getInstance().makeShort(
context.getString(R.string.error_modify_event)
)

}
}
}
Expand All @@ -135,6 +146,8 @@ fun MyStoreScrollScreen(
viewModel: MyStoreDetailViewModel,
onTabSelected: (Int) -> Unit = {},
onDeleteEvent: () -> Unit = {},
onMenuItemClicked: (Int) -> Unit,

) {
val toolBarHeight = 145.dp
val configuration = LocalConfiguration.current
Expand Down Expand Up @@ -198,60 +211,6 @@ fun MyStoreScrollScreen(
}
}
}
item {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 5.dp),
horizontalArrangement = Arrangement.End,
) {
Button(
onClick = { viewModel.onManageMenuClicked() },
modifier = Modifier
.padding(horizontal = 8.dp)
.border(1.dp, ColorPrimary, RoundedCornerShape(0.dp))
.width(107.dp)
.height(40.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = Color.White,
contentColor = Color.White
),
shape = RoundedCornerShape(0.dp),
elevation = ButtonDefaults.elevation(defaultElevation = 0.dp, pressedElevation = 0.dp),
) {
Text(
text = stringResource(R.string.manage_menu),
style = TextStyle(
color = ColorPrimary,
fontSize = 15.sp
)
)
}

Button(
onClick = { viewModel.onRegisterMenuClicked() },
modifier = Modifier
.padding(end = 20.dp)
.width(107.dp)
.height(40.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = ColorPrimary,
contentColor = Color.White
),
shape = RoundedCornerShape(0.dp),
elevation = ButtonDefaults.elevation(defaultElevation = 0.dp, pressedElevation = 0.dp),

) {
Text(
text = stringResource(R.string.register_menu),
style = TextStyle(
color = Color.White,
fontSize = 15.sp
)
)
}
}
}
item {
Divider(
modifier = Modifier
Expand Down Expand Up @@ -295,7 +254,14 @@ fun MyStoreScrollScreen(
modifier = Modifier.fillMaxSize()
) {
when (page) {
0 -> MenuScreen(isCollapsed, pagerState.currentPage, state)
0 -> MenuScreen(
verticalOffset = isCollapsed,
currentPage = pagerState.currentPage,
state = state,
onMenuItemClicked = {
onMenuItemClicked(it)
}
)
1 -> EventScreen(
isCollapsed,
pagerState.currentPage,
Expand All @@ -310,4 +276,4 @@ fun MyStoreScrollScreen(
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package `in`.koreatech.business.feature.store.storedetail

import `in`.koreatech.business.feature.store.modifyinfo.ModifyInfoSideEffect

sealed class MyStoreDetailSideEffect {
data object NavigateToUploadEventScreen : MyStoreDetailSideEffect()
data object NavigateToModifyScreen : MyStoreDetailSideEffect()
data object NavigateToManageMenuScreen : MyStoreDetailSideEffect()
data object NavigateToRegisterMenuScreen : MyStoreDetailSideEffect()

data class NavigateToModifyMenuScreen(val menuId: Int) : MyStoreDetailSideEffect()
data object NavigateToRegisterStoreScreen : MyStoreDetailSideEffect()
data class ShowErrorMessage(val errorMessage: String) : MyStoreDetailSideEffect()
data object ShowErrorModifyEventToast : MyStoreDetailSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ data class MyStoreDetailState(
val isEventExpanded: List<Boolean> = List(storeEvent?.size ?: 0) { false },
val isAllEventSelected: Boolean = false,
val isSelectedEvent: MutableList<Int> = mutableListOf(),
val isEditMode: Boolean = false,
val isEditMode: Boolean = false
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package `in`.koreatech.business.feature.store.storedetail


import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -176,6 +177,16 @@ class MyStoreDetailViewModel @Inject constructor(
fun onRegisterMenuClicked() = intent {
postSideEffect(MyStoreDetailSideEffect.NavigateToRegisterMenuScreen)
}

fun onModifyMenuClicked(menuId: Int){
intent {
postSideEffect(MyStoreDetailSideEffect.NavigateToModifyMenuScreen(menuId))
}
}

fun onRegisterStoreClicked() = intent {
postSideEffect(MyStoreDetailSideEffect.NavigateToRegisterStoreScreen)
}
fun modifyEventError() = intent {
postSideEffect(MyStoreDetailSideEffect.ShowErrorModifyEventToast)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package `in`.koreatech.business.feature.store.storedetail

import android.util.Log
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -15,6 +17,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Divider
Expand All @@ -33,6 +36,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import coil.compose.rememberAsyncImagePainter
import `in`.koreatech.business.R
import `in`.koreatech.business.ui.theme.ColorPrimary
import `in`.koreatech.business.ui.theme.ColorTextField
Expand Down Expand Up @@ -95,6 +99,90 @@ fun StoreInfoScreen(
) {
val state = viewModel.collectAsState().value
Column(modifier = Modifier) {

Row(
modifier = Modifier
.padding(vertical = 16.dp)
.fillMaxWidth(),
horizontalArrangement = Arrangement.Center
)
{
Button(
onClick = { viewModel.onRegisterStoreClicked() },
modifier = Modifier
.border(1.dp, ColorPrimary, RoundedCornerShape(0.dp))
.width(107.dp)
.height(40.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = ColorPrimary,
contentColor = Color.White
),
shape = RoundedCornerShape(0.dp),
elevation = ButtonDefaults.elevation(defaultElevation = 0.dp, pressedElevation = 0.dp),
) {
Text(
text = stringResource(R.string.register_store),
style = TextStyle(
color = Color.White,
fontSize = 15.sp
)
)
}

Button(
onClick = { }, //TODO 상점이 여러개일 경우 선택하는 기능 만들기
modifier = Modifier
.padding(horizontal = 16.dp)
.border(1.dp, ColorPrimary, RoundedCornerShape(0.dp))
.width(107.dp)
.height(40.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = ColorPrimary,
contentColor = Color.White
),
shape = RoundedCornerShape(0.dp),
elevation = ButtonDefaults.elevation(defaultElevation = 0.dp, pressedElevation = 0.dp),
) {
Text(
text = stringResource(R.string.select_store),
style = TextStyle(
color = Color.White,
fontSize = 15.sp
)
)
}

Button(
onClick = {
viewModel.onRegisterMenuClicked()
},
modifier = Modifier
.width(107.dp)
.height(40.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = ColorPrimary,
contentColor = Color.White
),
shape = RoundedCornerShape(0.dp),
elevation = ButtonDefaults.elevation(defaultElevation = 0.dp, pressedElevation = 0.dp),

) {
Text(
text = stringResource(R.string.register_menu),
style = TextStyle(
color = Color.White,
fontSize = 15.sp
)
)
}
}

Divider(
modifier = Modifier
.fillMaxWidth(),
color = ColorPrimary
)

Box(
modifier = Modifier
.fillMaxSize()
Expand All @@ -103,8 +191,9 @@ fun StoreInfoScreen(
) {
Image(
modifier = Modifier.height(255.dp),
painter = state.storeInfo?.imageUrls?.getOrNull(0)
.let { painterResource(id = R.drawable.no_image) },
painter = rememberAsyncImagePainter(
model = state.storeInfo?.imageUrls?.getOrNull(0) ?: R.drawable.no_image
),
contentDescription = stringResource(R.string.shop_image),
contentScale = ContentScale.Crop,
)
Expand All @@ -125,12 +214,12 @@ fun StoreInfoScreen(

) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(text = stringResource(R.string.shop_management), color = ColorPrimary, fontSize = 16.sp)
Spacer(modifier = Modifier.width(1.dp))
Image(
painter = painterResource(id = R.drawable.ic_setting),
contentDescription = stringResource(R.string.shop_management),
)
Spacer(modifier = Modifier.width(1.dp))
Text(text = stringResource(R.string.shop_management), color = ColorPrimary, fontSize = 16.sp)
}
}
Text(
Expand Down
Loading