From 56f2821bfcc4993a44a5c36b640d4810686da144 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Wed, 21 Aug 2024 13:41:27 +0900 Subject: [PATCH 01/35] =?UTF-8?q?:hammer:=20true,false=EC=9D=BC=EB=95=8C?= =?UTF-8?q?=20=EC=8B=A4=ED=96=89=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=9C=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharedalbum/presentation/ui/splash/SplashActivity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/splash/SplashActivity.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/splash/SplashActivity.kt index 0115f4af..234e3582 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/splash/SplashActivity.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/splash/SplashActivity.kt @@ -75,9 +75,9 @@ class SplashActivity : ComponentActivity() { @SuppressLint("InlinedApi") private fun checkNotificationPermission() { if (askNotificationPermission()) { - requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) - } else { viewModel.checkUserLoggedIn() + } else { + requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) } } From ab5a2a4079a2de80cc3985bb4d21673bd3372595 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Wed, 21 Aug 2024 18:16:27 +0900 Subject: [PATCH 02/35] :recycle: TopBar -> PicBackButtonTopBar --- .../presentation/ui/common/TopBar.kt | 197 ------------------ .../ui/main/groupmember/GroupMemberScreen.kt | 18 +- .../ui/main/mypage/MyPageScreen.kt | 20 +- 3 files changed, 8 insertions(+), 227 deletions(-) delete mode 100644 presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/TopBar.kt diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/TopBar.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/TopBar.kt deleted file mode 100644 index bcfdd13a..00000000 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/TopBar.kt +++ /dev/null @@ -1,197 +0,0 @@ -package com.mashup.gabbangzip.sharedalbum.presentation.ui.common - -import androidx.annotation.DrawableRes -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.tooling.preview.PreviewParameter -import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import com.mashup.gabbangzip.sharedalbum.presentation.R -import com.mashup.gabbangzip.sharedalbum.presentation.utils.rippleClickable - -@Composable -fun TopBar( - modifier: Modifier = Modifier, - titleText: String = "", - titleAlign: TopBarTitleAlign = TopBarTitleAlign.CENTER, - titleStyle: TextStyle = TextStyle.Default, - leftIcon: TopBarIcon? = null, - rightIcon1: TopBarIcon? = null, - rightIcon2: TopBarIcon? = null, - topPadding: Dp = 0.dp, - bottomPadding: Dp = 0.dp, -) { - Box( - modifier = modifier - .fillMaxWidth() - .padding(top = topPadding, bottom = bottomPadding), - contentAlignment = Alignment.Center, - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .wrapContentHeight(), - verticalAlignment = Alignment.CenterVertically, - ) { - if (leftIcon?.resId != null) { - Image( - modifier = Modifier - .rippleClickable { leftIcon.iconClickListener() } - .padding(start = leftIcon.leftPadding, end = leftIcon.rightPadding) - .size(leftIcon.size), - painter = painterResource(id = leftIcon.resId), - contentDescription = leftIcon.description, - ) - } - Text( - modifier = Modifier.weight(1.0f), - text = if (titleAlign == TopBarTitleAlign.LEFT) titleText else "", - style = titleStyle, - ) - if (rightIcon1?.resId != null) { - Image( - modifier = Modifier - .rippleClickable { rightIcon1.iconClickListener() } - .padding(start = rightIcon1.leftPadding, end = rightIcon1.rightPadding) - .size(rightIcon1.size), - painter = painterResource(id = rightIcon1.resId), - contentDescription = rightIcon1.description, - ) - } - if (rightIcon2?.resId != null) { - Image( - modifier = Modifier - .rippleClickable { rightIcon2.iconClickListener() } - .padding(start = rightIcon2.leftPadding, end = rightIcon2.rightPadding) - .size(rightIcon2.size), - painter = painterResource(id = rightIcon2.resId), - contentDescription = rightIcon2.description, - ) - } - } - if (titleAlign == TopBarTitleAlign.CENTER) { - Text( - modifier = Modifier - .fillMaxWidth(1.0f) - .wrapContentHeight(), - text = titleText, - textAlign = TextAlign.Center, - style = titleStyle, - ) - } - } -} - -enum class TopBarTitleAlign { - CENTER, LEFT -} - -data class TopBarIcon( - @DrawableRes val resId: Int, - val description: String, - val size: Dp, - val leftPadding: Dp = 0.dp, - val rightPadding: Dp = 0.dp, - val iconClickListener: () -> Unit, -) - -class TopBarProvider : PreviewParameterProvider { - override val values: Sequence = sequenceOf( - TopBarState( - title = "제목 가운데", - textAlign = TopBarTitleAlign.CENTER, - ), - TopBarState( - title = "왼쪽 아이콘이 있는 가운데 제목", - textAlign = TopBarTitleAlign.CENTER, - leftIcon = TopBarIcon( - resId = R.drawable.ic_back, - size = 26.dp, - leftPadding = 16.dp, - description = "", - iconClickListener = {}, - ), - ), - TopBarState( - title = "왼쪽 아이콘이 있는 왼쪽 제목", - textAlign = TopBarTitleAlign.LEFT, - topPadding = 10.dp, - bottomPadding = 10.dp, - leftIcon = TopBarIcon( - resId = R.drawable.ic_back, - size = 26.dp, - leftPadding = 16.dp, - rightPadding = 8.dp, - description = "", - iconClickListener = {}, - ), - ), - TopBarState( - title = "다양한 사이즈 아이콘과 가운데 제목", - textAlign = TopBarTitleAlign.CENTER, - leftIcon = TopBarIcon( - resId = R.drawable.ic_back, - size = 26.dp, - leftPadding = 16.dp, - description = "", - iconClickListener = {}, - ), - rightIcon1 = TopBarIcon( - resId = R.drawable.ic_back, - size = 20.dp, - rightPadding = 10.dp, - description = "", - iconClickListener = {}, - ), - rightIcon2 = TopBarIcon( - resId = R.drawable.ic_back, - size = 42.dp, - rightPadding = 10.dp, - description = "", - iconClickListener = {}, - ), - topPadding = 10.dp, - bottomPadding = 10.dp, - ), - ) -} - -data class TopBarState( - val title: String, - val textAlign: TopBarTitleAlign = TopBarTitleAlign.CENTER, - val leftIcon: TopBarIcon? = null, - val rightIcon1: TopBarIcon? = null, - val rightIcon2: TopBarIcon? = null, - val topPadding: Dp = 0.dp, - val bottomPadding: Dp = 0.dp, -) - -@Preview(showBackground = true) -@Composable -fun TopBarPreview( - @PreviewParameter(TopBarProvider::class) state: TopBarState, -) { - TopBar( - titleText = state.title, - titleAlign = state.textAlign, - topPadding = state.topPadding, - bottomPadding = state.bottomPadding, - leftIcon = state.leftIcon, - rightIcon1 = state.rightIcon1, - rightIcon2 = state.rightIcon2, - ) -} diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt index f0124b21..1d736685 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt @@ -34,10 +34,8 @@ import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray0 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray60 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray80 import com.mashup.gabbangzip.sharedalbum.presentation.theme.PicTypography +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicBackButtonTopBar import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicNormalButton -import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.TopBar -import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.TopBarIcon -import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.TopBarTitleAlign import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupmember.model.Member import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupKeyword @@ -81,18 +79,10 @@ private fun GroupMemberScreen( .fillMaxSize() .background(Gray0), ) { - TopBar( - leftIcon = TopBarIcon( - size = 26.dp, - leftPadding = 16.dp, - description = stringResource(id = R.string.go_back), - resId = R.drawable.ic_back, - iconClickListener = onClickBackButton, - ), + PicBackButtonTopBar( + modifier = Modifier.padding(top = 16.dp), titleText = stringResource(id = R.string.group_member_list_title), - titleAlign = TopBarTitleAlign.CENTER, - topPadding = 16.dp, - bottomPadding = 16.dp, + backButtonClicked = onClickBackButton, ) GroupMemberScreenContent( modifier = Modifier.fillMaxWidth(), diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt index 285d7170..0396f95d 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt @@ -33,11 +33,8 @@ import androidx.lifecycle.repeatOnLifecycle import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray0 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray20 -import com.mashup.gabbangzip.sharedalbum.presentation.theme.PicTypography +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicBackButtonTopBar import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicSnackbarHost -import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.TopBar -import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.TopBarIcon -import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.TopBarTitleAlign import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.showPicSnackbar import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.mypage.component.GroupItemNormal @@ -140,19 +137,10 @@ fun MyPageScreen( modifier = modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, ) { - TopBar( - leftIcon = TopBarIcon( - size = 26.dp, - leftPadding = 16.dp, - description = stringResource(id = R.string.go_back), - resId = R.drawable.ic_back, - iconClickListener = onClickBack, - ), + PicBackButtonTopBar( + modifier = Modifier.padding(top = 16.dp), titleText = stringResource(id = R.string.my_page), - titleAlign = TopBarTitleAlign.CENTER, - titleStyle = PicTypography.bodyMedium16, - topPadding = 10.dp, - bottomPadding = 10.dp, + backButtonClicked = onClickBack, ) UserContainer( modifier = Modifier From adf46554cf1c4a07c3f45b938102a74cb12bceab Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Wed, 21 Aug 2024 18:30:13 +0900 Subject: [PATCH 03/35] =?UTF-8?q?:buf:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=84=88=EB=AC=B4=20=EB=82=B4=EB=A0=A4?= =?UTF-8?q?=EC=99=80=EC=9E=88=EB=8A=94=20=EC=9D=B4=EC=8A=88=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt index 0396f95d..c76d1076 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/mypage/MyPageScreen.kt @@ -138,7 +138,6 @@ fun MyPageScreen( horizontalAlignment = Alignment.CenterHorizontally, ) { PicBackButtonTopBar( - modifier = Modifier.padding(top = 16.dp), titleText = stringResource(id = R.string.my_page), backButtonClicked = onClickBack, ) From 1873243689484a64fb53992872c86064f3e04280 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Wed, 21 Aug 2024 18:38:26 +0900 Subject: [PATCH 04/35] =?UTF-8?q?:bug:=20FloatingActionButton=20=ED=81=B4?= =?UTF-8?q?=EB=A6=AD=ED=95=98=EB=A9=B4=20=EB=8B=AB=ED=9E=88=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=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/GroupHomeScreen.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 cd3b1f69..d5251fff 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 @@ -415,8 +415,14 @@ private fun GroupFloatingButton( shape = RoundedCornerShape(16.dp), ) .padding(16.dp), - onClickGroupMake = onClickGroupMake, - onClickGroupEnter = onClickGroupEnter, + onClickGroupMake = { + isExpanded = false + onClickGroupMake() + }, + onClickGroupEnter = { + isExpanded = false + onClickGroupEnter() + }, ) } From 4cbdff760166cf2cd78d7630197407fc76a8a3ac Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Wed, 21 Aug 2024 19:13:28 +0900 Subject: [PATCH 05/35] =?UTF-8?q?:bug:=20GroupHomeScreen=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=20=EC=8B=A4=ED=8C=A8=20=EC=8B=9C=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/grouphome/GroupHomeScreen.kt | 7 +++++++ .../ui/main/grouphome/GroupHomeViewModel.kt | 12 ++++++++++++ .../ui/main/grouphome/model/GroupHomeUiState.kt | 2 ++ .../main/grouphome/navigation/GroupHomeNavigation.kt | 3 +++ .../presentation/ui/main/navigation/MainNavHost.kt | 1 + .../sharedalbum/presentation/utils/ImmutableList.kt | 2 +- presentation/src/main/res/values/strings.xml | 3 +++ 7 files changed, 29 insertions(+), 1 deletion(-) 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 cd3b1f69..bd61b22a 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 @@ -56,6 +56,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.FlippableBox import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicNormalButton import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTag import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTopBar +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicTopBarIcon import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.GroupEvent import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.CardBackImage @@ -80,6 +81,7 @@ fun GroupHomeScreen( navigateToGroupCreationAndFinish: () -> Unit, onNavigateGallery: (eventId: Long) -> Unit, onNavigateVote: (eventId: Long) -> Unit, + onShowSnackbar: (PicSnackbarType, String) -> Unit, viewModel: GroupHomeViewModel = hiltViewModel(), ) { val state by viewModel.groupUiState.collectAsStateWithLifecycle() @@ -103,6 +105,11 @@ fun GroupHomeScreen( ) } + is GroupHomeUiState.Error -> { + val message = (state as GroupHomeUiState.Error).errorMessage + onShowSnackbar(PicSnackbarType.WARNING, stringResource(id = message)) + } + else -> {} } } 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 82e3ff85..b4aaf3e1 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 @@ -3,13 +3,16 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope 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.GroupHomeUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.toUiModel import com.mashup.gabbangzip.sharedalbum.presentation.utils.ImmutableList import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn +import java.net.UnknownHostException import javax.inject.Inject @HiltViewModel @@ -24,6 +27,15 @@ class GroupHomeViewModel @Inject constructor( } else { GroupHomeUiState.GroupList(ImmutableList(groupList.toUiModel())) } + }.catch { + emit( + GroupHomeUiState.Error( + when (it) { + is UnknownHostException -> R.string.error_network + else -> R.string.error_server + } + ) + ) } .stateIn( scope = viewModelScope, 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 c9ae1f57..30ed9d0a 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 @@ -1,5 +1,6 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model +import androidx.annotation.StringRes import com.mashup.gabbangzip.sharedalbum.presentation.utils.ImmutableList sealed class GroupHomeUiState { @@ -9,4 +10,5 @@ sealed class GroupHomeUiState { data class GroupList( val groupList: ImmutableList = ImmutableList(emptyList()), ) : GroupHomeUiState() + data class Error(@StringRes val errorMessage: Int) : GroupHomeUiState() } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/navigation/GroupHomeNavigation.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/navigation/GroupHomeNavigation.kt index 25498490..eb886f91 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/navigation/GroupHomeNavigation.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/navigation/GroupHomeNavigation.kt @@ -3,6 +3,7 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.navigat import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.GroupHomeScreen import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.navigation.MainRoute @@ -20,6 +21,7 @@ fun NavGraphBuilder.groupHomeNavGraph( onClickSendFcmButton: (eventId: Long) -> Unit, onNavigateGallery: (eventId: Long) -> Unit, onNavigateVote: (eventId: Long) -> Unit, + onShowSnackbar: (PicSnackbarType, String) -> Unit, ) { composable(route = MainRoute.GroupHomeRoute.route) { GroupHomeScreen( @@ -32,6 +34,7 @@ fun NavGraphBuilder.groupHomeNavGraph( onClickSendFcmButton = onClickSendFcmButton, onNavigateGallery = onNavigateGallery, onNavigateVote = onNavigateVote, + onShowSnackbar = onShowSnackbar, ) } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt index 25c37bfe..a823938a 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt @@ -52,6 +52,7 @@ fun MainNavHost( onClickSendFcmButton = onClickSendFcmButton, onNavigateGallery = onClickOpenPhotoPickerButton, onNavigateVote = { id -> VoteActivity.openActivity(context, id) }, + onShowSnackbar = onSnackbarRequired, ) groupDetailNavGraph( onClickGroupMemberButton = { id, keyword -> diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ImmutableList.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ImmutableList.kt index 7789e2de..0a418b20 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ImmutableList.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ImmutableList.kt @@ -4,4 +4,4 @@ import androidx.compose.runtime.Immutable import java.io.Serializable @Immutable -class ImmutableList(private val list: List) : List by list, Serializable +class ImmutableList(private val list: List = listOf()) : List by list, Serializable diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 55332961..8240342c 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -139,4 +139,7 @@ 좋아요 가이드 이미지 싫어요 가이드 이미지 그룹원들을 쿡 찔렀어요! + + 네트워크가 연결되어 있지 않습니다 + 서버가 원활하지 않습니다 From 8d5b2329c56b9bb4ecb18b8706f4ceab33187f11 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Wed, 21 Aug 2024 19:19:32 +0900 Subject: [PATCH 06/35] =?UTF-8?q?:hammer:=20ktlint=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=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 | 4 ++-- 1 file changed, 2 insertions(+), 2 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 b4aaf3e1..9c1a059b 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 @@ -33,8 +33,8 @@ class GroupHomeViewModel @Inject constructor( when (it) { is UnknownHostException -> R.string.error_network else -> R.string.error_server - } - ) + }, + ), ) } .stateIn( From a236b7919f7a1eabb053dcca2976c92feb003a5a Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Wed, 21 Aug 2024 19:53:40 +0900 Subject: [PATCH 07/35] =?UTF-8?q?:bug:=20=EC=B9=B4=EC=B9=B4=EC=98=A4?= =?UTF-8?q?=EC=95=B1=20=EA=B9=94=EB=A0=A4=EC=9E=88=EC=9D=84=20=EB=95=8C=20?= =?UTF-8?q?=EC=B9=B4=EC=B9=B4=EC=98=A4=EB=A1=9C=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/login/LoginActivity.kt | 9 ++- .../presentation/ui/login/LoginViewModel.kt | 61 ++++++++----------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginActivity.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginActivity.kt index f439e1d2..53a81e5c 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginActivity.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginActivity.kt @@ -20,6 +20,7 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.mashup.gabbangzip.sharedalbum.presentation.R +import com.mashup.gabbangzip.sharedalbum.presentation.auth.KakaoUserSdkUtil import com.mashup.gabbangzip.sharedalbum.presentation.theme.SharedAlbumTheme import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicSnackbarHost import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType @@ -51,7 +52,13 @@ class LoginActivity : ComponentActivity() { ) { contentPadding -> Box(modifier = Modifier.padding(contentPadding)) { LoginScreen( - onClickLoginButton = viewModel::login, + onClickLoginButton = { + KakaoUserSdkUtil.loginWithKakao( + context = this@LoginActivity, + onSuccess = viewModel::kakaoLoginSuccess, + onFailure = viewModel::kakaoLoginFailure, + ) + }, ) } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginViewModel.kt index de187ccb..eec6e758 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/login/LoginViewModel.kt @@ -1,13 +1,11 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.login -import android.content.Context import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.kakao.sdk.user.model.Profile import com.mashup.gabbangzip.sharedalbum.domain.model.LoginParam import com.mashup.gabbangzip.sharedalbum.domain.usecase.LoginUseCase -import com.mashup.gabbangzip.sharedalbum.presentation.auth.KakaoUserSdkUtil import dagger.hilt.android.lifecycle.HiltViewModel -import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow @@ -17,42 +15,37 @@ import javax.inject.Inject @HiltViewModel class LoginViewModel @Inject constructor( - @ApplicationContext private val context: Context, private val loginUseCase: LoginUseCase, ) : ViewModel() { private val _uiState = MutableStateFlow(LoginUiState()) val uiState: StateFlow = _uiState.asStateFlow() - fun login() { - KakaoUserSdkUtil.loginWithKakao( - context = context, - onSuccess = { idToken, profile -> - val nickname = profile.nickname - val profileImage = profile.profileImageUrl - if (nickname != null && profileImage != null) { - picLogin( - idToken = idToken, - nickname = nickname, - profileImage = profileImage, - ) - } else { - _uiState.update { state -> - state.copy( - isLoading = false, - errorMessage = "정보 조회 실패", - ) - } - } - }, - onFailure = { - _uiState.update { state -> - state.copy( - isLoading = false, - errorMessage = "카카오 로그인 실패 또는 정보 조회 실패 $it", - ) - } - }, - ) + fun kakaoLoginSuccess(idToken: String, profile: Profile) { + val nickname = profile.nickname + val profileImage = profile.profileImageUrl + if (nickname != null && profileImage != null) { + picLogin( + idToken = idToken, + nickname = nickname, + profileImage = profileImage, + ) + } else { + _uiState.update { state -> + state.copy( + isLoading = false, + errorMessage = "정보 조회 실패", + ) + } + } + } + + fun kakaoLoginFailure(throwable: Throwable?) { + _uiState.update { state -> + state.copy( + isLoading = false, + errorMessage = "카카오 로그인 실패 또는 정보 조회 실패 $throwable", + ) + } } private fun picLogin(idToken: String, nickname: String, profileImage: String) { From dfed1f912f8942b3d625c091e89c7e7ab0e84b75 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Thu, 22 Aug 2024 09:18:18 +0900 Subject: [PATCH 08/35] =?UTF-8?q?:sparkles:=20haptic=20boolean=20=EC=9D=B8?= =?UTF-8?q?=EC=9E=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/common/PicButton.kt | 5 +++-- .../ui/main/grouphome/GroupHomeScreen.kt | 2 ++ .../presentation/utils/ModifierExt.kt | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicButton.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicButton.kt index 26d410f4..05d958fe 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicButton.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicButton.kt @@ -103,6 +103,7 @@ fun PicNormalButton( backgroundColor: Color = Gray80, contentColor: Color = Gray0, @DrawableRes iconRes: Int? = null, + isHaptic: Boolean = false, onButtonClicked: () -> Unit = {}, ) { Box( @@ -111,9 +112,9 @@ fun PicNormalButton( .background(if (enable) backgroundColor else SilverSand) .then( if (isRippleClickable) { - Modifier.rippleClickable(onClick = onButtonClicked) + Modifier.rippleClickable(onClick = onButtonClicked, isHaptic = isHaptic) } else { - Modifier.noRippleClickable(onClick = onButtonClicked) + Modifier.noRippleClickable(onClick = onButtonClicked, isHaptic = isHaptic) }, ) .padding( 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 cd3b1f69..eba7de58 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 @@ -225,7 +225,9 @@ private fun GroupContainer( .padding(top = 16.dp) .align(Alignment.CenterHorizontally), iconRes = iconResId, + isRippleClickable = true, text = stringResource(textResId), + isHaptic = ClickType.Fcm == clickType, onButtonClicked = { when (clickType) { ClickType.Fcm -> onClickSendFcmButton(groupInfo.recentEvent.id) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ModifierExt.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ModifierExt.kt index 0fb72c07..10ccaf30 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ModifierExt.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ModifierExt.kt @@ -8,12 +8,15 @@ import androidx.compose.material.ripple.rememberRipple import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.composed +import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.semantics.Role fun Modifier.rippleClickable( enabled: Boolean = true, + isHaptic: Boolean = false, onClickLabel: String? = null, role: Role? = null, onClick: () -> Unit, @@ -22,6 +25,7 @@ fun Modifier.rippleClickable( interactionSource = remember { MutableInteractionSource() }, indication = rememberRipple(), enabled = enabled, + isHaptic = isHaptic, onClickLabel = onClickLabel, role = role, onClick = onClick, @@ -30,6 +34,7 @@ fun Modifier.rippleClickable( fun Modifier.noRippleClickable( enabled: Boolean = true, + isHaptic: Boolean = false, onClickLabel: String? = null, role: Role? = null, onClick: () -> Unit, @@ -37,10 +42,11 @@ fun Modifier.noRippleClickable( this then singleClickable( interactionSource = remember { MutableInteractionSource() }, indication = null, + onClick = onClick, enabled = enabled, + isHaptic = isHaptic, onClickLabel = onClickLabel, role = role, - onClick = onClick, ) } @@ -48,11 +54,13 @@ private fun Modifier.singleClickable( interactionSource: MutableInteractionSource, indication: Indication?, onClick: () -> Unit, + isHaptic: Boolean, enabled: Boolean = true, onClickLabel: String? = null, role: Role? = null, debounceMillis: Long = 300L, ): Modifier = composed { + val hapticFeedback = LocalHapticFeedback.current multipleEventsCutter(debounceMillis = debounceMillis) { manager -> this then clickable( interactionSource = interactionSource, @@ -60,7 +68,12 @@ private fun Modifier.singleClickable( enabled = enabled, onClickLabel = onClickLabel, role = role, - onClick = { manager.processEvent { onClick() } }, + onClick = { + if (isHaptic) { + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) + } + manager.processEvent { onClick() } + }, ) } } From 27777270d0baedbfbe0f6e51a32cf476c68192f9 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Thu, 22 Aug 2024 09:18:26 +0900 Subject: [PATCH 09/35] =?UTF-8?q?:sparkles:=20=EB=A6=AC=ED=94=8C=ED=9A=A8?= =?UTF-8?q?=EA=B3=BC=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/GroupHomePhotoCard.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt index 1ae395cc..ce14767f 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt @@ -63,6 +63,7 @@ fun GroupHomePhotoCard( modifier = Modifier .align(Alignment.BottomCenter) .padding(top = 19.dp, bottom = 34.dp), + isRippleClickable = true, text = stringResource(R.string.event_creation_btn_text), onButtonClicked = { onClickEventMake(groupInfo.id) From b877733f43d2def1ba32d4da740a958998eb5c76 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Thu, 22 Aug 2024 09:46:26 +0900 Subject: [PATCH 10/35] =?UTF-8?q?:recycle:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/grouphome/GroupHomeViewModel.kt | 3 ++- 1 file changed, 2 insertions(+), 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 9c1a059b..585a7fa1 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 @@ -27,7 +27,8 @@ class GroupHomeViewModel @Inject constructor( } else { GroupHomeUiState.GroupList(ImmutableList(groupList.toUiModel())) } - }.catch { + } + .catch { emit( GroupHomeUiState.Error( when (it) { From 9037b0d8b7e59c964519bd643745462abc34cce0 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Thu, 22 Aug 2024 09:46:57 +0900 Subject: [PATCH 11/35] =?UTF-8?q?:recycle:=204=EA=B0=9C=EB=A7=8C=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=AC=20=EC=88=98=20=EC=9E=88=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=BD=94=EB=93=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/model/CardBackImage.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt index ea2a7aa0..527f1df3 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt @@ -17,5 +17,9 @@ fun CardBackImageDomainModel.toUiModel(): CardBackImage { } fun List.toUiModel(): List { - return map { it.toUiModel() } + return if (size >= 4) { + take(4).toUiModel() + } else { + emptyList() + } } From 075300afa850d5a797452fc1d80f66625481e38f Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Thu, 22 Aug 2024 10:00:41 +0900 Subject: [PATCH 12/35] =?UTF-8?q?:sparkles:=20=EB=94=94=ED=85=8C=EC=9D=BC?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=97=90=20haptic=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/groupdetail/GroupDetailRecentEvent.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailRecentEvent.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailRecentEvent.kt index 7bd0fd2b..eedfe532 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailRecentEvent.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailRecentEvent.kt @@ -275,6 +275,8 @@ private fun RecentEventBottomSection( text = buttonState.textResId?.let { resId -> stringResource(id = resId) }.orEmpty(), + isRippleClickable = true, + isHaptic = R.drawable.ic_group_notice == buttonState.iconResId, iconRes = buttonState.iconResId, onButtonClicked = onClickActionButton, ) From 50ec54f570e40990992e90b1735a16a21abf6dfc Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Thu, 22 Aug 2024 21:20:52 +0900 Subject: [PATCH 13/35] =?UTF-8?q?:recycle:=20GroupDetail=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A1=B0=ED=9A=8C=20=EC=8B=A4=ED=8C=A8=EC=8B=9C=20?= =?UTF-8?q?Snackbar=20=ED=98=B8=EC=B6=9C=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/MainActivity.kt | 1 - .../ui/main/groupdetail/GroupDetailScreen.kt | 42 +++++++++++-------- .../main/groupdetail/GroupDetailViewModel.kt | 12 +++++- .../groupdetail/model/GroupDetailUiState.kt | 3 +- .../navigation/GroupDetailNavigation.kt | 5 ++- .../ui/main/navigation/MainNavHost.kt | 3 +- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt index b3e85f32..9c53962a 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt @@ -96,7 +96,6 @@ class MainActivity : ComponentActivity() { snackbarHostState.showPicSnackbar(type, message) } }, - onErrorEvent = { showToast(R.string.error_retry) }, ) } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailScreen.kt index 0fbae902..8b09f067 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailScreen.kt @@ -15,15 +15,18 @@ import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray0 import com.mashup.gabbangzip.sharedalbum.presentation.theme.SharedAlbumTheme import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicBackButtonTopBar import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTopBarTitleAlign +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicTopBarIcon import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.GroupDetailUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.GroupEvent @@ -45,13 +48,14 @@ fun GroupDetailScreen( onClickShareButton: (Bitmap) -> Unit, onClickEventMake: () -> Unit, onClickHistoryItem: (HistoryDetailState) -> Unit, - onErrorEvent: () -> Unit, + onShowSnackbar: (PicSnackbarType, String) -> Unit, viewModel: GroupDetailViewModel = hiltViewModel(), ) { val state by viewModel.uiState.collectAsStateWithLifecycle() + val errorRetryMessage = stringResource(id = R.string.error_retry) - if (state.isError) { - onErrorEvent() + state.errorMessage?.let { errorMessage -> + onShowSnackbar(PicSnackbarType.WARNING, stringResource(id = errorMessage)) } if (state.status == GroupStatusType.EVENT_COMPLETED) { @@ -61,11 +65,11 @@ fun GroupDetailScreen( GroupDetailScreen( state = state, onClickGroupMemberButton = { - state.groupInfo - ?.let { - onClickGroupMemberButton(it.keyword) - } - ?: onErrorEvent() + state.groupInfo?.let { + onClickGroupMemberButton(it.keyword) + } ?: run { + onShowSnackbar(PicSnackbarType.WARNING, errorRetryMessage) + } }, onClickBackButton = onClickBackButton, onClickActionButton = { status -> @@ -75,19 +79,19 @@ fun GroupDetailScreen( } GroupStatusType.AFTER_MY_UPLOAD, GroupStatusType.AFTER_MY_VOTE -> { - state.recentEvent - ?.let { - onClickSendFcmButton(it.id) - } - ?: onErrorEvent() + state.recentEvent?.let { + onClickSendFcmButton(it.id) + } ?: run { + onShowSnackbar(PicSnackbarType.WARNING, errorRetryMessage) + } } GroupStatusType.BEFORE_MY_VOTE -> { - state.recentEvent - ?.let { event -> - onClickVoteButton(event.id) - } - ?: onErrorEvent() + state.recentEvent?.let { event -> + onClickVoteButton(event.id) + } ?: run { + onShowSnackbar(PicSnackbarType.WARNING, errorRetryMessage) + } } else -> {} @@ -105,6 +109,8 @@ fun GroupDetailScreen( history = history, ), ) + } ?: run { + onShowSnackbar(PicSnackbarType.WARNING, errorRetryMessage) } }, ) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt index 6027c5d5..fe505383 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt @@ -5,8 +5,10 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.mashup.gabbangzip.sharedalbum.domain.usecase.event.MarkEventVisitUseCase import com.mashup.gabbangzip.sharedalbum.domain.usecase.group.GetGroupDetailUseCase +import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.GroupDetailUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.toUiModel +import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.GroupHomeUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.toUiModel import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.navigation.MainRoute import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupStatusType @@ -16,6 +18,7 @@ import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch +import java.net.UnknownHostException import javax.inject.Inject @HiltViewModel @@ -36,8 +39,13 @@ class GroupDetailViewModel @Inject constructor( history = groupDetail.history.map { it.toUiModel() }, ) }.catch { - GroupDetailUiState( - isError = true, + emit( + GroupDetailUiState( + errorMessage = when (it) { + is UnknownHostException -> R.string.error_network + else -> R.string.error_server + }, + ), ) }.stateIn( scope = viewModelScope, diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/model/GroupDetailUiState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/model/GroupDetailUiState.kt index 4e81bc74..4085210d 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/model/GroupDetailUiState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/model/GroupDetailUiState.kt @@ -1,5 +1,6 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model +import androidx.annotation.StringRes import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.GroupInfo import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupStatusType @@ -9,7 +10,7 @@ data class GroupDetailUiState( val status: GroupStatusType = GroupStatusType.NO_CURRENT_EVENT, val recentEvent: GroupEvent? = null, val history: List = emptyList(), - val isError: Boolean = false, + @StringRes val errorMessage: Int? = null, ) { val isEnabledNewEvent: Boolean get() = status == GroupStatusType.EVENT_COMPLETED || status == GroupStatusType.NO_CURRENT_EVENT diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/navigation/GroupDetailNavigation.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/navigation/GroupDetailNavigation.kt index e1f3dc56..c009791a 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/navigation/GroupDetailNavigation.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/navigation/GroupDetailNavigation.kt @@ -6,6 +6,7 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.NavType import androidx.navigation.compose.composable import androidx.navigation.navArgument +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.GroupDetailScreen import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.HistoryDetailState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.navigation.MainRoute @@ -24,7 +25,7 @@ fun NavGraphBuilder.groupDetailNavGraph( onClickEventMake: (Long) -> Unit, onClickShareButton: (Bitmap) -> Unit, onClickHistoryItem: (HistoryDetailState) -> Unit, - onErrorEvent: () -> Unit, + onShowSnackbar: (PicSnackbarType, String) -> Unit, ) { composable( route = "${MainRoute.GroupDetailRoute.route}/{$KEY_GROUP_ID}", @@ -44,7 +45,7 @@ fun NavGraphBuilder.groupDetailNavGraph( onClickShareButton = onClickShareButton, onClickHistoryItem = onClickHistoryItem, onClickEventMake = { onClickEventMake(groupId) }, - onErrorEvent = onErrorEvent, + onShowSnackbar = onShowSnackbar, ) } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt index a823938a..c5cd798d 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/navigation/MainNavHost.kt @@ -33,7 +33,6 @@ fun MainNavHost( onClickSendFcmButton: (eventId: Long) -> Unit, onClickShareButton: (Bitmap) -> Unit, onSnackbarRequired: (PicSnackbarType, String) -> Unit, - onErrorEvent: () -> Unit, ) { val context = LocalContext.current @@ -67,7 +66,7 @@ fun MainNavHost( onClickHistoryItem = { HistoryDetailActivity.openActivity(context, it) }, - onErrorEvent = onErrorEvent, + onShowSnackbar = onSnackbarRequired, ) groupMemberNavGraph( onClickBackButton = { navController.popBackStack() }, From 794cfc45581706c61a29ad73200ab4174b40c997 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Thu, 22 Aug 2024 21:22:54 +0900 Subject: [PATCH 14/35] =?UTF-8?q?:recycle:=20MainActivity=20showToast=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/MainActivity.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt index 9c53962a..4c468523 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt @@ -19,6 +19,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.navigation.compose.rememberNavController import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.theme.SharedAlbumTheme @@ -34,7 +35,6 @@ import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.MainEvent import com.mashup.gabbangzip.sharedalbum.presentation.utils.FileUtil import com.mashup.gabbangzip.sharedalbum.presentation.utils.PicPhotoPicker import com.mashup.gabbangzip.sharedalbum.presentation.utils.shareBitmap -import com.mashup.gabbangzip.sharedalbum.presentation.utils.showToast import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch @@ -122,6 +122,7 @@ class MainActivity : ComponentActivity() { @Composable private fun ObserveEvent(snackbarHostState: SnackbarHostState) { + val errorRetryMessage = stringResource(id = R.string.error_retry) LaunchedEffect(null) { viewModel.mainEvent.collect { event -> when (event) { @@ -130,16 +131,20 @@ class MainActivity : ComponentActivity() { message = getString(R.string.kook_snackbar), ) - MainEvent.FailNotification -> showToast(R.string.error_retry) + MainEvent.FailNotification -> snackbarHostState.showPicSnackbar( + type = PicSnackbarType.WARNING, + message = errorRetryMessage, + ) - MainEvent.SuccessUploadMyPic -> { - snackbarHostState.showPicSnackbar( - type = PicSnackbarType.CHECK, - message = getString(R.string.my_pic_upload_complete), - ) - } + MainEvent.SuccessUploadMyPic -> snackbarHostState.showPicSnackbar( + type = PicSnackbarType.CHECK, + message = getString(R.string.my_pic_upload_complete), + ) - MainEvent.FailUploadMyPic -> showToast(R.string.error_retry) + MainEvent.FailUploadMyPic -> snackbarHostState.showPicSnackbar( + type = PicSnackbarType.WARNING, + message = errorRetryMessage, + ) } } } From 0b42fa01322366cbf0e81aae540c7480a3c1f274 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Thu, 22 Aug 2024 21:28:39 +0900 Subject: [PATCH 15/35] =?UTF-8?q?:recycle:=20VoteActivity=20ShowToast=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/vote/VoteActivity.kt | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteActivity.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteActivity.kt index 96826c2a..eee834a0 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteActivity.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteActivity.kt @@ -10,20 +10,29 @@ import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHostState +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.compose.rememberNavController import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.theme.SharedAlbumTheme +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicSnackbarHost +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.showPicSnackbar import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.PicPhotoFrame import com.mashup.gabbangzip.sharedalbum.presentation.ui.vote.navigation.VoteNavHost import com.mashup.gabbangzip.sharedalbum.presentation.ui.vote.navigation.VoteNavRoute import com.mashup.gabbangzip.sharedalbum.presentation.ui.vote.navigation.navigateToVoteComplete -import com.mashup.gabbangzip.sharedalbum.presentation.utils.showToast import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.launch @AndroidEntryPoint class VoteActivity : ComponentActivity() { @@ -40,13 +49,27 @@ class VoteActivity : ComponentActivity() { setContent { val state by viewModel.voteUiState.collectAsStateWithLifecycle() + val snackbarHostState = remember { SnackbarHostState() } + val coroutineScope = rememberCoroutineScope() val navController = rememberNavController() - if (state.isError) { - showToast(R.string.error_retry) + val errorRetryMessage = stringResource(id = R.string.error_retry) + + LaunchedEffect(key1 = state.isError) { + coroutineScope.launch { + snackbarHostState.showPicSnackbar( + type = PicSnackbarType.WARNING, + message = errorRetryMessage, + ) + } } SharedAlbumTheme { - Scaffold { innerPadding -> + Scaffold( + modifier = Modifier + .fillMaxSize() + .navigationBarsPadding(), + snackbarHost = { PicSnackbarHost(state = snackbarHostState) }, + ) { innerPadding -> VoteNavHost( modifier = Modifier .fillMaxSize() @@ -76,7 +99,12 @@ class VoteActivity : ComponentActivity() { if (isUploadSuccess) { navController.navigateToVoteComplete() } else { - showToast(R.string.error_retry) + coroutineScope.launch { + snackbarHostState.showPicSnackbar( + type = PicSnackbarType.WARNING, + message = errorRetryMessage, + ) + } } }, ) From 7d08f43398bd5393eb067c2dc7bebd323d17cb82 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Thu, 22 Aug 2024 21:29:01 +0900 Subject: [PATCH 16/35] =?UTF-8?q?:fire:=20ContextUtil=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharedalbum/presentation/utils/ContextUtil.kt | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ContextUtil.kt diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ContextUtil.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ContextUtil.kt deleted file mode 100644 index 6f50c1cc..00000000 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/utils/ContextUtil.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.mashup.gabbangzip.sharedalbum.presentation.utils - -import android.content.Context -import android.widget.Toast - -fun Context.showToast(message: String) { - Toast.makeText(this, message, Toast.LENGTH_SHORT).show() -} - -fun Context.showToast(stringResId: Int) { - Toast.makeText(this, stringResId, Toast.LENGTH_SHORT).show() -} From a91d511b908af2e9d9a1999402ece41134e25bfd Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Thu, 22 Aug 2024 21:42:02 +0900 Subject: [PATCH 17/35] =?UTF-8?q?:bug:=20=EA=B7=B8=EB=A3=B9=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=ED=99=94=EB=A9=B4=EB=8F=84=20=EB=84=A4=ED=8A=B8?= =?UTF-8?q?=EC=9B=8C=ED=81=AC=EB=AF=B8=EC=97=B0=EA=B2=B0/API=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=20=EC=8B=9C=20=EC=8A=A4=EB=82=B5=EB=B0=94=20=EB=B3=B4?= =?UTF-8?q?=EC=9D=B4=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/groupmember/GroupMemberScreen.kt | 5 +++++ .../ui/main/groupmember/GroupMemberUiState.kt | 2 ++ .../ui/main/groupmember/GroupMemberViewModel.kt | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt index 1d736685..fc1ccfec 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt @@ -17,6 +17,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -54,6 +55,10 @@ fun GroupMemberScreen( val appStoreUrl = stringResource(id = R.string.app_store_url) val state by viewModel.state.collectAsStateWithLifecycle() + state.errorMessage?.let { errorMessage -> + onSnackbarRequired(PicSnackbarType.WARNING, stringResource(id = errorMessage)) + } + GroupMemberScreen( state = state, onClickBackButton = onClickBackButton, diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberUiState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberUiState.kt index f20ca356..2abcea4e 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberUiState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberUiState.kt @@ -1,5 +1,6 @@ package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupmember +import androidx.annotation.StringRes import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupmember.model.Member import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupKeyword import com.mashup.gabbangzip.sharedalbum.presentation.utils.ImmutableList @@ -8,6 +9,7 @@ data class GroupMemberUiState( val keyWord: GroupKeyword = GroupKeyword.SCHOOL, val members: ImmutableList = ImmutableList(emptyList()), val invitationCode: String = "", + @StringRes val errorMessage: Int? = null, ) { val isFull: Boolean = members.size == 6 } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberViewModel.kt index affbfabe..efd6eb6f 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.mashup.gabbangzip.sharedalbum.domain.model.group.MemberDomainModel import com.mashup.gabbangzip.sharedalbum.domain.usecase.group.GetGroupMembersUseCase +import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupmember.model.toUiModel import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.navigation.MainRoute import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupKeyword @@ -14,6 +15,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch +import java.net.UnknownHostException import javax.inject.Inject @HiltViewModel @@ -52,6 +54,15 @@ class GroupMemberViewModel @Inject constructor( invitationCode = response.invitationCode, ) } + }.onFailure { + _state.update { state -> + state.copy( + errorMessage = when (it) { + is UnknownHostException -> R.string.error_network + else -> R.string.error_server + }, + ) + } } } } From 920947da8133b184af4e17ea19a389800f6fa332 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Thu, 22 Aug 2024 21:45:15 +0900 Subject: [PATCH 18/35] =?UTF-8?q?:hammer:=20ktlint=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/groupdetail/GroupDetailViewModel.kt | 1 - .../presentation/ui/main/groupmember/GroupMemberScreen.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt index fe505383..fee6d220 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupdetail/GroupDetailViewModel.kt @@ -8,7 +8,6 @@ import com.mashup.gabbangzip.sharedalbum.domain.usecase.group.GetGroupDetailUseC import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.GroupDetailUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.toUiModel -import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.GroupHomeUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.toUiModel import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.navigation.MainRoute import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupStatusType diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt index fc1ccfec..4383173e 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/groupmember/GroupMemberScreen.kt @@ -17,7 +17,6 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier From f8edcd97d1686d56b63640be3665feb5db3c5bf4 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:16:46 +0900 Subject: [PATCH 19/35] =?UTF-8?q?:truck:=20=EB=A9=94=EC=9D=B8=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=AA=A8=EB=8D=B8=EB=A1=9C=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharedalbum/presentation/ui/{ => main}/model/MainEvent.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/{ => main}/model/MainEvent.kt (75%) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/model/MainEvent.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/model/MainEvent.kt similarity index 75% rename from presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/model/MainEvent.kt rename to presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/model/MainEvent.kt index 18915ee6..95ee903a 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/model/MainEvent.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/model/MainEvent.kt @@ -1,4 +1,4 @@ -package com.mashup.gabbangzip.sharedalbum.presentation.ui.model +package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.model sealed interface MainEvent { data object SuccessNotification : MainEvent From f69dbf3d1c918520942010e0b7c21e2eca4000a3 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:16:59 +0900 Subject: [PATCH 20/35] =?UTF-8?q?:sparkles:=20=EB=A9=94=EC=9D=B8=20uistate?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharedalbum/presentation/ui/main/model/MainUiState.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/model/MainUiState.kt diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/model/MainUiState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/model/MainUiState.kt new file mode 100644 index 00000000..6448b473 --- /dev/null +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/model/MainUiState.kt @@ -0,0 +1,5 @@ +package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.model + +data class MainUiState( + val isLoading: Boolean = false, +) From a29ac8fe0e6d044f114defe106d3d7ffbd69ed1f Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:17:25 +0900 Subject: [PATCH 21/35] =?UTF-8?q?:sparkles:=20=EB=A1=9C=EB=94=A9=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/common/PicLoadingIndicator.kt | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicLoadingIndicator.kt diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicLoadingIndicator.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicLoadingIndicator.kt new file mode 100644 index 00000000..89ca1cd1 --- /dev/null +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/common/PicLoadingIndicator.kt @@ -0,0 +1,72 @@ +package com.mashup.gabbangzip.sharedalbum.presentation.ui.common + +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.infiniteRepeatable +import androidx.compose.animation.core.rememberInfiniteTransition +import androidx.compose.animation.core.tween +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.mashup.gabbangzip.sharedalbum.presentation.theme.Conifer +import com.mashup.gabbangzip.sharedalbum.presentation.theme.Coral +import com.mashup.gabbangzip.sharedalbum.presentation.theme.Dandelion +import com.mashup.gabbangzip.sharedalbum.presentation.theme.Lavender +import com.mashup.gabbangzip.sharedalbum.presentation.theme.MagentaPink +import com.mashup.gabbangzip.sharedalbum.presentation.theme.Malibu +import com.mashup.gabbangzip.sharedalbum.presentation.theme.MayaBlue + +private val colorList = listOf( + Conifer, + MayaBlue, + MagentaPink, + Lavender, + Coral, + Dandelion, + Malibu, +) + +@Composable +fun PicLoadingIndicator(modifier: Modifier, isVisible: Boolean) { + if (isVisible) { + val infiniteTransition = rememberInfiniteTransition(label = "InfiniteTransition") + val transition = infiniteTransition.animateFloat( + initialValue = 0f, + targetValue = 1f, + animationSpec = infiniteRepeatable( + animation = tween(durationMillis = 10_000, easing = LinearEasing), + ), + label = "InfiniteTransition", + ) + val currentColorIndex = ((transition.value * colorList.size).toInt() % colorList.size) + val loadingColor by animateColorAsState( + targetValue = colorList[currentColorIndex], + animationSpec = tween(durationMillis = 1000, easing = LinearEasing), + label = "LoadingAnimation", + ) + + Box( + modifier = modifier, + ) { + CircularProgressIndicator( + modifier = Modifier.align(Alignment.Center), + color = loadingColor, + ) + } + } +} + +@Preview +@Composable +private fun PicLoadingScreenPreview() { + PicLoadingIndicator( + modifier = Modifier.fillMaxSize(), + isVisible = true, + ) +} From d54ce6fb274309191683938f02314ae65953460b Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:17:37 +0900 Subject: [PATCH 22/35] =?UTF-8?q?:sparkles:=20=ED=94=BD=EA=B3=A0=EB=A5=B4?= =?UTF-8?q?=EA=B8=B0=20=EB=A1=9C=EB=94=A9=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/MainActivity.kt | 15 ++++++++++++++- .../presentation/ui/main/MainViewModel.kt | 18 +++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt index 4c468523..0e07df26 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainActivity.kt @@ -9,6 +9,7 @@ import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels +import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding @@ -16,22 +17,26 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.compose.rememberNavController import com.mashup.gabbangzip.sharedalbum.presentation.R +import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray0 import com.mashup.gabbangzip.sharedalbum.presentation.theme.SharedAlbumTheme +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicLoadingIndicator import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicSnackbarHost import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.model.PicSnackbarType import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.showPicSnackbar import com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.GroupCreationActivity import com.mashup.gabbangzip.sharedalbum.presentation.ui.login.LoginActivity import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.navigation.navigateGroupDetail +import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.model.MainEvent import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.navigation.MainNavHost import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.navigation.MainRoute -import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.MainEvent import com.mashup.gabbangzip.sharedalbum.presentation.utils.FileUtil import com.mashup.gabbangzip.sharedalbum.presentation.utils.PicPhotoPicker import com.mashup.gabbangzip.sharedalbum.presentation.utils.shareBitmap @@ -55,6 +60,7 @@ class MainActivity : ComponentActivity() { initPhotoPicker() setContent { + val state by viewModel.mainState.collectAsStateWithLifecycle() val snackbarHostState = remember { SnackbarHostState() } val coroutineScope = rememberCoroutineScope() val navController = rememberNavController() @@ -105,6 +111,13 @@ class MainActivity : ComponentActivity() { navController.navigateGroupDetail(groupId) } } + + PicLoadingIndicator( + modifier = Modifier + .fillMaxSize() + .background(color = Gray0), + isVisible = state.isLoading, + ) } } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainViewModel.kt index 65bb9616..d5e798b3 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/MainViewModel.kt @@ -8,10 +8,14 @@ import com.mashup.gabbangzip.sharedalbum.domain.model.notification.FcmNotificati import com.mashup.gabbangzip.sharedalbum.domain.usecase.UploadMyPicUseCase import com.mashup.gabbangzip.sharedalbum.domain.usecase.notification.RegisterFcmTokenUseCase import com.mashup.gabbangzip.sharedalbum.domain.usecase.notification.SendFcmNotificationUseCase -import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.MainEvent +import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.model.MainEvent +import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.model.MainUiState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import java.io.File import javax.inject.Inject @@ -27,6 +31,9 @@ class MainViewModel @Inject constructor( private val _mainEvent = MutableSharedFlow() val mainEvent = _mainEvent.asSharedFlow() + private val _mainState = MutableStateFlow(MainUiState()) + val mainState = _mainState.asStateFlow() + fun registerFcmToken() { FirebaseMessaging.getInstance().token.addOnCompleteListener { task -> if (!task.isSuccessful) { @@ -45,6 +52,7 @@ class MainViewModel @Inject constructor( } fun uploadMyPic(fileList: List) { + updateLoadingState(isLoading = true) viewModelScope.launch { uploadMyPicUseCase( eventId = currentEventId, @@ -52,9 +60,11 @@ class MainViewModel @Inject constructor( ).onSuccess { Log.d(TAG, "내 PIC 올리기 성공") _mainEvent.emit(MainEvent.SuccessUploadMyPic) + updateLoadingState(isLoading = false) }.onFailure { Log.d(TAG, "내 PIC 올리기 실패") _mainEvent.emit(MainEvent.FailUploadMyPic) + updateLoadingState(isLoading = false) } } } @@ -73,6 +83,12 @@ class MainViewModel @Inject constructor( } } + private fun updateLoadingState(isLoading: Boolean) { + _mainState.update { + it.copy(isLoading = isLoading) + } + } + companion object { private const val TAG = "MainViewModel" } From 4d7f4b2e44d76b4c40d3ad9e0b838064466b8f68 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:17:59 +0900 Subject: [PATCH 23/35] =?UTF-8?q?:sparkles:=20=ED=88=AC=ED=91=9C=20?= =?UTF-8?q?=EC=8B=9C=EC=9E=91,=EC=99=84=EB=A3=8C=20=EB=A1=9C=EB=94=A9=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/vote/PhotoVoteScreen.kt | 7 ++++ .../presentation/ui/vote/VoteViewModel.kt | 41 ++++++++++++------- .../ui/vote/model/PhotoVoteState.kt | 2 +- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/PhotoVoteScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/PhotoVoteScreen.kt index 37977e13..490b9660 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/PhotoVoteScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/PhotoVoteScreen.kt @@ -45,6 +45,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray40 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray60 import com.mashup.gabbangzip.sharedalbum.presentation.theme.PicTypography import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicDialog +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicLoadingIndicator import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.UserInfo import com.mashup.gabbangzip.sharedalbum.presentation.ui.vote.contract.VoteConstant import com.mashup.gabbangzip.sharedalbum.presentation.ui.vote.model.PhotoVoteState @@ -132,6 +133,12 @@ fun PhotoVoteScreen( VoteGuideContainer(modifier = Modifier.fillMaxSize()) } } + PicLoadingIndicator( + modifier = Modifier + .fillMaxSize() + .background(color = Gray0), + isVisible = state.isLoading, + ) } @Composable diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt index 01839f36..6cdd0128 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt @@ -54,21 +54,25 @@ class VoteViewModel @Inject constructor( fun fetchVotePhotoList(eventIdKey: String) { savedStateHandle.get(eventIdKey)?.let { eventId -> viewModelScope.launch { - getVotePhotoListUseCase(eventId).onSuccess { votePhotoList -> - _voteUiState.update { state -> - state.copy( - photoList = ImmutableList(votePhotoList.toUiModel()), - voteResult = state.voteResult.copy( - eventId = eventId, - ), - voteClickInfo = state.voteClickInfo.copy( - index = votePhotoList.size, - ), - ) + getVotePhotoListUseCase(eventId) + .onSuccess { votePhotoList -> + _voteUiState.update { state -> + state.copy( + photoList = ImmutableList(votePhotoList.toUiModel()), + voteResult = state.voteResult.copy( + eventId = eventId, + ), + voteClickInfo = state.voteClickInfo.copy( + index = votePhotoList.size, + ), + isLoading = false, + ) + } + } + .onFailure { + updateLoadingState(isLoading = false) + updateErrorState() } - }.onFailure { - updateErrorState() - } } } ?: updateErrorState() } @@ -110,6 +114,7 @@ class VoteViewModel @Inject constructor( } fun finishVote() { + updateLoadingState(isLoading = true) viewModelScope.launch { requestVoteResultUseCase( VoteResultParam( @@ -123,7 +128,9 @@ class VoteViewModel @Inject constructor( isVoteUploadFinish = true, ) } + updateLoadingState(isLoading = false) }.onFailure { + updateLoadingState(isLoading = false) _voteUiState.update { state -> state.copy( isVoteUploadFinish = false, @@ -140,4 +147,10 @@ class VoteViewModel @Inject constructor( ) } } + + private fun updateLoadingState(isLoading: Boolean) { + _voteUiState.update { + it.copy(isLoading = isLoading) + } + } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt index 7f530b51..c0aa36fe 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt @@ -9,7 +9,7 @@ data class PhotoVoteState( val voteResult: VoteResult = VoteResult(), val voteClickInfo: VoteClickInfo = VoteClickInfo(), val isVoteCancel: Boolean = false, - val isLoading: Boolean = false, + val isLoading: Boolean = true, val isVoteUploadFinish: Boolean? = null, val isError: Boolean = false, val isFirstVisit: Boolean = false, From a1459424ab106af88dece4d92c1a6f9854246a55 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:18:25 +0900 Subject: [PATCH 24/35] =?UTF-8?q?:sparkles:=20=EA=B7=B8=EB=A3=B9=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EA=B0=80=EC=A0=B8=EC=98=AC=20?= =?UTF-8?q?=EC=8B=9C=20=EB=A1=9C=EB=94=A9=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/grouphome/GroupHomeScreen.kt | 5 +++++ .../presentation/ui/main/grouphome/GroupHomeViewModel.kt | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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 615ba012..c7e2b69d 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,6 +53,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray20 import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray80 import com.mashup.gabbangzip.sharedalbum.presentation.theme.PicTypography import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.FlippableBox +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicLoadingIndicator import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicNormalButton import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTag import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTopBar @@ -110,6 +111,10 @@ fun GroupHomeScreen( onShowSnackbar(PicSnackbarType.WARNING, stringResource(id = message)) } + is GroupHomeUiState.Loading -> { + PicLoadingIndicator(modifier = Modifier.fillMaxSize(), isVisible = true) + } + else -> {} } } 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 585a7fa1..13fdc705 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 @@ -41,6 +41,6 @@ class GroupHomeViewModel @Inject constructor( .stateIn( scope = viewModelScope, started = SharingStarted.WhileSubscribed(), - initialValue = GroupHomeUiState.NotInitialized, + initialValue = GroupHomeUiState.Loading, ) } From 0f1a72a2603b2bccd24289f09763890ac6f80583 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:20:19 +0900 Subject: [PATCH 25/35] =?UTF-8?q?:sparkles:=20=EA=B7=B8=EB=A3=B9=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A4=EA=B8=B0=20=EB=A1=9C=EB=94=A9=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/groupcreation/GroupCreationUiState.kt | 1 + .../groupcreation/GroupCreationViewModel.kt | 20 +++++++++++++++++-- .../thumbnail/GroupCreationThumbnailScreen.kt | 8 ++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationUiState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationUiState.kt index ed21bc77..2f24b565 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationUiState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationUiState.kt @@ -9,6 +9,7 @@ data class GroupCreationUiState( val keyword: GroupKeyword = GroupKeyword.SCHOOL, val thumbnail: Uri? = null, val groupCreationResult: GroupCreationResult? = null, + val isLoading: Boolean = false, ) { val isGroupCreated get() = groupCreationResult != null } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationViewModel.kt index b4c3e239..cb7bfc3e 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/GroupCreationViewModel.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import java.io.File import javax.inject.Inject @@ -54,6 +55,7 @@ class GroupCreationViewModel @Inject constructor( } fun createGroup(name: String, keyword: String, file: File) { + updateLoadingState(isLoading = true) viewModelScope.launch { createGroupUseCase( name = name, @@ -68,10 +70,17 @@ class GroupCreationViewModel @Inject constructor( imageUrl = it.imageUrl, invitationCode = it.invitationCode, ), + isLoading = false, ), ) }.onFailure { - _effect.emit(Event.ShowSnackBarMessageRes(PicSnackbarType.WARNING, message = R.string.image_upload_failed)) + _effect.emit( + Event.ShowSnackBarMessageRes( + PicSnackbarType.WARNING, + message = R.string.image_upload_failed, + ), + ) + updateLoadingState(isLoading = false) } } } @@ -88,9 +97,16 @@ class GroupCreationViewModel @Inject constructor( } } + private fun updateLoadingState(isLoading: Boolean) { + _uiState.update { + it.copy(isLoading = isLoading) + } + } + sealed interface Event { data class ShowSnackBarMessage(val type: PicSnackbarType, val message: String) : Event - data class ShowSnackBarMessageRes(val type: PicSnackbarType, @StringRes val message: Int) : Event + data class ShowSnackBarMessageRes(val type: PicSnackbarType, @StringRes val message: Int) : + Event } companion object { diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/thumbnail/GroupCreationThumbnailScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/thumbnail/GroupCreationThumbnailScreen.kt index aef54250..db5e4836 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/thumbnail/GroupCreationThumbnailScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/groupcreation/thumbnail/GroupCreationThumbnailScreen.kt @@ -6,6 +6,7 @@ import androidx.annotation.StringRes import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box 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 @@ -36,6 +37,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray80 import com.mashup.gabbangzip.sharedalbum.presentation.theme.PicTypography import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicBackButtonTopBar import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicButton +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicLoadingIndicator import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicProgressBar import com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.GroupCreationUiState import com.mashup.gabbangzip.sharedalbum.presentation.ui.groupcreation.common.GroupCreationScaffold @@ -136,6 +138,12 @@ private fun GroupCreationThumbnailScreen( ) }, ) + PicLoadingIndicator( + modifier = Modifier + .fillMaxSize() + .background(color = Gray0), + isVisible = state.isLoading, + ) } @Composable From b370f3065fb58bd18c0836261021a2c359e4118c Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:20:46 +0900 Subject: [PATCH 26/35] =?UTF-8?q?:sparkles:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=20=EB=A7=8C=EB=93=A4=EA=B8=B0=20=EB=A1=9C=EB=94=A9=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/eventcreation/EventCreationActivity.kt | 1 + .../presentation/ui/eventcreation/EventCreationState.kt | 1 + .../presentation/ui/eventcreation/EventCreationViewModel.kt | 6 ++++++ .../ui/eventcreation/detail/EventCreationDetailScreen.kt | 3 +++ 4 files changed, 11 insertions(+) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationActivity.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationActivity.kt index f2073e8d..40e166a5 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationActivity.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationActivity.kt @@ -73,6 +73,7 @@ class EventCreationActivity : ComponentActivity() { eventCreationState = state, clearEventCreationState = eventCreationViewModel::clearEventCreationState, onCompleteButtonClicked = { description -> + eventCreationViewModel.updateLoadingState(isLoading = true) state.pictures .mapNotNull { uri -> FileUtil.getFileFromUri(this@EventCreationActivity, uri) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationState.kt index 6fd737b9..8286e14c 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationState.kt @@ -8,6 +8,7 @@ data class EventCreationState( val date: String = LocalDateUtil.getNowDate(), val pictures: ImmutableList = ImmutableList(emptyList()), val eventCreationSuccess: Long? = null, + val isLoading: Boolean = false, ) sealed interface EventCreationEvent { diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationViewModel.kt index 24fa4817..ae91eca9 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/EventCreationViewModel.kt @@ -78,13 +78,19 @@ class EventCreationViewModel @Inject constructor( ).onSuccess { Log.d(TAG, "이벤트 생성 성공") _uiState.update { it.copy(eventCreationSuccess = groupId) } + updateLoadingState(isLoading = false) }.onFailure { Log.d(TAG, "이벤트 생성 실패") showSnackBar() + updateLoadingState(isLoading = false) } } } + fun updateLoadingState(isLoading: Boolean) { + _uiState.update { it.copy(isLoading = isLoading) } + } + private fun showSnackBar() { viewModelScope.launch { _eventFlow.emit(EventCreationEvent.Error) } } diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/detail/EventCreationDetailScreen.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/detail/EventCreationDetailScreen.kt index 4e76447f..16ec0677 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/detail/EventCreationDetailScreen.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/eventcreation/detail/EventCreationDetailScreen.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -41,6 +42,7 @@ import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicButton import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicDatePickerField import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicDialog import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicGallery +import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicLoadingIndicator import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTextField import com.mashup.gabbangzip.sharedalbum.presentation.ui.eventcreation.EventCreationActivity.Companion.PICTURES_MAX_COUNT import com.mashup.gabbangzip.sharedalbum.presentation.ui.eventcreation.EventCreationState @@ -161,6 +163,7 @@ fun EventCreationDetailScreen( }, ) } + PicLoadingIndicator(modifier = Modifier.fillMaxSize(), isVisible = state.isLoading) } @Composable From 8dbe9cfb617d4b2fa967b08bca692449a0ac2f43 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Sat, 24 Aug 2024 00:21:21 +0900 Subject: [PATCH 27/35] =?UTF-8?q?:bug:=204=EA=B0=9C=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EB=A7=8C=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8A=94=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=B2=84=EA=B7=B8=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/model/CardBackImage.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt index 527f1df3..9940a0fe 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/model/CardBackImage.kt @@ -18,7 +18,7 @@ fun CardBackImageDomainModel.toUiModel(): CardBackImage { fun List.toUiModel(): List { return if (size >= 4) { - take(4).toUiModel() + take(4).map { it.toUiModel() } } else { emptyList() } From 9ca144d906b399890b87fb523f76c6b3fc8d0330 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Mon, 26 Aug 2024 10:08:11 +0900 Subject: [PATCH 28/35] =?UTF-8?q?:sparkles:=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EB=A1=9C=EB=94=A9=20=ED=95=A8=EC=88=98=20=EC=8B=A4=ED=96=89=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80,=20=EB=A1=9C=EB=94=A9?= =?UTF-8?q?=20copy=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 --- .../sharedalbum/presentation/ui/vote/VoteViewModel.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt index 6cdd0128..f2e728ac 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt @@ -37,6 +37,7 @@ class VoteViewModel @Inject constructor( private val likedPhotoList = mutableListOf() init { + updateLoadingState(isLoading = true) checkFirstVisit() } @@ -126,9 +127,9 @@ class VoteViewModel @Inject constructor( state.copy( voteResult = voteResultDomain.toUiModel(), isVoteUploadFinish = true, + isLoading = false, ) } - updateLoadingState(isLoading = false) }.onFailure { updateLoadingState(isLoading = false) _voteUiState.update { state -> From bdca00ed29dfeb86652c63a02ca626f9dd432a97 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Mon, 26 Aug 2024 10:08:32 +0900 Subject: [PATCH 29/35] =?UTF-8?q?:hammer:=20state=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=EA=B0=92=20false=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 --- .../sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt index c0aa36fe..7f530b51 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/model/PhotoVoteState.kt @@ -9,7 +9,7 @@ data class PhotoVoteState( val voteResult: VoteResult = VoteResult(), val voteClickInfo: VoteClickInfo = VoteClickInfo(), val isVoteCancel: Boolean = false, - val isLoading: Boolean = true, + val isLoading: Boolean = false, val isVoteUploadFinish: Boolean? = null, val isError: Boolean = false, val isFirstVisit: Boolean = false, From 18eb056048be3544bfb3cdb26ddc4ee166e0d079 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Mon, 26 Aug 2024 17:21:06 +0900 Subject: [PATCH 30/35] =?UTF-8?q?:hammer:=20=EB=A1=9C=EB=94=A9=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=ED=95=A8=EC=88=98=20=EC=88=9C=EC=84=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharedalbum/presentation/ui/vote/VoteViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt index f2e728ac..9806e4bc 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/vote/VoteViewModel.kt @@ -37,7 +37,6 @@ class VoteViewModel @Inject constructor( private val likedPhotoList = mutableListOf() init { - updateLoadingState(isLoading = true) checkFirstVisit() } @@ -53,6 +52,7 @@ class VoteViewModel @Inject constructor( } fun fetchVotePhotoList(eventIdKey: String) { + updateLoadingState(isLoading = true) savedStateHandle.get(eventIdKey)?.let { eventId -> viewModelScope.launch { getVotePhotoListUseCase(eventId) From a15826ca403e75627969e7df28b0bd5ca4234895 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Tue, 27 Aug 2024 23:36:39 +0900 Subject: [PATCH 31/35] =?UTF-8?q?:bug:=20=ED=99=88=20=ED=8F=AC=ED=86=A0?= =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EB=92=B7=EB=A9=B4=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EC=A7=A4=EB=A6=BC=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/main/grouphome/GroupHomePhotoCard.kt | 5 +---- .../presentation/ui/main/grouphome/GroupHomeScreen.kt | 10 ++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt index ce14767f..45934d71 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt @@ -30,16 +30,13 @@ import com.mashup.gabbangzip.sharedalbum.presentation.utils.StableImage fun GroupHomePhotoCard( modifier: Modifier, groupInfo: GroupInfo, - contentMaxHeight: Dp, backgroundColor: Color, content: @Composable BoxScope.() -> Unit, eventName: String = "", onClickEventMake: (Long) -> Unit, ) { GroupPhotoCardContainer( - modifier = modifier - .heightIn(max = contentMaxHeight) - .wrapContentSize(), + modifier = modifier.wrapContentSize(), keywordType = groupInfo.keyword, backgroundColor = backgroundColor, ) { 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 c7e2b69d..0ccbbcb7 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 @@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize 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.wrapContentSize import androidx.compose.foundation.lazy.LazyColumn @@ -254,15 +255,12 @@ private fun GroupContainer( @Composable private fun GroupCard(modifier: Modifier, groupInfo: GroupInfo, onClickEventMake: (Long) -> Unit) { - val contentMaxHeight = LocalConfiguration.current.screenHeightDp.dp.div(2) - FlippableBox( modifier = modifier, frontScreen = { GroupHomePhotoCard( modifier = Modifier, groupInfo = groupInfo, - contentMaxHeight = contentMaxHeight, backgroundColor = groupInfo.keyword.frontCardBackgroundColor, eventName = groupInfo.recentEvent.title, content = { @@ -283,7 +281,6 @@ private fun GroupCard(modifier: Modifier, groupInfo: GroupInfo, onClickEventMake GroupHomePhotoCard( modifier = Modifier, groupInfo = groupInfo, - contentMaxHeight = contentMaxHeight, backgroundColor = groupInfo.keyword.behindCardBackGroundColor, eventName = groupInfo.recentEvent.title, content = { @@ -369,7 +366,7 @@ private fun FrontCardImage( contentDescription = stringResource(R.string.group_main_picture), ) StableImage( - modifier = Modifier.fillMaxSize(), + modifier = Modifier.aspectRatio(1f), drawableResId = frameResId, colorFilter = ColorFilter.tint(backgroundColor), contentScale = ContentScale.FillBounds, @@ -384,8 +381,9 @@ private fun BackCardImage( cardBackImageList: List, backgroundColor: Color, ) { + val contentMaxHeight = LocalConfiguration.current.screenHeightDp.dp LazyVerticalGrid( - modifier = modifier.wrapContentSize(), + modifier = modifier.wrapContentSize().heightIn(max = contentMaxHeight), verticalArrangement = Arrangement.spacedBy(7.46.dp), horizontalArrangement = Arrangement.spacedBy(7.46.dp), columns = GridCells.Fixed(2), From a7d41e9b5d44bcec5e05c294de7c6fad603c23a6 Mon Sep 17 00:00:00 2001 From: JeonK1 Date: Tue, 27 Aug 2024 23:46:14 +0900 Subject: [PATCH 32/35] =?UTF-8?q?delete=20:=20=EB=AF=B8=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/grouphome/GroupHomePhotoCard.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt index 45934d71..c11989a1 100644 --- a/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt +++ b/presentation/src/main/java/com/mashup/gabbangzip/sharedalbum/presentation/ui/main/grouphome/GroupHomePhotoCard.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope -import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentSize @@ -15,7 +14,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.mashup.gabbangzip.sharedalbum.presentation.R import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray80 From 2cf5d376fd60bf468de6ab453f7f18541972da80 Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Wed, 28 Aug 2024 13:18:22 +0900 Subject: [PATCH 33/35] =?UTF-8?q?:memo:=20=EB=A6=AC=EB=93=9C=EB=AF=B8=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 --- README.md | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 78e478aa..946e8211 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,102 @@ -# gabbangzip-Android -가자빵집으로 Android Repository +# 📸 PIC -### Shortcuts -- [Code Convention](https://github.com/mash-up-kr/gabbangzip-Android/wiki/Code-Convention) \ No newline at end of file + + +**그날의 추억을 기록하는 우리만의 네컷사진** + +- 원하는 친구들과 그룹방을 만들어요 +- 함께 찍은 사진들을 투표해요 +- 베스트 사진으로 네컷 사진이 만들어져요 + +# 💾 App Download + + + + + +# 💻 Contributor + +
+ + + + + + + + + + + + + +
+ + sooziini + + + + SEO-J17 + + + + oreocube + + + + JeonK1 + +
박수진서정우주지혜전계원
+
+ +# 🎨 Structure + + + ++ Claen Architecture와 MVVM 패턴을 적용하여 프로젝트를 구성했습니다 ++ 가이드에 따라 App, Data, Domain, Presentation 모듈로 분리하고 다음 그림과 같은 의존성을 가지도록 설계했습니다. + +# 🛠 Tech & Library + ++ Target SDK Level 34 ++ Min SDK Level 26 ++ Kotlin 1.9.10 + +| 구분 | 내용 | +|-------------------------|-----------------------------------------------------------------------| +| Architecture | Clean Architecture | +| DesignPattern | MVVM | +| Jetpack | Compose, Lifecycle, Navigation, EncryptedSharedPreferences, ViewModel | +| Network | Retrofit, OkHttp, Moshi | +| Asynchronous Processing | Coroutine, Flow | +| Dependency Injection | Hilt | +| Third Party Library | Coil-Compose, Kakao SDK, Firebase Cloud Messaging | +| Other Tool | Figma | + +# ✨ Features + +
+ image + image +
+ +
+ image + image +
From 07cd5fc5989aa126e4d68657a583fa436096b66a Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Thu, 29 Aug 2024 11:11:32 +0900 Subject: [PATCH 34/35] =?UTF-8?q?:construction=5Fworker:=20=EB=B2=84?= =?UTF-8?q?=EC=A0=84=20=EC=BD=94=EB=93=9C=20=EC=A6=9D=EA=B0=80,=20?= =?UTF-8?q?=EB=B2=84=EC=A0=84=20=EB=84=A4=EC=9E=84=201.1.0=EC=9C=BC?= =?UTF-8?q?=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 --- .../com/mashup/gabbangzip/sharedalbum/buildsrc/AppConfig.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/java/com/mashup/gabbangzip/sharedalbum/buildsrc/AppConfig.kt b/buildSrc/src/main/java/com/mashup/gabbangzip/sharedalbum/buildsrc/AppConfig.kt index ab58f2e7..747ed516 100644 --- a/buildSrc/src/main/java/com/mashup/gabbangzip/sharedalbum/buildsrc/AppConfig.kt +++ b/buildSrc/src/main/java/com/mashup/gabbangzip/sharedalbum/buildsrc/AppConfig.kt @@ -11,8 +11,8 @@ object AppConfig { const val applicationId = "com.mashup.gabbangzip.sharedalbum" const val appNameSpace = "com.mashup.gabbangzip.sharedalbum" - const val appVersionCode = 1 - const val appVersionName = "1.0.0" + const val appVersionCode = 2 + const val appVersionName = "1.1.0" const val dataNameSpace = "com.mashup.gabbangzip.sharedalbum.data" const val domainNameSpace = "com.mashup.gabbangzip.sharedalbum.domain" From 754c2c2267d48158ac7efda380fffd1c1084e21c Mon Sep 17 00:00:00 2001 From: seojeongwoo Date: Thu, 29 Aug 2024 11:22:25 +0900 Subject: [PATCH 35/35] =?UTF-8?q?:memo:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=B9=84=EC=9C=A8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 946e8211..89f04bef 100644 --- a/README.md +++ b/README.md @@ -77,25 +77,22 @@
image image -
- -
- image image