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] 내 상점 페이지 이벤트/공지 수정 삭제 #314

Merged
merged 34 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d9e7eb6
test
skdud0629 Jul 2, 2024
274176c
Merge remote-tracking branch 'origin/feature/business/store_detail' i…
skdud0629 Jul 2, 2024
06798fd
test
skdud0629 Jul 3, 2024
5abaa26
Merge branch 'store_detail_event' into feature/store_detail
skdud0629 Jul 6, 2024
72ab665
Add string, image resource
skdud0629 Jul 6, 2024
e54c753
Add OwnerStoreDialog
skdud0629 Jul 6, 2024
69123d8
Modify wrong code
skdud0629 Jul 6, 2024
63fb89e
Add navigation and toast SideEffect
skdud0629 Jul 6, 2024
2f55c1e
Add dialogVisibility state
skdud0629 Jul 6, 2024
d069788
Add event delete logic
skdud0629 Jul 6, 2024
fe47e3c
Add navigation and error handling
skdud0629 Jul 6, 2024
03ae9ed
Add resources
skdud0629 Jul 6, 2024
f63fa63
Modify event folded item
skdud0629 Jul 6, 2024
c253b01
Modify event expanded item
skdud0629 Jul 6, 2024
3eba131
Modify EventEditToolBar
skdud0629 Jul 6, 2024
4ed14a0
Delete unnecessary code
skdud0629 Jul 6, 2024
31178e9
Modify EventScreen
skdud0629 Jul 6, 2024
f05f2e7
Add DeleteOwnerEventsUseCase
skdud0629 Jul 6, 2024
8a6ea5b
Modify wrong code
skdud0629 Jul 6, 2024
68d8053
Update event handling logic in ViewModel
skdud0629 Jul 6, 2024
b2edd18
Add changeDialogVisibility and navigateToModifyScreen
skdud0629 Jul 6, 2024
2426855
Update storeId after setting storeList
skdud0629 Jul 6, 2024
1fb4594
Change pacakage
skdud0629 Jul 7, 2024
63df642
Add string resource
skdud0629 Jul 7, 2024
8168965
Seperate app bar
skdud0629 Jul 7, 2024
2e78e50
Modify function name
skdud0629 Jul 7, 2024
7772fad
Remove unnecessary import
skdud0629 Jul 7, 2024
214ca5a
Update business/src/main/java/in/koreatech/business/feature/store/Own…
skdud0629 Jul 9, 2024
03ea4c1
Delete wrong code
skdud0629 Jul 10, 2024
7fd915e
Change AppBar -> OwnerStoreAppBar
skdud0629 Jul 10, 2024
c8ee996
Add line break
skdud0629 Jul 10, 2024
bda2b9a
Change lambda to method reference
skdud0629 Jul 10, 2024
1b7439f
Add deleteEventAll function to MyStoreDetailViewModel
skdud0629 Jul 10, 2024
25a1bd5
Add error handling logic for delete shop event
skdud0629 Jul 10, 2024
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 @@ -11,7 +11,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import dagger.hilt.android.AndroidEntryPoint
import `in`.koreatech.business.feature.store.MyStoreDetailScreen
import `in`.koreatech.business.feature.store.storedetail.MyStoreDetailScreen
import `in`.koreatech.business.ui.theme.KOIN_ANDROIDTheme

@AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ import `in`.koreatech.koin.core.qualifier.PreSignedUrl
import `in`.koreatech.koin.core.qualifier.Refresh
import `in`.koreatech.koin.core.qualifier.ServerUrl
import `in`.koreatech.koin.data.api.PreSignedUrlApi
import `in`.koreatech.koin.data.api.StoreApi
import `in`.koreatech.koin.data.api.UploadUrlApi
import `in`.koreatech.koin.data.api.UserApi
import `in`.koreatech.koin.data.api.auth.OwnerAuthApi
import `in`.koreatech.koin.data.api.auth.UserAuthApi
import `in`.koreatech.koin.data.source.local.TokenLocalDataSource
import `in`.koreatech.koin.data.source.remote.UserRemoteDataSource
import kotlinx.coroutines.runBlocking
import okhttp3.Interceptor
import okhttp3.OkHttpClient
Expand Down Expand Up @@ -183,8 +181,6 @@ object BusinessAuthNetworkModule {
}




@Module
@InstallIn(SingletonComponent::class)
object PreSignedUrlNetworkModule {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package `in`.koreatech.business.feature.store

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.sp
import `in`.koreatech.business.R
import `in`.koreatech.business.ui.theme.ColorPrimary

@Composable
fun OwnerStoreAppBar(title: String) {
Box(
modifier = Modifier
.fillMaxWidth()
.background(ColorPrimary),
) {
IconButton(onClick = { /*TODO*/ }) {
Image(
painter = painterResource(id = R.drawable.ic_back),
contentDescription = stringResource(R.string.back),
colorFilter = ColorFilter.tint(Color.White),
)
}
Text(
text = title,
modifier = Modifier.align(Alignment.Center),
style = TextStyle(color = Color.White, fontSize = 18.sp),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package `in`.koreatech.business.feature.store

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
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.ButtonDefaults
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import `in`.koreatech.business.R
import `in`.koreatech.business.ui.theme.ColorDisabledButton
import `in`.koreatech.business.ui.theme.ColorMinor
import `in`.koreatech.business.ui.theme.ColorSecondary
import `in`.koreatech.business.ui.theme.Gray6


@Composable
fun OwnerStoreDialog(
dialogTitle: String,
dialogText: String,
positiveButtonText: String,
visibility: Boolean = false,
onConfirmation: () -> Unit,
onDismissRequest: () -> Unit,
) {
if (!visibility) {
return
}
Dialog(onDismissRequest = { onDismissRequest() }) {
Card(
modifier = Modifier
.padding(7.dp)
.fillMaxWidth(),
shape = RoundedCornerShape(16.dp),
) {
Column(
modifier = Modifier
.background(Color.White)
.padding(vertical = 40.dp, horizontal = 14.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,

) {
Text(
modifier = Modifier.fillMaxWidth(),
text = dialogTitle,
fontSize = 18.sp,
fontWeight = FontWeight(400),
textAlign = TextAlign.Center,
)

Spacer(modifier = Modifier.height(8.dp))

Text(
modifier = Modifier.fillMaxWidth(),
fontSize = 13.sp,
color = Color.Black,
text = dialogText,
textAlign = TextAlign.Center,
)
Spacer(modifier = Modifier.height(24.dp))

Row {
TextButton(
onClick = {
onDismissRequest()
},
border = BorderStroke(1.dp, Gray6),
shape = RoundedCornerShape(8.dp),
modifier = Modifier
.width(128.dp)
.height(48.dp),
) {
Text(
textAlign = TextAlign.Center,
text = stringResource(id = R.string.cancel),
color = ColorMinor,
)
}

Spacer(modifier = Modifier.width(10.dp))

TextButton(
onClick = {
onConfirmation()
},
colors = ButtonDefaults.buttonColors(
backgroundColor = ColorSecondary,
disabledBackgroundColor = ColorDisabledButton,
contentColor = Color.White,
disabledContentColor = Color.White,
),
border = BorderStroke(1.dp, ColorSecondary),
shape = RoundedCornerShape(8.dp),
modifier = Modifier
.width(128.dp)
.height(48.dp),
) {
Text(
textAlign = TextAlign.Center,
text = positiveButtonText
)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package `in`.koreatech.business.feature.store
package `in`.koreatech.business.feature.store.storedetail

import android.annotation.SuppressLint
import androidx.compose.foundation.ExperimentalFoundationApi
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
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.padding
import androidx.compose.foundation.layout.width
Expand All @@ -23,7 +20,6 @@ import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Divider
import androidx.compose.material.IconButton
import androidx.compose.material.Tab
import androidx.compose.material.TabRow
import androidx.compose.material.TabRowDefaults
Expand All @@ -39,14 +35,16 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex
import androidx.hilt.navigation.compose.hiltViewModel
import `in`.koreatech.business.R
import `in`.koreatech.business.feature.store.OwnerStoreAppBar
import `in`.koreatech.business.feature.store.storedetail.event.EventScreen
import `in`.koreatech.business.feature.store.storedetail.menu.MenuScreen
import `in`.koreatech.business.ui.theme.Blue2
import `in`.koreatech.business.ui.theme.ColorPrimary
import `in`.koreatech.business.ui.theme.ColorTextField
Expand All @@ -62,6 +60,8 @@ import org.orbitmvi.orbit.compose.collectSideEffect
fun MyStoreDetailScreen(
modifier: Modifier,
navigateToLoginScreen: () -> Unit = {},
navigateToUploadEventScreen: () -> Unit = {},
navigateToModifyScreen: () -> Unit = {},
) {
val viewModel: MyStoreDetailViewModel = hiltViewModel()
val state = viewModel.collectAsState().value
Expand All @@ -73,36 +73,28 @@ fun MyStoreDetailScreen(
Column(
modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally,
) {
Box(
modifier = Modifier
.fillMaxWidth()
.background(ColorPrimary),
) {
IconButton(onClick = { /*TODO*/ }) {
Image(
painter = painterResource(id = R.drawable.ic_setting),
contentDescription = stringResource(R.string.back),
)
}
Text(
text = stringResource(R.string.my_shop),
modifier = Modifier.align(Alignment.Center),
style = TextStyle(color = Color.White, fontSize = 18.sp),
)
}
MyStoreScrollScreen(state, listState, pagerState, viewModel, onTabSelected = {
coroutineScope.launch {
pagerState.animateScrollToPage(it)
}
})
OwnerStoreAppBar(stringResource(R.string.my_shop))
MyStoreScrollScreen(
state, listState, pagerState, viewModel, onTabSelected = {
coroutineScope.launch {
pagerState.animateScrollToPage(it)
}
},
viewModel::deleteEventAll
)
}
viewModel.collectSideEffect {
when (it) {
is MyStoreDetailSideEffect.ShowErrorMessage -> {
ToastUtil.getInstance().makeShort(it.errorMessage)
navigateToLoginScreen()}
MyStoreDetailSideEffect.NavigateToUploadEventScreen -> TODO()
MyStoreDetailSideEffect.ShowDialog -> TODO()
navigateToLoginScreen()
}

MyStoreDetailSideEffect.NavigateToUploadEventScreen -> navigateToUploadEventScreen()
MyStoreDetailSideEffect.NavigateToModifyScreen -> navigateToModifyScreen()
MyStoreDetailSideEffect.ShowErrorModifyEventToast -> ToastUtil.getInstance().makeShort(
context.getString(R.string.error_modify_event)
)
}
}
}
Expand All @@ -117,6 +109,7 @@ fun MyStoreScrollScreen(
pagerState: PagerState = rememberPagerState(0, 0f) { 2 },
viewModel: MyStoreDetailViewModel,
onTabSelected: (Int) -> Unit = {},
onDeleteEvent: () -> Unit = {},
) {
val toolBarHeight = 145.dp
val configuration = LocalConfiguration.current
Expand Down Expand Up @@ -149,7 +142,7 @@ fun MyStoreScrollScreen(
verticalArrangement = Arrangement.Top,
) {
item {
TopBar()
StoreInfoScreen()
}
storeDetailInfo(infoDataList)
item {
Expand Down Expand Up @@ -219,7 +212,14 @@ fun MyStoreScrollScreen(
) {
when (page) {
0 -> MenuScreen(isCollapsed, pagerState.currentPage, state)
1 -> EventScreen(isCollapsed, pagerState.currentPage, viewModel)
1 -> EventScreen(
isCollapsed,
pagerState.currentPage,
viewModel,
state,
) {
onDeleteEvent()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package `in`.koreatech.business.feature.store
package `in`.koreatech.business.feature.store.storedetail

sealed class MyStoreDetailSideEffect {
data object ShowDialog : MyStoreDetailSideEffect()
data object NavigateToUploadEventScreen : MyStoreDetailSideEffect()
data object NavigateToModifyScreen : MyStoreDetailSideEffect()
data class ShowErrorMessage(val errorMessage: String) : MyStoreDetailSideEffect()
data object ShowErrorModifyEventToast : MyStoreDetailSideEffect()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package `in`.koreatech.business.feature.store
package `in`.koreatech.business.feature.store.storedetail

import `in`.koreatech.koin.domain.model.store.ShopEvent
import `in`.koreatech.koin.domain.model.store.Store
Expand All @@ -12,5 +12,9 @@ data class MyStoreDetailState(
val storeId: Int = -1,
val storeEvent: ImmutableList<ShopEvent>? = null,
val storeMenu: ImmutableList<StoreMenuCategories>? = null,
val dialogVisibility: Boolean = false,
val isEventExpanded: List<Boolean> = List(storeEvent?.size ?: 0) { false },
val isAllEventSelected: Boolean = false,
val isSelectedEvent: MutableList<Int> = mutableListOf(),
val isEditMode: Boolean = false,
)
Loading