-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18412 from wordpress-mobile/feature/enable-accoun…
…t-closure Enable account closure
- Loading branch information
Showing
20 changed files
with
739 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...in/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.wordpress.android.ui.prefs.accountsettings.components | ||
|
||
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.shape.RoundedCornerShape | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Dialog | ||
|
||
@Composable | ||
fun AccountClosureDialog( | ||
onDismissRequest: () -> Unit, | ||
content: @Composable ColumnScope.() -> Unit, | ||
) { | ||
val padding = 10.dp | ||
Dialog(onDismissRequest = onDismissRequest) { | ||
Column( | ||
modifier = Modifier | ||
.clip(shape = RoundedCornerShape(padding)) | ||
.background(MaterialTheme.colors.background) | ||
.padding(padding), | ||
content = content, | ||
) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...c/main/java/org/wordpress/android/ui/prefs/accountsettings/components/AccountClosureUi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.wordpress.android.ui.prefs.accountsettings.components | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
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 | ||
|
||
@Composable | ||
fun AccountClosureUi(viewModel: AccountSettingsViewModel) { | ||
val uiState = viewModel.accountClosureUiState.collectAsState() | ||
|
||
CloseAccountButton(onClick = { viewModel.openAccountClosureDialog() }) | ||
|
||
(uiState.value as? Opened)?.let { | ||
AccountClosureDialog( | ||
onDismissRequest = { viewModel.dismissAccountClosureDialog() }, | ||
) { | ||
when(it) { | ||
is Opened.Default -> it.username?.let { currentUsername -> | ||
DialogUi( | ||
currentUsername = currentUsername, | ||
isPending = it.isPending, | ||
onCancel = { viewModel.dismissAccountClosureDialog() }, | ||
onConfirm = { viewModel.closeAccount() }, | ||
) | ||
} | ||
|
||
is Opened.Error -> DialogErrorUi( | ||
onDismissRequest = { viewModel.dismissAccountClosureDialog() }, | ||
onHelpRequested = { viewModel.userAction(HELP_VIEWED) }, | ||
it.errorType, | ||
) | ||
is Opened.Success -> DialogSuccessUi( | ||
onDismissRequest = { viewModel.userAction(ACCOUNT_CLOSED) } | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.