diff --git a/core/ui/src/main/kotlin/com/nexters/ilab/core/ui/component/Dialog.kt b/core/ui/src/main/kotlin/com/nexters/ilab/core/ui/component/Dialog.kt index 6596a95..bdbaa2a 100644 --- a/core/ui/src/main/kotlin/com/nexters/ilab/core/ui/component/Dialog.kt +++ b/core/ui/src/main/kotlin/com/nexters/ilab/core/ui/component/Dialog.kt @@ -1,5 +1,7 @@ package com.nexters.ilab.core.ui.component +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -33,13 +35,13 @@ import com.nexters.ilab.core.ui.ComponentPreview @OptIn(ExperimentalMaterial3Api::class) @Composable fun ILabDialog( - titleResId: Int, - iconResId: Int?, + @StringRes titleResId: Int, + @DrawableRes iconResId: Int?, iconDescription: String?, - firstDescriptionResId: Int, - secondDescriptionResId: Int?, - cancelTextResId: Int?, - confirmTextResId: Int, + @StringRes firstDescriptionResId: Int, + @StringRes secondDescriptionResId: Int?, + @StringRes cancelTextResId: Int?, + @StringRes confirmTextResId: Int, onCancelClick: () -> Unit, onConfirmClick: () -> Unit, modifier: Modifier = Modifier, @@ -113,7 +115,13 @@ fun ILabDialog( modifier = Modifier .weight(1f) .height(48.dp) - .padding(start = 4.dp), + .then( + if (cancelTextResId != null) { + Modifier.padding(start = 4.dp) + } else { + Modifier + }, + ), text = { Text( text = stringResource(id = confirmTextResId), @@ -161,9 +169,11 @@ fun NetworkErrorDialog( ) } -@ComponentPreview @Composable -fun CreateImageStopDialogPreview() { +fun CreateImageStopDialog( + onCancelClick: () -> Unit, + onConfirmClick: () -> Unit, +) { ILabDialog( titleResId = R.string.creating_image_stop_confirmation, iconResId = null, @@ -172,41 +182,50 @@ fun CreateImageStopDialogPreview() { secondDescriptionResId = R.string.creating_image_stop_warning_description2, cancelTextResId = R.string.creating_image_stop_confirm, confirmTextResId = R.string.creating_image_continue, - onCancelClick = {}, - onConfirmClick = {}, + onCancelClick = onCancelClick, + onConfirmClick = onConfirmClick, + ) +} + +@Composable +fun DeleteAccountDialog( + onCancelClick: () -> Unit, + onConfirmClick: () -> Unit, +) { + ILabDialog( + titleResId = R.string.setting_delete_account, + iconResId = R.drawable.ic_warning, + iconDescription = "Warning Icon", + firstDescriptionResId = R.string.setting_delete_account_description, + secondDescriptionResId = null, + cancelTextResId = R.string.setting_delete_account_cancel, + confirmTextResId = R.string.setting_delete_account_confirm, + onCancelClick = onCancelClick, + onConfirmClick = onConfirmClick, ) } @ComponentPreview @Composable -fun DeleteAccountDialogPreview() { +fun ServerErrorDialogPreview() { ILabTheme { - ILabDialog( - titleResId = R.string.setting_delete_account, - iconResId = R.drawable.ic_warning, - iconDescription = "Warning Icon", - firstDescriptionResId = R.string.setting_delete_account_description, - secondDescriptionResId = null, - cancelTextResId = R.string.setting_delete_account_cancel, - confirmTextResId = R.string.setting_delete_account_confirm, - onCancelClick = {}, - onConfirmClick = {}, - ) + ServerErrorDialog(onRetryClick = {}) } } @ComponentPreview @Composable -fun ServerErrorDialogPreview() { +fun NetworkErrorDialogPreview() { ILabTheme { - ILabDialog( - titleResId = R.string.server_error_title, - iconResId = R.drawable.ic_server_error, - iconDescription = "Network Error Icon", - firstDescriptionResId = R.string.server_error_description1, - secondDescriptionResId = R.string.server_error_description2, - confirmTextResId = R.string.retry, - cancelTextResId = null, + NetworkErrorDialog(onRetryClick = {}) + } +} + +@ComponentPreview +@Composable +fun CreateImageStopDialogPreview() { + ILabTheme { + CreateImageStopDialog( onCancelClick = {}, onConfirmClick = {}, ) @@ -215,16 +234,9 @@ fun ServerErrorDialogPreview() { @ComponentPreview @Composable -fun NetworkErrorDialogPreview() { +fun DeleteAccountDialogPreview() { ILabTheme { - ILabDialog( - titleResId = R.string.network_error_title, - iconResId = R.drawable.ic_network_error, - iconDescription = "Network Error Icon", - firstDescriptionResId = R.string.network_error_description1, - secondDescriptionResId = R.string.network_error_description2, - confirmTextResId = R.string.retry, - cancelTextResId = null, + DeleteAccountDialog( onCancelClick = {}, onConfirmClick = {}, ) diff --git a/feature/createimage/src/main/kotlin/com/nexters/ilab/feature/createimage/CreateImageScreen.kt b/feature/createimage/src/main/kotlin/com/nexters/ilab/feature/createimage/CreateImageScreen.kt index 88ffe16..8aed366 100644 --- a/feature/createimage/src/main/kotlin/com/nexters/ilab/feature/createimage/CreateImageScreen.kt +++ b/feature/createimage/src/main/kotlin/com/nexters/ilab/feature/createimage/CreateImageScreen.kt @@ -36,7 +36,7 @@ import com.nexters.ilab.android.core.designsystem.theme.ILabTheme import com.nexters.ilab.android.core.designsystem.theme.Subtitle2 import com.nexters.ilab.android.core.designsystem.theme.Title1 import com.nexters.ilab.core.ui.DevicePreview -import com.nexters.ilab.core.ui.component.ILabDialog +import com.nexters.ilab.core.ui.component.CreateImageStopDialog import com.nexters.ilab.core.ui.component.ILabTopAppBar import com.nexters.ilab.core.ui.component.LoadingImage import com.nexters.ilab.core.ui.component.NetworkErrorDialog @@ -208,24 +208,6 @@ private fun CreateImageContent(creatingImageWaitText: String) { } } -@Composable -private fun CreateImageStopDialog( - onCancelClick: () -> Unit, - onConfirmClick: () -> Unit, -) { - ILabDialog( - titleResId = R.string.creating_image_stop_confirmation, - iconResId = null, - iconDescription = null, - firstDescriptionResId = R.string.creating_image_stop_warning_description1, - secondDescriptionResId = R.string.creating_image_stop_warning_description2, - cancelTextResId = R.string.creating_image_stop_confirm, - confirmTextResId = R.string.creating_image_continue, - onCancelClick = onCancelClick, - onConfirmClick = onConfirmClick, - ) -} - @DevicePreview @Composable fun CreateImageScreenPreview() { diff --git a/feature/setting/src/main/kotlin/com/nexters/ilab/android/feature/setting/SettingScreen.kt b/feature/setting/src/main/kotlin/com/nexters/ilab/android/feature/setting/SettingScreen.kt index 669eaf9..cec1a3c 100644 --- a/feature/setting/src/main/kotlin/com/nexters/ilab/android/feature/setting/SettingScreen.kt +++ b/feature/setting/src/main/kotlin/com/nexters/ilab/android/feature/setting/SettingScreen.kt @@ -36,7 +36,7 @@ import com.nexters.ilab.android.feature.setting.viewmodel.SettingSideEffect import com.nexters.ilab.android.feature.setting.viewmodel.SettingState import com.nexters.ilab.android.feature.setting.viewmodel.SettingViewModel import com.nexters.ilab.core.ui.DevicePreview -import com.nexters.ilab.core.ui.component.ILabDialog +import com.nexters.ilab.core.ui.component.DeleteAccountDialog import com.nexters.ilab.core.ui.component.ILabTopAppBar import com.nexters.ilab.core.ui.component.TopAppBarNavigationType @@ -224,24 +224,6 @@ internal fun SettingTopAppBar(onBackClick: () -> Unit) { ) } -@Composable -internal fun DeleteAccountDialog( - onCancelClick: () -> Unit, - onConfirmClick: () -> Unit, -) { - ILabDialog( - titleResId = R.string.setting_delete_account, - iconResId = R.drawable.ic_warning, - iconDescription = "Warning Icon", - firstDescriptionResId = R.string.setting_delete_account_description, - secondDescriptionResId = null, - cancelTextResId = R.string.setting_delete_account_cancel, - confirmTextResId = R.string.setting_delete_account_confirm, - onCancelClick = onCancelClick, - onConfirmClick = onConfirmClick, - ) -} - @DevicePreview @Composable fun SettingScreenPreview() {