From 8ac2431e275c1445265264e00519ed436da51b84 Mon Sep 17 00:00:00 2001 From: hoyahozz <85336456+hoyahozz@users.noreply.github.com> Date: Wed, 3 Aug 2022 23:28:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat=20-=20=EC=8A=A4=EB=82=B5=EB=B0=94?= =?UTF-8?q?=EC=97=90=20=EB=B0=94=ED=85=80=20=ED=8C=A8=EB=94=A9=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yapp/growth/presentation/component/PlanzSnackBar.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/yapp/growth/presentation/component/PlanzSnackBar.kt b/presentation/src/main/java/com/yapp/growth/presentation/component/PlanzSnackBar.kt index 7d9200ec..618dfdee 100644 --- a/presentation/src/main/java/com/yapp/growth/presentation/component/PlanzSnackBar.kt +++ b/presentation/src/main/java/com/yapp/growth/presentation/component/PlanzSnackBar.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.yapp.growth.presentation.R import com.yapp.growth.presentation.theme.Gray900 @@ -22,13 +23,14 @@ import com.yapp.growth.presentation.theme.SubCoral @Composable fun PlanzSnackBar( message: String, + bottomPadding: Int, ) { Snackbar( modifier = Modifier .fillMaxWidth() .wrapContentHeight() .padding(horizontal = 20.dp) - .padding(bottom = 32.dp), + .padding(bottom = bottomPadding.dp), backgroundColor = Gray900 ) { Text( @@ -43,13 +45,14 @@ fun PlanzSnackBar( @Composable fun PlanzErrorSnackBar( message: String, + bottomPadding: Int, ) { Snackbar( modifier = Modifier .fillMaxWidth() .wrapContentHeight() .padding(horizontal = 20.dp) - .padding(bottom = 32.dp), + .padding(bottom = bottomPadding.dp), backgroundColor = Gray900 ) { Row( From 56f2f4d7fffa1ff2c596f26fc612d78cf4d69790 Mon Sep 17 00:00:00 2001 From: hoyahozz <85336456+hoyahozz@users.noreply.github.com> Date: Wed, 3 Aug 2022 23:28:27 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat=20-=20=ED=99=94=EB=A9=B4=EB=B3=84?= =?UTF-8?q?=EB=A1=9C=20=EC=8A=A4=EB=82=B5=EB=B0=94=20=EB=B0=94=ED=85=80=20?= =?UTF-8?q?=ED=8C=A8=EB=94=A9=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/createPlan/date/DateScreen.kt | 5 +- .../ui/createPlan/share/ShareScreen.kt | 48 ++++++++++++++++--- .../createPlan/timerange/TimeRangeScreen.kt | 5 +- .../presentation/ui/main/home/HomeScreen.kt | 6 ++- 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/date/DateScreen.kt b/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/date/DateScreen.kt index d86e4ac3..a7f488f8 100644 --- a/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/date/DateScreen.kt +++ b/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/date/DateScreen.kt @@ -76,7 +76,10 @@ fun DateScreen( }, snackbarHost = { snackbarHostState -> SnackbarHost(hostState = snackbarHostState) { snackbarData -> - PlanzErrorSnackBar(message = snackbarData.message) + PlanzErrorSnackBar( + message = snackbarData.message, + bottomPadding = 100 + ) } } ) { padding -> diff --git a/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/share/ShareScreen.kt b/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/share/ShareScreen.kt index 285f8e92..0ff0ff43 100644 --- a/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/share/ShareScreen.kt +++ b/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/share/ShareScreen.kt @@ -6,10 +6,32 @@ import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.runtime.* +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.Card +import androidx.compose.material.Icon +import androidx.compose.material.Scaffold +import androidx.compose.material.SnackbarHost +import androidx.compose.material.Text +import androidx.compose.material.rememberScaffoldState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -38,7 +60,14 @@ import com.yapp.growth.presentation.R import com.yapp.growth.presentation.component.PlanzErrorSnackBar import com.yapp.growth.presentation.component.PlanzSnackBar import com.yapp.growth.presentation.firebase.PLAN_ID_KEY_NAME -import com.yapp.growth.presentation.theme.* +import com.yapp.growth.presentation.theme.BackgroundColor1 +import com.yapp.growth.presentation.theme.CoolGray500 +import com.yapp.growth.presentation.theme.Gray200 +import com.yapp.growth.presentation.theme.Gray800 +import com.yapp.growth.presentation.theme.Gray900 +import com.yapp.growth.presentation.theme.MainPurple900 +import com.yapp.growth.presentation.theme.PlanzTypography +import com.yapp.growth.presentation.theme.SubYellow import kotlinx.coroutines.launch import timber.log.Timber @@ -59,8 +88,15 @@ fun ShareScreen( snackbarHost = { snackbarHostState -> SnackbarHost(hostState = snackbarHostState) { snackbarData -> when (viewState.snackBarType) { - ShareContract.ShareViewState.SnackBarType.SUCCESS -> PlanzSnackBar(message = snackbarData.message) - else -> PlanzErrorSnackBar(message = snackbarData.message) + ShareContract.ShareViewState.SnackBarType.SUCCESS -> + PlanzSnackBar( + message = snackbarData.message, + bottomPadding = 156 + ) + else -> PlanzErrorSnackBar( + message = snackbarData.message, + bottomPadding = 156 + ) } } } diff --git a/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/timerange/TimeRangeScreen.kt b/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/timerange/TimeRangeScreen.kt index 252457be..f10a55b3 100644 --- a/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/timerange/TimeRangeScreen.kt +++ b/presentation/src/main/java/com/yapp/growth/presentation/ui/createPlan/timerange/TimeRangeScreen.kt @@ -77,7 +77,10 @@ fun TimeRangeScreen( }, snackbarHost = { snackbarHostState -> SnackbarHost(hostState = snackbarHostState) { snackbarData -> - PlanzErrorSnackBar(message = snackbarData.message) + PlanzErrorSnackBar( + message = snackbarData.message, + bottomPadding = 100 + ) } } ) { padding -> diff --git a/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeScreen.kt b/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeScreen.kt index 139e4917..ad5fd709 100644 --- a/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeScreen.kt +++ b/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeScreen.kt @@ -149,6 +149,7 @@ fun HomeScreen( } LoadState.SUCCESS -> { Scaffold( + scaffoldState = scaffoldState, backgroundColor = BackgroundColor1, topBar = { HomeUserProfile( @@ -159,7 +160,10 @@ fun HomeScreen( modifier = Modifier.fillMaxSize(), snackbarHost = { snackbarHostState -> SnackbarHost(hostState = snackbarHostState) { snackbarData -> - PlanzErrorSnackBar(message = snackbarData.message) + PlanzErrorSnackBar( + message = snackbarData.message, + bottomPadding = 32 + ) } } ) { padding -> From e3f0f3d34d00927b30efd94871b1ac45467e8cf8 Mon Sep 17 00:00:00 2001 From: hoyahozz <85336456+hoyahozz@users.noreply.github.com> Date: Wed, 3 Aug 2022 23:28:51 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor=20-=20=ED=99=88=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=EC=9D=98=20flow=20=EA=B4=80=EB=A0=A8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9D=BC=EB=B6=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../growth/presentation/ui/main/home/HomeViewModel.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeViewModel.kt b/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeViewModel.kt index 589a3ff6..ea30a6ce 100644 --- a/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeViewModel.kt +++ b/presentation/src/main/java/com/yapp/growth/presentation/ui/main/home/HomeViewModel.kt @@ -26,7 +26,6 @@ import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch @@ -46,7 +45,6 @@ class HomeViewModel @Inject constructor( // 사용자가 여러 번 클릭했을 때 버벅거리는 현상을 없애기 위해 따로 분리 private val _currentDate = MutableStateFlow(CalendarDay.today()) - @OptIn(FlowPreview::class) val currentDate: StateFlow = _currentDate.debounce(300).stateIn( scope = viewModelScope, @@ -177,7 +175,7 @@ class HomeViewModel @Inject constructor( if (!isSubscribed) { isSubscribed = true - currentDate.collectLatest { currentDate -> + currentDate.collect { currentDate -> val calendarPlans = emptyList().toMutableList() val month = currentDate.month @@ -201,7 +199,7 @@ class HomeViewModel @Inject constructor( .onError { sendEffect({ HomeSideEffect.ShowSnackBar(resourcesProvider.getString(R.string.home_error_message)) }) updateState { copy(monthlyPlanLoadState = LoadState.ERROR) } - return@collectLatest + return@collect } getMonthlyFixedPlansUseCase.invoke(previousMonth.toFormatDate()) .onSuccess { plans -> @@ -210,7 +208,7 @@ class HomeViewModel @Inject constructor( .onError { sendEffect({ HomeSideEffect.ShowSnackBar(resourcesProvider.getString(R.string.home_error_message)) }) updateState { copy(monthlyPlanLoadState = LoadState.ERROR) } - return@collectLatest + return@collect } getMonthlyFixedPlansUseCase.invoke(nextMonth.toFormatDate()) .onSuccess { plans -> @@ -219,7 +217,7 @@ class HomeViewModel @Inject constructor( .onError { sendEffect({ HomeSideEffect.ShowSnackBar(resourcesProvider.getString(R.string.home_error_message)) }) updateState { copy(monthlyPlanLoadState = LoadState.ERROR) } - return@collectLatest + return@collect } updateState {