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 all 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,19 @@ fun MainNavHost(
navigateToSaveScreenWithoutLink = {
appState.navController.navigateToSaveLink()
},
navigateToCreateFolder = { appState.navController.navigateToHomeCrateFolder() },
)
homeCreateFolderNavigation(
navController = appState.navController,
onClickBackIcon = { 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
@@ -1,5 +1,6 @@
package com.mashup.dorabangs.core.designsystem.component.bottomsheet

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
Expand All @@ -21,6 +22,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 +42,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 +69,8 @@ object DoraBottomSheet : BottomSheetType {
isShowSheet: Boolean,
folderList: List<SelectableBottomSheetItemUIModel>,
onDismissRequest: () -> Unit,
onClickCreateFolder: () -> Unit,
onClickMoveFolder: () -> Unit,
) {
if (isShowSheet) {
DoraBaseBottomSheet(
Expand Down Expand Up @@ -93,13 +98,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 +132,8 @@ sealed interface BottomSheetType {
fun MoreButtonBottomSheet(
modifier: Modifier,
isShowSheet: Boolean,
@StringRes firstItemName: Int,
@StringRes secondItemName: Int,
onClickDeleteLink: () -> Unit,
onClickMoveFolder: () -> Unit,
onDismissRequest: () -> Unit,
Expand All @@ -136,5 +145,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,79 @@
package com.mashup.dorabangs.feature.createfolder

import android.util.Log
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 androidx.hilt.navigation.compose.hiltViewModel
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.feature.home.HomeViewModel
import com.mashup.dorabangs.home.R

@Composable
fun HomeCreateFolderRoute(
homeViewModel: HomeViewModel = hiltViewModel(),
onClickBackIcon: () -> Unit,
) {
Log.d("DOAROA", "HomeCreateFolderRoute: $homeViewModel")
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 @@ -57,10 +57,12 @@ fun HomeRoute(
navigateToClassification: () -> Unit = {},
navigateToSaveScreenWithLink: (String) -> Unit = {},
navigateToSaveScreenWithoutLink: () -> Unit = {},
navigateToCreateFolder: () -> Unit,
) {
val snackBarHostState by remember { mutableStateOf(SnackbarHostState()) }
val state by viewModel.collectAsState()
val scope = rememberCoroutineScope()

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

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

Expand Down Expand Up @@ -115,6 +117,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 +135,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 @@ -20,12 +20,21 @@ import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor(
private val savedStateHandle: SavedStateHandle,
val savedStateHandle: SavedStateHandle,
private val getLastCopiedUrlUseCase: GetLastCopiedUrlUseCase,
private val setLastCopiedUrlUseCase: SetLastCopiedUrlUseCase,
) : ViewModel(), ContainerHost<HomeState, HomeSideEffect> {
override val container = container<HomeState, HomeSideEffect>(HomeState())

init {
viewModelScope.doraLaunch {
savedStateHandle.getStateFlow(
"isVisibleMovingBottomSheet",
initialValue = false,
).collect { isVisible -> setVisibleMovingFolderBottomSheet(visible = isVisible) }
}
}

fun changeSelectedTapIdx(index: Int) = intent {
reduce {
state.copy(selectedIndex = index)
Expand Down Expand Up @@ -71,10 +80,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,34 @@
package com.mashup.dorabangs.feature.navigation

import androidx.hilt.navigation.compose.hiltViewModel
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
import com.mashup.dorabangs.feature.home.HomeViewModel

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

fun NavGraphBuilder.homeCreateFolderNavigation(
navController: NavController,
onClickBackIcon: () -> Unit,
) {
composable(
route = NavigationRoute.HomeScreen.HomeCreateFolder.route,
) {
navController.previousBackStackEntry?.let { backStackEntry ->
val homeViewModel: HomeViewModel = hiltViewModel(backStackEntry)
homeViewModel.savedStateHandle["isVisibleMovingBottomSheet"] = true

HomeCreateFolderRoute(
homeViewModel = homeViewModel,
onClickBackIcon = onClickBackIcon,
)
} ?: HomeCreateFolderRoute(
onClickBackIcon = onClickBackIcon,
)
}
}
Loading
Loading