diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/AccountSettingsViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/AccountSettingsViewModel.kt index 743af4cdb045..420f6f3ca08f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/AccountSettingsViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/AccountSettingsViewModel.kt @@ -333,18 +333,17 @@ class AccountSettingsViewModel @Inject constructor( _accountClosureUiState.value = uiState.copy(isPending = true) launch { - accountClosureUseCase.closeAccount( - onResult = { - when(it) { - is CloseAccountResult.Success -> { - _accountClosureUiState.value = Success - } - is CloseAccountResult.Failure -> { - _accountClosureUiState.value = Error(it.error.errorType) - } + accountClosureUseCase.closeAccount { result -> + when (result) { + is CloseAccountResult.Success -> { + _accountClosureUiState.value = Success + } + + is CloseAccountResult.Failure -> { + _accountClosureUiState.value = Error(result.error.errorType) } } - ) + } } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureDialog.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureDialog.kt index 3e3013a1d3f4..9d1c2d019770 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureDialog.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureDialog.kt @@ -4,23 +4,33 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable +import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties +@OptIn(ExperimentalComposeUiApi::class) @Composable fun AccountClosureDialog( onDismissRequest: () -> Unit, content: @Composable ColumnScope.() -> Unit, ) { val padding = 10.dp - Dialog(onDismissRequest = onDismissRequest) { + Dialog( + onDismissRequest = onDismissRequest, + properties = DialogProperties( + usePlatformDefaultWidth = false, + ), + ) { Column( modifier = Modifier + .widthIn(max = 320.dp) .clip(shape = RoundedCornerShape(padding)) .background(MaterialTheme.colors.background) .padding(padding), diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureUi.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureUi.kt index 4a595644280b..43f742a29d33 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureUi.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureUi.kt @@ -2,11 +2,13 @@ package org.wordpress.android.ui.prefs.accountsettings.components import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState +import androidx.compose.ui.ExperimentalComposeUiApi import org.wordpress.android.ui.prefs.accountsettings.AccountSettingsViewModel import org.wordpress.android.ui.prefs.accountsettings.AccountSettingsViewModel.AccountClosureUiState.Opened import org.wordpress.android.ui.prefs.accountsettings.AccountSettingsViewModel.Companion.AccountClosureAction.ACCOUNT_CLOSED import org.wordpress.android.ui.prefs.accountsettings.AccountSettingsViewModel.Companion.AccountClosureAction.HELP_VIEWED +@OptIn(ExperimentalComposeUiApi::class) @Composable fun AccountClosureUi(viewModel: AccountSettingsViewModel) { val uiState = viewModel.accountClosureUiState.collectAsState() diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/DialogUi.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/DialogUi.kt index d10ce9ca8d1a..7f2c7fa0a1d7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/DialogUi.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/accountsettings/components/DialogUi.kt @@ -17,6 +17,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester @@ -55,6 +56,7 @@ fun DialogUi( .focusRequester(focusRequester), value = username, onValueChange = { username = it }, + enabled = !isPending, ) Row( modifier = Modifier @@ -92,6 +94,7 @@ fun DialogUi( } } +@OptIn(ExperimentalComposeUiApi::class) @Preview @Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable