diff --git a/feature/mypage/src/main/java/org/sopt/official/feature/mypage/component/MyPageDialog.kt b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/component/MyPageDialog.kt index 3270c4ce..ab7e752d 100644 --- a/feature/mypage/src/main/java/org/sopt/official/feature/mypage/component/MyPageDialog.kt +++ b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/component/MyPageDialog.kt @@ -36,11 +36,9 @@ fun MyPageDialog( @StringRes subTitle: Int, @StringRes negativeText: Int, @StringRes positiveText: Int, + modifier: Modifier = Modifier, properties: DialogProperties = DialogProperties( usePlatformDefaultWidth = false, - decorFitsSystemWindows = true, - dismissOnBackPress = true, - dismissOnClickOutside = true, ), onNegativeButtonClick: () -> Unit = {}, onPositiveButtonClick: () -> Unit = {} @@ -50,7 +48,7 @@ fun MyPageDialog( properties = properties, ) { Column( - modifier = Modifier + modifier = modifier .wrapContentSize() .padding(horizontal = 25.dp) .background( diff --git a/feature/mypage/src/main/java/org/sopt/official/feature/mypage/component/MyPageSection.kt b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/component/MyPageSection.kt new file mode 100644 index 00000000..811449a5 --- /dev/null +++ b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/component/MyPageSection.kt @@ -0,0 +1,52 @@ +package org.sopt.official.feature.mypage.component + +import androidx.compose.foundation.background +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.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import org.sopt.official.designsystem.Gray400 +import org.sopt.official.designsystem.Gray900 +import org.sopt.official.designsystem.SoptTheme +import org.sopt.official.feature.mypage.model.MyPageUiModel + +@Composable +fun MyPageSection(items: List) { + Column( + modifier = Modifier + .padding(horizontal = 20.dp) + .background( + color = Gray900, + shape = RoundedCornerShape(10.dp) + ) + ) { + Spacer(modifier = Modifier.height(16.dp)) + items.forEach { item -> + when (item) { + is MyPageUiModel.Header -> { + Text( + text = item.title, + style = SoptTheme.typography.label12SB, + color = Gray400, + modifier = Modifier.padding(start = 16.dp) + ) + Spacer(modifier = Modifier.height(23.dp)) + } + + is MyPageUiModel.MyPageItem -> { + MyPageItem( + text = item.title, + onButtonClick = item.onItemClick + ) + Spacer(modifier = Modifier.height(22.dp)) + } + } + } + Spacer(modifier = Modifier.height(5.dp)) + } +} \ No newline at end of file diff --git a/feature/mypage/src/main/java/org/sopt/official/feature/mypage/model/MyPageUiModel.kt b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/model/MyPageUiModel.kt new file mode 100644 index 00000000..aaafc4e1 --- /dev/null +++ b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/model/MyPageUiModel.kt @@ -0,0 +1,16 @@ +package org.sopt.official.feature.mypage.model + +import androidx.compose.runtime.Immutable + +sealed interface MyPageUiModel { + @Immutable + data class Header( + val title: String + ) : MyPageUiModel + + @Immutable + data class MyPageItem( + val title: String, + val onItemClick: () -> Unit + ) : MyPageUiModel +} \ No newline at end of file diff --git a/feature/mypage/src/main/java/org/sopt/official/feature/mypage/mypage/MyPageActivity.kt b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/mypage/MyPageActivity.kt index 6f1bac1b..b462e923 100644 --- a/feature/mypage/src/main/java/org/sopt/official/feature/mypage/mypage/MyPageActivity.kt +++ b/feature/mypage/src/main/java/org/sopt/official/feature/mypage/mypage/MyPageActivity.kt @@ -64,7 +64,9 @@ import org.sopt.official.designsystem.SoptTheme import org.sopt.official.feature.mypage.R import org.sopt.official.feature.mypage.component.MyPageDialog import org.sopt.official.feature.mypage.component.MyPageItem +import org.sopt.official.feature.mypage.component.MyPageSection import org.sopt.official.feature.mypage.component.MyPageTopBar +import org.sopt.official.feature.mypage.model.MyPageUiModel import org.sopt.official.feature.mypage.model.MyPageUiState import org.sopt.official.feature.mypage.signOut.SignOutActivity import org.sopt.official.feature.mypage.soptamp.sentence.AdjustSentenceActivity @@ -96,6 +98,64 @@ class MyPageActivity : AppCompatActivity() { val logoutDialogState by viewModel.logoutDialogState.collectAsStateWithLifecycle() val scrollState = rememberScrollState() + val serviceSectionItems = listOf( + MyPageUiModel.Header(title = stringResource(R.string.mypage_service_info_title)), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_private_info), + onItemClick = { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(WebUrlConstant.NOTICE_PRIVATE_INFO))) } + ), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_service_rule), + onItemClick = { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(WebUrlConstant.NOTICE_SERVICE_RULE))) } + ), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_send_opinion), + onItemClick = { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(WebUrlConstant.OPINION_KAKAO_CHAT))) } + ) + ) + + val notificationSectionItems = listOf( + MyPageUiModel.Header(title = stringResource(R.string.mypage_notification_setting)), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_notification), + onItemClick = { + Intent().apply { + action = Settings.ACTION_APP_NOTIFICATION_SETTINGS + putExtra(Settings.EXTRA_APP_PACKAGE, packageName) + startActivity(this) + } + } + ) + ) + + val soptampSectionItems = listOf( + MyPageUiModel.Header(title = stringResource(R.string.mypage_soptamp_setting_title)), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_adjust_sentence), + onItemClick = { startActivity(AdjustSentenceActivity.getIntent(context)) } + ), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_reset_stamp), + onItemClick = { viewModel.updateSoptampDialog(true) } + ) + ) + + val etcSectionItems = listOf( + MyPageUiModel.Header(title = stringResource(R.string.mypage_etc_title)), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_log_out), + onItemClick = { + viewModel.updateLogoutDialog(true) + } + ), + MyPageUiModel.MyPageItem( + title = stringResource(R.string.mypage_sign_out), + onItemClick = { + startActivity(SignOutActivity.getIntent(context)) + } + ) + ) + LaunchedEffect(Unit) { args?.userActiveState?.let { viewModel.setUserActiveState(MyPageUiState.User(it)) @@ -151,46 +211,14 @@ class MyPageActivity : AppCompatActivity() { .verticalScroll(scrollState) ) { Spacer(modifier = Modifier.height(20.dp)) - ServiceInfo( - onPrivateClick = { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(WebUrlConstant.NOTICE_PRIVATE_INFO))) - }, - onServiceClick = { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(WebUrlConstant.NOTICE_SERVICE_RULE))) - }, - onOpinionClick = { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(WebUrlConstant.OPINION_KAKAO_CHAT))) - } - ) + MyPageSection(items = serviceSectionItems) Spacer(modifier = Modifier.height(16.dp)) if (isAuthenticated) { - NotificationSetting( - onNotificationClick = { - Intent().apply { - action = Settings.ACTION_APP_NOTIFICATION_SETTINGS - putExtra(Settings.EXTRA_APP_PACKAGE, packageName) - startActivity(this) - } - } - ) + MyPageSection(items = notificationSectionItems) Spacer(modifier = Modifier.height(16.dp)) - SoptampInfo( - onAdjustSentenceClick = { - startActivity(AdjustSentenceActivity.getIntent(context)) - }, - onResetStampClick = { - viewModel.updateSoptampDialog(true) - } - ) + MyPageSection(items = soptampSectionItems) Spacer(modifier = Modifier.height(16.dp)) - Etc( - onLogoutClick = { - viewModel.updateLogoutDialog(true) - }, - onSignOutClick = { - startActivity(SignOutActivity.getIntent(context)) - } - ) + MyPageSection(items = etcSectionItems) } else { EtcLogin( onLoginClick = { @@ -218,146 +246,6 @@ class MyPageActivity : AppCompatActivity() { } } -@Composable -private fun ServiceInfo( - onPrivateClick: () -> Unit, - onServiceClick: () -> Unit, - onOpinionClick: () -> Unit, - modifier: Modifier = Modifier, -) { - Column( - modifier = modifier - .padding(horizontal = 20.dp) - .background( - color = Gray900, - shape = RoundedCornerShape(10.dp) - ) - ) { - Spacer(modifier = Modifier.height(16.dp)) - Text( - text = stringResource(id = R.string.mypage_service_info_title), - style = SoptTheme.typography.label12SB, - color = Gray400, - modifier = Modifier.padding(start = 16.dp) - ) - Spacer(modifier = Modifier.height(23.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_private_info), - onButtonClick = onPrivateClick - ) - Spacer(modifier = Modifier.height(22.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_service_rule), - onButtonClick = onServiceClick - ) - Spacer(modifier = Modifier.height(22.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_send_opinion), - onButtonClick = onOpinionClick - ) - Spacer(modifier = Modifier.height(27.dp)) - } -} - -@Composable -private fun NotificationSetting( - modifier: Modifier = Modifier, - onNotificationClick: () -> Unit, -) { - Column( - modifier = modifier - .padding(horizontal = 20.dp) - .background( - color = Gray900, - shape = RoundedCornerShape(10.dp) - ) - ) { - Spacer(modifier = Modifier.height(16.dp)) - Text( - text = stringResource(id = R.string.mypage_notification_setting), - style = SoptTheme.typography.label12SB, - color = Gray400, - modifier = Modifier.padding(start = 16.dp) - ) - Spacer(modifier = Modifier.height(23.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_notification), - onButtonClick = onNotificationClick - ) - Spacer(modifier = Modifier.height(27.dp)) - } -} - -@Composable -private fun SoptampInfo( - modifier: Modifier = Modifier, - onAdjustSentenceClick: () -> Unit, - onResetStampClick: () -> Unit -) { - Column( - modifier = modifier - .padding(horizontal = 20.dp) - .background( - color = Gray900, - shape = RoundedCornerShape(10.dp) - ) - ) { - Spacer(modifier = Modifier.height(16.dp)) - Text( - text = stringResource(id = R.string.mypage_soptamp_setting_title), - style = SoptTheme.typography.label12SB, - color = Gray400, - modifier = Modifier.padding(start = 16.dp) - ) - Spacer(modifier = Modifier.height(23.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_adjust_sentence), - onButtonClick = onAdjustSentenceClick - ) - Spacer(modifier = Modifier.height(22.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_reset_stamp), - onButtonClick = onResetStampClick - ) - Spacer(modifier = Modifier.height(27.dp)) - } -} - -@Composable -private fun Etc( - modifier: Modifier = Modifier, - onLogoutClick: () -> Unit, - onSignOutClick: () -> Unit -) { - Column( - modifier = modifier - .padding(horizontal = 20.dp) - .background( - color = Gray900, - shape = RoundedCornerShape(10.dp) - ) - ) { - Spacer(modifier = Modifier.height(16.dp)) - Text( - text = stringResource(id = R.string.mypage_etc_title), - style = SoptTheme.typography.label12SB, - color = Gray400, - modifier = Modifier.padding(start = 16.dp) - ) - Spacer(modifier = Modifier.height(23.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_log_out), - onButtonClick = onLogoutClick - ) - Spacer(modifier = Modifier.height(22.dp)) - MyPageItem( - text = stringResource(id = R.string.mypage_sign_out), - onButtonClick = onSignOutClick - ) - Spacer(modifier = Modifier.height(27.dp)) - } -} - @Composable private fun EtcLogin( modifier: Modifier = Modifier,