From d97a9e36105b81d404b3855b7d4ea20512d7be8d Mon Sep 17 00:00:00 2001 From: Sehwan Yun <39579912+l5x5l@users.noreply.github.com> Date: Tue, 30 Jul 2024 22:00:37 +0900 Subject: [PATCH] =?UTF-8?q?[Base]=20#26=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C-BottomSheet=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=88=98=EC=A0=95=20(#27)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FIX] #26 기존 bottomSheet에서 close animation이 제대로 동작하지 않던 문제 수정 * [FEATURE+FIX] #26 단일 버튼 BottomSheet 구현 및 기존 RemoveItemBottomSheet를 TwoButtonBottomSheet로 변경 * [CHORE] #26 ktlint 적용 * [CHORE] #26 코드 리뷰 피드백 반영 --- .../template/bottomsheet/PokitBottomSheet.kt | 78 +++++++---- .../OneButtonBottomSheetContent.kt | 76 ++++++++++ .../template/onebuttonbottomsheet/Preview.kt | 39 ++++++ .../template/removeItemBottomSheet/Preview.kt | 30 +++- ...tent.kt => TwoButtonBottomSheetContent.kt} | 34 +++-- .../attributes/RemoveItemType.kt | 14 -- core/ui/src/main/res/values/string.xml | 7 +- .../com/strayalpaca/addlink/AddLinkScreen.kt | 76 +++++----- .../strayalpaca/addpokit/AddPokitScreen.kt | 31 +++-- .../pokitdetail/PokitDetailScreen.kt | 131 ++++++++++-------- .../FilterSelectBottomSheet.kt | 6 +- .../LinkDetailBottomSheet.kt | 6 +- .../com/strayalpaca/pokitdetail/model/Link.kt | 18 +-- .../src/main/res/values/string.xml | 5 + .../search/components/calendar/Preview.kt | 2 +- .../filterbottomsheet/FilterBottomSheet.kt | 96 ++----------- 16 files changed, 377 insertions(+), 272 deletions(-) create mode 100644 core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/OneButtonBottomSheetContent.kt create mode 100644 core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/Preview.kt rename core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/{RemoveItemBottomSheetContent.kt => TwoButtonBottomSheetContent.kt} (76%) delete mode 100644 core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/attributes/RemoveItemType.kt diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt index e3a4d861..427b2860 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/bottomsheet/PokitBottomSheet.kt @@ -16,48 +16,78 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.rememberModalBottomSheetState 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.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp +import kotlinx.coroutines.launch import pokitmons.pokit.core.ui.theme.PokitTheme @OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) @Composable fun PokitBottomSheet( onHideBottomSheet: () -> Unit, + show: Boolean = false, content: @Composable (ColumnScope.() -> Unit), ) { val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) + var visibility by remember { mutableStateOf(show) } + val scope = rememberCoroutineScope() - ModalBottomSheet( - onDismissRequest = onHideBottomSheet, - sheetState = bottomSheetState, - scrimColor = Color.Transparent, - shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), - containerColor = PokitTheme.colors.backgroundBase, - dragHandle = { - Column { - Spacer(modifier = Modifier.height(8.dp)) + LaunchedEffect(show) { + if (visibility && !show) { + scope.launch { + bottomSheetState.hide() + }.invokeOnCompletion { + onHideBottomSheet() + visibility = false + } + } else { + visibility = show + } + } - Box( - Modifier - .clip(RoundedCornerShape(4.dp)) - .width(36.dp) - .height(4.dp) - .background(color = PokitTheme.colors.iconTertiary) - ) + if (visibility) { + ModalBottomSheet( + onDismissRequest = remember { + { + onHideBottomSheet() + visibility = false + } + }, + sheetState = bottomSheetState, + scrimColor = Color.Transparent, + shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), + containerColor = PokitTheme.colors.backgroundBase, + dragHandle = { + Column { + Spacer(modifier = Modifier.height(8.dp)) - Spacer(modifier = Modifier.height(12.dp)) + Box( + Modifier + .clip(RoundedCornerShape(4.dp)) + .width(36.dp) + .height(4.dp) + .background(color = PokitTheme.colors.iconTertiary) + ) + + Spacer(modifier = Modifier.height(12.dp)) + } } - } - ) { - content() + ) { + content() - Spacer( - Modifier.windowInsetsBottomHeight( - WindowInsets.navigationBarsIgnoringVisibility + Spacer( + Modifier.windowInsetsBottomHeight( + WindowInsets.navigationBarsIgnoringVisibility + ) ) - ) + } } } diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/OneButtonBottomSheetContent.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/OneButtonBottomSheetContent.kt new file mode 100644 index 00000000..6011bca5 --- /dev/null +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/OneButtonBottomSheetContent.kt @@ -0,0 +1,76 @@ +package pokitmons.pokit.core.ui.components.template.onebuttonbottomsheet + +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.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import pokitmons.pokit.core.ui.R +import pokitmons.pokit.core.ui.components.atom.button.PokitButton +import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonShape +import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonSize +import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonStyle +import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonType +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Composable +fun OneButtonBottomSheetContent( + title: String, + subText: String? = null, + buttonText: String = stringResource(id = R.string.confirmation), + onClickButton: () -> Unit = {}, +) { + Column( + modifier = Modifier.fillMaxWidth() + ) { + Spacer(modifier = Modifier.height(36.dp)) + + Text( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp), + text = title, + textAlign = TextAlign.Center, + style = PokitTheme.typography.title2.copy(color = PokitTheme.colors.textPrimary) + ) + + subText?.let { subText -> + Spacer(modifier = Modifier.height(8.dp)) + + Text( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp), + text = subText, + textAlign = TextAlign.Center, + style = PokitTheme.typography.body2Medium.copy(color = PokitTheme.colors.textSecondary) + ) + } + + Spacer(modifier = Modifier.height(20.dp)) + + Row( + modifier = Modifier + .fillMaxWidth() + .padding(top = 16.dp, start = 20.dp, end = 20.dp, bottom = 28.dp) + ) { + PokitButton( + text = buttonText, + icon = null, + onClick = onClickButton, + shape = PokitButtonShape.RECTANGLE, + type = PokitButtonType.PRIMARY, + size = PokitButtonSize.LARGE, + style = PokitButtonStyle.FILLED, + modifier = Modifier.weight(1f) + ) + } + } +} diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/Preview.kt new file mode 100644 index 00000000..6d84b526 --- /dev/null +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/onebuttonbottomsheet/Preview.kt @@ -0,0 +1,39 @@ +package pokitmons.pokit.core.ui.components.template.onebuttonbottomsheet + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Surface +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Preview(showBackground = true) +@Composable +private fun Preview() { + PokitTheme { + Surface(modifier = Modifier.fillMaxSize()) { + Column( + modifier = Modifier.fillMaxWidth() + ) { + OneButtonBottomSheetContent( + title = "로그인 오류", + subText = "현재 서버 오류로 로그인에 실패했습니다.\n잠시 후에 다시 시도해 주세요." + ) + + HorizontalDivider( + modifier = Modifier.height(16.dp).background(PokitTheme.colors.borderTertiary) + ) + + OneButtonBottomSheetContent( + title = "여기에 타이틀이 들어갑니다" + ) + } + } + } +} diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/Preview.kt index 7f2131e0..530009e7 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/Preview.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/Preview.kt @@ -1,11 +1,16 @@ package pokitmons.pokit.core.ui.components.template.removeItemBottomSheet +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview -import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.attributes.RemoveItemType +import androidx.compose.ui.unit.dp import pokitmons.pokit.core.ui.theme.PokitTheme @Preview(showBackground = true) @@ -13,11 +18,24 @@ import pokitmons.pokit.core.ui.theme.PokitTheme private fun RemoveItemBottomSheetContentPreview() { PokitTheme { Surface(modifier = Modifier.fillMaxSize()) { - RemoveItemBottomSheetContent( - removeItemType = RemoveItemType.LINK, - onClickCancel = {}, - onClickRemove = {} - ) + Column(modifier = Modifier.fillMaxWidth()) { + TwoButtonBottomSheetContent( + title = "포킷을 정말 삭제하시겠습니까?", + subText = "함께 저장한 모든 링크가 삭제되며,\n복구하실 수 없습니다.", + onClickLeftButton = {}, + onClickRightButton = {} + ) + + HorizontalDivider( + modifier = Modifier.height(16.dp).background(PokitTheme.colors.borderTertiary) + ) + + TwoButtonBottomSheetContent( + title = "로그아웃 하시겠습니까?", + onClickLeftButton = {}, + onClickRightButton = {} + ) + } } } } diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/RemoveItemBottomSheetContent.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/TwoButtonBottomSheetContent.kt similarity index 76% rename from core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/RemoveItemBottomSheetContent.kt rename to core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/TwoButtonBottomSheetContent.kt index 6f171700..a5adac04 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/RemoveItemBottomSheetContent.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/TwoButtonBottomSheetContent.kt @@ -20,14 +20,16 @@ import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonShap import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonSize import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonStyle import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonType -import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.attributes.RemoveItemType import pokitmons.pokit.core.ui.theme.PokitTheme @Composable -fun RemoveItemBottomSheetContent( - removeItemType: RemoveItemType, - onClickCancel: () -> Unit, - onClickRemove: () -> Unit, +fun TwoButtonBottomSheetContent( + title: String, + subText: String? = null, + leftButtonText: String = stringResource(id = R.string.cancellation), + rightButtonText: String = stringResource(id = R.string.removal), + onClickLeftButton: () -> Unit, + onClickRightButton: () -> Unit, ) { Column( modifier = Modifier @@ -36,17 +38,19 @@ fun RemoveItemBottomSheetContent( horizontalAlignment = Alignment.CenterHorizontally ) { Text( - text = stringResource(id = removeItemType.titleStringResourceId), + text = title, style = PokitTheme.typography.title2.copy(color = PokitTheme.colors.textPrimary) ) Spacer(modifier = Modifier.height(8.dp)) - Text( - text = stringResource(id = removeItemType.subStringResourceId), - style = PokitTheme.typography.body2Medium.copy(color = PokitTheme.colors.textSecondary), - textAlign = TextAlign.Center - ) + subText?.let { subString -> + Text( + text = subString, + style = PokitTheme.typography.body2Medium.copy(color = PokitTheme.colors.textSecondary), + textAlign = TextAlign.Center + ) + } } Row( @@ -56,9 +60,9 @@ fun RemoveItemBottomSheetContent( horizontalArrangement = Arrangement.spacedBy(8.dp) ) { PokitButton( - text = stringResource(id = R.string.cancellation), + text = leftButtonText, icon = null, - onClick = onClickCancel, + onClick = onClickLeftButton, shape = PokitButtonShape.RECTANGLE, type = PokitButtonType.SECONDARY, size = PokitButtonSize.LARGE, @@ -67,9 +71,9 @@ fun RemoveItemBottomSheetContent( ) PokitButton( - text = stringResource(id = R.string.removal), + text = rightButtonText, icon = null, - onClick = onClickRemove, + onClick = onClickRightButton, shape = PokitButtonShape.RECTANGLE, type = PokitButtonType.PRIMARY, size = PokitButtonSize.LARGE, diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/attributes/RemoveItemType.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/attributes/RemoveItemType.kt deleted file mode 100644 index 70fd6b0a..00000000 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/removeItemBottomSheet/attributes/RemoveItemType.kt +++ /dev/null @@ -1,14 +0,0 @@ -package pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.attributes - -import pokitmons.pokit.core.ui.R - -enum class RemoveItemType(val titleStringResourceId: Int, val subStringResourceId: Int) { - POKIT( - titleStringResourceId = R.string.title_remove_pokit, - subStringResourceId = R.string.sub_remove_link - ), - LINK( - titleStringResourceId = R.string.title_remove_link, - subStringResourceId = R.string.sub_remove_link - ), -} diff --git a/core/ui/src/main/res/values/string.xml b/core/ui/src/main/res/values/string.xml index 865a964e..200ad902 100644 --- a/core/ui/src/main/res/values/string.xml +++ b/core/ui/src/main/res/values/string.xml @@ -3,15 +3,12 @@ 안읽음 링크 %d개 - 포킷을 정말 삭제하시겠습니까? - 함께 저장한 모든 링크가 삭제되며,\n복구하실 수 없습니다. - 링크를 정말 삭제하시겠습니까? - 함께 저장한 모든 정보가 삭제되며,\n복구하실 수 없습니다. - 취소 삭제 공유하기 수정하기 삭제하기 + + 확인 \ No newline at end of file diff --git a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt index 522fa644..04332847 100644 --- a/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt +++ b/feature/addlink/src/main/java/com/strayalpaca/addlink/AddLinkScreen.kt @@ -73,9 +73,11 @@ fun AddLinkScreenContainer( AddLinkScreenSideEffect.AddLinkSuccess -> { onBackPressed() } + AddLinkScreenSideEffect.OnNavigationBack -> { onBackPressed() } + is AddLinkScreenSideEffect.ToastMessage -> { Toast.makeText(context, context.getString(sideEffect.toastMessageEvent.stringResourceId), Toast.LENGTH_SHORT).show() } @@ -292,48 +294,50 @@ fun AddLinkScreen( } } - if (state.step == ScreenStep.POKIT_SELECT) { - PokitBottomSheet(onHideBottomSheet = dismissPokitSelectBottomSheet) { - LazyColumn { - items( - items = state.pokitList - ) { - PokitList( - item = it, - title = it.title, - sub = stringResource(id = R.string.count_format, it.count), - onClickItem = onClickSelectPokitItem, - state = PokitListState.ACTIVE - ) - } + PokitBottomSheet( + onHideBottomSheet = dismissPokitSelectBottomSheet, + show = state.step == ScreenStep.POKIT_SELECT + ) { + LazyColumn { + items( + items = state.pokitList + ) { pokit -> + PokitList( + item = pokit, + title = pokit.title, + sub = stringResource(id = R.string.count_format, pokit.count), + onClickItem = onClickSelectPokitItem, + state = PokitListState.ACTIVE + ) } } } - if (state.step == ScreenStep.POKIT_ADD) { - PokitBottomSheet(onHideBottomSheet = dismissPokitAddBottomSheet) { - Column( - modifier = Modifier.padding(horizontal = 20.dp) - ) { - LabeledInput( - label = "", - inputText = pokitName, - hintText = stringResource(id = R.string.placeholder_input_pokit_name), - onChangeText = inputNewPokitName, - maxLength = 10 - ) + PokitBottomSheet( + onHideBottomSheet = dismissPokitAddBottomSheet, + show = state.step == ScreenStep.POKIT_ADD + ) { + Column( + modifier = Modifier.padding(horizontal = 20.dp) + ) { + LabeledInput( + label = "", + inputText = pokitName, + hintText = stringResource(id = R.string.placeholder_input_pokit_name), + onChangeText = inputNewPokitName, + maxLength = 10 + ) - Spacer(modifier = Modifier.height(12.dp)) + Spacer(modifier = Modifier.height(12.dp)) - PokitButton( - text = stringResource(id = R.string.add), - icon = null, - onClick = onClickSavePokit, - modifier = Modifier.fillMaxWidth(), - size = PokitButtonSize.LARGE, - enable = pokitName.isNotEmpty() - ) - } + PokitButton( + text = stringResource(id = R.string.add), + icon = null, + onClick = onClickSavePokit, + modifier = Modifier.fillMaxWidth(), + size = PokitButtonSize.LARGE, + enable = pokitName.isNotEmpty() + ) } } } diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt index 42bbef6b..34b7e6d1 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt @@ -236,21 +236,22 @@ fun AddPokitScreen( ) } - if (state.step == AddPokitScreenStep.SELECT_PROFILE) { - PokitBottomSheet(onHideBottomSheet = hideProfileSelectBottomSheet) { - LazyVerticalGrid( - modifier = Modifier.padding(vertical = 12.dp, horizontal = 40.dp), - columns = GridCells.Adaptive(66.dp), - horizontalArrangement = Arrangement.spacedBy(20.dp), - verticalArrangement = Arrangement.spacedBy(12.dp) - ) { - items(samplePokitProfileList) { profileImage -> - PokitProfileImage( - pokitProfile = profileImage, - onClick = selectPokitProfileImage, - focused = (state.pokitProfile?.id == profileImage.id) - ) - } + PokitBottomSheet( + onHideBottomSheet = hideProfileSelectBottomSheet, + show = state.step == AddPokitScreenStep.SELECT_PROFILE + ) { + LazyVerticalGrid( + modifier = Modifier.padding(vertical = 12.dp, horizontal = 40.dp), + columns = GridCells.Adaptive(66.dp), + horizontalArrangement = Arrangement.spacedBy(20.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + items(samplePokitProfileList) { profileImage -> + PokitProfileImage( + pokitProfile = profileImage, + onClick = selectPokitProfileImage, + focused = (state.pokitProfile?.id == profileImage.id) + ) } } } diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt index aab50b80..1264b5ad 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt @@ -30,8 +30,7 @@ import pokitmons.pokit.core.ui.components.block.pokitlist.PokitList import pokitmons.pokit.core.ui.components.block.pokitlist.attributes.PokitListState import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.core.ui.components.template.modifybottomsheet.ModifyBottomSheetContent -import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.RemoveItemBottomSheetContent -import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.attributes.RemoveItemType +import pokitmons.pokit.core.ui.components.template.removeItemBottomSheet.TwoButtonBottomSheetContent import pokitmons.pokit.core.ui.theme.PokitTheme import pokitmons.pokit.core.ui.R.drawable as coreDrawable @@ -130,75 +129,87 @@ fun PokitDetailScreen( } } - if (state.linkDetailBottomSheetVisible && state.currentLink != null) { - LinkDetailBottomSheet(link = state.currentLink, onHideBottomSheet = hideLinkDetailBottomSheet) - } + LinkDetailBottomSheet( + show = state.linkDetailBottomSheetVisible && state.currentLink != null, + link = state.currentLink ?: Link(), + onHideBottomSheet = hideLinkDetailBottomSheet + ) - if (state.filterChangeBottomSheetVisible) { - FilterSelectBottomSheet( - filter = state.currentFilter, - onHideRequest = hideFilterChangeBottomSheet, - onFilterChange = changeFilter - ) - } + FilterSelectBottomSheet( + filter = state.currentFilter, + onHideRequest = hideFilterChangeBottomSheet, + onFilterChange = changeFilter, + show = state.filterChangeBottomSheetVisible + ) - if (state.pokitSelectBottomSheetVisible) { - PokitBottomSheet(onHideBottomSheet = hidePokitSelectBottomSheet) { - LazyColumn { - items( - items = pokitList - ) { pokit -> - PokitList( - item = pokit, - title = pokit.title, - sub = stringResource(id = R.string.link_count_format, pokit.count), - onClickItem = changePokit, - state = PokitListState.ACTIVE - ) - } + PokitBottomSheet( + onHideBottomSheet = hidePokitSelectBottomSheet, + show = state.pokitSelectBottomSheetVisible + ) { + LazyColumn { + items( + items = pokitList + ) { pokit -> + PokitList( + item = pokit, + title = pokit.title, + sub = stringResource(id = R.string.link_count_format, pokit.count), + onClickItem = changePokit, + state = PokitListState.ACTIVE + ) } } } - if (state.linkBottomSheetType != null) { - PokitBottomSheet(onHideBottomSheet = hideLinkModifyBottomSheet) { - when (state.linkBottomSheetType) { - BottomSheetType.MODIFY -> { - ModifyBottomSheetContent( - onClickShare = {}, - onClickModify = {}, - onClickRemove = showLinkRemoveBottomSheet - ) - } - BottomSheetType.REMOVE -> { - RemoveItemBottomSheetContent( - removeItemType = RemoveItemType.LINK, - onClickCancel = hideLinkModifyBottomSheet, - onClickRemove = {} - ) - } + PokitBottomSheet( + onHideBottomSheet = hideLinkModifyBottomSheet, + show = state.linkBottomSheetType != null + ) { + when (state.linkBottomSheetType) { + BottomSheetType.MODIFY -> { + ModifyBottomSheetContent( + onClickShare = {}, + onClickModify = {}, + onClickRemove = showLinkRemoveBottomSheet + ) } + + BottomSheetType.REMOVE -> { + TwoButtonBottomSheetContent( + title = stringResource(id = R.string.title_remove_link), + subText = stringResource(id = R.string.sub_remove_link), + onClickLeftButton = hideLinkModifyBottomSheet, + onClickRightButton = {} + ) + } + + else -> {} } } - if (state.pokitBottomSheetType != null) { - PokitBottomSheet(onHideBottomSheet = hidePokitModifyBottomSheet) { - when (state.pokitBottomSheetType) { - BottomSheetType.MODIFY -> { - ModifyBottomSheetContent( - onClickShare = {}, - onClickModify = {}, - onClickRemove = showPokitRemoveBottomSheet - ) - } - BottomSheetType.REMOVE -> { - RemoveItemBottomSheetContent( - removeItemType = RemoveItemType.POKIT, - onClickCancel = hidePokitModifyBottomSheet, - onClickRemove = {} - ) - } + PokitBottomSheet( + onHideBottomSheet = hidePokitModifyBottomSheet, + show = state.pokitBottomSheetType != null + ) { + when (state.pokitBottomSheetType) { + BottomSheetType.MODIFY -> { + ModifyBottomSheetContent( + onClickShare = {}, + onClickModify = {}, + onClickRemove = showPokitRemoveBottomSheet + ) + } + + BottomSheetType.REMOVE -> { + TwoButtonBottomSheetContent( + title = stringResource(id = R.string.title_remove_pokit), + subText = stringResource(id = R.string.sub_remove_pokit), + onClickLeftButton = hidePokitModifyBottomSheet, + onClickRightButton = {} + ) } + + else -> {} } } } diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/filterselectbottomsheet/FilterSelectBottomSheet.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/filterselectbottomsheet/FilterSelectBottomSheet.kt index f1af4f0b..faf3199a 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/filterselectbottomsheet/FilterSelectBottomSheet.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/filterselectbottomsheet/FilterSelectBottomSheet.kt @@ -36,10 +36,14 @@ internal fun FilterSelectBottomSheet( filter: Filter = Filter(), onHideRequest: () -> Unit = {}, onFilterChange: (Filter) -> Unit = {}, + show: Boolean = false, ) { var currentFilter by remember { mutableStateOf(filter) } - PokitBottomSheet(onHideBottomSheet = onHideRequest) { + PokitBottomSheet( + onHideBottomSheet = onHideRequest, + show = show + ) { Box( modifier = Modifier .fillMaxWidth() diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt index db2f7fc1..d43c9d4c 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt @@ -35,8 +35,12 @@ import pokitmons.pokit.core.ui.R.drawable as coreDrawable fun LinkDetailBottomSheet( link: Link, onHideBottomSheet: () -> Unit, + show: Boolean = false, ) { - PokitBottomSheet(onHideBottomSheet = onHideBottomSheet) { + PokitBottomSheet( + onHideBottomSheet = onHideBottomSheet, + show = show + ) { Column( modifier = Modifier .fillMaxWidth() diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt index ae3cef60..dac79178 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt @@ -3,15 +3,15 @@ package com.strayalpaca.pokitdetail.model import com.strayalpaca.pokitdetail.R data class Link( - val id: String, - val title: String, - val dateString: String, - val domainUrl: String, - val isRead: Boolean, - val linkType: LinkType, - val url: String, - val memo: String, - val bookmark: Boolean, + val id: String = "", + val title: String = "", + val dateString: String = "", + val domainUrl: String = "", + val isRead: Boolean = false, + val linkType: LinkType = LinkType.TEXT, + val url: String = "", + val memo: String = "", + val bookmark: Boolean = false, val imageUrl: String? = null, ) diff --git a/feature/pokitdetail/src/main/res/values/string.xml b/feature/pokitdetail/src/main/res/values/string.xml index 071af5f5..2438a87e 100644 --- a/feature/pokitdetail/src/main/res/values/string.xml +++ b/feature/pokitdetail/src/main/res/values/string.xml @@ -12,4 +12,9 @@ 링크 %d개 텍스트 + + 포킷을 정말 삭제하시겠습니까? + 함께 저장한 모든 링크가 삭제되며,\n복구하실 수 없습니다. + 링크를 정말 삭제하시겠습니까? + 함께 저장한 모든 정보가 삭제되며,\n복구하실 수 없습니다. \ No newline at end of file diff --git a/feature/search/src/main/java/pokitmons/pokit/search/components/calendar/Preview.kt b/feature/search/src/main/java/pokitmons/pokit/search/components/calendar/Preview.kt index 89781404..14565eec 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/components/calendar/Preview.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/components/calendar/Preview.kt @@ -44,7 +44,7 @@ private fun Preview() { startDate = date endDate = null } - } + } } ) } diff --git a/feature/search/src/main/java/pokitmons/pokit/search/components/filterbottomsheet/FilterBottomSheet.kt b/feature/search/src/main/java/pokitmons/pokit/search/components/filterbottomsheet/FilterBottomSheet.kt index 648c08ae..9ceff05a 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/components/filterbottomsheet/FilterBottomSheet.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/components/filterbottomsheet/FilterBottomSheet.kt @@ -1,38 +1,12 @@ package pokitmons.pokit.search.components.filterbottomsheet -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ExperimentalLayoutApi -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.navigationBarsIgnoringVisibility -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.windowInsetsBottomHeight -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.rememberModalBottomSheetState 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.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import kotlinx.coroutines.launch -import pokitmons.pokit.core.ui.theme.PokitTheme +import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.search.model.Filter import pokitmons.pokit.search.model.FilterType import pokitmons.pokit.search.model.Pokit import pokitmons.pokit.search.model.samplePokits -@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) @Composable fun FilterBottomSheet( filter: Filter = Filter(), @@ -42,63 +16,15 @@ fun FilterBottomSheet( show: Boolean = false, onDismissRequest: () -> Unit = {}, ) { - val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) - var visibility by remember { mutableStateOf(show) } - val scope = rememberCoroutineScope() - - LaunchedEffect(show) { - if (visibility && !show) { - scope.launch { - bottomSheetState.hide() - }.invokeOnCompletion { - onDismissRequest() - visibility = false - } - } else { - visibility = show - } - } - - if (visibility) { - ModalBottomSheet( - onDismissRequest = remember { - { - onDismissRequest() - visibility = false - } - }, - sheetState = bottomSheetState, - scrimColor = Color.Transparent, - shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), - containerColor = PokitTheme.colors.backgroundBase, - dragHandle = { - Column { - Spacer(modifier = Modifier.height(8.dp)) - - Box( - Modifier - .clip(RoundedCornerShape(4.dp)) - .width(36.dp) - .height(4.dp) - .background(color = PokitTheme.colors.iconTertiary) - ) - - Spacer(modifier = Modifier.height(12.dp)) - } - } - ) { - FilterBottomSheetContent( - filter = filter, - firstShowType = firstShowType, - onSaveClilck = onSaveClilck, - pokits = pokits - ) - - Spacer( - Modifier.windowInsetsBottomHeight( - WindowInsets.navigationBarsIgnoringVisibility - ) - ) - } + PokitBottomSheet( + onHideBottomSheet = onDismissRequest, + show = show + ) { + FilterBottomSheetContent( + filter = filter, + firstShowType = firstShowType, + onSaveClilck = onSaveClilck, + pokits = pokits + ) } }