From 8b6b8b0e62bb7f59bf402f770bfdafd6f16087e1 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 16:55:37 +0900 Subject: [PATCH 01/62] =?UTF-8?q?[FEATURE]=20#74=20:=20dialog=20State=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 --- .../profile/profilesetting/ProfileSettingScreen.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 5c870c02..e7e519ae 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -14,6 +14,9 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.Divider import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource @@ -83,10 +86,20 @@ internal fun ProfileSettingScreen( onClickedTermsAndPolicies: () -> Unit, onClickedPrivacyPolicy: () -> Unit, ) { + val showWithdrawalDialog by remember { mutableStateOf(false) } + val showLogoutDialog by remember { mutableStateOf(false) } val dividerThickness = 1.dp val dividerColor = WappTheme.colors.black42 val scrollState = rememberScrollState() + if (showWithdrawalDialog) { + // Todo + } + + if (showLogoutDialog) { + // Todo + } + Column( modifier = Modifier .fillMaxSize() From 1adf789deb5077bc5042d7eae07c60060b641b7c Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 16:58:32 +0900 Subject: [PATCH 02/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EA=B3=BC=EB=8F=84?= =?UTF-8?q?=ED=95=9C=20=ED=98=B8=EC=9D=B4=EC=8A=A4=ED=8C=85=20=EB=82=B4?= =?UTF-8?q?=EB=A6=AC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 75 ++++++++----------- 1 file changed, 33 insertions(+), 42 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index e7e519ae..25b20a57 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -36,61 +36,24 @@ internal fun ProfileSettingRoute( navigateToProfile: () -> Unit, viewModel: ProfileSettingViewModel = hiltViewModel(), ) { - val context = LocalContext.current - ProfileSettingScreen( navigateToProfile = navigateToProfile, - onClickedPrivacyPolicy = { - navigateToUri( - context, - PRIVACY_POLICY_URL, - ) - }, - onClickedFAQ = { - navigateToUri( - context, - FAQ_URL, - ) - }, - onClickedInquiry = { - navigateToUri( - context, - INQUIRY_URL, - ) - }, - onClickedTermsAndPolicies = { - navigateToUri( - context, - TERMS_AND_POLICIES_URL, - ) - }, ) } -private fun navigateToUri(context: Context, url: String) = startActivity( - context, - generateUriIntent(url), - null, -) - -private fun generateUriIntent(url: String) = Intent(Intent.ACTION_VIEW, url.toUri()) - @Composable internal fun ProfileSettingScreen( navigateToProfile: () -> Unit, onClickedAlarmSetting: () -> Unit = {}, onClickedSignOut: () -> Unit = {}, onClickedWithdrawal: () -> Unit = {}, - onClickedInquiry: () -> Unit, - onClickedFAQ: () -> Unit, - onClickedTermsAndPolicies: () -> Unit, - onClickedPrivacyPolicy: () -> Unit, ) { val showWithdrawalDialog by remember { mutableStateOf(false) } val showLogoutDialog by remember { mutableStateOf(false) } val dividerThickness = 1.dp val dividerColor = WappTheme.colors.black42 val scrollState = rememberScrollState() + val context = LocalContext.current if (showWithdrawalDialog) { // Todo @@ -175,7 +138,12 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.inquiry), - onClicked = onClickedInquiry, + onClicked = { + navigateToUri( + context, + INQUIRY_URL, + ) + }, ) Divider( @@ -185,7 +153,12 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.faq), - onClicked = onClickedFAQ, + onClicked = { + navigateToUri( + context, + FAQ_URL, + ) + }, ) Divider( @@ -195,7 +168,12 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.terms_and_policies), - onClicked = onClickedTermsAndPolicies, + onClicked = { + navigateToUri( + context, + TERMS_AND_POLICIES_URL, + ) + }, ) Divider( @@ -205,7 +183,12 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.privacy_policy), - onClicked = onClickedPrivacyPolicy, + onClicked = { + navigateToUri( + context, + PRIVACY_POLICY_URL, + ) + }, ) Divider( @@ -214,3 +197,11 @@ internal fun ProfileSettingScreen( ) } } + +private fun navigateToUri(context: Context, url: String) = startActivity( + context, + generateUriIntent(url), + null, +) + +private fun generateUriIntent(url: String) = Intent(Intent.ACTION_VIEW, url.toUri()) From 08741a999227b42bf2738322743c6fd0a1469a76 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 16:59:35 +0900 Subject: [PATCH 03/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EA=B0=9C=ED=96=89=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 25b20a57..699cb93e 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -138,12 +138,7 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.inquiry), - onClicked = { - navigateToUri( - context, - INQUIRY_URL, - ) - }, + onClicked = { navigateToUri(context, INQUIRY_URL) }, ) Divider( @@ -153,12 +148,7 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.faq), - onClicked = { - navigateToUri( - context, - FAQ_URL, - ) - }, + onClicked = { navigateToUri(context, FAQ_URL) }, ) Divider( @@ -168,12 +158,7 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.terms_and_policies), - onClicked = { - navigateToUri( - context, - TERMS_AND_POLICIES_URL, - ) - }, + onClicked = { navigateToUri(context, TERMS_AND_POLICIES_URL) }, ) Divider( @@ -183,12 +168,7 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.privacy_policy), - onClicked = { - navigateToUri( - context, - PRIVACY_POLICY_URL, - ) - }, + onClicked = { navigateToUri(context, PRIVACY_POLICY_URL) }, ) Divider( From 2da507141ffd433d63b789f8f326973db58ccf1f Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 17:03:57 +0900 Subject: [PATCH 04/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EC=96=BC=EB=A1=9C=EA=B7=B8=20visible=20=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 699cb93e..3d4858bf 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -17,11 +17,13 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Dialog import androidx.core.content.ContextCompat.startActivity import androidx.core.net.toUri import androidx.hilt.navigation.compose.hiltViewModel @@ -45,22 +47,26 @@ internal fun ProfileSettingRoute( internal fun ProfileSettingScreen( navigateToProfile: () -> Unit, onClickedAlarmSetting: () -> Unit = {}, - onClickedSignOut: () -> Unit = {}, - onClickedWithdrawal: () -> Unit = {}, ) { - val showWithdrawalDialog by remember { mutableStateOf(false) } - val showLogoutDialog by remember { mutableStateOf(false) } + var showWithdrawalDialog by remember { mutableStateOf(false) } + var showLogoutDialog by remember { mutableStateOf(false) } val dividerThickness = 1.dp val dividerColor = WappTheme.colors.black42 val scrollState = rememberScrollState() val context = LocalContext.current if (showWithdrawalDialog) { - // Todo + Dialog( + onDismissRequest = { showWithdrawalDialog = false }, + ) { + } } if (showLogoutDialog) { - // Todo + Dialog( + onDismissRequest = { showLogoutDialog = false }, + ) { + } } Column( @@ -103,7 +109,7 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.sign_out), - onClicked = onClickedSignOut, + onClicked = { showLogoutDialog = true }, ) Divider( @@ -113,7 +119,7 @@ internal fun ProfileSettingScreen( WappRowBar( title = stringResource(id = com.wap.wapp.feature.profile.R.string.withdrawal), - onClicked = onClickedWithdrawal, + onClicked = { showWithdrawalDialog = true }, ) Divider( From a163f822d6b0a4ebbf6b02239dd3d862d3558a39 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 20:55:35 +0900 Subject: [PATCH 05/62] =?UTF-8?q?[FEATURE]=20#74=20:=20ProfileSettingDialo?= =?UTF-8?q?g=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 53 ++++++-- .../component/ProfileSettingDialog.kt | 118 ++++++++++++++++++ .../profile/src/main/res/values/strings.xml | 4 +- 3 files changed, 162 insertions(+), 13 deletions(-) create mode 100644 feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 3d4858bf..4c731044 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -22,6 +22,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import androidx.core.content.ContextCompat.startActivity @@ -32,6 +36,7 @@ import com.wap.designsystem.component.WappRowBar import com.wap.designsystem.component.WappSubTopBar import com.wap.wapp.core.designresource.R import com.wap.wapp.feature.profile.R.string +import com.wap.wapp.feature.profile.profilesetting.component.ProfileSettingDialog @Composable internal fun ProfileSettingRoute( @@ -63,10 +68,11 @@ internal fun ProfileSettingScreen( } if (showLogoutDialog) { - Dialog( + ProfileSettingDialog( onDismissRequest = { showLogoutDialog = false }, - ) { - } + title = string.logout, + content = generateLogoutDialogString(), + ) } Column( @@ -91,14 +97,14 @@ internal fun ProfileSettingScreen( contentDescription = "", ) Text( - text = stringResource(id = com.wap.wapp.feature.profile.R.string.account_setting), + text = stringResource(id = string.account_setting), style = WappTheme.typography.titleBold, color = WappTheme.colors.white, ) } WappRowBar( - title = stringResource(id = com.wap.wapp.feature.profile.R.string.alarm_setting), + title = stringResource(id = string.alarm_setting), onClicked = onClickedAlarmSetting, ) @@ -108,7 +114,7 @@ internal fun ProfileSettingScreen( ) WappRowBar( - title = stringResource(id = com.wap.wapp.feature.profile.R.string.sign_out), + title = stringResource(id = string.logout), onClicked = { showLogoutDialog = true }, ) @@ -118,7 +124,7 @@ internal fun ProfileSettingScreen( ) WappRowBar( - title = stringResource(id = com.wap.wapp.feature.profile.R.string.withdrawal), + title = stringResource(id = string.withdrawal), onClicked = { showWithdrawalDialog = true }, ) @@ -136,14 +142,14 @@ internal fun ProfileSettingScreen( contentDescription = "", ) Text( - text = stringResource(id = com.wap.wapp.feature.profile.R.string.more), + text = stringResource(id = string.more), style = WappTheme.typography.titleBold, color = WappTheme.colors.white, ) } WappRowBar( - title = stringResource(id = com.wap.wapp.feature.profile.R.string.inquiry), + title = stringResource(id = string.inquiry), onClicked = { navigateToUri(context, INQUIRY_URL) }, ) @@ -153,7 +159,7 @@ internal fun ProfileSettingScreen( ) WappRowBar( - title = stringResource(id = com.wap.wapp.feature.profile.R.string.faq), + title = stringResource(id = string.faq), onClicked = { navigateToUri(context, FAQ_URL) }, ) @@ -163,7 +169,7 @@ internal fun ProfileSettingScreen( ) WappRowBar( - title = stringResource(id = com.wap.wapp.feature.profile.R.string.terms_and_policies), + title = stringResource(id = string.terms_and_policies), onClicked = { navigateToUri(context, TERMS_AND_POLICIES_URL) }, ) @@ -173,7 +179,7 @@ internal fun ProfileSettingScreen( ) WappRowBar( - title = stringResource(id = com.wap.wapp.feature.profile.R.string.privacy_policy), + title = stringResource(id = string.privacy_policy), onClicked = { navigateToUri(context, PRIVACY_POLICY_URL) }, ) @@ -191,3 +197,26 @@ private fun navigateToUri(context: Context, url: String) = startActivity( ) private fun generateUriIntent(url: String) = Intent(Intent.ACTION_VIEW, url.toUri()) + +@Composable +private fun generateLogoutDialogString() = buildAnnotatedString { + append("정말로 ") + withStyle( + style = SpanStyle( + textDecoration = TextDecoration.Underline, + color = WappTheme.colors.yellow34, + ), + ) { + append("로그아웃") + } + append("을 원하신다면 ") + withStyle( + style = SpanStyle( + textDecoration = TextDecoration.Underline, + color = WappTheme.colors.yellow34, + ), + ) { + append("완료") + } + append(" 버튼을 눌러주세요.") +} diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt new file mode 100644 index 00000000..85c06c66 --- /dev/null +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -0,0 +1,118 @@ +package com.wap.wapp.feature.profile.profilesetting.component + +import androidx.annotation.StringRes +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties +import com.wap.designsystem.WappTheme +import com.wap.wapp.feature.profile.R.string + +@Composable +internal fun ProfileSettingDialog( + onDismissRequest: () -> Unit, + onConfirmRequest: () -> Unit = {}, + @StringRes title: Int, + content: AnnotatedString, +) { + Dialog( + onDismissRequest = onDismissRequest, + properties = DialogProperties( + usePlatformDefaultWidth = false, + ), + ) { + Column( + verticalArrangement = Arrangement.spacedBy(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .wrapContentHeight() + .wrapContentWidth() + .padding(horizontal = 12.dp) + .clip(RoundedCornerShape(8.dp)) + .background(WappTheme.colors.black25), + ) { + Text( + text = stringResource(title), + style = WappTheme.typography.contentBold.copy(fontSize = 20.sp), + color = WappTheme.colors.yellow34, + modifier = Modifier.padding(top = 16.dp), + ) + + Divider( + color = WappTheme.colors.gray82, + modifier = Modifier.padding(horizontal = 12.dp), + ) + + Text( + text = content, + style = WappTheme.typography.contentRegular, + color = WappTheme.colors.white, + ) + + Row( + horizontalArrangement = Arrangement.spacedBy(20.dp), + modifier = Modifier + .padding(horizontal = 12.dp) + .padding(vertical = 16.dp), + ) { + Button( + onClick = { /*TODO*/ }, + shape = RoundedCornerShape(8.dp), + colors = ButtonDefaults.buttonColors( + containerColor = WappTheme.colors.yellow34, + ), + contentPadding = PaddingValues(vertical = 12.dp), + modifier = Modifier.weight(1f), + ) { + Text( + text = stringResource(string.complete), + style = WappTheme.typography.titleRegular, + color = WappTheme.colors.black, + ) + } + + Button( + onClick = onDismissRequest, + shape = RoundedCornerShape(10.dp), + colors = ButtonDefaults.buttonColors( + containerColor = WappTheme.colors.black25, + ), + contentPadding = PaddingValues(vertical = 12.dp), + modifier = Modifier + .weight(1f) + .border( + width = 1.dp, + color = WappTheme.colors.yellow34, + shape = RoundedCornerShape(8.dp), + ), + ) { + Text( + text = stringResource(string.cancel), + style = WappTheme.typography.titleRegular, + color = WappTheme.colors.yellow34, + ) + } + } + } + } +} diff --git a/feature/profile/src/main/res/values/strings.xml b/feature/profile/src/main/res/values/strings.xml index 235150c4..44ff146e 100644 --- a/feature/profile/src/main/res/values/strings.xml +++ b/feature/profile/src/main/res/values/strings.xml @@ -11,9 +11,11 @@ 내가 한 설문 계정 설정 알람 설정 - 로그아웃 + 로그아웃 회원 탈퇴 문의하기 + 완료 + 취소 더보기 FAQ 약관 및 정책 From b28fbe15dd25b277c7271e3fd176742f922b2857 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 20:58:08 +0900 Subject: [PATCH 06/62] =?UTF-8?q?[FEATURE]=20#74=20:=20AnnotaedString=20Di?= =?UTF-8?q?alog=20=ED=8C=8C=EC=9D=BC=20=EB=82=B4=EB=B6=80=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=A7=8C=EB=93=A4=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 28 ----------------- .../component/ProfileSettingDialog.kt | 31 +++++++++++++++++-- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 4c731044..41623b6d 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -22,10 +22,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.SpanStyle -import androidx.compose.ui.text.buildAnnotatedString -import androidx.compose.ui.text.style.TextDecoration -import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import androidx.core.content.ContextCompat.startActivity @@ -71,7 +67,6 @@ internal fun ProfileSettingScreen( ProfileSettingDialog( onDismissRequest = { showLogoutDialog = false }, title = string.logout, - content = generateLogoutDialogString(), ) } @@ -197,26 +192,3 @@ private fun navigateToUri(context: Context, url: String) = startActivity( ) private fun generateUriIntent(url: String) = Intent(Intent.ACTION_VIEW, url.toUri()) - -@Composable -private fun generateLogoutDialogString() = buildAnnotatedString { - append("정말로 ") - withStyle( - style = SpanStyle( - textDecoration = TextDecoration.Underline, - color = WappTheme.colors.yellow34, - ), - ) { - append("로그아웃") - } - append("을 원하신다면 ") - withStyle( - style = SpanStyle( - textDecoration = TextDecoration.Underline, - color = WappTheme.colors.yellow34, - ), - ) { - append("완료") - } - append(" 버튼을 눌러주세요.") -} diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt index 85c06c66..920a894a 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -20,7 +20,10 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.window.Dialog @@ -33,7 +36,6 @@ internal fun ProfileSettingDialog( onDismissRequest: () -> Unit, onConfirmRequest: () -> Unit = {}, @StringRes title: Int, - content: AnnotatedString, ) { Dialog( onDismissRequest = onDismissRequest, @@ -64,7 +66,7 @@ internal fun ProfileSettingDialog( ) Text( - text = content, + text = generateDialogContentString(title = title), style = WappTheme.typography.contentRegular, color = WappTheme.colors.white, ) @@ -116,3 +118,26 @@ internal fun ProfileSettingDialog( } } } + +@Composable +private fun generateDialogContentString(@StringRes title: Int) = buildAnnotatedString { + append("정말로 ") + withStyle( + style = SpanStyle( + textDecoration = TextDecoration.Underline, + color = WappTheme.colors.yellow34, + ), + ) { + append(stringResource(title)) + } + append("을 원하신다면 ") + withStyle( + style = SpanStyle( + textDecoration = TextDecoration.Underline, + color = WappTheme.colors.yellow34, + ), + ) { + append("완료") + } + append(" 버튼을 눌러주세요.") +} From 6c66ef654699dab4856f73035b370ea41b714f9a Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 21:03:03 +0900 Subject: [PATCH 07/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=ED=83=88=ED=87=B4=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/profile/profilesetting/ProfileSettingScreen.kt | 7 +++---- .../profilesetting/component/ProfileSettingDialog.kt | 1 + feature/profile/src/main/res/values/strings.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 41623b6d..191174bc 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -23,7 +23,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Dialog import androidx.core.content.ContextCompat.startActivity import androidx.core.net.toUri import androidx.hilt.navigation.compose.hiltViewModel @@ -57,10 +56,10 @@ internal fun ProfileSettingScreen( val context = LocalContext.current if (showWithdrawalDialog) { - Dialog( + ProfileSettingDialog( onDismissRequest = { showWithdrawalDialog = false }, - ) { - } + title = string.withdrawal, + ) } if (showLogoutDialog) { diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt index 920a894a..92b30168 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -69,6 +69,7 @@ internal fun ProfileSettingDialog( text = generateDialogContentString(title = title), style = WappTheme.typography.contentRegular, color = WappTheme.colors.white, + modifier = Modifier.padding(top = 12.dp), ) Row( diff --git a/feature/profile/src/main/res/values/strings.xml b/feature/profile/src/main/res/values/strings.xml index 44ff146e..b638f939 100644 --- a/feature/profile/src/main/res/values/strings.xml +++ b/feature/profile/src/main/res/values/strings.xml @@ -12,7 +12,7 @@ 계정 설정 알람 설정 로그아웃 - 회원 탈퇴 + 회원탈퇴 문의하기 완료 취소 From 63081262046758497cb86d15c7feef42926d13b4 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 21:04:08 +0900 Subject: [PATCH 08/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EB=B3=80=EC=88=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 36 ++++--------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 191174bc..9488383d 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -50,7 +50,6 @@ internal fun ProfileSettingScreen( ) { var showWithdrawalDialog by remember { mutableStateOf(false) } var showLogoutDialog by remember { mutableStateOf(false) } - val dividerThickness = 1.dp val dividerColor = WappTheme.colors.black42 val scrollState = rememberScrollState() val context = LocalContext.current @@ -102,30 +101,21 @@ internal fun ProfileSettingScreen( onClicked = onClickedAlarmSetting, ) - Divider( - color = dividerColor, - thickness = dividerThickness, - ) + Divider(color = dividerColor) WappRowBar( title = stringResource(id = string.logout), onClicked = { showLogoutDialog = true }, ) - Divider( - color = dividerColor, - thickness = dividerThickness, - ) + Divider(color = dividerColor) WappRowBar( title = stringResource(id = string.withdrawal), onClicked = { showWithdrawalDialog = true }, ) - Divider( - color = dividerColor, - thickness = dividerThickness, - ) + Divider(color = dividerColor) Row( horizontalArrangement = Arrangement.spacedBy(15.dp), @@ -147,40 +137,28 @@ internal fun ProfileSettingScreen( onClicked = { navigateToUri(context, INQUIRY_URL) }, ) - Divider( - color = dividerColor, - thickness = dividerThickness, - ) + Divider(color = dividerColor) WappRowBar( title = stringResource(id = string.faq), onClicked = { navigateToUri(context, FAQ_URL) }, ) - Divider( - color = dividerColor, - thickness = dividerThickness, - ) + Divider(color = dividerColor) WappRowBar( title = stringResource(id = string.terms_and_policies), onClicked = { navigateToUri(context, TERMS_AND_POLICIES_URL) }, ) - Divider( - color = dividerColor, - thickness = dividerThickness, - ) + Divider(color = dividerColor) WappRowBar( title = stringResource(id = string.privacy_policy), onClicked = { navigateToUri(context, PRIVACY_POLICY_URL) }, ) - Divider( - color = dividerColor, - thickness = dividerThickness, - ) + Divider(color = dividerColor) } } From ac21d288ade47177fd42991a936fca0e6cc1f5c6 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 21:24:30 +0900 Subject: [PATCH 09/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EC=96=BC=EB=A1=9C=EA=B7=B8=20Content=20Horizontal=20Padding=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 --- .../profile/profilesetting/component/ProfileSettingDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt index 92b30168..2302018c 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -69,7 +69,7 @@ internal fun ProfileSettingDialog( text = generateDialogContentString(title = title), style = WappTheme.typography.contentRegular, color = WappTheme.colors.white, - modifier = Modifier.padding(top = 12.dp), + modifier = Modifier.padding(top = 12.dp, start = 12.dp, end = 12.dp), ) Row( From d4ef400e52e9182684f2951a3be11b1048dc8b44 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 21:25:38 +0900 Subject: [PATCH 10/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20Modifier=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/profilesetting/component/ProfileSettingDialog.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt index 2302018c..1bb16469 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -74,9 +74,7 @@ internal fun ProfileSettingDialog( Row( horizontalArrangement = Arrangement.spacedBy(20.dp), - modifier = Modifier - .padding(horizontal = 12.dp) - .padding(vertical = 16.dp), + modifier = Modifier.padding(horizontal = 12.dp, vertical = 16.dp), ) { Button( onClick = { /*TODO*/ }, From 38069492a6093d6398a69340e9a7c29c53a1ee5b Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 21:26:16 +0900 Subject: [PATCH 11/62] [CHORE] #74 : WrapContentHeight + WrapContentWidth -> WrapContentSize --- .../profilesetting/component/ProfileSettingDialog.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt index 1bb16469..3f6a87e6 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -8,8 +8,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults @@ -47,8 +46,7 @@ internal fun ProfileSettingDialog( verticalArrangement = Arrangement.spacedBy(16.dp), horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier - .wrapContentHeight() - .wrapContentWidth() + .wrapContentSize() .padding(horizontal = 12.dp) .clip(RoundedCornerShape(8.dp)) .background(WappTheme.colors.black25), From 0de88bef7c97323342c7a0337fcab83d5ca739c5 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Thu, 11 Jan 2024 21:26:48 +0900 Subject: [PATCH 12/62] =?UTF-8?q?[CHORE]=20#74=20:=20clickable=20onConfirm?= =?UTF-8?q?Request=20=EC=9E=A5=EC=B0=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/profilesetting/component/ProfileSettingDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt index 3f6a87e6..957540be 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -75,7 +75,7 @@ internal fun ProfileSettingDialog( modifier = Modifier.padding(horizontal = 12.dp, vertical = 16.dp), ) { Button( - onClick = { /*TODO*/ }, + onClick = onConfirmRequest, shape = RoundedCornerShape(8.dp), colors = ButtonDefaults.buttonColors( containerColor = WappTheme.colors.yellow34, From 19b699d169fca0791222ee659e94c29c21d38f3f Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 16:40:47 +0900 Subject: [PATCH 13/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EC=96=BC=EB=A1=9C=EA=B7=B8=20=EB=A7=88=EC=A7=84=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 --- .../profile/profilesetting/component/ProfileSettingDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt index 957540be..0796aa7a 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/ProfileSettingDialog.kt @@ -47,7 +47,7 @@ internal fun ProfileSettingDialog( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .wrapContentSize() - .padding(horizontal = 12.dp) + .padding(horizontal = 30.dp) .clip(RoundedCornerShape(8.dp)) .background(WappTheme.colors.black25), ) { From 5169808f9e452384c9abbb230ac85a23539d0358 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 17:32:36 +0900 Subject: [PATCH 14/62] =?UTF-8?q?[FEATURE]=20#74=20:=20UserRole=20StateFlo?= =?UTF-8?q?w=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileViewModel.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 032bb038..6edc715c 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -4,7 +4,9 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase import com.wap.wapp.core.model.event.Event +import com.wap.wapp.core.model.user.UserRole import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow @@ -14,13 +16,24 @@ import javax.inject.Inject @HiltViewModel class ProfileViewModel @Inject constructor( + private val getUserRoleUseCase: GetUserRoleUseCase, private val getEventListUseCase: GetEventListUseCase, ) : ViewModel() { private val _todayEvents = MutableStateFlow(EventsState.Loading) val todayEvents: StateFlow = _todayEvents.asStateFlow() + private val _userRole = MutableStateFlow(UserRole.GUEST) + val userRole: StateFlow = _userRole.asStateFlow() + init { - getTodayDateEvents() + // getTodayDateEvents() + } + + private fun checkUserRole() { + viewModelScope.launch { + getUserRoleUseCase().onSuccess { } + .onFailure { } + } } private fun getTodayDateEvents() { From 07b9e395a49d4e0133aae40faf322bc060a267b0 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 17:34:43 +0900 Subject: [PATCH 15/62] =?UTF-8?q?[CHORE]=20#74=20:=20Role=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20UserRole=EC=9C=BC=EB=A1=9C=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/feature/profile/ProfileScreen.kt | 11 ++++++----- .../main/java/com/wap/wapp/feature/profile/Role.kt | 5 ----- 2 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 feature/profile/src/main/java/com/wap/wapp/feature/profile/Role.kt diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 13954b45..f655939a 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -16,6 +16,7 @@ import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappMainTopBar import com.wap.wapp.core.designresource.R.drawable import com.wap.wapp.core.designresource.R.string +import com.wap.wapp.core.model.user.UserRole import com.wap.wapp.feature.profile.component.WappProfileCard import com.wap.wapp.feature.profile.screen.GuestProfile import com.wap.wapp.feature.profile.screen.UserProfile @@ -37,7 +38,7 @@ internal fun ProfileRoute( @Composable internal fun ProfileScreen( - role: Role = Role.MANAGER, + role: UserRole = UserRole.MANAGER, userName: String = "", eventsState: ProfileViewModel.EventsState, navigateToProfileSetting: () -> Unit, @@ -55,12 +56,12 @@ internal fun ProfileScreen( titleRes = string.profile, contentRes = R.string.profile_content, settingButtonDescriptionRes = R.string.profile_setting_description, - showSettingButton = role != Role.GUEST, + showSettingButton = role != UserRole.GUEST, onClickSettingButton = navigateToProfileSetting, ) when (role) { - Role.MANAGER -> { + UserRole.MANAGER -> { WappProfileCard( position = stringResource(R.string.manager), githubImage = drawable.ic_manager_github, @@ -78,7 +79,7 @@ internal fun ProfileScreen( UserProfile(eventsState = eventsState) } - Role.NORMAL -> { + UserRole.MEMBER -> { WappProfileCard( position = stringResource(R.string.normal), githubImage = drawable.ic_normal_github, @@ -96,7 +97,7 @@ internal fun ProfileScreen( UserProfile(eventsState = eventsState) } - Role.GUEST -> { + UserRole.GUEST -> { WappProfileCard( position = stringResource(R.string.guest), githubImage = drawable.ic_guest_github, diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/Role.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/Role.kt deleted file mode 100644 index 94048aa6..00000000 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/Role.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.wap.wapp.feature.profile - -enum class Role { - MANAGER, NORMAL, GUEST -} From f47eb229b968509492380f63da1703764e4c8d66 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 17:37:42 +0900 Subject: [PATCH 16/62] =?UTF-8?q?[FEATURE]=20#74=20:=20UserRole=20?= =?UTF-8?q?=EC=96=BB=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/ProfileViewModel.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 6edc715c..cf666037 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -26,14 +26,19 @@ class ProfileViewModel @Inject constructor( val userRole: StateFlow = _userRole.asStateFlow() init { - // getTodayDateEvents() + checkUserRole() } - private fun checkUserRole() { - viewModelScope.launch { - getUserRoleUseCase().onSuccess { } - .onFailure { } - } + private fun checkUserRole() = viewModelScope.launch { + getUserRoleUseCase() + .onSuccess { userRole -> + when (userRole) { + UserRole.GUEST -> Unit + UserRole.MEMBER, UserRole.MANAGER -> getTodayDateEvents() + } + _userRole.value = userRole + } + .onFailure { } } private fun getTodayDateEvents() { From cacef87e0b60d72e4fe08f4fc6603fdc7f85aeac Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 17:39:32 +0900 Subject: [PATCH 17/62] =?UTF-8?q?[CHORE]=20#74=20:=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/feature/profile/ProfileViewModel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index cf666037..363bd398 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -26,10 +26,10 @@ class ProfileViewModel @Inject constructor( val userRole: StateFlow = _userRole.asStateFlow() init { - checkUserRole() + checkUserRoleAndGetEvents() } - private fun checkUserRole() = viewModelScope.launch { + private fun checkUserRoleAndGetEvents() = viewModelScope.launch { getUserRoleUseCase() .onSuccess { userRole -> when (userRole) { From 4e558f803843278b8cefbb92eb0823c8d3c3468e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 17:50:01 +0900 Subject: [PATCH 18/62] =?UTF-8?q?[FEATURE]=20#74=20:=20UserRoleState?= =?UTF-8?q?=EB=A1=9C=20Wrapping=20=EB=B0=8F=20Lottie=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileScreen.kt | 122 ++++++++++-------- .../wapp/feature/profile/ProfileViewModel.kt | 14 +- 2 files changed, 76 insertions(+), 60 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index f655939a..2b05e68b 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -13,10 +13,12 @@ import androidx.compose.ui.res.stringResource import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.wap.designsystem.WappTheme +import com.wap.designsystem.component.CircleLoader import com.wap.designsystem.component.WappMainTopBar import com.wap.wapp.core.designresource.R.drawable import com.wap.wapp.core.designresource.R.string import com.wap.wapp.core.model.user.UserRole +import com.wap.wapp.feature.profile.ProfileViewModel.UserRoleState import com.wap.wapp.feature.profile.component.WappProfileCard import com.wap.wapp.feature.profile.screen.GuestProfile import com.wap.wapp.feature.profile.screen.UserProfile @@ -28,9 +30,11 @@ internal fun ProfileRoute( navigateToSignInScreen: () -> Unit, ) { val eventsState by viewModel.todayEvents.collectAsStateWithLifecycle() + val userRoleState by viewModel.userRole.collectAsStateWithLifecycle() ProfileScreen( eventsState = eventsState, + userRoleState = userRoleState, navigateToProfileSetting = navigateToProfileSetting, navigateToSignInScreen = navigateToSignInScreen, ) @@ -38,7 +42,7 @@ internal fun ProfileRoute( @Composable internal fun ProfileScreen( - role: UserRole = UserRole.MANAGER, + userRoleState: UserRoleState, userName: String = "", eventsState: ProfileViewModel.EventsState, navigateToProfileSetting: () -> Unit, @@ -52,67 +56,73 @@ internal fun ProfileScreen( .verticalScroll(scrollState) .background(WappTheme.colors.backgroundBlack), ) { - WappMainTopBar( - titleRes = string.profile, - contentRes = R.string.profile_content, - settingButtonDescriptionRes = R.string.profile_setting_description, - showSettingButton = role != UserRole.GUEST, - onClickSettingButton = navigateToProfileSetting, - ) - - when (role) { - UserRole.MANAGER -> { - WappProfileCard( - position = stringResource(R.string.manager), - githubImage = drawable.ic_manager_github, - catImage = drawable.ic_manager_cat, - brush = Brush.horizontalGradient( - listOf( - WappTheme.colors.blue2FF, - WappTheme.colors.blue4FF, - WappTheme.colors.blue1FF, - ), - ), - userName = "$userName 님", + when (userRoleState) { + is UserRoleState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) + is UserRoleState.Failure -> {} + is UserRoleState.Success -> { + WappMainTopBar( + titleRes = string.profile, + contentRes = R.string.profile_content, + settingButtonDescriptionRes = R.string.profile_setting_description, + showSettingButton = userRoleState.userRole != UserRole.GUEST, + onClickSettingButton = navigateToProfileSetting, ) - UserProfile(eventsState = eventsState) - } + when (userRoleState.userRole) { + UserRole.MANAGER -> { + WappProfileCard( + position = stringResource(R.string.manager), + githubImage = drawable.ic_manager_github, + catImage = drawable.ic_manager_cat, + brush = Brush.horizontalGradient( + listOf( + WappTheme.colors.blue2FF, + WappTheme.colors.blue4FF, + WappTheme.colors.blue1FF, + ), + ), + userName = "$userName 님", + ) - UserRole.MEMBER -> { - WappProfileCard( - position = stringResource(R.string.normal), - githubImage = drawable.ic_normal_github, - catImage = drawable.ic_normal_cat, - brush = Brush.horizontalGradient( - listOf( - WappTheme.colors.yellow3C, - WappTheme.colors.yellow34, - WappTheme.colors.yellowA4, - ), - ), - userName = "$userName 님", - ) + UserProfile(eventsState = eventsState) + } - UserProfile(eventsState = eventsState) - } + UserRole.MEMBER -> { + WappProfileCard( + position = stringResource(R.string.normal), + githubImage = drawable.ic_normal_github, + catImage = drawable.ic_normal_cat, + brush = Brush.horizontalGradient( + listOf( + WappTheme.colors.yellow3C, + WappTheme.colors.yellow34, + WappTheme.colors.yellowA4, + ), + ), + userName = "$userName 님", + ) - UserRole.GUEST -> { - WappProfileCard( - position = stringResource(R.string.guest), - githubImage = drawable.ic_guest_github, - catImage = drawable.ic_guest_cat, - brush = Brush.horizontalGradient( - listOf( - WappTheme.colors.grayA2, - WappTheme.colors.gray7C, - WappTheme.colors.gray4A, - ), - ), - userName = stringResource(id = R.string.non_user), - ) + UserProfile(eventsState = eventsState) + } + + UserRole.GUEST -> { + WappProfileCard( + position = stringResource(R.string.guest), + githubImage = drawable.ic_guest_github, + catImage = drawable.ic_guest_cat, + brush = Brush.horizontalGradient( + listOf( + WappTheme.colors.grayA2, + WappTheme.colors.gray7C, + WappTheme.colors.gray4A, + ), + ), + userName = stringResource(id = R.string.non_user), + ) - GuestProfile(navigateToSignInScreen = navigateToSignInScreen) + GuestProfile(navigateToSignInScreen = navigateToSignInScreen) + } + } } } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 363bd398..461e873a 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -22,8 +22,8 @@ class ProfileViewModel @Inject constructor( private val _todayEvents = MutableStateFlow(EventsState.Loading) val todayEvents: StateFlow = _todayEvents.asStateFlow() - private val _userRole = MutableStateFlow(UserRole.GUEST) - val userRole: StateFlow = _userRole.asStateFlow() + private val _userRole = MutableStateFlow(UserRoleState.Loading) + val userRole: StateFlow = _userRole.asStateFlow() init { checkUserRoleAndGetEvents() @@ -36,9 +36,9 @@ class ProfileViewModel @Inject constructor( UserRole.GUEST -> Unit UserRole.MEMBER, UserRole.MANAGER -> getTodayDateEvents() } - _userRole.value = userRole + _userRole.value = UserRoleState.Success(userRole) } - .onFailure { } + .onFailure { throwable -> _userRole.value = UserRoleState.Failure(throwable) } } private fun getTodayDateEvents() { @@ -63,4 +63,10 @@ class ProfileViewModel @Inject constructor( data class Success(val events: List) : EventsState() data class Failure(val throwable: Throwable) : EventsState() } + + sealed class UserRoleState { + data object Loading : UserRoleState() + data class Success(val userRole: UserRole) : UserRoleState() + data class Failure(val throwable: Throwable) : UserRoleState() + } } From e5d8e8196ce9a488df9850db7cdf1eb8618c3b3c Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:00:22 +0900 Subject: [PATCH 19/62] [FEATURE] #74 : GetUserProfileUseCase --- .../domain/usecase/user/GetUserProfileUseCase.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/GetUserProfileUseCase.kt diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/GetUserProfileUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/GetUserProfileUseCase.kt new file mode 100644 index 00000000..3df73744 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/GetUserProfileUseCase.kt @@ -0,0 +1,16 @@ +package com.wap.wapp.core.domain.usecase.user + +import com.wap.wapp.core.data.repository.user.UserRepository +import com.wap.wapp.core.model.user.UserProfile +import javax.inject.Inject + +class GetUserProfileUseCase @Inject constructor(private val userRepository: UserRepository) { + suspend operator fun invoke(): Result = runCatching { + val userId = userRepository.getUserId().getOrThrow() + + userRepository.getUserProfile(userId).fold( + onSuccess = { userProfile -> userProfile }, + onFailure = { throw it }, + ) + } +} From 8d3ef56b626e6fc2fb7688bfb999f32292ac2c5b Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:11:31 +0900 Subject: [PATCH 20/62] =?UTF-8?q?[FEATURE]=20#74=20:=20UserProfile=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileScreen.kt | 9 +++-- .../wapp/feature/profile/ProfileViewModel.kt | 37 ++++++++++++++++--- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 2b05e68b..42c4e30c 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -17,6 +17,7 @@ import com.wap.designsystem.component.CircleLoader import com.wap.designsystem.component.WappMainTopBar import com.wap.wapp.core.designresource.R.drawable import com.wap.wapp.core.designresource.R.string +import com.wap.wapp.core.model.user.UserProfile import com.wap.wapp.core.model.user.UserRole import com.wap.wapp.feature.profile.ProfileViewModel.UserRoleState import com.wap.wapp.feature.profile.component.WappProfileCard @@ -31,10 +32,12 @@ internal fun ProfileRoute( ) { val eventsState by viewModel.todayEvents.collectAsStateWithLifecycle() val userRoleState by viewModel.userRole.collectAsStateWithLifecycle() + val userProfile by viewModel.userProfile.collectAsStateWithLifecycle() ProfileScreen( eventsState = eventsState, userRoleState = userRoleState, + userProfile = userProfile, navigateToProfileSetting = navigateToProfileSetting, navigateToSignInScreen = navigateToSignInScreen, ) @@ -43,7 +46,7 @@ internal fun ProfileRoute( @Composable internal fun ProfileScreen( userRoleState: UserRoleState, - userName: String = "", + userProfile: UserProfile, eventsState: ProfileViewModel.EventsState, navigateToProfileSetting: () -> Unit, navigateToSignInScreen: () -> Unit, @@ -81,7 +84,7 @@ internal fun ProfileScreen( WappTheme.colors.blue1FF, ), ), - userName = "$userName 님", + userName = "${userProfile.userName} 님", ) UserProfile(eventsState = eventsState) @@ -99,7 +102,7 @@ internal fun ProfileScreen( WappTheme.colors.yellowA4, ), ), - userName = "$userName 님", + userName = "$userProfile 님", ) UserProfile(eventsState = eventsState) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 461e873a..19e31565 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -4,10 +4,13 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase import com.wap.wapp.core.model.event.Event +import com.wap.wapp.core.model.user.UserProfile import com.wap.wapp.core.model.user.UserRole import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow @@ -17,6 +20,7 @@ import javax.inject.Inject @HiltViewModel class ProfileViewModel @Inject constructor( private val getUserRoleUseCase: GetUserRoleUseCase, + private val getUserProfileUseCase: GetUserProfileUseCase, private val getEventListUseCase: GetEventListUseCase, ) : ViewModel() { private val _todayEvents = MutableStateFlow(EventsState.Loading) @@ -25,20 +29,37 @@ class ProfileViewModel @Inject constructor( private val _userRole = MutableStateFlow(UserRoleState.Loading) val userRole: StateFlow = _userRole.asStateFlow() + private val _userProfile = MutableStateFlow(DEFAULT_USER_PROFILE) + val userProfile: StateFlow = _userProfile.asStateFlow() + init { - checkUserRoleAndGetEvents() + checkUserInformationAndGetEvents() } - private fun checkUserRoleAndGetEvents() = viewModelScope.launch { + private fun checkUserInformationAndGetEvents() = viewModelScope.launch { getUserRoleUseCase() + .onFailure { throwable -> _userRole.value = UserRoleState.Failure(throwable) } .onSuccess { userRole -> when (userRole) { - UserRole.GUEST -> Unit - UserRole.MEMBER, UserRole.MANAGER -> getTodayDateEvents() + // 비회원 일 경우, 바로 UserCard 갱신 + UserRole.GUEST -> _userRole.value = UserRoleState.Success(userRole) + + // 일반 회원 혹은 운영진 일 경우, + // 오늘 일정 정보, UserProfile 정보를 가져온 뒤 한꺼번에 갱신 + UserRole.MEMBER, UserRole.MANAGER -> { + getTodayDateEvents() + val userProfile = async { getUserProfileUseCase() } + + userProfile.await() + .onSuccess { + _userRole.value = UserRoleState.Success(userRole) + _userProfile.value = it + }.onFailure { throwable -> + _userRole.value = UserRoleState.Failure(throwable) + } + } } - _userRole.value = UserRoleState.Success(userRole) } - .onFailure { throwable -> _userRole.value = UserRoleState.Failure(throwable) } } private fun getTodayDateEvents() { @@ -69,4 +90,8 @@ class ProfileViewModel @Inject constructor( data class Success(val userRole: UserRole) : UserRoleState() data class Failure(val throwable: Throwable) : UserRoleState() } + + companion object { + val DEFAULT_USER_PROFILE = UserProfile("", "", "", "") + } } From 891e506529abc450c30ffdf881ce39570b426a35 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:13:36 +0900 Subject: [PATCH 21/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EC=9D=BC=EB=B0=98=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EB=8F=84=20userName=20=EB=B3=B4=EC=97=AC?= =?UTF-8?q?=EC=A3=BC=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 42c4e30c..e5b9afba 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -102,7 +102,7 @@ internal fun ProfileScreen( WappTheme.colors.yellowA4, ), ), - userName = "$userProfile 님", + userName = "${userProfile.userName} 님", ) UserProfile(eventsState = eventsState) From 60e4969af27854a63d42500569c6d41eb38378d9 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:16:57 +0900 Subject: [PATCH 22/62] =?UTF-8?q?[FEATURE]=20#74=20:=20Profile=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20SnackBar=20=EB=9B=B0=EC=9B=8C=EC=A3=BC=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=EC=84=9C=20Column=20->=20Scaffold=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileScreen.kt | 131 +++++++++--------- 1 file changed, 69 insertions(+), 62 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index e5b9afba..7e421973 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -2,14 +2,18 @@ package com.wap.wapp.feature.profile import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.wap.designsystem.WappTheme @@ -53,77 +57,80 @@ internal fun ProfileScreen( ) { val scrollState = rememberScrollState() - Column( - modifier = Modifier - .fillMaxSize() - .verticalScroll(scrollState) - .background(WappTheme.colors.backgroundBlack), - ) { - when (userRoleState) { - is UserRoleState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) - is UserRoleState.Failure -> {} - is UserRoleState.Success -> { - WappMainTopBar( - titleRes = string.profile, - contentRes = R.string.profile_content, - settingButtonDescriptionRes = R.string.profile_setting_description, - showSettingButton = userRoleState.userRole != UserRole.GUEST, - onClickSettingButton = navigateToProfileSetting, - ) + Scaffold(contentWindowInsets = WindowInsets(0.dp)) { paddingValues -> + Column( + modifier = Modifier + .padding(paddingValues) + .fillMaxSize() + .verticalScroll(scrollState) + .background(WappTheme.colors.backgroundBlack), + ) { + when (userRoleState) { + is UserRoleState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) + is UserRoleState.Failure -> {} + is UserRoleState.Success -> { + WappMainTopBar( + titleRes = string.profile, + contentRes = R.string.profile_content, + settingButtonDescriptionRes = R.string.profile_setting_description, + showSettingButton = userRoleState.userRole != UserRole.GUEST, + onClickSettingButton = navigateToProfileSetting, + ) - when (userRoleState.userRole) { - UserRole.MANAGER -> { - WappProfileCard( - position = stringResource(R.string.manager), - githubImage = drawable.ic_manager_github, - catImage = drawable.ic_manager_cat, - brush = Brush.horizontalGradient( - listOf( - WappTheme.colors.blue2FF, - WappTheme.colors.blue4FF, - WappTheme.colors.blue1FF, + when (userRoleState.userRole) { + UserRole.MANAGER -> { + WappProfileCard( + position = stringResource(R.string.manager), + githubImage = drawable.ic_manager_github, + catImage = drawable.ic_manager_cat, + brush = Brush.horizontalGradient( + listOf( + WappTheme.colors.blue2FF, + WappTheme.colors.blue4FF, + WappTheme.colors.blue1FF, + ), ), - ), - userName = "${userProfile.userName} 님", - ) + userName = "${userProfile.userName} 님", + ) - UserProfile(eventsState = eventsState) - } + UserProfile(eventsState = eventsState) + } - UserRole.MEMBER -> { - WappProfileCard( - position = stringResource(R.string.normal), - githubImage = drawable.ic_normal_github, - catImage = drawable.ic_normal_cat, - brush = Brush.horizontalGradient( - listOf( - WappTheme.colors.yellow3C, - WappTheme.colors.yellow34, - WappTheme.colors.yellowA4, + UserRole.MEMBER -> { + WappProfileCard( + position = stringResource(R.string.normal), + githubImage = drawable.ic_normal_github, + catImage = drawable.ic_normal_cat, + brush = Brush.horizontalGradient( + listOf( + WappTheme.colors.yellow3C, + WappTheme.colors.yellow34, + WappTheme.colors.yellowA4, + ), ), - ), - userName = "${userProfile.userName} 님", - ) + userName = "${userProfile.userName} 님", + ) - UserProfile(eventsState = eventsState) - } + UserProfile(eventsState = eventsState) + } - UserRole.GUEST -> { - WappProfileCard( - position = stringResource(R.string.guest), - githubImage = drawable.ic_guest_github, - catImage = drawable.ic_guest_cat, - brush = Brush.horizontalGradient( - listOf( - WappTheme.colors.grayA2, - WappTheme.colors.gray7C, - WappTheme.colors.gray4A, + UserRole.GUEST -> { + WappProfileCard( + position = stringResource(R.string.guest), + githubImage = drawable.ic_guest_github, + catImage = drawable.ic_guest_cat, + brush = Brush.horizontalGradient( + listOf( + WappTheme.colors.grayA2, + WappTheme.colors.gray7C, + WappTheme.colors.gray4A, + ), ), - ), - userName = stringResource(id = R.string.non_user), - ) + userName = stringResource(id = R.string.non_user), + ) - GuestProfile(navigateToSignInScreen = navigateToSignInScreen) + GuestProfile(navigateToSignInScreen = navigateToSignInScreen) + } } } } From 72fb826bcb3e6cf6d2c874602d0f76eaaf48a785 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:25:31 +0900 Subject: [PATCH 23/62] =?UTF-8?q?[FEATURE]=20#74=20:=20ErrorFlow=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20UiState=20Failure=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 --- .../wap/wapp/feature/profile/ProfileScreen.kt | 12 ++++++++++-- .../wap/wapp/feature/profile/ProfileViewModel.kt | 16 +++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 7e421973..315ca36d 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -8,8 +8,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.res.stringResource @@ -37,11 +40,13 @@ internal fun ProfileRoute( val eventsState by viewModel.todayEvents.collectAsStateWithLifecycle() val userRoleState by viewModel.userRole.collectAsStateWithLifecycle() val userProfile by viewModel.userProfile.collectAsStateWithLifecycle() + val snackbarHostState = remember { SnackbarHostState() } ProfileScreen( eventsState = eventsState, userRoleState = userRoleState, userProfile = userProfile, + snackbarHostState = snackbarHostState, navigateToProfileSetting = navigateToProfileSetting, navigateToSignInScreen = navigateToSignInScreen, ) @@ -52,12 +57,16 @@ internal fun ProfileScreen( userRoleState: UserRoleState, userProfile: UserProfile, eventsState: ProfileViewModel.EventsState, + snackbarHostState: SnackbarHostState, navigateToProfileSetting: () -> Unit, navigateToSignInScreen: () -> Unit, ) { val scrollState = rememberScrollState() - Scaffold(contentWindowInsets = WindowInsets(0.dp)) { paddingValues -> + Scaffold( + contentWindowInsets = WindowInsets(0.dp), + snackbarHost = { SnackbarHost(snackbarHostState) }, + ) { paddingValues -> Column( modifier = Modifier .padding(paddingValues) @@ -67,7 +76,6 @@ internal fun ProfileScreen( ) { when (userRoleState) { is UserRoleState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) - is UserRoleState.Failure -> {} is UserRoleState.Success -> { WappMainTopBar( titleRes = string.profile, diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 19e31565..1c463c15 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -11,8 +11,11 @@ import com.wap.wapp.core.model.user.UserProfile import com.wap.wapp.core.model.user.UserRole import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import javax.inject.Inject @@ -23,6 +26,9 @@ class ProfileViewModel @Inject constructor( private val getUserProfileUseCase: GetUserProfileUseCase, private val getEventListUseCase: GetEventListUseCase, ) : ViewModel() { + private val _errorFlow: MutableSharedFlow = MutableSharedFlow() + val errorFlow: SharedFlow = _errorFlow.asSharedFlow() + private val _todayEvents = MutableStateFlow(EventsState.Loading) val todayEvents: StateFlow = _todayEvents.asStateFlow() @@ -38,7 +44,7 @@ class ProfileViewModel @Inject constructor( private fun checkUserInformationAndGetEvents() = viewModelScope.launch { getUserRoleUseCase() - .onFailure { throwable -> _userRole.value = UserRoleState.Failure(throwable) } + .onFailure { exception -> _errorFlow.emit(exception) } .onSuccess { userRole -> when (userRole) { // 비회원 일 경우, 바로 UserCard 갱신 @@ -54,9 +60,7 @@ class ProfileViewModel @Inject constructor( .onSuccess { _userRole.value = UserRoleState.Success(userRole) _userProfile.value = it - }.onFailure { throwable -> - _userRole.value = UserRoleState.Failure(throwable) - } + }.onFailure { exception -> _errorFlow.emit(exception) } } } } @@ -74,7 +78,7 @@ class ProfileViewModel @Inject constructor( }, ) }, - onFailure = { _todayEvents.value = EventsState.Failure(it) }, + onFailure = { exception -> _errorFlow.emit(exception) }, ) } } @@ -82,13 +86,11 @@ class ProfileViewModel @Inject constructor( sealed class EventsState { data object Loading : EventsState() data class Success(val events: List) : EventsState() - data class Failure(val throwable: Throwable) : EventsState() } sealed class UserRoleState { data object Loading : UserRoleState() data class Success(val userRole: UserRole) : UserRoleState() - data class Failure(val throwable: Throwable) : UserRoleState() } companion object { From a318dca482123e478dc6a53c1945503c1ced3dbb Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:27:12 +0900 Subject: [PATCH 24/62] =?UTF-8?q?[FEATURE]=20#74=20:=20Error=20=EC=8B=9C,?= =?UTF-8?q?=20SnackBar=EB=A5=BC=20=EB=B3=B4=EC=97=AC=EC=A3=BC=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileScreen.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 315ca36d..1d588da0 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost 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.ui.Modifier @@ -22,6 +23,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.wap.designsystem.WappTheme import com.wap.designsystem.component.CircleLoader import com.wap.designsystem.component.WappMainTopBar +import com.wap.wapp.core.commmon.extensions.toSupportingText import com.wap.wapp.core.designresource.R.drawable import com.wap.wapp.core.designresource.R.string import com.wap.wapp.core.model.user.UserProfile @@ -30,6 +32,7 @@ import com.wap.wapp.feature.profile.ProfileViewModel.UserRoleState import com.wap.wapp.feature.profile.component.WappProfileCard import com.wap.wapp.feature.profile.screen.GuestProfile import com.wap.wapp.feature.profile.screen.UserProfile +import kotlinx.coroutines.flow.collectLatest @Composable internal fun ProfileRoute( @@ -40,13 +43,21 @@ internal fun ProfileRoute( val eventsState by viewModel.todayEvents.collectAsStateWithLifecycle() val userRoleState by viewModel.userRole.collectAsStateWithLifecycle() val userProfile by viewModel.userProfile.collectAsStateWithLifecycle() - val snackbarHostState = remember { SnackbarHostState() } + val snackBarHostState = remember { SnackbarHostState() } + + LaunchedEffect(true) { + viewModel.errorFlow.collectLatest { throwable -> + snackBarHostState.showSnackbar( + message = throwable.toSupportingText(), + ) + } + } ProfileScreen( eventsState = eventsState, userRoleState = userRoleState, userProfile = userProfile, - snackbarHostState = snackbarHostState, + snackBarHostState = snackBarHostState, navigateToProfileSetting = navigateToProfileSetting, navigateToSignInScreen = navigateToSignInScreen, ) @@ -57,7 +68,7 @@ internal fun ProfileScreen( userRoleState: UserRoleState, userProfile: UserProfile, eventsState: ProfileViewModel.EventsState, - snackbarHostState: SnackbarHostState, + snackBarHostState: SnackbarHostState, navigateToProfileSetting: () -> Unit, navigateToSignInScreen: () -> Unit, ) { @@ -65,7 +76,7 @@ internal fun ProfileScreen( Scaffold( contentWindowInsets = WindowInsets(0.dp), - snackbarHost = { SnackbarHost(snackbarHostState) }, + snackbarHost = { SnackbarHost(snackBarHostState) }, ) { paddingValues -> Column( modifier = Modifier From c7971ba2ee730be485aed034ca5192d3fd0ca57b Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:32:00 +0900 Subject: [PATCH 25/62] =?UTF-8?q?[FEATURE]=20#74=20:=20Loading=20Lottie=20?= =?UTF-8?q?=EA=B0=80=EC=9A=B4=EB=8D=B0=20=EB=B0=B0=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/feature/profile/ProfileScreen.kt | 12 +++++++++++- .../wap/wapp/feature/profile/screen/UserProfile.kt | 2 -- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 1d588da0..2667095a 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -2,6 +2,7 @@ package com.wap.wapp.feature.profile import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding @@ -86,7 +87,16 @@ internal fun ProfileScreen( .background(WappTheme.colors.backgroundBlack), ) { when (userRoleState) { - is UserRoleState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) + is UserRoleState.Loading -> { + Spacer(modifier = Modifier.weight(1f)) + CircleLoader( + modifier = Modifier + .fillMaxSize() + .weight(1f), + ) + Spacer(modifier = Modifier.weight(1f)) + } + is UserRoleState.Success -> { WappMainTopBar( titleRes = string.profile, diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index 8f7f1509..24c87bfa 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -54,8 +54,6 @@ private fun handleMonthEventsState( modifier = Modifier.padding(top = 20.dp), ) } - - is ProfileViewModel.EventsState.Failure -> {} } @Composable From 05eeedd1492a3571e2145faccab08f649497ef5b Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:37:53 +0900 Subject: [PATCH 26/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A2=85=EB=A3=8C=20=EC=9D=BC=EC=A0=95=EC=9D=84=20?= =?UTF-8?q?=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20=EB=B0=9B=EC=95=84?= =?UTF-8?q?=EC=98=A4=EB=8D=98=20=EA=B2=83=EC=9D=84=20=EC=8B=9C=EC=9E=91=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=EB=A5=BC=20=EA=B8=B0=EC=A4=80=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=9B=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 --- .../wapp/feature/profile/ProfileViewModel.kt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 1c463c15..e995cde4 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -69,17 +69,14 @@ class ProfileViewModel @Inject constructor( private fun getTodayDateEvents() { _todayEvents.value = EventsState.Loading viewModelScope.launch { - getEventListUseCase(DateUtil.generateNowDate()).fold( - onSuccess = { - _todayEvents.value = - EventsState.Success( - it.filter { - it.endDateTime == DateUtil.generateNowDateTime() - }, - ) - }, - onFailure = { exception -> _errorFlow.emit(exception) }, - ) + getEventListUseCase(DateUtil.generateNowDate()).onSuccess { eventList -> + _todayEvents.value = + EventsState.Success( + eventList.filter { event -> + event.startDateTime == DateUtil.generateNowDateTime() + }, + ) + }.onFailure { exception -> _errorFlow.emit(exception) } } } From ff65ad376c6f33cfebe475d83e01c4bc3e43cf29 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:42:49 +0900 Subject: [PATCH 27/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EA=B8=B0=EC=A4=80=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=95=EB=A0=AC=ED=95=B4=EC=84=9C=20=EB=B0=9B?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/feature/profile/ProfileViewModel.kt | 4 ++-- .../com/wap/wapp/feature/profile/screen/UserProfile.kt | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index e995cde4..8b50b3a4 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -73,8 +73,8 @@ class ProfileViewModel @Inject constructor( _todayEvents.value = EventsState.Success( eventList.filter { event -> - event.startDateTime == DateUtil.generateNowDateTime() - }, + event.startDateTime.toLocalDate() == DateUtil.generateNowDate() + }.sortedBy { event -> event.title }, ) }.onFailure { exception -> _errorFlow.emit(exception) } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index 24c87bfa..d477dcb1 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -171,7 +171,7 @@ private fun MySurveyHistory(modifier: Modifier = Modifier) { @Composable private fun generateTodayEventString(events: List) = buildAnnotatedString { - append("오늘은") + append("오늘은 ") withStyle( style = SpanStyle( @@ -179,10 +179,8 @@ private fun generateTodayEventString(events: List) = buildAnnotatedString textDecoration = TextDecoration.Underline, ), ) { - events.forEach { event -> - append(event.title + ", ") - } + append(events.map { it.title }.joinToString(separator = ", ")) } - append("날 이에요!") + append(" 날 이에요!") } From f03411929d203eb975d63f15496c81edd58e3c33 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 18:44:12 +0900 Subject: [PATCH 28/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EA=B3=B5=EC=A7=80?= =?UTF-8?q?=EC=82=AC=ED=95=AD=20=EC=9D=BC=EC=A0=95=20=EB=B0=9B=EC=95=84?= =?UTF-8?q?=EC=98=AC=20=EB=95=8C,=20=EC=8B=9C=EC=9E=91=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=EC=9D=84=20=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=EB=90=98=EC=96=B4=20=EB=B0=9B=EC=95=84?= =?UTF-8?q?=EC=98=A4=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index 33c36896..815cb660 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -46,7 +46,8 @@ class NoticeViewModel @Inject constructor( viewModelScope.launch { getEventListUseCase(_selectedDate.value).onSuccess { _selectedDateEvents.value = EventsState.Success( - it.filter { it.startDateTime.toLocalDate() == _selectedDate.value }, + it.filter { it.startDateTime.toLocalDate() == _selectedDate.value } + .sortedBy { it.startDateTime }, ) }.onFailure { _selectedDateEvents.value = EventsState.Failure(it) } } From a76fe19791a2a9036213e2b80e3fa5924b10d64e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 19:08:56 +0900 Subject: [PATCH 29/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EC=B6=9C=EC=84=9D?= =?UTF-8?q?=ED=99=95=EC=9D=B8=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=B5=9C?= =?UTF-8?q?=EA=B7=BC=203=EA=B0=9C=EC=9B=94=20=EC=9D=BC=EC=A0=95=EC=9D=84?= =?UTF-8?q?=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8A=94=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/ProfileViewModel.kt | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 8b50b3a4..cea21a16 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -18,6 +18,8 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import java.time.LocalDate +import java.time.temporal.ChronoUnit import javax.inject.Inject @HiltViewModel @@ -80,6 +82,43 @@ class ProfileViewModel @Inject constructor( } } + private suspend fun getRecentEventsForAttendanceCheck() { + val registeredAt = _userProfile.value.registeredAt + val (registeredYear, registeredSemester) = registeredAt.split(" ") + + val registrationDateTime = + createRegistrationDateTime(registeredYear.toInt(), registeredSemester) + + // 현재 날짜 + val currentDateTime = LocalDate.now() + + val eventsList = mutableListOf() + + for (i in 1..3) { + val targetDateTime = currentDateTime.minus(i.toLong(), ChronoUnit.MONTHS) + + // 만약 가입한 날짜보다 빠르다면 반복문을 멈춤 + if (targetDateTime < registrationDateTime) break + + getEventListUseCase(targetDateTime) + .onSuccess { eventsList.addAll(it) } + .onFailure { _errorFlow.emit(it) } + } + } + + private fun createRegistrationDateTime(year: Int, semester: String): LocalDate { + // 학기에 따른 기준 날짜 설정 (예: 1학기는 3월 1일, 2학기는 9월 1일) + val semesterNumber = semester.removeSuffix("학기").toInt() + val baseDate = + if (semesterNumber == 1) { + LocalDate.of(year, 3, 1) + } else { + LocalDate.of(year, 9, 1) + } + + return baseDate + } + sealed class EventsState { data object Loading : EventsState() data class Success(val events: List) : EventsState() From ccc1593ebbdc11bf62094b831f086b91b5ae6414 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 19:13:46 +0900 Subject: [PATCH 30/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EC=B6=9C=EC=84=9D?= =?UTF-8?q?=ED=99=95=EC=9D=B8=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=B5=9C?= =?UTF-8?q?=EA=B7=BC=20=EC=9D=BC=EC=A0=95=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?StateFlow=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileViewModel.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index cea21a16..9e5f3133 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -11,6 +11,7 @@ import com.wap.wapp.core.model.user.UserProfile import com.wap.wapp.core.model.user.UserRole import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -34,6 +35,9 @@ class ProfileViewModel @Inject constructor( private val _todayEvents = MutableStateFlow(EventsState.Loading) val todayEvents: StateFlow = _todayEvents.asStateFlow() + private val _recentEvents = MutableStateFlow(EventsState.Loading) + val recentEvents: StateFlow = _recentEvents.asStateFlow() + private val _userRole = MutableStateFlow(UserRoleState.Loading) val userRole: StateFlow = _userRole.asStateFlow() @@ -41,10 +45,13 @@ class ProfileViewModel @Inject constructor( val userProfile: StateFlow = _userProfile.asStateFlow() init { - checkUserInformationAndGetEvents() + viewModelScope.launch { + checkUserInformationAndGetEvents() + launch { getRecentEventsForAttendanceCheck() } + } } - private fun checkUserInformationAndGetEvents() = viewModelScope.launch { + private suspend fun checkUserInformationAndGetEvents() = coroutineScope { getUserRoleUseCase() .onFailure { exception -> _errorFlow.emit(exception) } .onSuccess { userRole -> @@ -93,7 +100,6 @@ class ProfileViewModel @Inject constructor( val currentDateTime = LocalDate.now() val eventsList = mutableListOf() - for (i in 1..3) { val targetDateTime = currentDateTime.minus(i.toLong(), ChronoUnit.MONTHS) @@ -104,6 +110,8 @@ class ProfileViewModel @Inject constructor( .onSuccess { eventsList.addAll(it) } .onFailure { _errorFlow.emit(it) } } + + _recentEvents.value = EventsState.Success(eventsList) } private fun createRegistrationDateTime(year: Int, semester: String): LocalDate { From eeb86c60952331bda38d3174c6366edc971508f3 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 22:35:23 +0900 Subject: [PATCH 31/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EC=B5=9C=EA=B7=BC?= =?UTF-8?q?=203=EA=B0=9C=EC=9B=94=20=EC=9D=BC=EC=A0=95=EC=9D=84=20?= =?UTF-8?q?=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/notice/BottomSheetContent.kt | 3 - .../wap/wapp/feature/profile/ProfileScreen.kt | 19 ++- .../wapp/feature/profile/ProfileViewModel.kt | 6 +- .../profile/component/WappAttendanceRow.kt | 11 +- .../feature/profile/screen/UserProfile.kt | 161 ++++++++++-------- 5 files changed, 112 insertions(+), 88 deletions(-) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt index df47cf48..10677a70 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt @@ -33,7 +33,6 @@ import com.wap.wapp.core.commmon.util.DateUtil.MONTH_DATE_START_INDEX import com.wap.wapp.core.commmon.util.DateUtil.yyyyMMddFormatter import com.wap.wapp.core.model.event.Event import java.time.LocalDate -import java.time.format.DateTimeFormatter import java.time.format.TextStyle import java.util.Locale @@ -110,8 +109,6 @@ private fun EventsList(events: List) { @Composable private fun EventItem(event: Event) { - val formatter = DateTimeFormatter.ofPattern("MM-dd") - Column { Row( modifier = Modifier diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 2667095a..8483467b 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -41,7 +41,8 @@ internal fun ProfileRoute( navigateToProfileSetting: () -> Unit, navigateToSignInScreen: () -> Unit, ) { - val eventsState by viewModel.todayEvents.collectAsStateWithLifecycle() + val todayEventsState by viewModel.todayEvents.collectAsStateWithLifecycle() + val recentEventsState by viewModel.recentEvents.collectAsStateWithLifecycle() val userRoleState by viewModel.userRole.collectAsStateWithLifecycle() val userProfile by viewModel.userProfile.collectAsStateWithLifecycle() val snackBarHostState = remember { SnackbarHostState() } @@ -55,7 +56,8 @@ internal fun ProfileRoute( } ProfileScreen( - eventsState = eventsState, + todayEventsState = todayEventsState, + recentEventsState = recentEventsState, userRoleState = userRoleState, userProfile = userProfile, snackBarHostState = snackBarHostState, @@ -68,7 +70,8 @@ internal fun ProfileRoute( internal fun ProfileScreen( userRoleState: UserRoleState, userProfile: UserProfile, - eventsState: ProfileViewModel.EventsState, + todayEventsState: ProfileViewModel.EventsState, + recentEventsState: ProfileViewModel.EventsState, snackBarHostState: SnackbarHostState, navigateToProfileSetting: () -> Unit, navigateToSignInScreen: () -> Unit, @@ -122,7 +125,10 @@ internal fun ProfileScreen( userName = "${userProfile.userName} 님", ) - UserProfile(eventsState = eventsState) + UserProfile( + todayEventsState = todayEventsState, + recentEventsState = recentEventsState, + ) } UserRole.MEMBER -> { @@ -140,7 +146,10 @@ internal fun ProfileScreen( userName = "${userProfile.userName} 님", ) - UserProfile(eventsState = eventsState) + UserProfile( + todayEventsState = todayEventsState, + recentEventsState = recentEventsState, + ) } UserRole.GUEST -> { diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 9e5f3133..1d3bbc90 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -1,5 +1,6 @@ package com.wap.wapp.feature.profile +import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil @@ -92,7 +93,6 @@ class ProfileViewModel @Inject constructor( private suspend fun getRecentEventsForAttendanceCheck() { val registeredAt = _userProfile.value.registeredAt val (registeredYear, registeredSemester) = registeredAt.split(" ") - val registrationDateTime = createRegistrationDateTime(registeredYear.toInt(), registeredSemester) @@ -100,9 +100,8 @@ class ProfileViewModel @Inject constructor( val currentDateTime = LocalDate.now() val eventsList = mutableListOf() - for (i in 1..3) { + for (i in 0..3) { val targetDateTime = currentDateTime.minus(i.toLong(), ChronoUnit.MONTHS) - // 만약 가입한 날짜보다 빠르다면 반복문을 멈춤 if (targetDateTime < registrationDateTime) break @@ -110,7 +109,6 @@ class ProfileViewModel @Inject constructor( .onSuccess { eventsList.addAll(it) } .onFailure { _errorFlow.emit(it) } } - _recentEvents.value = EventsState.Success(eventsList) } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappAttendanceRow.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappAttendanceRow.kt index 5df5054b..60d1fc99 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappAttendanceRow.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappAttendanceRow.kt @@ -12,19 +12,20 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.wap.designsystem.WappTheme +import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.designresource.R +import com.wap.wapp.core.model.event.Event @Composable internal fun WappAttendacneRow( + event: Event, isAttendance: Boolean, onClick: () -> Unit = {}, modifier: Modifier = Modifier, ) { Row( verticalAlignment = Alignment.CenterVertically, - modifier = modifier - .padding(horizontal = 10.dp) - .clickable { onClick() }, + modifier = modifier.clickable { onClick() }, ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -32,7 +33,7 @@ internal fun WappAttendacneRow( ) { WappAttendanceBadge(isAttendance = isAttendance) Text( - text = "프로젝트 세미나", + text = event.title, style = WappTheme.typography.labelRegular, color = WappTheme.colors.white, maxLines = 1, @@ -41,7 +42,7 @@ internal fun WappAttendacneRow( ) } Text( - text = "09월 04일", + text = event.startDateTime.format(DateUtil.HHmmFormatter), style = WappTheme.typography.labelRegular, color = WappTheme.colors.gray95, modifier = Modifier.padding(start = 10.dp), diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index d477dcb1..d99da117 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -1,13 +1,17 @@ package com.wap.wapp.feature.profile.screen +import android.util.Log import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row 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.wrapContentHeight +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -33,86 +37,88 @@ import com.wap.wapp.feature.profile.component.WappAttendacneRow import com.wap.wapp.feature.profile.component.WappSurveyHistoryRow @Composable -internal fun UserProfile(eventsState: ProfileViewModel.EventsState) { +internal fun UserProfile( + todayEventsState: ProfileViewModel.EventsState, + recentEventsState: ProfileViewModel.EventsState, +) { Column(modifier = Modifier.padding(horizontal = 10.dp)) { - handleMonthEventsState(eventsState = eventsState) - - MyAttendanceStatus(modifier = Modifier.padding(top = 20.dp)) - - MySurveyHistory(modifier = Modifier.padding(vertical = 20.dp)) - } -} - -@Composable -private fun handleMonthEventsState( - eventsState: ProfileViewModel.EventsState, -) = when (eventsState) { - is ProfileViewModel.EventsState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) - is ProfileViewModel.EventsState.Success -> { ProfileAttendanceCard( - events = eventsState.events, + todayEventsState = todayEventsState, modifier = Modifier.padding(top = 20.dp), ) + MyAttendanceStatus( + recentEventsState = recentEventsState, + modifier = Modifier.padding(top = 20.dp), + ) + + MySurveyHistory(modifier = Modifier.padding(vertical = 20.dp)) } } @Composable private fun ProfileAttendanceCard( - events: List, + todayEventsState: ProfileViewModel.EventsState, modifier: Modifier, ) { - WappCard( - modifier = modifier - .fillMaxWidth() - .wrapContentHeight(), - ) { - Column( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 15.dp, vertical = 10.dp), - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - Text( - text = stringResource(id = R.string.wap_attendance), - style = WappTheme.typography.captionBold.copy(fontSize = 20.sp), - color = WappTheme.colors.white, - ) - - Image( - painter = painterResource(id = drawable.ic_check), - contentDescription = "", - modifier = Modifier.padding(start = 10.dp), - ) - } - - Text( - text = DateUtil.generateNowDate().format(DateUtil.yyyyMMddFormatter), - style = WappTheme.typography.contentRegular, - color = WappTheme.colors.white, - modifier = Modifier.padding(top = 20.dp), - ) - - if (events.isEmpty()) { - Text( - text = stringResource(id = R.string.no_event_today), - style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), - color = WappTheme.colors.white, - modifier = Modifier.padding(top = 5.dp), - ) - } else { - Text( - text = generateTodayEventString(events = events), - style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), - color = WappTheme.colors.white, - modifier = Modifier.padding(top = 5.dp), - ) + when (todayEventsState) { + is ProfileViewModel.EventsState.Loading -> CircleLoader(modifier = Modifier.fillMaxSize()) + is ProfileViewModel.EventsState.Success -> { + WappCard( + modifier = modifier + .fillMaxWidth() + .wrapContentHeight(), + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 15.dp, vertical = 10.dp), + ) { + Row(verticalAlignment = Alignment.CenterVertically) { + Text( + text = stringResource(id = R.string.wap_attendance), + style = WappTheme.typography.captionBold.copy(fontSize = 20.sp), + color = WappTheme.colors.white, + ) + + Image( + painter = painterResource(id = drawable.ic_check), + contentDescription = "", + modifier = Modifier.padding(start = 10.dp), + ) + } + Text( + text = DateUtil.generateNowDate().format(DateUtil.yyyyMMddFormatter), + style = WappTheme.typography.contentRegular, + color = WappTheme.colors.white, + modifier = Modifier.padding(top = 20.dp), + ) + + if (todayEventsState.events.isEmpty()) { + Text( + text = stringResource(id = R.string.no_event_today), + style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), + color = WappTheme.colors.white, + modifier = Modifier.padding(top = 5.dp), + ) + } else { + Text( + text = generateTodayEventString(events = todayEventsState.events), + style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), + color = WappTheme.colors.white, + modifier = Modifier.padding(top = 5.dp), + ) + } + } } } } } @Composable -private fun MyAttendanceStatus(modifier: Modifier = Modifier) { +private fun MyAttendanceStatus( + recentEventsState: ProfileViewModel.EventsState, + modifier: Modifier = Modifier, +) { Column(modifier = modifier) { Text( text = stringResource(id = R.string.my_attendance), @@ -127,14 +133,27 @@ private fun MyAttendanceStatus(modifier: Modifier = Modifier) { .wrapContentHeight() .padding(top = 10.dp), ) { - Column( - verticalArrangement = Arrangement.spacedBy(10.dp), - modifier = Modifier.padding(vertical = 10.dp), - ) { - WappAttendacneRow(isAttendance = false) - WappAttendacneRow(isAttendance = true) - WappAttendacneRow(isAttendance = false) - WappAttendacneRow(isAttendance = true) + when (recentEventsState) { + is ProfileViewModel.EventsState.Success -> { + LazyColumn( + verticalArrangement = Arrangement.spacedBy(10.dp), + modifier = Modifier + .padding(10.dp) + .height(130.dp), + ) { + items( + items = recentEventsState.events, + key = { event -> event.eventId }, + ) { event -> + Log.d("test", recentEventsState.events.toString()) + WappAttendacneRow(isAttendance = true, event = event) + } + } + } + + is ProfileViewModel.EventsState.Loading -> CircleLoader( + modifier = Modifier.weight(1f), + ) } } } From b2576fe089d7e14d46cdab9aea6641562307832a Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 22:36:15 +0900 Subject: [PATCH 32/62] [CHORE] #74 : events.size > 0 -> events.isNotEmpty --- .../main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt index 10677a70..b6647ffd 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt @@ -71,7 +71,7 @@ private fun HandleEventsState(events: NoticeViewModel.EventsState) = when (event @Composable private fun EventsList(events: List) { - if (events.size > 0) { + if (events.isNotEmpty()) { LazyColumn( contentPadding = PaddingValues(horizontal = 15.dp), verticalArrangement = Arrangement.spacedBy(12.dp), From a95d21823c3deff2d8bb27330d767f02816ccbbc Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 22:40:51 +0900 Subject: [PATCH 33/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EC=B6=9C=EA=B2=B0?= =?UTF-8?q?=20=ED=98=84=ED=99=A9=20Lottie=20=EC=82=AC=EC=9D=B4=EC=A6=88=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 --- .../com/wap/wapp/feature/notice/BottomSheetContent.kt | 8 ++++---- .../com/wap/wapp/feature/profile/screen/UserProfile.kt | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt index b6647ffd..02999c1a 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/BottomSheetContent.kt @@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Divider import androidx.compose.material.Text @@ -77,10 +77,10 @@ private fun EventsList(events: List) { verticalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.fillMaxWidth(), ) { - itemsIndexed( + items( items = events, - key = { _, event -> event.eventId }, - ) { _, event -> + key = { event -> event.eventId }, + ) { event -> EventItem(event = event) } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index d99da117..18b26549 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -134,6 +134,12 @@ private fun MyAttendanceStatus( .padding(top = 10.dp), ) { when (recentEventsState) { + is ProfileViewModel.EventsState.Loading -> CircleLoader( + modifier = Modifier + .padding(vertical = 10.dp) + .height(130.dp), + ) + is ProfileViewModel.EventsState.Success -> { LazyColumn( verticalArrangement = Arrangement.spacedBy(10.dp), @@ -150,10 +156,6 @@ private fun MyAttendanceStatus( } } } - - is ProfileViewModel.EventsState.Loading -> CircleLoader( - modifier = Modifier.weight(1f), - ) } } } From 13475aff446c3158ecee439c12fefee13fa8486f Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 22:50:26 +0900 Subject: [PATCH 34/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EC=B5=9C=EA=B7=BC?= =?UTF-8?q?=20=EC=A7=84=ED=96=89=EB=90=9C=20=EC=9D=BC=EC=A0=95=EC=9D=B4=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=20=EA=B2=BD=EC=9A=B0=20UI=20=EC=99=84?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/ProfileViewModel.kt | 4 ++-- .../feature/profile/screen/UserProfile.kt | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 1d3bbc90..5e1a5771 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -1,6 +1,5 @@ package com.wap.wapp.feature.profile -import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil @@ -109,7 +108,8 @@ class ProfileViewModel @Inject constructor( .onSuccess { eventsList.addAll(it) } .onFailure { _errorFlow.emit(it) } } - _recentEvents.value = EventsState.Success(eventsList) +// _recentEvents.value = EventsState.Success(eventsList) + _recentEvents.value = EventsState.Success(emptyList()) } private fun createRegistrationDateTime(year: Int, semester: String): LocalDate { diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index 18b26549..f4b53d4b 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement 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 @@ -21,6 +22,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp @@ -141,6 +143,26 @@ private fun MyAttendanceStatus( ) is ProfileViewModel.EventsState.Success -> { + if (recentEventsState.events.isEmpty()) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .padding(10.dp) + .height(130.dp), + ) { + Spacer(modifier = Modifier.weight(1f)) + Text( + text = "가입한 이후로 진행된 일정이 없어요!", + style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), + color = WappTheme.colors.white, + textAlign = TextAlign.Center, + modifier = Modifier.weight(1f), + ) + Spacer(modifier = Modifier.weight(1f)) + } + return@WappCard + } + LazyColumn( verticalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier From be44f6ea94f93d88967f9ec8a2fc0205f2947fb6 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 22:53:54 +0900 Subject: [PATCH 35/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EB=82=B4=20?= =?UTF-8?q?=EC=84=A4=EB=AC=B8=EC=A1=B0=EC=82=AC=20State=20Flow=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileViewModel.kt | 14 ++++++++++++-- .../wap/wapp/feature/profile/screen/UserProfile.kt | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 5e1a5771..c92ee445 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -4,9 +4,11 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.survey.GetSurveyListUseCase import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase import com.wap.wapp.core.model.event.Event +import com.wap.wapp.core.model.survey.SurveyAnswer import com.wap.wapp.core.model.user.UserProfile import com.wap.wapp.core.model.user.UserRole import dagger.hilt.android.lifecycle.HiltViewModel @@ -28,6 +30,7 @@ class ProfileViewModel @Inject constructor( private val getUserRoleUseCase: GetUserRoleUseCase, private val getUserProfileUseCase: GetUserProfileUseCase, private val getEventListUseCase: GetEventListUseCase, + private val getSurveyListUseCase: GetSurveyListUseCase, ) : ViewModel() { private val _errorFlow: MutableSharedFlow = MutableSharedFlow() val errorFlow: SharedFlow = _errorFlow.asSharedFlow() @@ -38,6 +41,9 @@ class ProfileViewModel @Inject constructor( private val _recentEvents = MutableStateFlow(EventsState.Loading) val recentEvents: StateFlow = _recentEvents.asStateFlow() + private val _mySurveys = MutableStateFlow(SurveysState.Loading) + val mySurveys: StateFlow = _mySurveys.asStateFlow() + private val _userRole = MutableStateFlow(UserRoleState.Loading) val userRole: StateFlow = _userRole.asStateFlow() @@ -108,8 +114,7 @@ class ProfileViewModel @Inject constructor( .onSuccess { eventsList.addAll(it) } .onFailure { _errorFlow.emit(it) } } -// _recentEvents.value = EventsState.Success(eventsList) - _recentEvents.value = EventsState.Success(emptyList()) + _recentEvents.value = EventsState.Success(eventsList) } private fun createRegistrationDateTime(year: Int, semester: String): LocalDate { @@ -130,6 +135,11 @@ class ProfileViewModel @Inject constructor( data class Success(val events: List) : EventsState() } + sealed class SurveysState { + data object Loading : SurveysState() + data class Success(val events: List) : SurveysState() + } + sealed class UserRoleState { data object Loading : UserRoleState() data class Success(val userRole: UserRole) : UserRoleState() diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index f4b53d4b..6fada90b 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -48,6 +48,7 @@ internal fun UserProfile( todayEventsState = todayEventsState, modifier = Modifier.padding(top = 20.dp), ) + MyAttendanceStatus( recentEventsState = recentEventsState, modifier = Modifier.padding(top = 20.dp), From 2ec52c6b650ee9aac6daea5ad648f5b531876143 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 22:56:54 +0900 Subject: [PATCH 36/62] =?UTF-8?q?[CHORE]=20#74=20:=20MySurveys=20->=20user?= =?UTF-8?q?RespondedSurveys=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/ProfileViewModel.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index c92ee445..22cd26ca 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -41,8 +41,8 @@ class ProfileViewModel @Inject constructor( private val _recentEvents = MutableStateFlow(EventsState.Loading) val recentEvents: StateFlow = _recentEvents.asStateFlow() - private val _mySurveys = MutableStateFlow(SurveysState.Loading) - val mySurveys: StateFlow = _mySurveys.asStateFlow() + private val _userRespondedSurveys = MutableStateFlow(SurveysState.Loading) + val userRespondedSurveys: StateFlow = _userRespondedSurveys.asStateFlow() private val _userRole = MutableStateFlow(UserRoleState.Loading) val userRole: StateFlow = _userRole.asStateFlow() @@ -95,6 +95,20 @@ class ProfileViewModel @Inject constructor( } } + private suspend fun getUserRespondedSurveys() { + _todayEvents.value = EventsState.Loading + viewModelScope.launch { + getEventListUseCase(DateUtil.generateNowDate()).onSuccess { eventList -> + _todayEvents.value = + EventsState.Success( + eventList.filter { event -> + event.startDateTime.toLocalDate() == DateUtil.generateNowDate() + }.sortedBy { event -> event.title }, + ) + }.onFailure { exception -> _errorFlow.emit(exception) } + } + } + private suspend fun getRecentEventsForAttendanceCheck() { val registeredAt = _userProfile.value.registeredAt val (registeredYear, registeredSemester) = registeredAt.split(" ") From 30b18d1dbb430ea15358267c66fba811b90860a3 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 23:09:46 +0900 Subject: [PATCH 37/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EB=82=B4=EA=B0=80?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1=ED=95=9C=20=EC=84=A4=EB=AC=B8=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20ViewModel=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=8B=9C=EA=B7=B8=EB=8B=88=EC=B2=98=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/ProfileViewModel.kt | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 22cd26ca..be7ad633 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -8,12 +8,11 @@ import com.wap.wapp.core.domain.usecase.survey.GetSurveyListUseCase import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase import com.wap.wapp.core.model.event.Event -import com.wap.wapp.core.model.survey.SurveyAnswer +import com.wap.wapp.core.model.survey.Survey import com.wap.wapp.core.model.user.UserProfile import com.wap.wapp.core.model.user.UserRole import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async -import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -51,13 +50,10 @@ class ProfileViewModel @Inject constructor( val userProfile: StateFlow = _userProfile.asStateFlow() init { - viewModelScope.launch { - checkUserInformationAndGetEvents() - launch { getRecentEventsForAttendanceCheck() } - } + checkUserInformationAndGetEvents() } - private suspend fun checkUserInformationAndGetEvents() = coroutineScope { + private fun checkUserInformationAndGetEvents() = viewModelScope.launch { getUserRoleUseCase() .onFailure { exception -> _errorFlow.emit(exception) } .onSuccess { userRole -> @@ -75,6 +71,8 @@ class ProfileViewModel @Inject constructor( .onSuccess { _userRole.value = UserRoleState.Success(userRole) _userProfile.value = it + launch { getRecentEventsForAttendanceCheck() } + launch { getUserRespondedSurveys() } }.onFailure { exception -> _errorFlow.emit(exception) } } } @@ -96,17 +94,13 @@ class ProfileViewModel @Inject constructor( } private suspend fun getUserRespondedSurveys() { - _todayEvents.value = EventsState.Loading - viewModelScope.launch { - getEventListUseCase(DateUtil.generateNowDate()).onSuccess { eventList -> - _todayEvents.value = - EventsState.Success( - eventList.filter { event -> - event.startDateTime.toLocalDate() == DateUtil.generateNowDate() - }.sortedBy { event -> event.title }, - ) - }.onFailure { exception -> _errorFlow.emit(exception) } - } + getSurveyListUseCase().onSuccess { surveyList -> + _userRespondedSurveys.value = + SurveysState.Success( + surveyList.filter { survey -> survey.userName == _userProfile.value.userName } + .sortedBy { survey -> survey.surveyedAt }, + ) + }.onFailure { exception -> _errorFlow.emit(exception) } } private suspend fun getRecentEventsForAttendanceCheck() { @@ -124,8 +118,7 @@ class ProfileViewModel @Inject constructor( // 만약 가입한 날짜보다 빠르다면 반복문을 멈춤 if (targetDateTime < registrationDateTime) break - getEventListUseCase(targetDateTime) - .onSuccess { eventsList.addAll(it) } + getEventListUseCase(targetDateTime).onSuccess { eventsList.addAll(it) } .onFailure { _errorFlow.emit(it) } } _recentEvents.value = EventsState.Success(eventsList) @@ -151,7 +144,7 @@ class ProfileViewModel @Inject constructor( sealed class SurveysState { data object Loading : SurveysState() - data class Success(val events: List) : SurveysState() + data class Success(val surveys: List) : SurveysState() } sealed class UserRoleState { From 4b4af449e34a33b5e5d4f9704bc8917ce68cb847 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 23:14:12 +0900 Subject: [PATCH 38/62] =?UTF-8?q?[CHORE]=20#74=20:=20Profile=20Component?= =?UTF-8?q?=20SurveyState=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=A1=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/feature/profile/ProfileScreen.kt | 5 +++++ .../wap/wapp/feature/profile/screen/UserProfile.kt | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 8483467b..9ca45861 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -43,6 +43,7 @@ internal fun ProfileRoute( ) { val todayEventsState by viewModel.todayEvents.collectAsStateWithLifecycle() val recentEventsState by viewModel.recentEvents.collectAsStateWithLifecycle() + val userRespondedSurveysState by viewModel.userRespondedSurveys.collectAsStateWithLifecycle() val userRoleState by viewModel.userRole.collectAsStateWithLifecycle() val userProfile by viewModel.userProfile.collectAsStateWithLifecycle() val snackBarHostState = remember { SnackbarHostState() } @@ -60,6 +61,7 @@ internal fun ProfileRoute( recentEventsState = recentEventsState, userRoleState = userRoleState, userProfile = userProfile, + userRespondedSurveyState = userRespondedSurveysState, snackBarHostState = snackBarHostState, navigateToProfileSetting = navigateToProfileSetting, navigateToSignInScreen = navigateToSignInScreen, @@ -72,6 +74,7 @@ internal fun ProfileScreen( userProfile: UserProfile, todayEventsState: ProfileViewModel.EventsState, recentEventsState: ProfileViewModel.EventsState, + userRespondedSurveyState: ProfileViewModel.SurveysState, snackBarHostState: SnackbarHostState, navigateToProfileSetting: () -> Unit, navigateToSignInScreen: () -> Unit, @@ -128,6 +131,7 @@ internal fun ProfileScreen( UserProfile( todayEventsState = todayEventsState, recentEventsState = recentEventsState, + userRespondedSurveyState = userRespondedSurveysState, ) } @@ -149,6 +153,7 @@ internal fun ProfileScreen( UserProfile( todayEventsState = todayEventsState, recentEventsState = recentEventsState, + userRespondedSurveyState = userRespondedSurveysState, ) } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index 6fada90b..d96a8e10 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -42,6 +42,7 @@ import com.wap.wapp.feature.profile.component.WappSurveyHistoryRow internal fun UserProfile( todayEventsState: ProfileViewModel.EventsState, recentEventsState: ProfileViewModel.EventsState, + userRespondedSurveyState: ProfileViewModel.SurveysState, ) { Column(modifier = Modifier.padding(horizontal = 10.dp)) { ProfileAttendanceCard( @@ -54,7 +55,10 @@ internal fun UserProfile( modifier = Modifier.padding(top = 20.dp), ) - MySurveyHistory(modifier = Modifier.padding(vertical = 20.dp)) + MySurveyHistory( + userRespondedSurveyState = userRespondedSurveyState, + modifier = Modifier.padding(vertical = 20.dp), + ) } } @@ -185,7 +189,10 @@ private fun MyAttendanceStatus( } @Composable -private fun MySurveyHistory(modifier: Modifier = Modifier) { +private fun MySurveyHistory( + userRespondedSurveyState: ProfileViewModel.SurveysState, + modifier: Modifier = Modifier, +) { Column(modifier = modifier) { Text( text = stringResource(id = R.string.survey_i_did), From 2d8ee45924fdf32c81869c1978bd59834f526692 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 23:33:52 +0900 Subject: [PATCH 39/62] =?UTF-8?q?[FEATURE]=20#74=20:=20GetDateEventListUse?= =?UTF-8?q?Case=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/event/EventRepository.kt | 2 + .../repository/event/EventRepositoryImpl.kt | 7 +++ .../usecase/event/GetDateEventListUseCase.kt | 17 ++++++ ...UseCase.kt => GetMonthEventListUseCase.kt} | 2 +- .../network/source/event/EventDataSource.kt | 2 + .../source/event/EventDataSourceImpl.kt | 25 +++++++++ .../survey/edit/SurveyFormEditViewModel.kt | 6 +- .../SurveyFormRegistrationViewModel.kt | 6 +- .../feature/management/ManagementViewModel.kt | 6 +- .../wapp/feature/notice/NoticeViewModel.kt | 8 +-- .../wap/wapp/feature/profile/ProfileScreen.kt | 8 +-- .../wapp/feature/profile/ProfileViewModel.kt | 8 +-- .../feature/profile/screen/UserProfile.kt | 56 +++++++++++++++---- 13 files changed, 120 insertions(+), 33 deletions(-) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt rename core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/{GetEventListUseCase.kt => GetMonthEventListUseCase.kt} (90%) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt index d374838f..948582e9 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt @@ -7,6 +7,8 @@ import java.time.LocalDateTime interface EventRepository { suspend fun getMonthEvents(date: LocalDate): Result> + suspend fun getDateEvents(date: LocalDate): Result> + suspend fun getEvent(date: LocalDateTime, eventId: String): Result suspend fun postEvent( diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index 3bc9c704..7a3cbd15 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -17,6 +17,13 @@ class EventRepositoryImpl @Inject constructor( } } + override suspend fun getDateEvents(date: LocalDate): Result> = + eventDataSource.getDateEvents(date).mapCatching { eventResponses -> + eventResponses.map { eventResponse -> + eventResponse.toDomain() + } + } + override suspend fun getEvent(date: LocalDateTime, eventId: String): Result = eventDataSource.getEvent(date, eventId).mapCatching { eventResponse -> eventResponse.toDomain() diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt new file mode 100644 index 00000000..7250b6bb --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt @@ -0,0 +1,17 @@ +package com.wap.wapp.core.domain.usecase.event + +import com.wap.wapp.core.data.repository.event.EventRepository +import com.wap.wapp.core.model.event.Event +import java.time.LocalDate +import javax.inject.Inject + +class GetDateEventListUseCase @Inject constructor( + private val eventRepository: EventRepository, +) { + suspend operator fun invoke(date: LocalDate): Result> = runCatching { + eventRepository.getDateEvents(date).fold( + onSuccess = { eventsList -> eventsList }, + onFailure = { throw (it) }, + ) + } +} diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetEventListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetMonthEventListUseCase.kt similarity index 90% rename from core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetEventListUseCase.kt rename to core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetMonthEventListUseCase.kt index d8189491..cdba0ff4 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetEventListUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetMonthEventListUseCase.kt @@ -5,7 +5,7 @@ import com.wap.wapp.core.model.event.Event import java.time.LocalDate import javax.inject.Inject -class GetEventListUseCase @Inject constructor( +class GetMonthEventListUseCase @Inject constructor( private val eventRepository: EventRepository, ) { suspend operator fun invoke(date: LocalDate): Result> = runCatching { diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt index 7f87485e..0e84df10 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt @@ -7,6 +7,8 @@ import java.time.LocalDateTime interface EventDataSource { suspend fun getMonthEvents(date: LocalDate): Result> + suspend fun getDateEvents(date: LocalDate): Result> + suspend fun getEvent(date: LocalDateTime, eventId: String): Result suspend fun postEvent( diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index 364188e4..d154c289 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -10,6 +10,7 @@ import com.wap.wapp.core.network.utils.await import com.wap.wapp.core.network.utils.toISOLocalDateTime import java.time.LocalDate import java.time.LocalDateTime +import java.time.LocalTime import java.time.format.DateTimeFormatter import javax.inject.Inject @@ -35,6 +36,30 @@ class EventDataSourceImpl @Inject constructor( result } + override suspend fun getDateEvents(date: LocalDate): Result> = + runCatching { + val result = mutableListOf() + + val startDateTime = date.atStartOfDay() + val endDateTime = date.atTime(LocalTime.MAX) + + val task = firebaseFirestore.collection(EVENT_COLLECTION) + .document(getMonth(date)) + .collection(EVENT_COLLECTION) + .whereGreaterThanOrEqualTo("startDateTime", startDateTime) + .whereLessThanOrEqualTo("startDateTime", endDateTime) + .get() + .await() + + for (document in task.documents) { + val event = document.toObject() + checkNotNull(event) + result.add(event) + } + + result + } + override suspend fun getEvent(date: LocalDateTime, eventId: String): Result = runCatching { val document = firebaseFirestore.collection(EVENT_COLLECTION) diff --git a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt index fc9f4c4c..da93baf4 100644 --- a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt +++ b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt @@ -3,7 +3,7 @@ package com.wap.wapp.feature.management.survey.edit import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil -import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase import com.wap.wapp.core.domain.usecase.survey.GetSurveyFormUseCase import com.wap.wapp.core.domain.usecase.survey.UpdateSurveyFormUseCase import com.wap.wapp.core.model.event.Event @@ -27,7 +27,7 @@ import javax.inject.Inject @HiltViewModel class SurveyFormEditViewModel @Inject constructor( private val getSurveyFormUseCase: GetSurveyFormUseCase, - private val getEventListUseCase: GetEventListUseCase, + private val getMonthEventListUseCase: GetMonthEventListUseCase, private val updateSurveyFormUseCase: UpdateSurveyFormUseCase, ) : ViewModel() { private val _surveyFormEditUiEvent: MutableSharedFlow = @@ -113,7 +113,7 @@ class SurveyFormEditViewModel @Inject constructor( } fun getEventList() = viewModelScope.launch { - getEventListUseCase(DateUtil.generateNowDate()) + getMonthEventListUseCase(DateUtil.generateNowDate()) .onSuccess { eventList -> _eventList.value = EventsState.Success(eventList) }.onFailure { throwable -> diff --git a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt index bbbefcb4..ca2ce7f7 100644 --- a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt +++ b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt @@ -3,7 +3,7 @@ package com.wap.wapp.feature.management.survey.registration import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil -import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase import com.wap.wapp.core.domain.usecase.survey.PostSurveyFormUseCase import com.wap.wapp.core.model.event.Event import com.wap.wapp.core.model.survey.QuestionType @@ -24,7 +24,7 @@ import javax.inject.Inject @HiltViewModel class SurveyFormRegistrationViewModel @Inject constructor( private val registerSurveyUseCase: PostSurveyFormUseCase, - private val getEventListUseCase: GetEventListUseCase, + private val getMonthEventListUseCase: GetMonthEventListUseCase, ) : ViewModel() { private val _surveyRegistrationEvent: MutableSharedFlow = MutableSharedFlow() @@ -67,7 +67,7 @@ class SurveyFormRegistrationViewModel @Inject constructor( val surveyDateDeadline = _surveyDateDeadline.asStateFlow() fun getEventList() = viewModelScope.launch { - getEventListUseCase(DateUtil.generateNowDate()) + getMonthEventListUseCase(DateUtil.generateNowDate()) .onSuccess { eventList -> _eventList.value = EventsState.Success(eventList) }.onFailure { throwable -> diff --git a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementViewModel.kt b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementViewModel.kt index 46f84be9..2e226dca 100644 --- a/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementViewModel.kt +++ b/feature/management/src/main/java/com/wap/wapp/feature/management/ManagementViewModel.kt @@ -3,7 +3,7 @@ package com.wap.wapp.feature.management import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil.generateNowDate -import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase import com.wap.wapp.core.domain.usecase.management.HasManagerStateUseCase import com.wap.wapp.core.domain.usecase.survey.GetSurveyFormListUseCase import com.wap.wapp.core.model.event.Event @@ -22,7 +22,7 @@ import javax.inject.Inject class ManagementViewModel @Inject constructor( private val hasManagerStateUseCase: HasManagerStateUseCase, private val getSurveyFormListUseCase: GetSurveyFormListUseCase, - private val getEventListUseCase: GetEventListUseCase, + private val getMonthEventListUseCase: GetMonthEventListUseCase, ) : ViewModel() { private val _errorFlow: MutableSharedFlow = MutableSharedFlow() @@ -68,7 +68,7 @@ class ManagementViewModel @Inject constructor( private suspend fun getMonthEventList() { _eventList.value = EventsState.Loading - getEventListUseCase(generateNowDate()).onSuccess { events -> + getMonthEventListUseCase(generateNowDate()).onSuccess { events -> _eventList.value = EventsState.Success(events) }.onFailure { exception -> _errorFlow.emit(exception) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index 815cb660..aba85162 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -3,7 +3,7 @@ package com.wap.wapp.feature.notice import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil -import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase import com.wap.wapp.core.model.event.Event import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow @@ -15,7 +15,7 @@ import javax.inject.Inject @HiltViewModel class NoticeViewModel @Inject constructor( - private val getEventListUseCase: GetEventListUseCase, + private val getMonthEventListUseCase: GetMonthEventListUseCase, ) : ViewModel() { private val _monthEvents = MutableStateFlow(EventsState.Loading) @@ -35,7 +35,7 @@ class NoticeViewModel @Inject constructor( private fun getMonthEvents() { _monthEvents.value = EventsState.Loading viewModelScope.launch { - getEventListUseCase(_selectedDate.value) + getMonthEventListUseCase(_selectedDate.value) .onSuccess { _monthEvents.value = EventsState.Success(it) } .onFailure { _monthEvents.value = EventsState.Failure(it) } } @@ -44,7 +44,7 @@ class NoticeViewModel @Inject constructor( fun getSelectedDateEvents() { _selectedDateEvents.value = EventsState.Loading viewModelScope.launch { - getEventListUseCase(_selectedDate.value).onSuccess { + getMonthEventListUseCase(_selectedDate.value).onSuccess { _selectedDateEvents.value = EventsState.Success( it.filter { it.startDateTime.toLocalDate() == _selectedDate.value } .sortedBy { it.startDateTime }, diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index 9ca45861..f757ea95 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -61,7 +61,7 @@ internal fun ProfileRoute( recentEventsState = recentEventsState, userRoleState = userRoleState, userProfile = userProfile, - userRespondedSurveyState = userRespondedSurveysState, + userRespondedSurveysState = userRespondedSurveysState, snackBarHostState = snackBarHostState, navigateToProfileSetting = navigateToProfileSetting, navigateToSignInScreen = navigateToSignInScreen, @@ -74,7 +74,7 @@ internal fun ProfileScreen( userProfile: UserProfile, todayEventsState: ProfileViewModel.EventsState, recentEventsState: ProfileViewModel.EventsState, - userRespondedSurveyState: ProfileViewModel.SurveysState, + userRespondedSurveysState: ProfileViewModel.SurveysState, snackBarHostState: SnackbarHostState, navigateToProfileSetting: () -> Unit, navigateToSignInScreen: () -> Unit, @@ -131,7 +131,7 @@ internal fun ProfileScreen( UserProfile( todayEventsState = todayEventsState, recentEventsState = recentEventsState, - userRespondedSurveyState = userRespondedSurveysState, + userRespondedSurveysState = userRespondedSurveysState, ) } @@ -153,7 +153,7 @@ internal fun ProfileScreen( UserProfile( todayEventsState = todayEventsState, recentEventsState = recentEventsState, - userRespondedSurveyState = userRespondedSurveysState, + userRespondedSurveysState = userRespondedSurveysState, ) } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index be7ad633..f65d04ab 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -3,7 +3,7 @@ package com.wap.wapp.feature.profile import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil -import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase +import com.wap.wapp.core.domain.usecase.event.GetDateEventListUseCase import com.wap.wapp.core.domain.usecase.survey.GetSurveyListUseCase import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase @@ -28,7 +28,7 @@ import javax.inject.Inject class ProfileViewModel @Inject constructor( private val getUserRoleUseCase: GetUserRoleUseCase, private val getUserProfileUseCase: GetUserProfileUseCase, - private val getEventListUseCase: GetEventListUseCase, + private val getDateEventListUseCase: GetDateEventListUseCase, private val getSurveyListUseCase: GetSurveyListUseCase, ) : ViewModel() { private val _errorFlow: MutableSharedFlow = MutableSharedFlow() @@ -82,7 +82,7 @@ class ProfileViewModel @Inject constructor( private fun getTodayDateEvents() { _todayEvents.value = EventsState.Loading viewModelScope.launch { - getEventListUseCase(DateUtil.generateNowDate()).onSuccess { eventList -> + getDateEventListUseCase(DateUtil.generateNowDate()).onSuccess { eventList -> _todayEvents.value = EventsState.Success( eventList.filter { event -> @@ -118,7 +118,7 @@ class ProfileViewModel @Inject constructor( // 만약 가입한 날짜보다 빠르다면 반복문을 멈춤 if (targetDateTime < registrationDateTime) break - getEventListUseCase(targetDateTime).onSuccess { eventsList.addAll(it) } + getDateEventListUseCase(targetDateTime).onSuccess { eventsList.addAll(it) } .onFailure { _errorFlow.emit(it) } } _recentEvents.value = EventsState.Success(eventsList) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index d96a8e10..0a90d0c9 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -42,7 +42,7 @@ import com.wap.wapp.feature.profile.component.WappSurveyHistoryRow internal fun UserProfile( todayEventsState: ProfileViewModel.EventsState, recentEventsState: ProfileViewModel.EventsState, - userRespondedSurveyState: ProfileViewModel.SurveysState, + userRespondedSurveysState: ProfileViewModel.SurveysState, ) { Column(modifier = Modifier.padding(horizontal = 10.dp)) { ProfileAttendanceCard( @@ -56,7 +56,7 @@ internal fun UserProfile( ) MySurveyHistory( - userRespondedSurveyState = userRespondedSurveyState, + userRespondedSurveysState = userRespondedSurveysState, modifier = Modifier.padding(vertical = 20.dp), ) } @@ -190,7 +190,7 @@ private fun MyAttendanceStatus( @Composable private fun MySurveyHistory( - userRespondedSurveyState: ProfileViewModel.SurveysState, + userRespondedSurveysState: ProfileViewModel.SurveysState, modifier: Modifier = Modifier, ) { Column(modifier = modifier) { @@ -207,14 +207,48 @@ private fun MySurveyHistory( .wrapContentHeight() .padding(top = 10.dp), ) { - Column( - verticalArrangement = Arrangement.spacedBy(10.dp), - modifier = Modifier.padding(vertical = 10.dp), - ) { - WappSurveyHistoryRow() - WappSurveyHistoryRow() - WappSurveyHistoryRow() - WappSurveyHistoryRow() + when (userRespondedSurveysState) { + is ProfileViewModel.SurveysState.Loading -> CircleLoader( + modifier = Modifier + .padding(vertical = 10.dp) + .height(130.dp), + ) + + is ProfileViewModel.SurveysState.Success -> { + if (userRespondedSurveysState.surveys.isEmpty()) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .padding(10.dp) + .height(130.dp), + ) { + Spacer(modifier = Modifier.weight(1f)) + Text( + text = "가입한 이후로 참여한 설문이 없어요!", + style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), + color = WappTheme.colors.white, + textAlign = TextAlign.Center, + modifier = Modifier.weight(1f), + ) + Spacer(modifier = Modifier.weight(1f)) + } + return@WappCard + } + + LazyColumn( + verticalArrangement = Arrangement.spacedBy(10.dp), + modifier = Modifier + .padding(10.dp) + .height(130.dp), + ) { + items( + items = userRespondedSurveysState.surveys, + key = { survey -> survey.surveyId }, + ) { event -> + WappSurveyHistoryRow() + } + } + } } } } From 6496a64b96a04bd1379dea90cae42e70697c6fe9 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 23:43:23 +0900 Subject: [PATCH 40/62] =?UTF-8?q?[FEATURE]=20#74=20:=20GetDateEventListUse?= =?UTF-8?q?Case=20=EB=B2=84=EA=B7=B8=20=ED=94=BD=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/network/source/event/EventDataSourceImpl.kt | 7 +++++-- .../java/com/wap/wapp/feature/notice/NoticeViewModel.kt | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index d154c289..e417c956 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -40,8 +40,8 @@ class EventDataSourceImpl @Inject constructor( runCatching { val result = mutableListOf() - val startDateTime = date.atStartOfDay() - val endDateTime = date.atTime(LocalTime.MAX) + val startDateTime = date.atStartOfDay().toISOLocalDateTimeString() + val endDateTime = date.atTime(LocalTime.MAX).toISOLocalDateTimeString() val task = firebaseFirestore.collection(EVENT_COLLECTION) .document(getMonth(date)) @@ -131,3 +131,6 @@ class EventDataSourceImpl @Inject constructor( return date.format(formatter) } } + +private fun LocalDateTime.toISOLocalDateTimeString(): String = + this.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index aba85162..b21486d5 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -3,6 +3,7 @@ package com.wap.wapp.feature.notice import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil +import com.wap.wapp.core.domain.usecase.event.GetDateEventListUseCase import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase import com.wap.wapp.core.model.event.Event import dagger.hilt.android.lifecycle.HiltViewModel @@ -16,6 +17,7 @@ import javax.inject.Inject @HiltViewModel class NoticeViewModel @Inject constructor( private val getMonthEventListUseCase: GetMonthEventListUseCase, + private val getDateEventListUseCase: GetDateEventListUseCase, ) : ViewModel() { private val _monthEvents = MutableStateFlow(EventsState.Loading) @@ -44,10 +46,9 @@ class NoticeViewModel @Inject constructor( fun getSelectedDateEvents() { _selectedDateEvents.value = EventsState.Loading viewModelScope.launch { - getMonthEventListUseCase(_selectedDate.value).onSuccess { + getDateEventListUseCase(_selectedDate.value).onSuccess { _selectedDateEvents.value = EventsState.Success( - it.filter { it.startDateTime.toLocalDate() == _selectedDate.value } - .sortedBy { it.startDateTime }, + it.sortedBy { it.startDateTime }, ) }.onFailure { _selectedDateEvents.value = EventsState.Failure(it) } } From 6dfb7e58e5e367e1304267eaf5d0597e20053691 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 23:51:17 +0900 Subject: [PATCH 41/62] =?UTF-8?q?[FEATURE]=20#74=20:=20GetUserRespondedSur?= =?UTF-8?q?veyList=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/survey/SurveyRepository.kt | 2 ++ .../repository/survey/SurveyRepositoryImpl.kt | 16 ++++++++++++++++ .../GetUserRespondedSurveyListUseCase.kt | 12 ++++++++++++ .../network/source/survey/SurveyDataSource.kt | 2 ++ .../source/survey/SurveyDataSourceImpl.kt | 19 +++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetUserRespondedSurveyListUseCase.kt diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt index 46fbfd7c..79f635b8 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepository.kt @@ -7,6 +7,8 @@ import java.time.LocalDateTime interface SurveyRepository { suspend fun getSurveyList(): Result> + suspend fun getUserRespondedSurveyList(userId: String): Result> + suspend fun getSurvey(surveyId: String): Result suspend fun postSurvey( diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt index ad582583..be67814c 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/survey/SurveyRepositoryImpl.kt @@ -28,6 +28,22 @@ class SurveyRepositoryImpl @Inject constructor( } } + override suspend fun getUserRespondedSurveyList(userId: String): Result> = + surveyDataSource.getUserRespondedSurveyList(userId).mapCatching { surveyList -> + surveyList.map { surveyResponse -> + userDataSource.getUserProfile(userId = surveyResponse.userId) + .mapCatching { userProfileResponse -> + val userName = userProfileResponse.toDomain().userName + + noticeNameResponse.mapCatching { noticeNameResponse -> + val eventName = noticeNameResponse.toDomain() + + surveyResponse.toDomain(userName = userName, eventName = eventName) + }.getOrThrow() + }.getOrThrow() + } + } + override suspend fun getSurvey(surveyId: String): Result = surveyDataSource.getSurvey(surveyId).mapCatching { surveyResponse -> userDataSource.getUserProfile(userId = surveyResponse.userId) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetUserRespondedSurveyListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetUserRespondedSurveyListUseCase.kt new file mode 100644 index 00000000..d4697af5 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetUserRespondedSurveyListUseCase.kt @@ -0,0 +1,12 @@ +package com.wap.wapp.core.domain.usecase.survey + +import com.wap.wapp.core.data.repository.survey.SurveyRepository +import com.wap.wapp.core.model.survey.Survey +import javax.inject.Inject + +class GetUserRespondedSurveyListUseCase @Inject constructor( + private val surveyRepository: SurveyRepository, +) { + suspend operator fun invoke(userId: String): Result> = + surveyRepository.getUserRespondedSurveyList(userId) +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt index 20b3efcd..6022af5e 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSource.kt @@ -11,6 +11,8 @@ interface SurveyDataSource { suspend fun getSurveyList(): Result> + suspend fun getUserRespondedSurveyList(userId: String): Result> + suspend fun getSurvey(surveyId: String): Result suspend fun postSurvey( diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt index ff7f7c90..2916973f 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt @@ -29,6 +29,25 @@ class SurveyDataSourceImpl @Inject constructor( result } + override suspend fun getUserRespondedSurveyList(userId: String): Result> = + runCatching { + val result: MutableList = mutableListOf() + + val task = firebaseFirestore.collection(SURVEY_COLLECTION) + .whereEqualTo("userId", userId) + .get() + .await() + + for (document in task.documents) { + val surveyResponse = document.toObject(SurveyResponse::class.java) + checkNotNull(surveyResponse) + + result.add(surveyResponse) + } + + result + } + override suspend fun getSurvey(surveyId: String): Result = runCatching { val result = firebaseFirestore.collection(SURVEY_COLLECTION) .document(surveyId) From 30e2adaa1e4fed3f2340289d23f0a892b02148b0 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 23:54:48 +0900 Subject: [PATCH 42/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EB=82=B4=EA=B0=80?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1=ED=95=9C=20=EC=84=A4=EB=AC=B8=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EB=8A=94=20=EB=A1=9C=EC=A7=81=20ViewModel?= =?UTF-8?q?=EC=97=90=EC=84=9C=20Filter=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20?= =?UTF-8?q?whereEqualTo=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileViewModel.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index f65d04ab..0e8fd06f 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.domain.usecase.event.GetDateEventListUseCase -import com.wap.wapp.core.domain.usecase.survey.GetSurveyListUseCase +import com.wap.wapp.core.domain.usecase.survey.GetUserRespondedSurveyListUseCase import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase import com.wap.wapp.core.model.event.Event @@ -29,7 +29,7 @@ class ProfileViewModel @Inject constructor( private val getUserRoleUseCase: GetUserRoleUseCase, private val getUserProfileUseCase: GetUserProfileUseCase, private val getDateEventListUseCase: GetDateEventListUseCase, - private val getSurveyListUseCase: GetSurveyListUseCase, + private val getUserRespondedSurveyListUseCase: GetUserRespondedSurveyListUseCase, ) : ViewModel() { private val _errorFlow: MutableSharedFlow = MutableSharedFlow() val errorFlow: SharedFlow = _errorFlow.asSharedFlow() @@ -72,7 +72,7 @@ class ProfileViewModel @Inject constructor( _userRole.value = UserRoleState.Success(userRole) _userProfile.value = it launch { getRecentEventsForAttendanceCheck() } - launch { getUserRespondedSurveys() } + getUserRespondedSurveys() }.onFailure { exception -> _errorFlow.emit(exception) } } } @@ -94,12 +94,9 @@ class ProfileViewModel @Inject constructor( } private suspend fun getUserRespondedSurveys() { - getSurveyListUseCase().onSuccess { surveyList -> + getUserRespondedSurveyListUseCase(_userProfile.value.userId).onSuccess { surveyList -> _userRespondedSurveys.value = - SurveysState.Success( - surveyList.filter { survey -> survey.userName == _userProfile.value.userName } - .sortedBy { survey -> survey.surveyedAt }, - ) + SurveysState.Success(surveyList.sortedBy { survey -> survey.surveyedAt }) }.onFailure { exception -> _errorFlow.emit(exception) } } From 50bab5aa2c9323cd83ff66a51ce463aa3a932d5d Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 12 Jan 2024 23:59:01 +0900 Subject: [PATCH 43/62] =?UTF-8?q?[FEATURE]=20#74=20:=20Profile=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/component/WappSurveyHistoryRow.kt | 4 +++- .../java/com/wap/wapp/feature/profile/screen/UserProfile.kt | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt index 318dae01..da585a5f 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/component/WappSurveyHistoryRow.kt @@ -13,9 +13,11 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.wap.designsystem.WappTheme import com.wap.wapp.core.designresource.R +import com.wap.wapp.core.model.survey.Survey @Composable internal fun WappSurveyHistoryRow( + survey: Survey, modifier: Modifier = Modifier, onClick: () -> Unit = {}, ) { @@ -35,7 +37,7 @@ internal fun WappSurveyHistoryRow( ) Text( - text = "프로젝트 세미나에서 보완해야 할 점이 많아요 아싸라비야", + text = survey.title, style = WappTheme.typography.labelRegular, color = WappTheme.colors.white, maxLines = 1, diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index 0a90d0c9..f752fb95 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -244,8 +244,8 @@ private fun MySurveyHistory( items( items = userRespondedSurveysState.surveys, key = { survey -> survey.surveyId }, - ) { event -> - WappSurveyHistoryRow() + ) { survey -> + WappSurveyHistoryRow(survey) } } } From de51429eff809f876c04ae2e4559efe20ce13b46 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 00:26:00 +0900 Subject: [PATCH 44/62] =?UTF-8?q?[FEATURE]=20#74=20:=20ProfileSettingViewM?= =?UTF-8?q?odel=20UseCase=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 2 +- .../profilesetting/ProfileSettingViewModel.kt | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 867745c2..8d8f7183 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -15,7 +15,7 @@ - + diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt index e8c255eb..a6e65593 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt @@ -1,8 +1,34 @@ package com.wap.wapp.feature.profile.profilesetting import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.wap.wapp.core.domain.usecase.auth.DeleteUserUseCase +import com.wap.wapp.core.domain.usecase.auth.SignOutUseCase +import com.wap.wapp.core.model.user.UserProfile +import com.wap.wapp.feature.profile.ProfileViewModel import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel -class ProfileSettingViewModel @Inject constructor() : ViewModel() +class ProfileSettingViewModel @Inject constructor( + private val signOutUseCase: SignOutUseCase, + private val deleteUserUseCase: DeleteUserUseCase, +) : ViewModel() { + + private val _userProfile = MutableStateFlow(ProfileViewModel.DEFAULT_USER_PROFILE) + val userProfile: StateFlow = _userProfile.asStateFlow() + + fun signOut() = viewModelScope.launch { + signOutUseCase().onSuccess { } + .onFailure { } + } + + fun withdrawal() = viewModelScope.launch { + deleteUserUseCase(_userProfile.value.userId).onSuccess { } + .onFailure { } + } +} From 1ffebad795475a835dd2e8077000628cbeb85394 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 00:36:31 +0900 Subject: [PATCH 45/62] =?UTF-8?q?[FEATURE]=20#74=20:=20ProfileSetting?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EA=B0=88=20=EB=95=8C,=20userId=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=8F=84=20=EA=B0=99=EC=9D=B4=20=EB=84=98?= =?UTF-8?q?=EA=B8=B0=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 --- .idea/deploymentTargetDropDown.xml | 12 +++++------ .../wap/designsystem/component/MainTopBar.kt | 1 - .../wap/wapp/feature/profile/ProfileScreen.kt | 6 +++--- .../profile/navigation/ProfileNavigation.kt | 2 +- .../profilesetting/ProfileSettingScreen.kt | 1 + .../navigation/ProfileSettingNavigation.kt | 21 ++++++++++++++----- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 8d8f7183..1e6a1f3e 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -4,18 +4,18 @@ - + - + - - + + - - + + diff --git a/core/designsystem/src/main/java/com/wap/designsystem/component/MainTopBar.kt b/core/designsystem/src/main/java/com/wap/designsystem/component/MainTopBar.kt index ad19a328..31cac16e 100644 --- a/core/designsystem/src/main/java/com/wap/designsystem/component/MainTopBar.kt +++ b/core/designsystem/src/main/java/com/wap/designsystem/component/MainTopBar.kt @@ -92,7 +92,6 @@ fun WappMainTopBarWithButton() { titleRes = R.string.notice, contentRes = R.string.notice, showSettingButton = true, - onClickSettingButton = {}, ) } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index f757ea95..c684839b 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -38,7 +38,7 @@ import kotlinx.coroutines.flow.collectLatest @Composable internal fun ProfileRoute( viewModel: ProfileViewModel = hiltViewModel(), - navigateToProfileSetting: () -> Unit, + navigateToProfileSetting: (String) -> Unit, navigateToSignInScreen: () -> Unit, ) { val todayEventsState by viewModel.todayEvents.collectAsStateWithLifecycle() @@ -76,7 +76,7 @@ internal fun ProfileScreen( recentEventsState: ProfileViewModel.EventsState, userRespondedSurveysState: ProfileViewModel.SurveysState, snackBarHostState: SnackbarHostState, - navigateToProfileSetting: () -> Unit, + navigateToProfileSetting: (String) -> Unit, navigateToSignInScreen: () -> Unit, ) { val scrollState = rememberScrollState() @@ -109,7 +109,7 @@ internal fun ProfileScreen( contentRes = R.string.profile_content, settingButtonDescriptionRes = R.string.profile_setting_description, showSettingButton = userRoleState.userRole != UserRole.GUEST, - onClickSettingButton = navigateToProfileSetting, + onClickSettingButton = { navigateToProfileSetting(userProfile.userId) }, ) when (userRoleState.userRole) { diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt index fc1a8337..ac3bd60f 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt @@ -14,7 +14,7 @@ fun NavController.navigateToProfile(navOptions: NavOptions? = navOptions {}) { } fun NavGraphBuilder.profileScreen( - navigateToProfileSetting: () -> Unit, + navigateToProfileSetting: (String) -> Unit, navigateToSignInScreen: () -> Unit, ) { composable(route = profileNavigationRoute) { diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 9488383d..91f908fc 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -35,6 +35,7 @@ import com.wap.wapp.feature.profile.profilesetting.component.ProfileSettingDialo @Composable internal fun ProfileSettingRoute( + userId: String, navigateToProfile: () -> Unit, viewModel: ProfileSettingViewModel = hiltViewModel(), ) { diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt index fbea9ac8..256e2827 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt @@ -3,18 +3,29 @@ package com.wap.wapp.feature.profile.profilesetting.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions +import androidx.navigation.NavType import androidx.navigation.compose.composable +import androidx.navigation.navArgument import androidx.navigation.navOptions import com.wap.wapp.feature.profile.profilesetting.ProfileSettingRoute -const val profileSettingNavigationRoute = "profile_setting_route" +const val profileSettingNavigationRoute = "profile_setting_route/{userId}" -fun NavController.navigateToProfileSetting(navOptions: NavOptions? = navOptions {}) { - this.navigate(profileSettingNavigationRoute, navOptions) +fun NavController.navigateToProfileSetting( + userId: String, + navOptions: NavOptions? = navOptions {}, +) { + this.navigate("profile_setting_route/$userId", navOptions) } fun NavGraphBuilder.profileSettingScreen(navigateToProfile: () -> Unit) { - composable(route = profileSettingNavigationRoute) { - ProfileSettingRoute(navigateToProfile) + composable( + route = profileSettingNavigationRoute, + arguments = listOf( + navArgument("userId") { type = NavType.StringType }, + ), + ) { navBackStackEntry -> + val userId = navBackStackEntry.arguments?.getString("userId") ?: "" + ProfileSettingRoute(userId = userId, navigateToProfile = navigateToProfile) } } From 1c752e5c1c4e3aae425e122542dd17a382d32f79 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 00:37:49 +0900 Subject: [PATCH 46/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/feature/profile/screen/UserProfile.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index f752fb95..71fe216d 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -1,6 +1,5 @@ package com.wap.wapp.feature.profile.screen -import android.util.Log import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -178,7 +177,6 @@ private fun MyAttendanceStatus( items = recentEventsState.events, key = { event -> event.eventId }, ) { event -> - Log.d("test", recentEventsState.events.toString()) WappAttendacneRow(isAttendance = true, event = event) } } From e3385578c848f69c3479134fcaa226b7212d219e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 00:45:26 +0900 Subject: [PATCH 47/62] =?UTF-8?q?[CHORE]=20#74=20:=20getDateEventListUseCa?= =?UTF-8?q?se=20->=20getMonthEventListUseCase=20=EC=9E=98=EB=AA=BB=20?= =?UTF-8?q?=EA=B8=B0=EC=9E=85=ED=95=9C=20=EA=B2=83=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/feature/profile/ProfileViewModel.kt | 4 +++- .../java/com/wap/wapp/feature/profile/screen/UserProfile.kt | 4 ++-- feature/profile/src/main/res/values/strings.xml | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 0e8fd06f..d0948e53 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.domain.usecase.event.GetDateEventListUseCase +import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase import com.wap.wapp.core.domain.usecase.survey.GetUserRespondedSurveyListUseCase import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase @@ -28,6 +29,7 @@ import javax.inject.Inject class ProfileViewModel @Inject constructor( private val getUserRoleUseCase: GetUserRoleUseCase, private val getUserProfileUseCase: GetUserProfileUseCase, + private val getMonthEventListUseCase: GetMonthEventListUseCase, private val getDateEventListUseCase: GetDateEventListUseCase, private val getUserRespondedSurveyListUseCase: GetUserRespondedSurveyListUseCase, ) : ViewModel() { @@ -115,7 +117,7 @@ class ProfileViewModel @Inject constructor( // 만약 가입한 날짜보다 빠르다면 반복문을 멈춤 if (targetDateTime < registrationDateTime) break - getDateEventListUseCase(targetDateTime).onSuccess { eventsList.addAll(it) } + getMonthEventListUseCase(targetDateTime).onSuccess { eventsList.addAll(it) } .onFailure { _errorFlow.emit(it) } } _recentEvents.value = EventsState.Success(eventsList) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt index 71fe216d..00c36c3c 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt @@ -156,7 +156,7 @@ private fun MyAttendanceStatus( ) { Spacer(modifier = Modifier.weight(1f)) Text( - text = "가입한 이후로 진행된 일정이 없어요!", + text = stringResource(id = R.string.no_events_recently), style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), color = WappTheme.colors.white, textAlign = TextAlign.Center, @@ -222,7 +222,7 @@ private fun MySurveyHistory( ) { Spacer(modifier = Modifier.weight(1f)) Text( - text = "가입한 이후로 참여한 설문이 없어요!", + text = stringResource(id = R.string.no_surveys_after_sign_up), style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), color = WappTheme.colors.white, textAlign = TextAlign.Center, diff --git a/feature/profile/src/main/res/values/strings.xml b/feature/profile/src/main/res/values/strings.xml index b638f939..d56ef8a9 100644 --- a/feature/profile/src/main/res/values/strings.xml +++ b/feature/profile/src/main/res/values/strings.xml @@ -23,4 +23,6 @@ 로그인 하러 가기 WAP 출석 오늘은 별 다른 행사가 없어요! + 가입한 이후로 참여한 설문이 없어요! + 가입한 이후로 진행된 일정이 없어요! From bac951622f81445e8e6c8603cfe0dcd2b9dc5641 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 00:57:23 +0900 Subject: [PATCH 48/62] =?UTF-8?q?[FEATURE]=20#74=20:=20ProfileSettingEvent?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20EventFlow=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/navigation/WappNavHost.kt | 12 ++++++++-- .../wap/wapp/feature/profile/ProfileScreen.kt | 8 +++---- .../profile/navigation/ProfileNavigation.kt | 4 ++-- .../profilesetting/ProfileSettingScreen.kt | 3 +++ .../profilesetting/ProfileSettingViewModel.kt | 22 ++++++++++--------- .../navigation/ProfileSettingNavigation.kt | 11 ++++++++-- .../feature/profile/screen/GuestProfile.kt | 4 ++-- 7 files changed, 42 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt index ce9e1de0..ab0e807d 100644 --- a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt +++ b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt @@ -9,6 +9,7 @@ import androidx.navigation.navOptions import com.wap.designsystem.WappTheme import com.wap.wapp.core.domain.usecase.auth.SignInUseCase import com.wap.wapp.feature.auth.signin.navigation.navigateToSignIn +import com.wap.wapp.feature.auth.signin.navigation.signInNavigationRoute import com.wap.wapp.feature.auth.signin.navigation.signInScreen import com.wap.wapp.feature.auth.signup.navigation.navigateToSignUp import com.wap.wapp.feature.auth.signup.navigation.signUpScreen @@ -17,9 +18,9 @@ import com.wap.wapp.feature.management.event.navigation.navigateToEventEdit import com.wap.wapp.feature.management.event.navigation.navigateToEventRegistration import com.wap.wapp.feature.management.navigation.managementScreen import com.wap.wapp.feature.management.navigation.navigateToManagement +import com.wap.wapp.feature.management.survey.navigation.managementSurveyNavGraph import com.wap.wapp.feature.management.survey.navigation.navigateToSurveyFormEdit import com.wap.wapp.feature.management.survey.navigation.navigateToSurveyFormRegistration -import com.wap.wapp.feature.management.survey.navigation.managementSurveyNavGraph import com.wap.wapp.feature.notice.navigation.navigateToNotice import com.wap.wapp.feature.notice.navigation.noticeScreen import com.wap.wapp.feature.profile.navigation.navigateToProfile @@ -89,7 +90,7 @@ fun WappNavHost( ) profileScreen( navigateToProfileSetting = navController::navigateToProfileSetting, - navigateToSignInScreen = { + navigateToSignIn = { navController.navigateToSignIn( navOptions { popUpTo(profileNavigationRoute) @@ -98,6 +99,13 @@ fun WappNavHost( }, ) profileSettingScreen( + navigateToSignIn = { + navController.navigateToSignIn( + navOptions { + popUpTo(signInNavigationRoute) { inclusive = true } + }, + ) + }, navigateToProfile = { navController.navigateToProfile( navOptions { diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index c684839b..e6d9bd2e 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -39,7 +39,7 @@ import kotlinx.coroutines.flow.collectLatest internal fun ProfileRoute( viewModel: ProfileViewModel = hiltViewModel(), navigateToProfileSetting: (String) -> Unit, - navigateToSignInScreen: () -> Unit, + navigateToSignIn: () -> Unit, ) { val todayEventsState by viewModel.todayEvents.collectAsStateWithLifecycle() val recentEventsState by viewModel.recentEvents.collectAsStateWithLifecycle() @@ -64,7 +64,7 @@ internal fun ProfileRoute( userRespondedSurveysState = userRespondedSurveysState, snackBarHostState = snackBarHostState, navigateToProfileSetting = navigateToProfileSetting, - navigateToSignInScreen = navigateToSignInScreen, + navigateToSignIn = navigateToSignIn, ) } @@ -77,7 +77,7 @@ internal fun ProfileScreen( userRespondedSurveysState: ProfileViewModel.SurveysState, snackBarHostState: SnackbarHostState, navigateToProfileSetting: (String) -> Unit, - navigateToSignInScreen: () -> Unit, + navigateToSignIn: () -> Unit, ) { val scrollState = rememberScrollState() @@ -172,7 +172,7 @@ internal fun ProfileScreen( userName = stringResource(id = R.string.non_user), ) - GuestProfile(navigateToSignInScreen = navigateToSignInScreen) + GuestProfile(navigateToSignIn = navigateToSignIn) } } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt index ac3bd60f..8f1fe340 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/navigation/ProfileNavigation.kt @@ -15,12 +15,12 @@ fun NavController.navigateToProfile(navOptions: NavOptions? = navOptions {}) { fun NavGraphBuilder.profileScreen( navigateToProfileSetting: (String) -> Unit, - navigateToSignInScreen: () -> Unit, + navigateToSignIn: () -> Unit, ) { composable(route = profileNavigationRoute) { ProfileRoute( navigateToProfileSetting = navigateToProfileSetting, - navigateToSignInScreen = navigateToSignInScreen, + navigateToSignIn = navigateToSignIn, ) } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 91f908fc..d48c7953 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -37,6 +37,7 @@ import com.wap.wapp.feature.profile.profilesetting.component.ProfileSettingDialo internal fun ProfileSettingRoute( userId: String, navigateToProfile: () -> Unit, + navigateToSignIn: () -> Unit, viewModel: ProfileSettingViewModel = hiltViewModel(), ) { ProfileSettingScreen( @@ -58,6 +59,7 @@ internal fun ProfileSettingScreen( if (showWithdrawalDialog) { ProfileSettingDialog( onDismissRequest = { showWithdrawalDialog = false }, + onConfirmRequest = {}, title = string.withdrawal, ) } @@ -65,6 +67,7 @@ internal fun ProfileSettingScreen( if (showLogoutDialog) { ProfileSettingDialog( onDismissRequest = { showLogoutDialog = false }, + onConfirmRequest = {}, title = string.logout, ) } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt index a6e65593..126b1af1 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt @@ -4,12 +4,10 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.domain.usecase.auth.DeleteUserUseCase import com.wap.wapp.core.domain.usecase.auth.SignOutUseCase -import com.wap.wapp.core.model.user.UserProfile -import com.wap.wapp.feature.profile.ProfileViewModel import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.launch import javax.inject.Inject @@ -18,17 +16,21 @@ class ProfileSettingViewModel @Inject constructor( private val signOutUseCase: SignOutUseCase, private val deleteUserUseCase: DeleteUserUseCase, ) : ViewModel() { - - private val _userProfile = MutableStateFlow(ProfileViewModel.DEFAULT_USER_PROFILE) - val userProfile: StateFlow = _userProfile.asStateFlow() + private val _eventFlow: MutableSharedFlow = MutableSharedFlow() + val eventFlow: SharedFlow = _eventFlow.asSharedFlow() fun signOut() = viewModelScope.launch { signOutUseCase().onSuccess { } .onFailure { } } - fun withdrawal() = viewModelScope.launch { - deleteUserUseCase(_userProfile.value.userId).onSuccess { } + fun withdrawal(userId: String) = viewModelScope.launch { + deleteUserUseCase(userId).onSuccess { } .onFailure { } } + + sealed class ProfileSettingEvent { + data object Failure : ProfileSettingEvent() + data object Success : ProfileSettingEvent() + } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt index 256e2827..620e3d00 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/navigation/ProfileSettingNavigation.kt @@ -18,7 +18,10 @@ fun NavController.navigateToProfileSetting( this.navigate("profile_setting_route/$userId", navOptions) } -fun NavGraphBuilder.profileSettingScreen(navigateToProfile: () -> Unit) { +fun NavGraphBuilder.profileSettingScreen( + navigateToSignIn: () -> Unit, + navigateToProfile: () -> Unit, +) { composable( route = profileSettingNavigationRoute, arguments = listOf( @@ -26,6 +29,10 @@ fun NavGraphBuilder.profileSettingScreen(navigateToProfile: () -> Unit) { ), ) { navBackStackEntry -> val userId = navBackStackEntry.arguments?.getString("userId") ?: "" - ProfileSettingRoute(userId = userId, navigateToProfile = navigateToProfile) + ProfileSettingRoute( + userId = userId, + navigateToSignIn = navigateToSignIn, + navigateToProfile = navigateToProfile, + ) } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/GuestProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/GuestProfile.kt index 54c1f9bf..90e132c9 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/GuestProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/GuestProfile.kt @@ -22,7 +22,7 @@ import com.wap.designsystem.WappTheme import com.wap.wapp.feature.profile.R @Composable -internal fun GuestProfile(navigateToSignInScreen: () -> Unit) { +internal fun GuestProfile(navigateToSignIn: () -> Unit) { Text( text = SpannableGuestText(), color = WappTheme.colors.white, @@ -41,7 +41,7 @@ internal fun GuestProfile(navigateToSignInScreen: () -> Unit) { .padding(top = 40.dp) .height(50.dp) .fillMaxWidth() - .clickable { navigateToSignInScreen() }, + .clickable { navigateToSignIn() }, ) { Text( text = stringResource(id = R.string.navigate_to_login), From 78ec001defecf7e17ff7570ec28e661958b73c0b Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 01:01:41 +0900 Subject: [PATCH 49/62] =?UTF-8?q?[FEATURE]=20#74=20:=20Withdrawl,=20SignOu?= =?UTF-8?q?t=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 20 +++++++++++++++++-- .../profilesetting/ProfileSettingViewModel.kt | 10 +++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index d48c7953..4db7d484 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.Divider import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -31,6 +32,8 @@ import com.wap.designsystem.component.WappRowBar import com.wap.designsystem.component.WappSubTopBar import com.wap.wapp.core.designresource.R import com.wap.wapp.feature.profile.R.string +import com.wap.wapp.feature.profile.profilesetting.ProfileSettingViewModel.ProfileSettingEvent.Failure +import com.wap.wapp.feature.profile.profilesetting.ProfileSettingViewModel.ProfileSettingEvent.Success import com.wap.wapp.feature.profile.profilesetting.component.ProfileSettingDialog @Composable @@ -40,7 +43,18 @@ internal fun ProfileSettingRoute( navigateToSignIn: () -> Unit, viewModel: ProfileSettingViewModel = hiltViewModel(), ) { + LaunchedEffect(true) { + viewModel.eventFlow.collect { + when (it) { + is Failure -> {} + is Success -> navigateToSignIn() + } + } + } + ProfileSettingScreen( + withdrawal = { viewModel.withdrawal(userId) }, + signOut = viewModel::signOut, navigateToProfile = navigateToProfile, ) } @@ -48,6 +62,8 @@ internal fun ProfileSettingRoute( @Composable internal fun ProfileSettingScreen( navigateToProfile: () -> Unit, + withdrawal: () -> Unit, + signOut: () -> Unit, onClickedAlarmSetting: () -> Unit = {}, ) { var showWithdrawalDialog by remember { mutableStateOf(false) } @@ -59,7 +75,7 @@ internal fun ProfileSettingScreen( if (showWithdrawalDialog) { ProfileSettingDialog( onDismissRequest = { showWithdrawalDialog = false }, - onConfirmRequest = {}, + onConfirmRequest = withdrawal, title = string.withdrawal, ) } @@ -67,7 +83,7 @@ internal fun ProfileSettingScreen( if (showLogoutDialog) { ProfileSettingDialog( onDismissRequest = { showLogoutDialog = false }, - onConfirmRequest = {}, + onConfirmRequest = signOut, title = string.logout, ) } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt index 126b1af1..0fddff72 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt @@ -20,17 +20,17 @@ class ProfileSettingViewModel @Inject constructor( val eventFlow: SharedFlow = _eventFlow.asSharedFlow() fun signOut() = viewModelScope.launch { - signOutUseCase().onSuccess { } - .onFailure { } + signOutUseCase().onSuccess { _eventFlow.emit(ProfileSettingEvent.Success) } + .onFailure { _eventFlow.emit(ProfileSettingEvent.Failure(it)) } } fun withdrawal(userId: String) = viewModelScope.launch { - deleteUserUseCase(userId).onSuccess { } - .onFailure { } + deleteUserUseCase(userId).onSuccess { _eventFlow.emit(ProfileSettingEvent.Success) } + .onFailure { _eventFlow.emit(ProfileSettingEvent.Failure(it)) } } sealed class ProfileSettingEvent { - data object Failure : ProfileSettingEvent() + data class Failure(val throwable: Throwable) : ProfileSettingEvent() data object Success : ProfileSettingEvent() } } From 792bd182fd1180575f91bcfd380a8c3793eaf0b3 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 01:09:10 +0900 Subject: [PATCH 50/62] =?UTF-8?q?[FEATURE]=20#74=20:=20ProfileSetting=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EB=A1=9C=EC=A7=81=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profilesetting/ProfileSettingScreen.kt | 174 ++++++++++-------- .../profilesetting/ProfileSettingViewModel.kt | 18 +- 2 files changed, 104 insertions(+), 88 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index 4db7d484..bbf74c0b 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -7,12 +7,16 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.Divider import androidx.compose.material.Text +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -30,10 +34,11 @@ import androidx.hilt.navigation.compose.hiltViewModel import com.wap.designsystem.WappTheme import com.wap.designsystem.component.WappRowBar import com.wap.designsystem.component.WappSubTopBar +import com.wap.wapp.core.commmon.extensions.toSupportingText import com.wap.wapp.core.designresource.R import com.wap.wapp.feature.profile.R.string -import com.wap.wapp.feature.profile.profilesetting.ProfileSettingViewModel.ProfileSettingEvent.Failure -import com.wap.wapp.feature.profile.profilesetting.ProfileSettingViewModel.ProfileSettingEvent.Success +import com.wap.wapp.feature.profile.profilesetting.ProfileSettingViewModel.EventResult.Failure +import com.wap.wapp.feature.profile.profilesetting.ProfileSettingViewModel.EventResult.Success import com.wap.wapp.feature.profile.profilesetting.component.ProfileSettingDialog @Composable @@ -43,10 +48,13 @@ internal fun ProfileSettingRoute( navigateToSignIn: () -> Unit, viewModel: ProfileSettingViewModel = hiltViewModel(), ) { + val snackBarHostState = remember { SnackbarHostState() } + LaunchedEffect(true) { - viewModel.eventFlow.collect { - when (it) { - is Failure -> {} + viewModel.eventFlow.collect { eventResult -> + when (eventResult) { + is Failure -> + snackBarHostState.showSnackbar(eventResult.throwable.toSupportingText()) is Success -> navigateToSignIn() } } @@ -55,6 +63,7 @@ internal fun ProfileSettingRoute( ProfileSettingScreen( withdrawal = { viewModel.withdrawal(userId) }, signOut = viewModel::signOut, + snackBarHostState = snackBarHostState, navigateToProfile = navigateToProfile, ) } @@ -64,6 +73,7 @@ internal fun ProfileSettingScreen( navigateToProfile: () -> Unit, withdrawal: () -> Unit, signOut: () -> Unit, + snackBarHostState: SnackbarHostState, onClickedAlarmSetting: () -> Unit = {}, ) { var showWithdrawalDialog by remember { mutableStateOf(false) } @@ -88,97 +98,103 @@ internal fun ProfileSettingScreen( ) } - Column( - modifier = Modifier - .fillMaxSize() - .verticalScroll(scrollState) - .background(color = WappTheme.colors.backgroundBlack), - ) { - WappSubTopBar( - titleRes = string.more, - showLeftButton = true, - onClickLeftButton = navigateToProfile, - modifier = Modifier.padding(top = 20.dp), - ) - - Row( - horizontalArrangement = Arrangement.spacedBy(15.dp), - modifier = Modifier.padding(start = 15.dp, top = 20.dp, bottom = 25.dp), + Scaffold( + contentWindowInsets = WindowInsets(0.dp), + snackbarHost = { SnackbarHost(snackBarHostState) }, + ) { paddingValues -> + Column( + modifier = Modifier + .padding(paddingValues) + .fillMaxSize() + .verticalScroll(scrollState) + .background(color = WappTheme.colors.backgroundBlack), ) { - Image( - painter = painterResource(id = R.drawable.ic_account_setting), - contentDescription = "", - ) - Text( - text = stringResource(id = string.account_setting), - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, + WappSubTopBar( + titleRes = string.more, + showLeftButton = true, + onClickLeftButton = navigateToProfile, + modifier = Modifier.padding(top = 20.dp), ) - } - - WappRowBar( - title = stringResource(id = string.alarm_setting), - onClicked = onClickedAlarmSetting, - ) - Divider(color = dividerColor) + Row( + horizontalArrangement = Arrangement.spacedBy(15.dp), + modifier = Modifier.padding(start = 15.dp, top = 20.dp, bottom = 25.dp), + ) { + Image( + painter = painterResource(id = R.drawable.ic_account_setting), + contentDescription = "", + ) + Text( + text = stringResource(id = string.account_setting), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + ) + } - WappRowBar( - title = stringResource(id = string.logout), - onClicked = { showLogoutDialog = true }, - ) + WappRowBar( + title = stringResource(id = string.alarm_setting), + onClicked = onClickedAlarmSetting, + ) - Divider(color = dividerColor) + Divider(color = dividerColor) - WappRowBar( - title = stringResource(id = string.withdrawal), - onClicked = { showWithdrawalDialog = true }, - ) + WappRowBar( + title = stringResource(id = string.logout), + onClicked = { showLogoutDialog = true }, + ) - Divider(color = dividerColor) + Divider(color = dividerColor) - Row( - horizontalArrangement = Arrangement.spacedBy(15.dp), - modifier = Modifier.padding(start = 15.dp, top = 25.dp, bottom = 25.dp), - ) { - Image( - painter = painterResource(id = R.drawable.ic_profile_more), - contentDescription = "", + WappRowBar( + title = stringResource(id = string.withdrawal), + onClicked = { showWithdrawalDialog = true }, ) - Text( - text = stringResource(id = string.more), - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, - ) - } - WappRowBar( - title = stringResource(id = string.inquiry), - onClicked = { navigateToUri(context, INQUIRY_URL) }, - ) + Divider(color = dividerColor) + + Row( + horizontalArrangement = Arrangement.spacedBy(15.dp), + modifier = Modifier.padding(start = 15.dp, top = 25.dp, bottom = 25.dp), + ) { + Image( + painter = painterResource(id = R.drawable.ic_profile_more), + contentDescription = "", + ) + Text( + text = stringResource(id = string.more), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + ) + } - Divider(color = dividerColor) + WappRowBar( + title = stringResource(id = string.inquiry), + onClicked = { navigateToUri(context, INQUIRY_URL) }, + ) - WappRowBar( - title = stringResource(id = string.faq), - onClicked = { navigateToUri(context, FAQ_URL) }, - ) + Divider(color = dividerColor) - Divider(color = dividerColor) + WappRowBar( + title = stringResource(id = string.faq), + onClicked = { navigateToUri(context, FAQ_URL) }, + ) - WappRowBar( - title = stringResource(id = string.terms_and_policies), - onClicked = { navigateToUri(context, TERMS_AND_POLICIES_URL) }, - ) + Divider(color = dividerColor) - Divider(color = dividerColor) + WappRowBar( + title = stringResource(id = string.terms_and_policies), + onClicked = { navigateToUri(context, TERMS_AND_POLICIES_URL) }, + ) - WappRowBar( - title = stringResource(id = string.privacy_policy), - onClicked = { navigateToUri(context, PRIVACY_POLICY_URL) }, - ) + Divider(color = dividerColor) - Divider(color = dividerColor) + WappRowBar( + title = stringResource(id = string.privacy_policy), + onClicked = { navigateToUri(context, PRIVACY_POLICY_URL) }, + ) + + Divider(color = dividerColor) + } } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt index 0fddff72..a0e11e3c 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingViewModel.kt @@ -16,21 +16,21 @@ class ProfileSettingViewModel @Inject constructor( private val signOutUseCase: SignOutUseCase, private val deleteUserUseCase: DeleteUserUseCase, ) : ViewModel() { - private val _eventFlow: MutableSharedFlow = MutableSharedFlow() - val eventFlow: SharedFlow = _eventFlow.asSharedFlow() + private val _eventFlow: MutableSharedFlow = MutableSharedFlow() + val eventFlow: SharedFlow = _eventFlow.asSharedFlow() fun signOut() = viewModelScope.launch { - signOutUseCase().onSuccess { _eventFlow.emit(ProfileSettingEvent.Success) } - .onFailure { _eventFlow.emit(ProfileSettingEvent.Failure(it)) } + signOutUseCase().onSuccess { _eventFlow.emit(EventResult.Success) } + .onFailure { _eventFlow.emit(EventResult.Failure(it)) } } fun withdrawal(userId: String) = viewModelScope.launch { - deleteUserUseCase(userId).onSuccess { _eventFlow.emit(ProfileSettingEvent.Success) } - .onFailure { _eventFlow.emit(ProfileSettingEvent.Failure(it)) } + deleteUserUseCase(userId).onSuccess { _eventFlow.emit(EventResult.Success) } + .onFailure { _eventFlow.emit(EventResult.Failure(it)) } } - sealed class ProfileSettingEvent { - data class Failure(val throwable: Throwable) : ProfileSettingEvent() - data object Success : ProfileSettingEvent() + sealed class EventResult { + data class Failure(val throwable: Throwable) : EventResult() + data object Success : EventResult() } } From c2f9fdd031b0ec7a21991650995d147021a20c99 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 01:09:55 +0900 Subject: [PATCH 51/62] =?UTF-8?q?[FEATURE]=20#74=20:=20=EC=95=8C=EB=9E=8C?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=20Row=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/profilesetting/ProfileSettingScreen.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt index bbf74c0b..d6472428 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/ProfileSettingScreen.kt @@ -74,7 +74,6 @@ internal fun ProfileSettingScreen( withdrawal: () -> Unit, signOut: () -> Unit, snackBarHostState: SnackbarHostState, - onClickedAlarmSetting: () -> Unit = {}, ) { var showWithdrawalDialog by remember { mutableStateOf(false) } var showLogoutDialog by remember { mutableStateOf(false) } @@ -131,13 +130,6 @@ internal fun ProfileSettingScreen( ) } - WappRowBar( - title = stringResource(id = string.alarm_setting), - onClicked = onClickedAlarmSetting, - ) - - Divider(color = dividerColor) - WappRowBar( title = stringResource(id = string.logout), onClicked = { showLogoutDialog = true }, From dc7413414d37242889c16f91aa39757ac911083d Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 16:49:50 +0900 Subject: [PATCH 52/62] =?UTF-8?q?[CHORE]=20#74=20:=20events=20->=20eventLi?= =?UTF-8?q?st=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/data/repository/event/EventRepository.kt | 4 ++-- .../core/data/repository/event/EventRepositoryImpl.kt | 8 ++++---- .../core/domain/usecase/event/GetDateEventListUseCase.kt | 2 +- .../core/domain/usecase/event/GetMonthEventListUseCase.kt | 2 +- .../wap/wapp/core/network/source/event/EventDataSource.kt | 4 ++-- .../wapp/core/network/source/event/EventDataSourceImpl.kt | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt index 948582e9..0190109b 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt @@ -5,9 +5,9 @@ import java.time.LocalDate import java.time.LocalDateTime interface EventRepository { - suspend fun getMonthEvents(date: LocalDate): Result> + suspend fun getMonthEventList(date: LocalDate): Result> - suspend fun getDateEvents(date: LocalDate): Result> + suspend fun getDateEventList(date: LocalDate): Result> suspend fun getEvent(date: LocalDateTime, eventId: String): Result diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index 7a3cbd15..c27284f3 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -10,15 +10,15 @@ import javax.inject.Inject class EventRepositoryImpl @Inject constructor( private val eventDataSource: EventDataSource, ) : EventRepository { - override suspend fun getMonthEvents(date: LocalDate): Result> = - eventDataSource.getMonthEvents(date).mapCatching { eventResponses -> + override suspend fun getMonthEventList(date: LocalDate): Result> = + eventDataSource.getMonthEventList(date).mapCatching { eventResponses -> eventResponses.map { eventResponse -> eventResponse.toDomain() } } - override suspend fun getDateEvents(date: LocalDate): Result> = - eventDataSource.getDateEvents(date).mapCatching { eventResponses -> + override suspend fun getDateEventList(date: LocalDate): Result> = + eventDataSource.getDateEventList(date).mapCatching { eventResponses -> eventResponses.map { eventResponse -> eventResponse.toDomain() } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt index 7250b6bb..b9ba576a 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt @@ -9,7 +9,7 @@ class GetDateEventListUseCase @Inject constructor( private val eventRepository: EventRepository, ) { suspend operator fun invoke(date: LocalDate): Result> = runCatching { - eventRepository.getDateEvents(date).fold( + eventRepository.getDateEventList(date).fold( onSuccess = { eventsList -> eventsList }, onFailure = { throw (it) }, ) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetMonthEventListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetMonthEventListUseCase.kt index cdba0ff4..1590ec67 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetMonthEventListUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetMonthEventListUseCase.kt @@ -9,7 +9,7 @@ class GetMonthEventListUseCase @Inject constructor( private val eventRepository: EventRepository, ) { suspend operator fun invoke(date: LocalDate): Result> = runCatching { - eventRepository.getMonthEvents(date).fold( + eventRepository.getMonthEventList(date).fold( onSuccess = { eventsList -> eventsList }, onFailure = { throw (it) }, ) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt index 0e84df10..5e38d1b1 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt @@ -5,9 +5,9 @@ import java.time.LocalDate import java.time.LocalDateTime interface EventDataSource { - suspend fun getMonthEvents(date: LocalDate): Result> + suspend fun getMonthEventList(date: LocalDate): Result> - suspend fun getDateEvents(date: LocalDate): Result> + suspend fun getDateEventList(date: LocalDate): Result> suspend fun getEvent(date: LocalDateTime, eventId: String): Result diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index e417c956..87dfb958 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -17,7 +17,7 @@ import javax.inject.Inject class EventDataSourceImpl @Inject constructor( private val firebaseFirestore: FirebaseFirestore, ) : EventDataSource { - override suspend fun getMonthEvents(date: LocalDate): Result> = + override suspend fun getMonthEventList(date: LocalDate): Result> = runCatching { val result = mutableListOf() @@ -36,7 +36,7 @@ class EventDataSourceImpl @Inject constructor( result } - override suspend fun getDateEvents(date: LocalDate): Result> = + override suspend fun getDateEventList(date: LocalDate): Result> = runCatching { val result = mutableListOf() From 093d4646b5617129bb02fa2ee68500ff352c2007 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 16:53:36 +0900 Subject: [PATCH 53/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20filter,=20sort=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/ProfileViewModel.kt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index d0948e53..751f4a6f 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -69,13 +69,12 @@ class ProfileViewModel @Inject constructor( getTodayDateEvents() val userProfile = async { getUserProfileUseCase() } - userProfile.await() - .onSuccess { - _userRole.value = UserRoleState.Success(userRole) - _userProfile.value = it - launch { getRecentEventsForAttendanceCheck() } - getUserRespondedSurveys() - }.onFailure { exception -> _errorFlow.emit(exception) } + userProfile.await().onSuccess { + _userRole.value = UserRoleState.Success(userRole) + _userProfile.value = it + launch { getRecentEventsForAttendanceCheck() } + getUserRespondedSurveys() + }.onFailure { exception -> _errorFlow.emit(exception) } } } } @@ -85,12 +84,7 @@ class ProfileViewModel @Inject constructor( _todayEvents.value = EventsState.Loading viewModelScope.launch { getDateEventListUseCase(DateUtil.generateNowDate()).onSuccess { eventList -> - _todayEvents.value = - EventsState.Success( - eventList.filter { event -> - event.startDateTime.toLocalDate() == DateUtil.generateNowDate() - }.sortedBy { event -> event.title }, - ) + _todayEvents.value = EventsState.Success(eventList) }.onFailure { exception -> _errorFlow.emit(exception) } } } From 0d1a216427c299ff11854f204599875ca06aee7c Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 17:00:19 +0900 Subject: [PATCH 54/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B3=B4=EC=97=AC?= =?UTF-8?q?=EC=A4=84=20=EC=BB=A8=ED=85=90=EC=B8=A0=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EC=9D=84=20=EB=95=8C=20Composable=20=EC=9E=AC=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9D=84=20=EC=9C=84=ED=95=B4=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/profile/ProfileScreen.kt | 4 +- .../component}/GuestProfile.kt | 2 +- .../component/NoContentColumn.kt | 36 ++++++++++++++++++ .../component}/UserProfile.kt | 38 ++----------------- 4 files changed, 42 insertions(+), 38 deletions(-) rename feature/profile/src/main/java/com/wap/wapp/feature/profile/{screen => profilesetting/component}/GuestProfile.kt (97%) create mode 100644 feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/NoContentColumn.kt rename feature/profile/src/main/java/com/wap/wapp/feature/profile/{screen => profilesetting/component}/UserProfile.kt (81%) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt index e6d9bd2e..fc3383eb 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileScreen.kt @@ -31,8 +31,8 @@ import com.wap.wapp.core.model.user.UserProfile import com.wap.wapp.core.model.user.UserRole import com.wap.wapp.feature.profile.ProfileViewModel.UserRoleState import com.wap.wapp.feature.profile.component.WappProfileCard -import com.wap.wapp.feature.profile.screen.GuestProfile -import com.wap.wapp.feature.profile.screen.UserProfile +import com.wap.wapp.feature.profile.profilesetting.component.GuestProfile +import com.wap.wapp.feature.profile.profilesetting.component.UserProfile import kotlinx.coroutines.flow.collectLatest @Composable diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/GuestProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/GuestProfile.kt similarity index 97% rename from feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/GuestProfile.kt rename to feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/GuestProfile.kt index 90e132c9..62ba49dd 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/GuestProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/GuestProfile.kt @@ -1,4 +1,4 @@ -package com.wap.wapp.feature.profile.screen +package com.wap.wapp.feature.profile.profilesetting.component import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.fillMaxWidth diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/NoContentColumn.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/NoContentColumn.kt new file mode 100644 index 00000000..d25dc9f6 --- /dev/null +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/NoContentColumn.kt @@ -0,0 +1,36 @@ +package com.wap.wapp.feature.profile.profilesetting.component + +import androidx.annotation.StringRes +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +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.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.wap.designsystem.WappTheme + +@Composable +internal fun NothingToShow(@StringRes title: Int) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .padding(10.dp) + .height(130.dp), + ) { + Spacer(modifier = Modifier.weight(1f)) + Text( + text = stringResource(id = title), + style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), + color = WappTheme.colors.white, + textAlign = TextAlign.Center, + modifier = Modifier.weight(1f), + ) + Spacer(modifier = Modifier.weight(1f)) + } +} diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/UserProfile.kt similarity index 81% rename from feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt rename to feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/UserProfile.kt index 00c36c3c..00fc9949 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/screen/UserProfile.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/profilesetting/component/UserProfile.kt @@ -1,10 +1,9 @@ -package com.wap.wapp.feature.profile.screen +package com.wap.wapp.feature.profile.profilesetting.component import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement 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 @@ -21,7 +20,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp @@ -148,22 +146,7 @@ private fun MyAttendanceStatus( is ProfileViewModel.EventsState.Success -> { if (recentEventsState.events.isEmpty()) { - Column( - horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier - .padding(10.dp) - .height(130.dp), - ) { - Spacer(modifier = Modifier.weight(1f)) - Text( - text = stringResource(id = R.string.no_events_recently), - style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), - color = WappTheme.colors.white, - textAlign = TextAlign.Center, - modifier = Modifier.weight(1f), - ) - Spacer(modifier = Modifier.weight(1f)) - } + NothingToShow(title = R.string.no_events_recently) return@WappCard } @@ -214,22 +197,7 @@ private fun MySurveyHistory( is ProfileViewModel.SurveysState.Success -> { if (userRespondedSurveysState.surveys.isEmpty()) { - Column( - horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier - .padding(10.dp) - .height(130.dp), - ) { - Spacer(modifier = Modifier.weight(1f)) - Text( - text = stringResource(id = R.string.no_surveys_after_sign_up), - style = WappTheme.typography.contentRegular.copy(fontSize = 20.sp), - color = WappTheme.colors.white, - textAlign = TextAlign.Center, - modifier = Modifier.weight(1f), - ) - Spacer(modifier = Modifier.weight(1f)) - } + NothingToShow(title = R.string.no_surveys_after_sign_up) return@WappCard } From 28ee87b64b4db977c5a5973f83e196355431631c Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 17:20:38 +0900 Subject: [PATCH 55/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EA=B0=9C=ED=96=89=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../survey/edit/SurveyFormEditViewModel.kt | 28 ++++----------- .../SurveyFormRegistrationViewModel.kt | 36 +++++-------------- 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt index 13771fd8..abf04d2f 100644 --- a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt +++ b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt @@ -168,37 +168,23 @@ class SurveyFormEditViewModel @Inject constructor( clearSurveyQuestionState() } - private fun setSurveyFormId(surveyFormId: String) { - this.surveyFormId.value = surveyFormId - } + private fun setSurveyFormId(surveyFormId: String) { this.surveyFormId.value = surveyFormId } - fun setSurveyEventSelection(event: Event) { - _surveyEventSelection.value = event - } + fun setSurveyEventSelection(event: Event) { _surveyEventSelection.value = event } - fun setSurveyTitle(title: String) { - _surveyTitle.value = title - } + fun setSurveyTitle(title: String) { _surveyTitle.value = title } - fun setSurveyContent(content: String) { - _surveyContent.value = content - } + fun setSurveyContent(content: String) { _surveyContent.value = content } - fun setSurveyQuestion(question: String) { - _surveyQuestion.value = question - } + fun setSurveyQuestion(question: String) { _surveyQuestion.value = question } fun setSurveyQuestionType(questionType: QuestionType) { _surveyQuestionType.value = questionType } - fun setSurveyTimeDeadline(time: LocalTime) { - _surveyTimeDeadline.value = time - } + fun setSurveyTimeDeadline(time: LocalTime) { _surveyTimeDeadline.value = time } - fun setSurveyDateDeadline(date: LocalDate) { - _surveyDateDeadline.value = date - } + fun setSurveyDateDeadline(date: LocalDate) { _surveyDateDeadline.value = date } private fun setSurveyQuestionList(surveyQuestionList: MutableList) { // 마지막 질문은 UI에 노출 diff --git a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt index b696ca8a..308d4dd7 100644 --- a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt +++ b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/registration/SurveyFormRegistrationViewModel.kt @@ -122,37 +122,21 @@ class SurveyFormRegistrationViewModel @Inject constructor( return true } - fun setSurveyFormState(nextState: SurveyFormState) { - _currentSurveyFormState.value = nextState - } + fun setSurveyFormState(nextState: SurveyFormState) { _currentSurveyFormState.value = nextState } - fun setSurveyEventSelection(event: Event) { - _surveyEventSelection.value = event - } + fun setSurveyEventSelection(event: Event) { _surveyEventSelection.value = event } - fun setSurveyTitle(title: String) { - _surveyTitle.value = title - } + fun setSurveyTitle(title: String) { _surveyTitle.value = title } - fun setSurveyContent(content: String) { - _surveyContent.value = content - } + fun setSurveyContent(content: String) { _surveyContent.value = content } - fun setSurveyQuestion(question: String) { - _surveyQuestion.value = question - } + fun setSurveyQuestion(question: String) { _surveyQuestion.value = question } - fun setSurveyQuestionType(type: QuestionType) { - _surveyQuestionType.value = type - } + fun setSurveyQuestionType(type: QuestionType) { _surveyQuestionType.value = type } - fun setSurveyTimeDeadline(time: LocalTime) { - _surveyTimeDeadline.value = time - } + fun setSurveyTimeDeadline(time: LocalTime) { _surveyTimeDeadline.value = time } - fun setSurveyDateDeadline(date: LocalDate) { - _surveyDateDeadline.value = date - } + fun setSurveyDateDeadline(date: LocalDate) { _surveyDateDeadline.value = date } fun addSurveyQuestion() { _surveyQuestionList.value.add( @@ -164,9 +148,7 @@ class SurveyFormRegistrationViewModel @Inject constructor( clearSurveyQuestionState() } - private fun clearSurveyQuestionState() { - _surveyQuestion.value = "" - } + private fun clearSurveyQuestionState() { _surveyQuestion.value = "" } private fun isNotValidSurveyQuestion() = _surveyQuestion.value.isBlank() From 0ff8a25a9c8749cb372b0e05e7b7c7d2747acc3e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 17:21:46 +0900 Subject: [PATCH 56/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EA=B0=9C=ED=96=89=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/survey/edit/SurveyFormEditViewModel.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt index abf04d2f..d04800da 100644 --- a/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt +++ b/feature/management-survey/src/main/java/com/wap/wapp/feature/management/survey/edit/SurveyFormEditViewModel.kt @@ -154,9 +154,7 @@ class SurveyFormEditViewModel @Inject constructor( return true } - fun setSurveyFormState(nextState: SurveyFormState) { - _currentSurveyFormState.value = nextState - } + fun setSurveyFormState(nextState: SurveyFormState) { _currentSurveyFormState.value = nextState } fun addSurveyQuestion() { _surveyQuestionList.value.add( @@ -195,9 +193,7 @@ class SurveyFormEditViewModel @Inject constructor( _surveyQuestionList.value.addAll(surveyQuestionList) } - private fun clearSurveyQuestionState() { - _surveyQuestion.value = "" - } + private fun clearSurveyQuestionState() { _surveyQuestion.value = "" } private fun isNotValidSurveyQuestion() = _surveyQuestion.value.isBlank() From 151ad1452d62adbf9f97151a18ba9cc77f17ead0 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 17:26:48 +0900 Subject: [PATCH 57/62] =?UTF-8?q?[REFACTOR]=20#74=20ViewModel=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=95=EB=A0=AC=ED=95=98=EB=8D=98=20=EA=B2=83=20?= =?UTF-8?q?datasource=EC=97=90=EC=84=9C=20=EC=A0=95=EB=A0=AC=ED=95=98?= =?UTF-8?q?=EA=B8=B0=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/network/source/event/EventDataSourceImpl.kt | 6 +++--- .../java/com/wap/wapp/feature/notice/NoticeViewModel.kt | 4 ++-- .../java/com/wap/wapp/feature/profile/ProfileViewModel.kt | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index 0dc094d2..80c4e32d 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -28,7 +28,7 @@ class EventDataSourceImpl @Inject constructor( result.add(event) } - result + result.sortedBy { it.startDateTime } } override suspend fun getMonthEventList(date: LocalDate): Result> = @@ -56,7 +56,7 @@ class EventDataSourceImpl @Inject constructor( result.add(event) } - result + result.sortedBy { it.startDateTime } } override suspend fun getDateEventList(date: LocalDate): Result> = @@ -78,7 +78,7 @@ class EventDataSourceImpl @Inject constructor( result.add(event) } - result + result.sortedBy { it.startDateTime } } override suspend fun getEvent(eventId: String): Result = diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt index c2db8f43..fc3dfd97 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeViewModel.kt @@ -45,8 +45,8 @@ class NoticeViewModel @Inject constructor( fun getSelectedDateEvents() { _selectedDateEvents.value = EventsState.Loading viewModelScope.launch { - getDateEventListUseCase(_selectedDate.value).onSuccess { - _selectedDateEvents.value = EventsState.Success(it.sortedBy { it.startDateTime }) + getDateEventListUseCase(_selectedDate.value).onSuccess { eventList -> + _selectedDateEvents.value = EventsState.Success(eventList) }.onFailure { _selectedDateEvents.value = EventsState.Failure(it) } } } diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 751f4a6f..6451b0a4 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -91,8 +91,7 @@ class ProfileViewModel @Inject constructor( private suspend fun getUserRespondedSurveys() { getUserRespondedSurveyListUseCase(_userProfile.value.userId).onSuccess { surveyList -> - _userRespondedSurveys.value = - SurveysState.Success(surveyList.sortedBy { survey -> survey.surveyedAt }) + _userRespondedSurveys.value = SurveysState.Success(surveyList) }.onFailure { exception -> _errorFlow.emit(exception) } } From 6abb5d544cafbfcc60e6ce521398f80ea9daead2 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 17:34:48 +0900 Subject: [PATCH 58/62] =?UTF-8?q?[REFACTOR]=20#74=20Datasource=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=95=EB=A0=AC=ED=95=98=EB=8D=98=20=EA=B2=83,?= =?UTF-8?q?=20Repository=EB=A1=9C=20=EB=84=98=EA=B2=A8=EC=A4=84=20?= =?UTF-8?q?=EB=96=84=20=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B0=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/data/repository/event/EventRepositoryImpl.kt | 6 +++--- .../core/domain/usecase/event/GetDateEventListUseCase.kt | 2 +- .../wapp/core/network/source/event/EventDataSourceImpl.kt | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index ad4ba87c..debcd9f9 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -14,21 +14,21 @@ class EventRepositoryImpl @Inject constructor( eventDataSource.getMonthEventList(date).mapCatching { eventResponses -> eventResponses.map { eventResponse -> eventResponse.toDomain() - } + }.sortedBy { it.startDateTime } } override suspend fun getEventList(): Result> = eventDataSource.getEventList().mapCatching { eventResponses -> eventResponses.map { eventResponse -> eventResponse.toDomain() - } + }.sortedBy { it.startDateTime } } override suspend fun getDateEventList(date: LocalDate): Result> = eventDataSource.getDateEventList(date).mapCatching { eventResponses -> eventResponses.map { eventResponse -> eventResponse.toDomain() - } + }.sortedBy { it.startDateTime } } override suspend fun getEvent(eventId: String): Result = diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt index a3768420..f3406db4 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetDateEventListUseCase.kt @@ -9,5 +9,5 @@ class GetDateEventListUseCase @Inject constructor( private val eventRepository: EventRepository, ) { suspend operator fun invoke(date: LocalDate): Result> = - eventRepository.getDateEventList(date) + eventRepository.getMonthEventList(date) } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index 80c4e32d..0dc094d2 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -28,7 +28,7 @@ class EventDataSourceImpl @Inject constructor( result.add(event) } - result.sortedBy { it.startDateTime } + result } override suspend fun getMonthEventList(date: LocalDate): Result> = @@ -56,7 +56,7 @@ class EventDataSourceImpl @Inject constructor( result.add(event) } - result.sortedBy { it.startDateTime } + result } override suspend fun getDateEventList(date: LocalDate): Result> = @@ -78,7 +78,7 @@ class EventDataSourceImpl @Inject constructor( result.add(event) } - result.sortedBy { it.startDateTime } + result } override suspend fun getEvent(eventId: String): Result = From 70d85bed97cc08cf99ab6ad57fceb59053a5f974 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 21:49:38 +0900 Subject: [PATCH 59/62] =?UTF-8?q?[FEATURE]=20#74=20:=20GetEventListFromDat?= =?UTF-8?q?e=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 15 +------------ .../data/repository/event/EventRepository.kt | 2 ++ .../repository/event/EventRepositoryImpl.kt | 7 +++++++ .../event/GetRecentEventListUseCase.kt | 19 +++++++++++++++++ .../network/source/event/EventDataSource.kt | 2 ++ .../source/event/EventDataSourceImpl.kt | 21 +++++++++++++++++++ 6 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 1e6a1f3e..0c0c3383 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -3,20 +3,7 @@ - - - - - - - - - - - - - - + diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt index e663662e..a052f913 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt @@ -9,6 +9,8 @@ interface EventRepository { suspend fun getDateEventList(date: LocalDate): Result> + suspend fun getEventListFromDate(date: LocalDate): Result> + suspend fun getEventList(): Result> suspend fun getEvent(eventId: String): Result diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index debcd9f9..cecbfd55 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -31,6 +31,13 @@ class EventRepositoryImpl @Inject constructor( }.sortedBy { it.startDateTime } } + override suspend fun getEventListFromDate(date: LocalDate): Result> = + eventDataSource.getEventListFromDate(date).mapCatching { eventResponses -> + eventResponses.map { eventResponse -> + eventResponse.toDomain() + }.sortedBy { it.startDateTime } + } + override suspend fun getEvent(eventId: String): Result = eventDataSource.getEvent(eventId).mapCatching { eventResponse -> eventResponse.toDomain() } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt new file mode 100644 index 00000000..187ec4dd --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt @@ -0,0 +1,19 @@ +package com.wap.wapp.core.domain.usecase.event + +import com.wap.wapp.core.data.repository.event.EventRepository +import com.wap.wapp.core.model.event.Event +import java.time.LocalDate +import java.time.ZoneId +import java.time.temporal.ChronoUnit +import javax.inject.Inject + +class GetRecentEventListUseCase @Inject constructor( + private val eventRepository: EventRepository, +) { + suspend operator fun invoke(registrationDate: LocalDate): Result> { + val currentDate = LocalDate.now(ZoneId.of("Asia/Seoul")) + val minimumDate = currentDate.minus(3, ChronoUnit.MONTHS) + val selectedDate = minOf(registrationDate, minimumDate) + return eventRepository.getEventListFromDate(selectedDate) + } +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt index 64b6eba4..95a36997 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt @@ -10,6 +10,8 @@ interface EventDataSource { suspend fun getEventList(): Result> + suspend fun getEventListFromDate(date: LocalDate): Result> + suspend fun getEvent(eventId: String): Result suspend fun postEvent( diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index 0dc094d2..54b51350 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -31,6 +31,27 @@ class EventDataSourceImpl @Inject constructor( result } + override suspend fun getEventListFromDate(date: LocalDate): Result> = + runCatching { + val result = mutableListOf() + + // 선택된 날짜 1일 00시 00분 00초 + val startDateTime = date.atStartOfDay().toISOLocalDateTimeString() + + val task = firebaseFirestore.collection(EVENT_COLLECTION) + .whereGreaterThanOrEqualTo("startDateTime", startDateTime) + .get() + .await() + + for (document in task.documents) { + val event = document.toObject() + checkNotNull(event) + result.add(event) + } + + result + } + override suspend fun getMonthEventList(date: LocalDate): Result> = runCatching { val result = mutableListOf() From 02baaebfcd49949468f0508d140c57216db73f27 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 21:59:07 +0900 Subject: [PATCH 60/62] =?UTF-8?q?[FEATURE]=20#74=20:=20GetRecentEventListU?= =?UTF-8?q?seCase=20=EB=B7=B0=EB=AA=A8=EB=8D=B8=EC=97=90=20=EC=9E=A5?= =?UTF-8?q?=EC=B0=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/profile/ProfileViewModel.kt | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 6451b0a4..916fc644 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.domain.usecase.event.GetDateEventListUseCase import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase +import com.wap.wapp.core.domain.usecase.event.GetRecentEventListUseCase import com.wap.wapp.core.domain.usecase.survey.GetUserRespondedSurveyListUseCase import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase @@ -22,13 +23,13 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import java.time.LocalDate -import java.time.temporal.ChronoUnit import javax.inject.Inject @HiltViewModel class ProfileViewModel @Inject constructor( private val getUserRoleUseCase: GetUserRoleUseCase, private val getUserProfileUseCase: GetUserProfileUseCase, + private val getRecentEventListUseCase: GetRecentEventListUseCase, private val getMonthEventListUseCase: GetMonthEventListUseCase, private val getDateEventListUseCase: GetDateEventListUseCase, private val getUserRespondedSurveyListUseCase: GetUserRespondedSurveyListUseCase, @@ -98,35 +99,23 @@ class ProfileViewModel @Inject constructor( private suspend fun getRecentEventsForAttendanceCheck() { val registeredAt = _userProfile.value.registeredAt val (registeredYear, registeredSemester) = registeredAt.split(" ") - val registrationDateTime = - createRegistrationDateTime(registeredYear.toInt(), registeredSemester) + val registrationDate = + createRegistrationDate(registeredYear.toInt(), registeredSemester) - // 현재 날짜 - val currentDateTime = LocalDate.now() - - val eventsList = mutableListOf() - for (i in 0..3) { - val targetDateTime = currentDateTime.minus(i.toLong(), ChronoUnit.MONTHS) - // 만약 가입한 날짜보다 빠르다면 반복문을 멈춤 - if (targetDateTime < registrationDateTime) break - - getMonthEventListUseCase(targetDateTime).onSuccess { eventsList.addAll(it) } - .onFailure { _errorFlow.emit(it) } - } - _recentEvents.value = EventsState.Success(eventsList) + getRecentEventListUseCase(registrationDate) + .onSuccess { + _recentEvents.value = EventsState.Success(it) + }.onFailure { _errorFlow.emit(it) } } - private fun createRegistrationDateTime(year: Int, semester: String): LocalDate { + private fun createRegistrationDate(year: Int, semester: String): LocalDate { // 학기에 따른 기준 날짜 설정 (예: 1학기는 3월 1일, 2학기는 9월 1일) val semesterNumber = semester.removeSuffix("학기").toInt() - val baseDate = - if (semesterNumber == 1) { - LocalDate.of(year, 3, 1) - } else { - LocalDate.of(year, 9, 1) - } - return baseDate + if (semesterNumber == 1) { + return LocalDate.of(year, 3, 1) + } + return LocalDate.of(year, 9, 1) } sealed class EventsState { From 9b6f97b2d55765ee4505c23573fc7dc9e739a9a9 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 22:01:49 +0900 Subject: [PATCH 61/62] =?UTF-8?q?[CHORE]=20#74=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt index 916fc644..063bdb87 100644 --- a/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/wap/wapp/feature/profile/ProfileViewModel.kt @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.wap.wapp.core.commmon.util.DateUtil import com.wap.wapp.core.domain.usecase.event.GetDateEventListUseCase -import com.wap.wapp.core.domain.usecase.event.GetMonthEventListUseCase import com.wap.wapp.core.domain.usecase.event.GetRecentEventListUseCase import com.wap.wapp.core.domain.usecase.survey.GetUserRespondedSurveyListUseCase import com.wap.wapp.core.domain.usecase.user.GetUserProfileUseCase @@ -30,7 +29,6 @@ class ProfileViewModel @Inject constructor( private val getUserRoleUseCase: GetUserRoleUseCase, private val getUserProfileUseCase: GetUserProfileUseCase, private val getRecentEventListUseCase: GetRecentEventListUseCase, - private val getMonthEventListUseCase: GetMonthEventListUseCase, private val getDateEventListUseCase: GetDateEventListUseCase, private val getUserRespondedSurveyListUseCase: GetUserRespondedSurveyListUseCase, ) : ViewModel() { From c3a6baeb6ca3362422ab1c38ef512cd6caf0420e Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sat, 13 Jan 2024 22:03:17 +0900 Subject: [PATCH 62/62] =?UTF-8?q?[CHORE]=20#74=20:=20getRecentEventUseCase?= =?UTF-8?q?=EC=97=90=EC=84=9C=20minOf=20->=20maxOf=20=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt index 187ec4dd..7cd5445d 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/GetRecentEventListUseCase.kt @@ -13,7 +13,7 @@ class GetRecentEventListUseCase @Inject constructor( suspend operator fun invoke(registrationDate: LocalDate): Result> { val currentDate = LocalDate.now(ZoneId.of("Asia/Seoul")) val minimumDate = currentDate.minus(3, ChronoUnit.MONTHS) - val selectedDate = minOf(registrationDate, minimumDate) + val selectedDate = maxOf(registrationDate, minimumDate) return eventRepository.getEventListFromDate(selectedDate) } }