From 1a980f4dbbe9cbf435ac28e15aaf4075c58dfee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Mon, 2 Oct 2023 14:31:03 +0200 Subject: [PATCH] Remove report problem state dialog --- .../dialog/ReportProblemStateDialog.kt | 216 ------------------ .../compose/screen/ReportProblemScreen.kt | 21 +- .../compose/screen/ViewLogsScreen.kt | 4 +- .../lib/theme/dimensions/Dimensions.kt | 2 +- 4 files changed, 9 insertions(+), 234 deletions(-) delete mode 100644 android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemStateDialog.kt diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemStateDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemStateDialog.kt deleted file mode 100644 index f58552c671a3..000000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ReportProblemStateDialog.kt +++ /dev/null @@ -1,216 +0,0 @@ -package net.mullvad.mullvadvpn.compose.dialog - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.size -import androidx.compose.material3.AlertDialog -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.SpanStyle -import androidx.compose.ui.text.buildAnnotatedString -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.withStyle -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.window.DialogProperties -import net.mullvad.mullvadvpn.R -import net.mullvad.mullvadvpn.compose.button.ActionButton -import net.mullvad.mullvadvpn.lib.theme.AppTheme -import net.mullvad.mullvadvpn.lib.theme.Dimens -import net.mullvad.mullvadvpn.viewmodel.SendingReportUiState - -@Composable -fun ShowReportProblemState( - sendingState: SendingReportUiState, - onDismiss: () -> Unit, - onClearForm: () -> Unit, - retry: () -> Unit -) { - when (sendingState) { - SendingReportUiState.Sending -> ReportProblemSendingDialog() - is SendingReportUiState.Error -> - ReportProblemErrorDialog(onDismiss = onDismiss, retry = retry) - is SendingReportUiState.Success -> - ReportProblemSuccessDialog( - sendingState.email, - onConfirm = { - onClearForm() - onDismiss() - } - ) - } -} - -@Preview -@Composable -private fun PreviewReportProblemSendingDialog() { - AppTheme { ReportProblemSendingDialog() } -} - -@Composable -private fun ReportProblemSendingDialog() { - AlertDialog( - onDismissRequest = {}, - icon = { - CircularProgressIndicator( - color = MaterialTheme.colorScheme.onPrimary, - modifier = Modifier.size(Dimens.progressIndicatorSize) - ) - }, - title = { Text(text = stringResource(id = R.string.sending)) }, - confirmButton = {}, - properties = - DialogProperties( - dismissOnClickOutside = false, - dismissOnBackPress = false, - ), - containerColor = MaterialTheme.colorScheme.background - ) -} - -@Preview -@Composable -private fun PreviewReportProblemSuccessDialog() { - AppTheme { - ReportProblemSuccessDialog( - "Email@em.com", - onConfirm = {}, - ) - } -} - -@Composable -fun ReportProblemSuccessDialog(email: String?, onConfirm: () -> Unit) { - AlertDialog( - onDismissRequest = { onConfirm() }, - icon = { - Icon( - painter = painterResource(id = R.drawable.icon_success), - contentDescription = stringResource(id = R.string.sent), - modifier = Modifier.size(Dimens.dialogIconHeight), - tint = Color.Unspecified - ) - }, - title = { Text(text = stringResource(id = R.string.sent)) }, - text = { - Column { - Text( - text = - buildAnnotatedString { - withStyle(SpanStyle(color = MaterialTheme.colorScheme.surface)) { - append(stringResource(id = R.string.sent_thanks)) - } - append(" ") - withStyle(SpanStyle(color = MaterialTheme.colorScheme.onPrimary)) { - append(stringResource(id = R.string.we_will_look_into_this)) - } - }, - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.fillMaxWidth() - ) - - Spacer(modifier = Modifier.height(Dimens.smallPadding)) - email?.let { - val emailTemplate = stringResource(R.string.sent_contact) - val annotatedEmailString = - remember(it) { - val emailStart = emailTemplate.indexOf('%') - - buildAnnotatedString { - append(emailTemplate.substring(0, emailStart)) - withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { append(email) } - } - } - - Text( - text = annotatedEmailString, - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.fillMaxWidth() - ) - } - } - }, - confirmButton = { - ActionButton( - modifier = Modifier.fillMaxWidth(), - colors = - ButtonDefaults.buttonColors( - containerColor = MaterialTheme.colorScheme.primary, - contentColor = MaterialTheme.colorScheme.onPrimary, - ), - onClick = { onConfirm() }, - text = stringResource(id = R.string.dismiss) - ) - }, - containerColor = MaterialTheme.colorScheme.background, - ) -} - -@Preview -@Composable -private fun PreviewReportProblemErrorDialog() { - AppTheme { - ReportProblemErrorDialog( - onDismiss = {}, - retry = {}, - ) - } -} - -@Composable -fun ReportProblemErrorDialog(onDismiss: () -> Unit, retry: () -> Unit) { - AlertDialog( - onDismissRequest = onDismiss, - icon = { - Icon( - painter = painterResource(id = R.drawable.icon_fail), - contentDescription = stringResource(id = R.string.failed_to_send), - modifier = Modifier.size(Dimens.dialogIconHeight), - tint = Color.Unspecified - ) - }, - title = { Text(text = stringResource(id = R.string.failed_to_send)) }, - text = { - Text( - text = stringResource(id = R.string.failed_to_send_details), - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.fillMaxWidth() - ) - }, - dismissButton = { - ActionButton( - modifier = Modifier.fillMaxWidth(), - colors = - ButtonDefaults.buttonColors( - containerColor = MaterialTheme.colorScheme.primary, - contentColor = MaterialTheme.colorScheme.onPrimary, - ), - onClick = onDismiss, - text = stringResource(id = R.string.edit_message) - ) - }, - confirmButton = { - ActionButton( - modifier = Modifier.fillMaxWidth(), - colors = - ButtonDefaults.buttonColors( - containerColor = MaterialTheme.colorScheme.surface, - contentColor = MaterialTheme.colorScheme.onPrimary, - ), - onClick = retry, - text = stringResource(id = R.string.try_again) - ) - }, - containerColor = MaterialTheme.colorScheme.background - ) -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt index f536523ccf22..4d524c28dca1 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ReportProblemScreen.kt @@ -49,13 +49,13 @@ import net.mullvad.mullvadvpn.viewmodel.SendingReportUiState @Preview @Composable -private fun ReportProblemScreenPreview() { +private fun PreviewReportProblemScreen() { AppTheme { ReportProblemScreen(uiState = ReportProblemUiState()) } } @Preview @Composable -private fun ReportProblemSendingScreenPreview() { +private fun PreviewReportProblemSendingScreen() { AppTheme { ReportProblemScreen(uiState = ReportProblemUiState(false, SendingReportUiState.Sending)) } @@ -63,13 +63,13 @@ private fun ReportProblemSendingScreenPreview() { @Preview @Composable -private fun ReportProblemConfirmNoEmailScreenPreview() { +private fun PreviewReportProblemConfirmNoEmailScreen() { AppTheme { ReportProblemScreen(uiState = ReportProblemUiState(true)) } } @Preview @Composable -private fun ReportProblemSuccessScreenPreview() { +private fun PreviewReportProblemSuccessScreen() { AppTheme { ReportProblemScreen( uiState = ReportProblemUiState(false, SendingReportUiState.Success("email@mail.com")) @@ -79,7 +79,7 @@ private fun ReportProblemSuccessScreenPreview() { @Preview @Composable -private fun ReportProblemErrorScreenPreview() { +private fun PreviewReportProblemErrorScreen() { AppTheme { ReportProblemScreen( uiState = @@ -127,7 +127,7 @@ fun ReportProblemScreen( var email by rememberSaveable { mutableStateOf("") } var description by rememberSaveable { mutableStateOf("") } - // Dialog to show sending states + // Show sending states if (uiState.sendingState != null) { Column( modifier = @@ -140,15 +140,6 @@ fun ReportProblemScreen( ErrorContent({ onSendReport(email, description) }, onClearSendResult) is SendingReportUiState.Success -> SentContent(uiState.sendingState) } - // ShowReportProblemState( - // uiState.sendingState, - // onDismiss = onClearSendResult, - // onClearForm = { - // email = "" - // description = "" - // }, - // retry = { onSendReport(email, description) } - // ) return@CollapsingToolbarScaffold } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt index 53c3f9ff0c1e..091d19f480a3 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ViewLogsScreen.kt @@ -29,13 +29,13 @@ import net.mullvad.mullvadvpn.viewmodel.ViewLogsUiState @Preview @Composable -private fun ViewLogsScreenPreview() { +private fun PreviewViewLogsScreen() { AppTheme { ViewLogsScreen(uiState = ViewLogsUiState("Lorem ipsum")) } } @Preview @Composable -private fun ViewLogsLoadingScreenPreview() { +private fun PreviewViewLogsLoadingScreen() { AppTheme { ViewLogsScreen(uiState = ViewLogsUiState()) } } diff --git a/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt b/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt index 7e32466b8926..c3fd722a1240 100644 --- a/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt +++ b/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt @@ -20,6 +20,7 @@ data class Dimensions( val countryRowPadding: Dp = 18.dp, val customPortBoxMinWidth: Dp = 80.dp, val dialogIconHeight: Dp = 44.dp, + val dialogIconSize: Dp = 48.dp, val expandableCellChevronSize: Dp = 30.dp, val iconFailSuccessSize: Dp = 60.dp, val iconFailSuccessTopMargin: Dp = 30.dp, @@ -58,7 +59,6 @@ data class Dimensions( val topBarHeight: Dp = 64.dp, val verticalSpace: Dp = 20.dp, val verticalSpacer: Dp = 1.dp, - val dialogIconSize: Dp = 48.dp ) val defaultDimensions = Dimensions()