From f1b0fb5a1fbd7257a79036b4d468790f19303f3c Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 00:35:50 +0900 Subject: [PATCH 01/11] =?UTF-8?q?:sparkle:=20=EB=A6=AC=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=EA=B7=B8=EB=A6=AC=EB=93=9C=20=EC=95=84=EC=9D=B4=EC=BD=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=B3=80=ED=99=98=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EB=8F=84=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/grouphome/GroupHomeScreen.kt | 150 ++++++++++++++---- .../ui/main/grouphome/GroupHomeViewModel.kt | 14 +- .../main/grouphome/model/GroupHomeUiState.kt | 6 + .../src/main/res/drawable/align_grid.xml | 18 +++ .../src/main/res/drawable/align_list.xml | 12 ++ presentation/src/main/res/values/strings.xml | 3 + 6 files changed, 174 insertions(+), 29 deletions(-) create mode 100644 presentation/src/main/res/drawable/align_grid.xml create mode 100644 presentation/src/main/res/drawable/align_list.xml diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt index e9d62c9c6..610e72268 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.LazyColumn @@ -42,6 +43,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.painter.ColorPainter @@ -51,6 +53,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.max import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import coil.compose.AsyncImage @@ -59,6 +62,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray0 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray100 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray20 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray40 +import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray50 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray60 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray80 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Malibu @@ -76,6 +80,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.Cl import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.FilterTag import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.GroupHomeUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.GroupInfo +import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.ViewType import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupKeyword import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupStatusType import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.PicPhotoFrame @@ -112,6 +117,7 @@ fun GroupHomeScreen( .padding(innerPadding), groupList = groupHomeUiState.groupList, filterTagList = groupHomeUiState.filterTagList, + viewType = groupHomeUiState.viewType, onClickGroupDetail = onClickGroupDetail, onClickEventMake = onClickEventMake, onClickMyPage = onClickMyPage, @@ -121,6 +127,7 @@ fun GroupHomeScreen( onNavigateVote = onNavigateVote, onNavigateGallery = onNavigateGallery, onClickFilterTag = viewModel::clickedFilterTag, + onClickViewType = viewModel::clickedViewType, ) } @@ -142,6 +149,7 @@ fun GroupHomeScreen( modifier: Modifier, groupList: ImmutableList, filterTagList: ImmutableList, + viewType: ViewType, onClickGroupDetail: (id: Long) -> Unit, onClickEventMake: (Long) -> Unit, onClickMyPage: () -> Unit, @@ -151,6 +159,7 @@ fun GroupHomeScreen( onNavigateGallery: (eventId: Long) -> Unit, onNavigateVote: (eventId: Long) -> Unit, onClickFilterTag: (FilterTag) -> Unit, + onClickViewType: (ViewType) -> Unit, ) { Box { Column( @@ -164,13 +173,35 @@ fun GroupHomeScreen( rightIconClicked = onClickMyPage, ) - TagFilter( + Box( modifier = Modifier .fillMaxWidth() .wrapContentHeight(), - filterTagList = filterTagList, - onTagClicked = onClickFilterTag, - ) + ) { + TagFilter( + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight(), + filterTagList = filterTagList, + onTagClicked = onClickFilterTag, + ) + Box( + modifier = Modifier + .width(100.dp) + .wrapContentHeight() + .background(brush = Brush.linearGradient(listOf(Color.Transparent, Gray0, Gray0))) + .align(Alignment.CenterEnd), + ) { + ViewTypeButton( + modifier = Modifier + .padding(top = 11.dp, bottom = 11.dp, end = 20.dp) + .wrapContentSize() + .align(Alignment.CenterEnd), + currentViewType = viewType, + onClickViewType = onClickViewType, + ) + } + } Spacer( modifier = Modifier @@ -180,33 +211,20 @@ fun GroupHomeScreen( .background(Gray20), ) - LazyColumn { - itemsIndexed(groupList) { index, groupInfo -> - GroupContainer( - modifier = if (index == 0) { - Modifier.padding(top = 24.dp) - } else if (index == groupList.lastIndex) { - Modifier.padding(bottom = 16.dp) - } else { - Modifier - }, - groupInfo = groupInfo, - onGroupDetailClick = onClickGroupDetail, - onClickSendFcmButton = onClickSendFcmButton, + when (viewType) { + ViewType.List -> { + GroupContainerList( + groupList = groupList, + onClickGroupDetail = onClickGroupDetail, onClickEventMake = onClickEventMake, - onNavigateVote = onNavigateVote, + onClickSendFcmButton = onClickSendFcmButton, onNavigateGallery = onNavigateGallery, + onNavigateVote = onNavigateVote, ) + } - if (groupList.lastIndex != index) { - Spacer( - modifier = Modifier - .padding(top = 46.dp, bottom = 24.dp) - .height(8.dp) - .fillMaxWidth() - .background(color = Gray20), - ) - } + ViewType.Grid -> { + // Todo : Grid 개발 } } } @@ -221,6 +239,80 @@ fun GroupHomeScreen( } } +@Composable +private fun ViewTypeButton( + modifier: Modifier, + currentViewType: ViewType, + onClickViewType: (ViewType) -> Unit, +) { + StableImage( + modifier = modifier.noRippleClickable { + when (currentViewType) { + ViewType.List -> onClickViewType(ViewType.Grid) + ViewType.Grid -> onClickViewType(ViewType.List) + } + }, + drawableResId = when (currentViewType) { + ViewType.List -> R.drawable.align_grid + ViewType.Grid -> R.drawable.align_list + }, + contentDescription = stringResource( + id = when (currentViewType) { + ViewType.List -> R.string.align_grid + ViewType.Grid -> R.string.align_list + }, + ), + colorFilter = ColorFilter.tint(color = Gray50), + ) +} + +@Composable +private fun GroupContainerList( + groupList: ImmutableList, + onClickGroupDetail: (id: Long) -> Unit, + onClickEventMake: (Long) -> Unit, + onClickSendFcmButton: (eventId: Long) -> Unit, + onNavigateGallery: (eventId: Long) -> Unit, + onNavigateVote: (eventId: Long) -> Unit, +) { + LazyColumn { + itemsIndexed(groupList) { index, groupInfo -> + GroupContainer( + modifier = if (index == 0) { + Modifier.padding(top = 24.dp) + } else if (index == groupList.lastIndex) { + Modifier.padding(bottom = 16.dp) + } else { + Modifier + }, + groupInfo = groupInfo, + onGroupDetailClick = onClickGroupDetail, + onClickSendFcmButton = onClickSendFcmButton, + onClickEventMake = onClickEventMake, + onNavigateVote = onNavigateVote, + onNavigateGallery = onNavigateGallery, + ) + + if (groupList.lastIndex != index) { + Spacer( + modifier = Modifier + .padding(top = 46.dp, bottom = 24.dp) + .height(8.dp) + .fillMaxWidth() + .background(color = Gray20), + ) + } + } + } +} + +@Composable +private fun GroupContainerGrid( + groupList: ImmutableList, +) { + +} + @Composable private fun TagFilter( modifier: Modifier, @@ -230,7 +322,7 @@ private fun TagFilter( LazyRow( modifier = modifier, horizontalArrangement = Arrangement.spacedBy(6.dp), - contentPadding = PaddingValues(horizontal = 10.dp), + contentPadding = PaddingValues(start = 10.dp, end = 70.dp), ) { itemsIndexed(filterTagList, key = { _, item -> item.name }) { _, tagInfo -> PicTag( @@ -747,6 +839,7 @@ private fun GroupHomeScreenPreview() { ), ), ), + viewType = ViewType.List, onClickGroupDetail = {}, onClickEventMake = {}, onClickMyPage = {}, @@ -756,5 +849,6 @@ private fun GroupHomeScreenPreview() { onNavigateGallery = {}, onNavigateVote = {}, onClickFilterTag = {}, + onClickViewType = {}, ) } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt index 4d4c187a6..879e2b6a5 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt @@ -6,6 +6,7 @@ import com.mashup.gabbangzip.sharedalbum.domain.usecase.group.GetGroupListUseCas import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.FilterTag import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.GroupHomeUiState +import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.ViewType import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.toFilterTag import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.toUiModel import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupKeyword @@ -26,8 +27,12 @@ class GroupHomeViewModel @Inject constructor( ) : ViewModel() { private val groupUiState = getGroupListUseCase() private val selectedTagFlow = MutableStateFlow(FilterTag.getTotalFilter()) + private val viewTypeFlow = MutableStateFlow(ViewType.List) + private val optionFlow = selectedTagFlow.combine(viewTypeFlow) { selectedTag, viewType -> + Pair(selectedTag, viewType) + } - val uiState = groupUiState.combine(selectedTagFlow) { groupList, selectedTag -> + val uiState = groupUiState.combine(optionFlow) { groupList, (selectedTag, viewType) -> if (groupList.isEmpty()) { GroupHomeUiState.NoGroup } else { @@ -50,6 +55,7 @@ class GroupHomeViewModel @Inject constructor( .toFilterTag(isSelected = it.keyword == selectedTag.name) }.distinct(), ), + viewType = viewType, ) } }.catch { @@ -72,4 +78,10 @@ class GroupHomeViewModel @Inject constructor( selectedTagFlow.emit(filterTag) } } + + fun clickedViewType(viewType: ViewType) { + viewModelScope.launch { + viewTypeFlow.emit(viewType) + } + } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt index d82730f51..acd7ab2ec 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt @@ -10,6 +10,12 @@ sealed class GroupHomeUiState { data class GroupList( val groupList: ImmutableList = ImmutableList(emptyList()), val filterTagList: ImmutableList = ImmutableList(emptyList()), + val viewType: ViewType = ViewType.List, ) : GroupHomeUiState() + data class Error(@StringRes val errorMessage: Int) : GroupHomeUiState() } + +enum class ViewType { + List, Grid +} diff --git a/presentation/src/main/res/drawable/align_grid.xml b/presentation/src/main/res/drawable/align_grid.xml new file mode 100644 index 000000000..4ad73acd3 --- /dev/null +++ b/presentation/src/main/res/drawable/align_grid.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/presentation/src/main/res/drawable/align_list.xml b/presentation/src/main/res/drawable/align_list.xml new file mode 100644 index 000000000..f3f899a20 --- /dev/null +++ b/presentation/src/main/res/drawable/align_list.xml @@ -0,0 +1,12 @@ + + + + diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index b3ddeed9d..5f39f860e 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -144,6 +144,9 @@ 싫어요 가이드 이미지 그룹원들을 쿡 찔렀어요! + 한줄로 보기 + 두줄로 보기 + 네트워크가 연결되어 있지 않습니다 서버가 원활하지 않습니다 From 5fe7dcf1c4fcded45ffbfea8bd823c66857eed91 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 01:03:16 +0900 Subject: [PATCH 02/11] =?UTF-8?q?:sparkle:=20GridItem=20Composable=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/grouphome/GroupHomeScreen.kt | 74 ++++++++++++++++--- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt index 610e72268..0a470b5e7 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt @@ -189,16 +189,29 @@ fun GroupHomeScreen( modifier = Modifier .width(100.dp) .wrapContentHeight() - .background(brush = Brush.linearGradient(listOf(Color.Transparent, Gray0, Gray0))) + .background( + brush = Brush.linearGradient( + listOf( + Color.Transparent, + Gray0, + Gray0, + ), + ), + ) .align(Alignment.CenterEnd), ) { ViewTypeButton( modifier = Modifier + .noRippleClickable { + when (viewType) { + ViewType.List -> onClickViewType(ViewType.Grid) + ViewType.Grid -> onClickViewType(ViewType.List) + } + } .padding(top = 11.dp, bottom = 11.dp, end = 20.dp) .wrapContentSize() .align(Alignment.CenterEnd), currentViewType = viewType, - onClickViewType = onClickViewType, ) } } @@ -224,7 +237,10 @@ fun GroupHomeScreen( } ViewType.Grid -> { - // Todo : Grid 개발 + GroupContainerGrid( + groupList = groupList, + onClickGroupDetail = onClickGroupDetail, + ) } } } @@ -243,15 +259,9 @@ fun GroupHomeScreen( private fun ViewTypeButton( modifier: Modifier, currentViewType: ViewType, - onClickViewType: (ViewType) -> Unit, ) { StableImage( - modifier = modifier.noRippleClickable { - when (currentViewType) { - ViewType.List -> onClickViewType(ViewType.Grid) - ViewType.Grid -> onClickViewType(ViewType.List) - } - }, + modifier = modifier, drawableResId = when (currentViewType) { ViewType.List -> R.drawable.align_grid ViewType.Grid -> R.drawable.align_list @@ -309,8 +319,52 @@ private fun GroupContainerList( @Composable private fun GroupContainerGrid( groupList: ImmutableList, + onClickGroupDetail: (id: Long) -> Unit, ) { + LazyVerticalGrid( + columns = GridCells.Fixed(2), + contentPadding = PaddingValues(vertical = 18.dp, horizontal = 16.dp), + verticalArrangement = Arrangement.spacedBy(18.dp), + horizontalArrangement = Arrangement.spacedBy(21.dp), + ) { + items(items = groupList) { groupInfo -> + GroupContainerGridItem( + groupInfo = groupInfo, + onClickGroupDetail = onClickGroupDetail, + ) + } + } +} +@Composable +private fun GroupContainerGridItem( + groupInfo: GroupInfo, + onClickGroupDetail: (id: Long) -> Unit, +) { + Column( + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight() + .noRippleClickable { onClickGroupDetail(groupInfo.id) }, + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + FrontCardImage( + modifier = Modifier.fillMaxSize(), + frameResId = groupInfo.frontImageFrame.frameResId, + imageUrl = groupInfo.cardFrontImageUrl, + backgroundColor = Gray0, + ) + Text( + text = groupInfo.name, + style = PicTypography.headBold16, + color = Gray80, + ) + GroupTag( + modifier = Modifier.fillMaxWidth(), + keyword = groupInfo.keyword, + statusDesc = groupInfo.statusDescription, + ) + } } @Composable From 28bc3d64056b6e3b8b54732b2b07607411b1cc76 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 01:03:39 +0900 Subject: [PATCH 03/11] :refactor: viewType -> currentViewType --- .../ui/main/grouphome/GroupHomeScreen.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt index 0a470b5e7..e3d4a0697 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt @@ -53,7 +53,6 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.max import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import coil.compose.AsyncImage @@ -117,7 +116,7 @@ fun GroupHomeScreen( .padding(innerPadding), groupList = groupHomeUiState.groupList, filterTagList = groupHomeUiState.filterTagList, - viewType = groupHomeUiState.viewType, + currentViewType = groupHomeUiState.viewType, onClickGroupDetail = onClickGroupDetail, onClickEventMake = onClickEventMake, onClickMyPage = onClickMyPage, @@ -149,7 +148,7 @@ fun GroupHomeScreen( modifier: Modifier, groupList: ImmutableList, filterTagList: ImmutableList, - viewType: ViewType, + currentViewType: ViewType, onClickGroupDetail: (id: Long) -> Unit, onClickEventMake: (Long) -> Unit, onClickMyPage: () -> Unit, @@ -203,7 +202,7 @@ fun GroupHomeScreen( ViewTypeButton( modifier = Modifier .noRippleClickable { - when (viewType) { + when (currentViewType) { ViewType.List -> onClickViewType(ViewType.Grid) ViewType.Grid -> onClickViewType(ViewType.List) } @@ -211,7 +210,7 @@ fun GroupHomeScreen( .padding(top = 11.dp, bottom = 11.dp, end = 20.dp) .wrapContentSize() .align(Alignment.CenterEnd), - currentViewType = viewType, + currentViewType = currentViewType, ) } } @@ -224,7 +223,7 @@ fun GroupHomeScreen( .background(Gray20), ) - when (viewType) { + when (currentViewType) { ViewType.List -> { GroupContainerList( groupList = groupList, @@ -893,7 +892,7 @@ private fun GroupHomeScreenPreview() { ), ), ), - viewType = ViewType.List, + currentViewType = ViewType.List, onClickGroupDetail = {}, onClickEventMake = {}, onClickMyPage = {}, From e2d945e6ddee248ce711bae63383450b5b312cc0 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 09:08:15 +0900 Subject: [PATCH 04/11] =?UTF-8?q?:truck:=20ViewType=20class=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/grouphome/model/GroupHomeUiState.kt | 4 ---- .../presentation/ui/main/grouphome/model/ViewType.kt | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt index acd7ab2ec..82c606bc2 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt @@ -15,7 +15,3 @@ sealed class GroupHomeUiState { data class Error(@StringRes val errorMessage: Int) : GroupHomeUiState() } - -enum class ViewType { - List, Grid -} diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt new file mode 100644 index 000000000..4a43243f9 --- /dev/null +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt @@ -0,0 +1,5 @@ +package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model + +enum class ViewType { + List, Grid +} From c445c0e2928e0b055945b9f0cadf71eb70c5509d Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 09:09:27 +0900 Subject: [PATCH 05/11] =?UTF-8?q?:recycle:=20combine=20=ED=95=98=EB=82=98?= =?UTF-8?q?=EB=A1=9C=20=EB=AA=A8=EC=95=84=EC=A3=BC=EB=8A=94=20=EB=B0=A9?= =?UTF-8?q?=ED=96=A5=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/grouphome/GroupHomeViewModel.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt index 879e2b6a5..405fc7610 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt @@ -28,11 +28,8 @@ class GroupHomeViewModel @Inject constructor( private val groupUiState = getGroupListUseCase() private val selectedTagFlow = MutableStateFlow(FilterTag.getTotalFilter()) private val viewTypeFlow = MutableStateFlow(ViewType.List) - private val optionFlow = selectedTagFlow.combine(viewTypeFlow) { selectedTag, viewType -> - Pair(selectedTag, viewType) - } - val uiState = groupUiState.combine(optionFlow) { groupList, (selectedTag, viewType) -> + val uiState = combine(groupUiState, selectedTagFlow, viewTypeFlow) { groupList, selectedTag, viewType -> if (groupList.isEmpty()) { GroupHomeUiState.NoGroup } else { From 3533b4ac11573f4dabffb70bf90a9d04d54a733c Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 09:12:12 +0900 Subject: [PATCH 06/11] =?UTF-8?q?:truck:=20ViewType=20=EA=B3=BC=20Gradient?= =?UTF-8?q?=20=EB=A5=BC=20=EB=B3=84=EB=8F=84=EC=9D=98=20Composable=20?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/grouphome/GroupHomeScreen.kt | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt index e3d4a0697..25074fbd0 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt @@ -10,6 +10,7 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row @@ -184,35 +185,10 @@ fun GroupHomeScreen( filterTagList = filterTagList, onTagClicked = onClickFilterTag, ) - Box( - modifier = Modifier - .width(100.dp) - .wrapContentHeight() - .background( - brush = Brush.linearGradient( - listOf( - Color.Transparent, - Gray0, - Gray0, - ), - ), - ) - .align(Alignment.CenterEnd), - ) { - ViewTypeButton( - modifier = Modifier - .noRippleClickable { - when (currentViewType) { - ViewType.List -> onClickViewType(ViewType.Grid) - ViewType.Grid -> onClickViewType(ViewType.List) - } - } - .padding(top = 11.dp, bottom = 11.dp, end = 20.dp) - .wrapContentSize() - .align(Alignment.CenterEnd), - currentViewType = currentViewType, - ) - } + ViewTypeWithGradient( + currentViewType = currentViewType, + onClickViewType = onClickViewType, + ) } Spacer( @@ -254,6 +230,42 @@ fun GroupHomeScreen( } } +@Composable +private fun BoxScope.ViewTypeWithGradient( + currentViewType: ViewType, + onClickViewType: (ViewType) -> Unit, +) { + Box( + modifier = Modifier + .width(100.dp) + .wrapContentHeight() + .background( + brush = Brush.linearGradient( + listOf( + Color.Transparent, + Gray0, + Gray0, + ), + ), + ) + .align(Alignment.CenterEnd), + ) { + ViewTypeButton( + modifier = Modifier + .noRippleClickable { + when (currentViewType) { + ViewType.List -> onClickViewType(ViewType.Grid) + ViewType.Grid -> onClickViewType(ViewType.List) + } + } + .padding(top = 11.dp, bottom = 11.dp, end = 20.dp) + .wrapContentSize() + .align(Alignment.CenterEnd), + currentViewType = currentViewType, + ) + } +} + @Composable private fun ViewTypeButton( modifier: Modifier, From 159bbfc4891370ffd0bba5c51824fabaeabe1e08 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 09:29:19 +0900 Subject: [PATCH 07/11] =?UTF-8?q?:sparkle:=20dataLayer,=20domainLayer=20?= =?UTF-8?q?=ED=99=88=20=EC=A0=95=EB=A0=AC=EC=83=81=ED=83=9C=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/LocalDataSourceImpl.kt | 9 +++++++++ .../data/repository/ConfigRepositoryImpl.kt | 8 ++++++++ .../domain/datasource/LocalDataSource.kt | 2 ++ .../domain/repository/ConfigRepository.kt | 2 ++ .../usecase/config/GetHomeAlignStateUseCase.kt | 14 ++++++++++++++ .../usecase/config/SaveHomeAlignStateUseCase.kt | 12 ++++++++++++ 6 files changed, 47 insertions(+) create mode 100644 domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt create mode 100644 domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt diff --git a/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/datasource/LocalDataSourceImpl.kt b/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/datasource/LocalDataSourceImpl.kt index 94cfb5125..ff241feb0 100644 --- a/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/datasource/LocalDataSourceImpl.kt +++ b/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/datasource/LocalDataSourceImpl.kt @@ -163,6 +163,14 @@ class LocalDataSourceImpl @Inject constructor( return getBoolean(KEY_IS_FIRST_OPEN, true) } + override fun saveHomeAlignState(alignState: String) { + putString(KEY_HOME_ALIGN_STATE, alignState) + } + + override fun getHomeAlignState(): String { + return getString(KEY_HOME_ALIGN_STATE, "") + } + companion object { private const val TAG = "preferences" private const val PREF_NAME = "pic_preferences" @@ -171,5 +179,6 @@ class LocalDataSourceImpl @Inject constructor( private const val KEY_USER_NAME = "key_user_name" private const val KEY_VOTE_FIRST_VISIT = "key_vote_first_visit" private const val KEY_IS_FIRST_OPEN = "key_is_first_open" + private const val KEY_HOME_ALIGN_STATE = "key_home_align_state" } } diff --git a/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/repository/ConfigRepositoryImpl.kt b/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/repository/ConfigRepositoryImpl.kt index 38ea64ef1..a1dd57cde 100644 --- a/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/repository/ConfigRepositoryImpl.kt +++ b/data/src/main/java/com/mashup/gabbangzip/sharedalbum/data/repository/ConfigRepositoryImpl.kt @@ -14,4 +14,12 @@ class ConfigRepositoryImpl @Inject constructor( override suspend fun getIsFirstOpen(): Boolean { return localDataSource.getIsFirstOpen() } + + override suspend fun saveHomeAlignState(alignState: String) { + localDataSource.saveHomeAlignState(alignState) + } + + override suspend fun getHomeAlignState(): String { + return localDataSource.getHomeAlignState() + } } diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/datasource/LocalDataSource.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/datasource/LocalDataSource.kt index 675497972..392cd934d 100644 --- a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/datasource/LocalDataSource.kt +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/datasource/LocalDataSource.kt @@ -15,4 +15,6 @@ interface LocalDataSource { fun getVoteFirstVisit(): Boolean fun saveIsFirstOpen(isFirstOpen: Boolean) fun getIsFirstOpen(): Boolean + fun saveHomeAlignState(alignState: String) + fun getHomeAlignState(): String } diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/repository/ConfigRepository.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/repository/ConfigRepository.kt index 125aacf05..d3071213c 100644 --- a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/repository/ConfigRepository.kt +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/repository/ConfigRepository.kt @@ -3,4 +3,6 @@ package com.mashup.gabbangzip.sharedalbum.domain.repository interface ConfigRepository { suspend fun saveIsFirstOpen(isFirstOpen: Boolean) suspend fun getIsFirstOpen(): Boolean + suspend fun saveHomeAlignState(alignState: String) + suspend fun getHomeAlignState(): String } diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt new file mode 100644 index 000000000..0e8506153 --- /dev/null +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt @@ -0,0 +1,14 @@ +package com.mashup.gabbangzip.sharedalbum.domain.usecase.config + +import com.mashup.gabbangzip.sharedalbum.domain.repository.ConfigRepository +import javax.inject.Inject + +class GetHomeAlignStateUseCase @Inject constructor( + private val configRepository: ConfigRepository, +) { + suspend operator fun invoke(): Result { + return runCatching { + configRepository.getHomeAlignState() + } + } +} diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt new file mode 100644 index 000000000..f8944e97a --- /dev/null +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt @@ -0,0 +1,12 @@ +package com.mashup.gabbangzip.sharedalbum.domain.usecase.config + +import com.mashup.gabbangzip.sharedalbum.domain.repository.ConfigRepository +import javax.inject.Inject + +class SaveHomeAlignStateUseCase @Inject constructor( + private val configRepository: ConfigRepository, +) { + suspend operator fun invoke(alignState: String) { + configRepository.saveHomeAlignState(alignState) + } +} From b13323b127c0dd26852339c99ac2897e47f64935 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 09:36:38 +0900 Subject: [PATCH 08/11] =?UTF-8?q?:recycle:=20Reusable=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/usecase/config/GetHomeAlignStateUseCase.kt | 2 ++ .../sharedalbum/domain/usecase/config/GetIsFirstOpenUseCase.kt | 2 ++ .../domain/usecase/config/SaveHomeAlignStateUseCase.kt | 2 ++ .../sharedalbum/domain/usecase/config/SaveIsFirstOpenUseCase.kt | 2 ++ 4 files changed, 8 insertions(+) diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt index 0e8506153..05ee02dbe 100644 --- a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt @@ -1,8 +1,10 @@ package com.mashup.gabbangzip.sharedalbum.domain.usecase.config import com.mashup.gabbangzip.sharedalbum.domain.repository.ConfigRepository +import dagger.Reusable import javax.inject.Inject +@Reusable class GetHomeAlignStateUseCase @Inject constructor( private val configRepository: ConfigRepository, ) { diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetIsFirstOpenUseCase.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetIsFirstOpenUseCase.kt index e2a409ff6..f4601f3b3 100644 --- a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetIsFirstOpenUseCase.kt +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetIsFirstOpenUseCase.kt @@ -1,8 +1,10 @@ package com.mashup.gabbangzip.sharedalbum.domain.usecase.config import com.mashup.gabbangzip.sharedalbum.domain.repository.ConfigRepository +import dagger.Reusable import javax.inject.Inject +@Reusable class GetIsFirstOpenUseCase @Inject constructor( private val configRepository: ConfigRepository, ) { diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt index f8944e97a..a4a596ba2 100644 --- a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveHomeAlignStateUseCase.kt @@ -1,8 +1,10 @@ package com.mashup.gabbangzip.sharedalbum.domain.usecase.config import com.mashup.gabbangzip.sharedalbum.domain.repository.ConfigRepository +import dagger.Reusable import javax.inject.Inject +@Reusable class SaveHomeAlignStateUseCase @Inject constructor( private val configRepository: ConfigRepository, ) { diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveIsFirstOpenUseCase.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveIsFirstOpenUseCase.kt index d563e5718..72b50ec7d 100644 --- a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveIsFirstOpenUseCase.kt +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/SaveIsFirstOpenUseCase.kt @@ -1,8 +1,10 @@ package com.mashup.gabbangzip.sharedalbum.domain.usecase.config import com.mashup.gabbangzip.sharedalbum.domain.repository.ConfigRepository +import dagger.Reusable import javax.inject.Inject +@Reusable class SaveIsFirstOpenUseCase @Inject constructor( private val configRepository: ConfigRepository, ) { From 909cd5c3f8fe3d6c6d23383f7a986a8bb897e101 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 09:52:58 +0900 Subject: [PATCH 09/11] =?UTF-8?q?:sparkle:=20ui=20Layer=20=ED=99=88=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=EC=83=81=ED=83=9C=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/config/GetHomeAlignStateUseCase.kt | 8 +++++--- .../ui/main/grouphome/GroupHomeViewModel.kt | 14 +++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt index 05ee02dbe..c8b2bad64 100644 --- a/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt +++ b/domain/src/main/java/com/mashup/gabbangzip/sharedalbum/domain/usecase/config/GetHomeAlignStateUseCase.kt @@ -2,15 +2,17 @@ package com.mashup.gabbangzip.sharedalbum.domain.usecase.config import com.mashup.gabbangzip.sharedalbum.domain.repository.ConfigRepository import dagger.Reusable +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow import javax.inject.Inject @Reusable class GetHomeAlignStateUseCase @Inject constructor( private val configRepository: ConfigRepository, ) { - suspend operator fun invoke(): Result { - return runCatching { - configRepository.getHomeAlignState() + operator fun invoke(): Flow { + return flow { + emit(configRepository.getHomeAlignState()) } } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt index 405fc7610..0b1fd48ba 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt @@ -2,6 +2,8 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.mashup.gabbangzip.sharedalbum.domain.usecase.config.GetHomeAlignStateUseCase +import com.mashup.gabbangzip.sharedalbum.domain.usecase.config.SaveHomeAlignStateUseCase import com.mashup.gabbangzip.sharedalbum.domain.usecase.group.GetGroupListUseCase import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.FilterTag @@ -16,6 +18,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import java.net.UnknownHostException @@ -24,10 +27,18 @@ import javax.inject.Inject @HiltViewModel class GroupHomeViewModel @Inject constructor( getGroupListUseCase: GetGroupListUseCase, + getHomeAlignStateUseCase: GetHomeAlignStateUseCase, + private val saveHomeAlignStateUseCase: SaveHomeAlignStateUseCase, ) : ViewModel() { private val groupUiState = getGroupListUseCase() private val selectedTagFlow = MutableStateFlow(FilterTag.getTotalFilter()) - private val viewTypeFlow = MutableStateFlow(ViewType.List) + private val viewTypeFlow = MutableStateFlow(ViewType.List).also { viewTypeFlow -> + viewModelScope.launch { + getHomeAlignStateUseCase() + .map { ViewType.valueOf(it) } + .collect(viewTypeFlow) + } + } val uiState = combine(groupUiState, selectedTagFlow, viewTypeFlow) { groupList, selectedTag, viewType -> if (groupList.isEmpty()) { @@ -79,6 +90,7 @@ class GroupHomeViewModel @Inject constructor( fun clickedViewType(viewType: ViewType) { viewModelScope.launch { viewTypeFlow.emit(viewType) + saveHomeAlignStateUseCase(viewType.name) } } } From b4dc9b3658a3d4bd4ba804d02b6d902420466348 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 09:58:17 +0900 Subject: [PATCH 10/11] =?UTF-8?q?:lipstick:=20List,=20Grid=20=EB=AA=A8?= =?UTF-8?q?=EB=91=90=20=EB=8C=80=EB=AC=B8=EC=9E=90=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/grouphome/GroupHomeScreen.kt | 18 +++++++++--------- .../ui/main/grouphome/GroupHomeViewModel.kt | 2 +- .../main/grouphome/model/GroupHomeUiState.kt | 2 +- .../ui/main/grouphome/model/ViewType.kt | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt index 25074fbd0..b52a7a14e 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeScreen.kt @@ -200,7 +200,7 @@ fun GroupHomeScreen( ) when (currentViewType) { - ViewType.List -> { + ViewType.LIST -> { GroupContainerList( groupList = groupList, onClickGroupDetail = onClickGroupDetail, @@ -211,7 +211,7 @@ fun GroupHomeScreen( ) } - ViewType.Grid -> { + ViewType.GRID -> { GroupContainerGrid( groupList = groupList, onClickGroupDetail = onClickGroupDetail, @@ -254,8 +254,8 @@ private fun BoxScope.ViewTypeWithGradient( modifier = Modifier .noRippleClickable { when (currentViewType) { - ViewType.List -> onClickViewType(ViewType.Grid) - ViewType.Grid -> onClickViewType(ViewType.List) + ViewType.LIST -> onClickViewType(ViewType.GRID) + ViewType.GRID -> onClickViewType(ViewType.LIST) } } .padding(top = 11.dp, bottom = 11.dp, end = 20.dp) @@ -274,13 +274,13 @@ private fun ViewTypeButton( StableImage( modifier = modifier, drawableResId = when (currentViewType) { - ViewType.List -> R.drawable.align_grid - ViewType.Grid -> R.drawable.align_list + ViewType.LIST -> R.drawable.align_grid + ViewType.GRID -> R.drawable.align_list }, contentDescription = stringResource( id = when (currentViewType) { - ViewType.List -> R.string.align_grid - ViewType.Grid -> R.string.align_list + ViewType.LIST -> R.string.align_grid + ViewType.GRID -> R.string.align_list }, ), colorFilter = ColorFilter.tint(color = Gray50), @@ -904,7 +904,7 @@ private fun GroupHomeScreenPreview() { ), ), ), - currentViewType = ViewType.List, + currentViewType = ViewType.LIST, onClickGroupDetail = {}, onClickEventMake = {}, onClickMyPage = {}, diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt index 0b1fd48ba..23c2b955a 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt @@ -32,7 +32,7 @@ class GroupHomeViewModel @Inject constructor( ) : ViewModel() { private val groupUiState = getGroupListUseCase() private val selectedTagFlow = MutableStateFlow(FilterTag.getTotalFilter()) - private val viewTypeFlow = MutableStateFlow(ViewType.List).also { viewTypeFlow -> + private val viewTypeFlow = MutableStateFlow(ViewType.LIST).also { viewTypeFlow -> viewModelScope.launch { getHomeAlignStateUseCase() .map { ViewType.valueOf(it) } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt index 82c606bc2..5686fb848 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/GroupHomeUiState.kt @@ -10,7 +10,7 @@ sealed class GroupHomeUiState { data class GroupList( val groupList: ImmutableList = ImmutableList(emptyList()), val filterTagList: ImmutableList = ImmutableList(emptyList()), - val viewType: ViewType = ViewType.List, + val viewType: ViewType = ViewType.LIST, ) : GroupHomeUiState() data class Error(@StringRes val errorMessage: Int) : GroupHomeUiState() diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt index 4a43243f9..0fe25a20c 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/ViewType.kt @@ -1,5 +1,5 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model enum class ViewType { - List, Grid + LIST, GRID } From ab5caf1a9a21f05408ae04c829dfac029e403220 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Fri, 4 Oct 2024 10:02:31 +0900 Subject: [PATCH 11/11] =?UTF-8?q?:bug:=20valueOf=20=EC=97=90=EC=84=9C=20cr?= =?UTF-8?q?ash=20=EB=B0=9C=EC=83=9D=ED=96=88=EC=9D=84=20=EB=95=8C=EC=9D=98?= =?UTF-8?q?=20=EB=B0=A9=EC=96=B4=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/grouphome/GroupHomeViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt index 23c2b955a..d72ccdcc2 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomeViewModel.kt @@ -35,7 +35,7 @@ class GroupHomeViewModel @Inject constructor( private val viewTypeFlow = MutableStateFlow(ViewType.LIST).also { viewTypeFlow -> viewModelScope.launch { getHomeAlignStateUseCase() - .map { ViewType.valueOf(it) } + .map { kotlin.runCatching { ViewType.valueOf(it) }.getOrDefault(ViewType.LIST) } .collect(viewTypeFlow) } }