Skip to content

Commit

Permalink
Merge pull request #18470 from wordpress-mobile/feature/enable-accoun…
Browse files Browse the repository at this point in the history
…t-closure--fix-stale-dialog-height-issue

Fix stale height issue in account closure dialog
  • Loading branch information
Antonis Lilis authored May 19, 2023
2 parents ad4e0b3 + 4c1190b commit 2929cc5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,6 +56,7 @@ fun DialogUi(
.focusRequester(focusRequester),
value = username,
onValueChange = { username = it },
enabled = !isPending,
)
Row(
modifier = Modifier
Expand Down Expand Up @@ -92,6 +94,7 @@ fun DialogUi(
}
}

@OptIn(ExperimentalComposeUiApi::class)
@Preview
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
Expand Down

0 comments on commit 2929cc5

Please sign in to comment.