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

홈과 보관함 폴더 생성/이름 변경 UI 및 navigation 추가 #67

Merged
merged 23 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
98d27bd
[feat] 홈화면 폴더 생성 화면 추가
ddyeon Jul 7, 2024
0f2dcb1
[feat] 폴더생성 navigation 생성
ddyeon Jul 7, 2024
fab70fa
[feat] 홈화면- 폴더생성 navigation 연결 및 bottomSheet 데이터 수정
ddyeon Jul 7, 2024
59a9d3b
[feat] 보관함쪽 폴더 생성 UI 추가
ddyeon Jul 7, 2024
f7d407a
[feat] 보관함 폴더 생성 네비게이션 연결
ddyeon Jul 7, 2024
4f4141e
[feat] 필요한 string 추가
ddyeon Jul 7, 2024
5a5d642
[feat] 폴더관리 모델 및 타입 생성
ddyeon Jul 7, 2024
47f7320
[feat] 보관함 dilaog, bottomsheet추가
ddyeon Jul 7, 2024
b0e0a0e
[feat] 보관함 dilaog, bottomsheet추가
ddyeon Jul 7, 2024
b39c6f8
[feat] 보관함에서 폴더관리 navigation 세팅
ddyeon Jul 7, 2024
637e0e6
[fix] spotless 적용
ddyeon Jul 7, 2024
bcdb5b8
Merge branch 'develop' into feature/create-folder-ui
ddyeon Jul 7, 2024
fd66fbc
[fix] 홈 폴더생성 뒤로가기 추가
ddyeon Jul 7, 2024
2f80adf
[fix] bottomsheet 닫힌 후 이동하도록 수정
ddyeon Jul 8, 2024
776d6b6
[fix] 폴더 생성 페이지에서 뒤로가기 시 바텀 시트 노출되도록 수정
ddyeon Jul 8, 2024
b087a47
[fix] bottomsheet annotation 추가
ddyeon Jul 9, 2024
c749480
[fix] defaultvalue제거
ddyeon Jul 9, 2024
2e35cb8
[fix] savestatehandler로 값 받기 수정
ddyeon Jul 9, 2024
af5835a
[fix] savestatehandle 찾는중,,
ddyeon Jul 10, 2024
ff0bd1a
[fix] savestatehandle을 위한,, viewmodel공유
ddyeon Jul 10, 2024
bb8d8ea
[fix] savestatehandle을 위한,, viewmodel공유
ddyeon Jul 10, 2024
a8dac49
[fix] bottomsheet 변경
ddyeon Jul 10, 2024
66093bb
[fix] 홈 폴더 생성 naventry 변경
ddyeon 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 @@ -12,7 +12,7 @@ import androidx.navigation.navOptions
import com.mashup.core.navigation.NavigationRoute
import com.mashup.dorabangs.core.designsystem.component.bottomnavigation.BottomNavigationDestination
import com.mashup.dorabangs.feature.navigation.navigateToHome
import com.mashup.dorabangs.feature.storage.navigation.navigateToStorage
import com.mashup.dorabangs.feature.navigation.navigateToStorage

@Composable
fun rememberDoraAppState(navController: NavHostController = rememberNavController()): DoraAppState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import com.dorabangs.feature.navigation.navigateToSaveLinkSelectFolder
import com.dorabangs.feature.navigation.saveLinkNavigation
import com.dorabangs.feature.navigation.saveLinkSelectFolder
import com.mashup.core.navigation.NavigationRoute
import com.mashup.dorabangs.feature.navigation.homeCreateFolderNavigation
import com.mashup.dorabangs.feature.navigation.homeNavigation
import com.mashup.dorabangs.feature.navigation.navigateToHome
import com.mashup.dorabangs.feature.navigation.navigateToHomeCrateFolder
import com.mashup.dorabangs.feature.navigation.navigateToStorageDetail
import com.mashup.dorabangs.feature.navigation.navigateToStorageFolderManage
import com.mashup.dorabangs.feature.navigation.onBoardingNavigation
import com.mashup.dorabangs.feature.storage.navigation.storageDetailNavigation
import com.mashup.dorabangs.feature.storage.navigation.storageNavigation
import com.mashup.dorabangs.feature.navigation.storageDetailNavigation
import com.mashup.dorabangs.feature.navigation.storageFolderManageNavigation
import com.mashup.dorabangs.feature.navigation.storageNavigation
import com.mashup.feature.classification.navigation.classificationNavigation
import com.mashup.feature.classification.navigation.navigateToClassification

Expand All @@ -28,6 +33,7 @@ fun MainNavHost(
navController = appState.navController,
startDestination = startDestination,
) {
onBoardingNavigation { appState.navController.navigateToHome() }
homeNavigation(
navigateToClassification = { appState.navController.navigateToClassification() },
navigateToSaveScreenWithLink = { copiedUrl ->
Expand All @@ -36,9 +42,24 @@ fun MainNavHost(
navigateToSaveScreenWithoutLink = {
appState.navController.navigateToSaveLink()
},
navigateToCreateFolder = { appState.navController.navigateToHomeCrateFolder() },
)
homeCreateFolderNavigation(
onClickBackIcon = {
appState.navController.previousBackStackEntry?.savedStateHandle?.set(
key = "isVisibleMovingBottomSheet",
value = true,
)
appState.navController.popBackStack()
},
)
storageNavigation(
navigateToStorageDetail = { appState.navController.navigateToStorageDetail() },
navigateToFolderManage = { folderManageType -> appState.navController.navigateToStorageFolderManage(folderManageType = folderManageType) },
)
storageFolderManageNavigation(
onClickBackIcon = { appState.navController.popBackStack() },
)
onBoardingNavigation { appState.navController.navigateToHome() }
storageNavigation(appState.navController)
storageDetailNavigation(appState.navController)
classificationNavigation(appState.navController)
saveLinkNavigation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ object DoraBottomSheet : BottomSheetType {
override fun MoreButtonBottomSheet(
modifier: Modifier,
isShowSheet: Boolean,
firstItemName: Int,
secondItemName: Int,
Comment on lines +25 to +26
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddyeon
리소스 어노테이션 붙이면 더 좋을듯 ~~

onClickDeleteLinkButton: () -> Unit,
onClickMoveFolderButton: () -> Unit,
onDismissRequest: () -> Unit,
Expand All @@ -39,12 +41,12 @@ object DoraBottomSheet : BottomSheetType {
items = listOf(
BottomSheetItemUIModel(
icon = R.drawable.ic_plus,
itemName = stringResource(id = R.string.more_button_bottom_sheet_remove_link),
itemName = stringResource(id = firstItemName),
color = DoraColorTokens.Alert,
),
BottomSheetItemUIModel(
icon = R.drawable.ic_plus,
itemName = stringResource(id = R.string.more_button_bottom_sheet_moving_folder),
itemName = stringResource(id = secondItemName),
),
),
onClickItem = { index ->
Expand All @@ -66,6 +68,8 @@ object DoraBottomSheet : BottomSheetType {
isShowSheet: Boolean,
folderList: List<SelectableBottomSheetItemUIModel>,
onDismissRequest: () -> Unit,
onClickCreateFolder: () -> Unit,
onClickMoveFolder: () -> Unit,
) {
if (isShowSheet) {
DoraBaseBottomSheet(
Expand Down Expand Up @@ -93,13 +97,15 @@ object DoraBottomSheet : BottomSheetType {
itemName = stringResource(id = R.string.moving_folder_dialog_add_folder),
isSelected = false,
),
onClickItem = onClickCreateFolder,
)
}

items(folderList.size) { index ->
DoraBottomSheetFolderItem(
modifier = Modifier.fillMaxWidth(),
data = folderList[index],
onClickItem = onClickMoveFolder,
)
}

Expand All @@ -125,6 +131,8 @@ sealed interface BottomSheetType {
fun MoreButtonBottomSheet(
modifier: Modifier,
isShowSheet: Boolean,
firstItemName: Int,
secondItemName: Int,
onClickDeleteLink: () -> Unit,
onClickMoveFolder: () -> Unit,
onDismissRequest: () -> Unit,
Expand All @@ -136,5 +144,7 @@ sealed interface BottomSheetType {
isShowSheet: Boolean,
folderList: List<SelectableBottomSheetItemUIModel>,
onDismissRequest: () -> Unit,
onClickCreateFolder: () -> Unit,
onClickMoveFolder: () -> Unit,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fun DoraBottomSheetFolderItem(
data: SelectableBottomSheetItemUIModel,
modifier: Modifier = Modifier,
background: Color = BottomSheetColorTokens.MovingFolderColor,
onClickItem: () -> Unit = {},
) {
Row(
modifier = modifier
Expand All @@ -102,10 +103,11 @@ fun DoraBottomSheetFolderItem(
verticalAlignment = Alignment.CenterVertically,
) {
DoraFolderListItem(
BottomSheetItemUIModel(
data = BottomSheetItemUIModel(
icon = data.icon,
itemName = data.itemName,
),
modifier = Modifier.clickable { onClickItem() },
)
if (data.isSelected) {
Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package com.mashup.core.navigation

sealed class NavigationRoute(val route: String) {
object OnBoardingScreen : NavigationRoute("onboarding")
object HomeScreen : NavigationRoute("home")
object HomeScreen : NavigationRoute("home") {
object HomeCreateFolder : NavigationRoute("home/createFolder")
}
object StorageScreen : NavigationRoute("storage") {
object StorageDetailScreen : NavigationRoute("storage/detail")
object StorageFolderManageScreen : NavigationRoute("storage/folderManage")
}
object ClassificationScreen : NavigationRoute("classification")
object SaveLink : NavigationRoute("save/copiedUrl") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.mashup.dorabangs.feature.createfolder

import androidx.compose.foundation.background
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.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.mashup.dorabangs.core.designsystem.component.buttons.DoraButtons
import com.mashup.dorabangs.core.designsystem.component.textfield.DoraTextField
import com.mashup.dorabangs.core.designsystem.component.topbar.DoraTopBar
import com.mashup.dorabangs.core.designsystem.theme.LinkSaveColorTokens
import com.mashup.dorabangs.home.R

@Composable
fun HomeCreateFolderRoute(
onClickBackIcon: () -> Unit,
) {
HomeCreateFolderScreen(
onClickBackIcon = onClickBackIcon,
onClickSaveButton = {},
)
}

@Composable
fun HomeCreateFolderScreen(
onClickBackIcon: () -> Unit,
onClickSaveButton: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier
.fillMaxSize()
.background(color = LinkSaveColorTokens.ContainerColor),
) {
DoraTopBar.BackNavigationTopBar(
modifier = Modifier,
title = stringResource(id = R.string.home_create_folder_title),
isTitleCenter = true,
onClickBackIcon = onClickBackIcon,
)
Spacer(modifier = Modifier.height(height = 24.dp))
Column(
modifier = modifier
.fillMaxSize()
.padding(horizontal = 20.dp),
) {
DoraTextField(
text = "",
hintText = stringResource(id = R.string.home_create_folder_hint),
labelText = stringResource(id = R.string.home_create_folder_label),
helperText = stringResource(id = R.string.home_create_folder_helper),
helperEnabled = true,
counterEnabled = true,
onValueChanged = {},
)
Spacer(modifier = Modifier.height(20.dp))
DoraButtons.DoraBtnMaxFull(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 20.dp),
buttonText = stringResource(id = R.string.home_create_folder_save),
enabled = true,
onClickButton = onClickSaveButton,
)
Spacer(modifier = Modifier.height(20.dp))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHostState
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
Expand Down Expand Up @@ -50,17 +51,26 @@ import org.orbitmvi.orbit.compose.collectSideEffect

@Composable
fun HomeRoute(
isVisibleBottomSheet: Boolean,
modifier: Modifier = Modifier,
view: View = LocalView.current,
clipboardManager: ClipboardManager = LocalClipboardManager.current,
viewModel: HomeViewModel = hiltViewModel(),
navigateToClassification: () -> Unit = {},
navigateToSaveScreenWithLink: (String) -> Unit = {},
navigateToSaveScreenWithoutLink: () -> Unit = {},
navigateToCreateFolder: () -> Unit,
) {
val snackBarHostState by remember { mutableStateOf(SnackbarHostState()) }
val state by viewModel.collectAsState()
val scope = rememberCoroutineScope()

LaunchedEffect(key1 = Unit) {
if (isVisibleBottomSheet) {
viewModel.setVisibleMovingFolderBottomSheet(true)
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddyeon
viewModel에 있는 데이터를 업데이트 하는 것 보다는 ViewModel의 SavedStateHandle에서 데이터를 받는게 더 좋아보여 ~
hiltViewModel이 그런거 해주는 녀석일거야

viewModel.collectSideEffect { sideEffect ->
when (sideEffect) {
is HomeSideEffect.ShowSnackBar -> {
Expand All @@ -71,10 +81,10 @@ fun HomeRoute(
)
}
}

HomeSideEffect.HideSnackBar -> {
is HomeSideEffect.HideSnackBar -> {
snackBarHostState.currentSnackbarData?.dismiss()
}
is HomeSideEffect.NavigateToCreateFolder -> navigateToCreateFolder()
}
}

Expand Down Expand Up @@ -115,6 +125,8 @@ fun HomeRoute(
DoraBottomSheet.MoreButtonBottomSheet(
modifier = Modifier.height(320.dp),
isShowSheet = state.isShowMoreButtonSheet,
firstItemName = R.string.more_button_bottom_sheet_remove_link,
secondItemName = R.string.more_button_bottom_sheet_moving_folder,
onClickDeleteLinkButton = {
viewModel.setVisibleMoreButtonBottomSheet(false)
viewModel.setVisibleDialog(true)
Expand All @@ -131,6 +143,8 @@ fun HomeRoute(
isShowSheet = state.isShowMovingFolderSheet,
folderList = testFolderListData,
onDismissRequest = { viewModel.setVisibleMovingFolderBottomSheet(false) },
onClickCreateFolder = { viewModel.setVisibleMovingFolderBottomSheet(visible = false, isNavigate = true) },
onClickMoveFolder = {},
)

DoraDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package com.mashup.dorabangs.feature.home
sealed class HomeSideEffect {
data class ShowSnackBar(val copiedText: String) : HomeSideEffect()
object HideSnackBar : HomeSideEffect()
object NavigateToCreateFolder : HomeSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ class HomeViewModel @Inject constructor(
}
}

fun setVisibleMovingFolderBottomSheet(visible: Boolean) = intent {
fun setVisibleMovingFolderBottomSheet(visible: Boolean, isNavigate: Boolean = false) = intent {
reduce {
state.copy(isShowMovingFolderSheet = visible)
}
if (isNavigate) postSideEffect(HomeSideEffect.NavigateToCreateFolder)
}

init {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mashup.dorabangs.feature.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import com.mashup.core.navigation.NavigationRoute
import com.mashup.dorabangs.feature.createfolder.HomeCreateFolderRoute

fun NavController.navigateToHomeCrateFolder(navOptions: NavOptions? = null) =
navigate(NavigationRoute.HomeScreen.HomeCreateFolder.route, navOptions)

fun NavGraphBuilder.homeCreateFolderNavigation(
onClickBackIcon: () -> Unit,
) {
composable(
route = NavigationRoute.HomeScreen.HomeCreateFolder.route,
) {
HomeCreateFolderRoute(
onClickBackIcon = onClickBackIcon,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.mashup.dorabangs.feature.navigation

import androidx.compose.runtime.collectAsState
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.mashup.core.navigation.NavigationRoute
import com.mashup.dorabangs.feature.home.HomeRoute

Expand All @@ -14,14 +17,28 @@ fun NavGraphBuilder.homeNavigation(
navigateToClassification: () -> Unit = {},
navigateToSaveScreenWithLink: (String) -> Unit,
navigateToSaveScreenWithoutLink: () -> Unit,
navigateToCreateFolder: () -> Unit,
) {
composable(
route = NavigationRoute.HomeScreen.route,
) {
arguments = listOf(
navArgument(name = "isVisibleMovingBottomSheet") {
type = NavType.BoolType
defaultValue = false
},
),
) { backStackEntry ->

val isVisibleBottomSheet = backStackEntry.savedStateHandle.getStateFlow(
"isVisibleMovingBottomSheet",
initialValue = false,
).collectAsState().value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddyeon
flow로 넘기고 collet해서 받는 방법이 필요한 이유가 뭐야 ??
그냥 Boolean 값을 가져오면 안되나?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

없는 것 같습니다. viewmodel에서 collect할 일이 없을 것 같아소 get으로 변경하겠숨당~

HomeRoute(
isVisibleBottomSheet = isVisibleBottomSheet,
navigateToClassification = navigateToClassification,
navigateToSaveScreenWithLink = navigateToSaveScreenWithLink,
navigateToSaveScreenWithoutLink = navigateToSaveScreenWithoutLink,
navigateToCreateFolder = navigateToCreateFolder,
)
}
}
Loading
Loading