-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add payment support to account screen
- Loading branch information
Showing
13 changed files
with
284 additions
and
20 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
26 changes: 26 additions & 0 deletions
26
...id/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/PaymentBillingErrorDialog.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,26 @@ | ||
package net.mullvad.mullvadvpn.compose.dialog | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import net.mullvad.mullvadvpn.R | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewPaymentBillingErrorDialog() { | ||
PaymentBillingErrorDialog(onTryAgain = {}, onClose = {}) | ||
} | ||
|
||
@Composable | ||
fun PaymentBillingErrorDialog(onTryAgain: () -> Unit, onClose: () -> Unit) { | ||
PaymentDialog( | ||
title = stringResource(id = R.string.payment_billing_error_dialog_title), | ||
message = stringResource(id = R.string.payment_billing_error_dialog_message), | ||
icon = R.drawable.icon_fail, | ||
onConfirmClick = onClose, | ||
confirmText = stringResource(id = R.string.cancel), | ||
onDismissRequest = onClose, | ||
dismissText = stringResource(id = R.string.try_again), | ||
onDismissClick = onTryAgain | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/PaymentCompletedDialog.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,24 @@ | ||
package net.mullvad.mullvadvpn.compose.dialog | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import net.mullvad.mullvadvpn.R | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewPaymentCompletedDialog() { | ||
PaymentCompletedDialog {} | ||
} | ||
|
||
@Composable | ||
fun PaymentCompletedDialog(onClose: () -> Unit) { | ||
PaymentDialog( | ||
title = stringResource(id = R.string.payment_completed_dialog_title), | ||
message = stringResource(id = R.string.payment_completed_dialog_message), | ||
icon = R.drawable.icon_success, | ||
onConfirmClick = onClose, | ||
confirmText = stringResource(id = R.string.got_it), | ||
onDismissRequest = onClose | ||
) | ||
} |
88 changes: 88 additions & 0 deletions
88
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/PaymentDialog.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,88 @@ | ||
package net.mullvad.mullvadvpn.compose.dialog | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import net.mullvad.mullvadvpn.R | ||
import net.mullvad.mullvadvpn.compose.button.ActionButton | ||
import net.mullvad.mullvadvpn.lib.theme.AlphaDescription | ||
import net.mullvad.mullvadvpn.lib.theme.Dimens | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewPaymentDialog() { | ||
PaymentDialog( | ||
title = "Payment was unsuccessful", | ||
message = "We were unable to verify your paymenmt, please try again", | ||
icon = R.drawable.icon_fail, | ||
onConfirmClick = {}, | ||
confirmText = "Cancel", | ||
onDismissRequest = {}, | ||
dismissText = "Try again", | ||
onDismissClick = {}, | ||
) | ||
} | ||
|
||
@Composable | ||
fun PaymentDialog( | ||
title: String, | ||
message: String, | ||
icon: Int, | ||
onConfirmClick: () -> Unit, | ||
confirmText: String, | ||
dismissText: String? = null, | ||
onDismissClick: () -> Unit = {}, | ||
onDismissRequest: () -> Unit | ||
) { | ||
AlertDialog( | ||
title = { | ||
Column { | ||
Icon( | ||
modifier = Modifier.fillMaxWidth().height(Dimens.iconHeight), | ||
painter = painterResource(id = icon), | ||
contentDescription = "" | ||
) | ||
Text(text = title, style = MaterialTheme.typography.headlineSmall) | ||
} | ||
}, | ||
text = { Text(text = message, style = MaterialTheme.typography.bodySmall) }, | ||
containerColor = MaterialTheme.colorScheme.background, | ||
titleContentColor = MaterialTheme.colorScheme.onBackground, | ||
textContentColor = MaterialTheme.colorScheme.onBackground.copy(alpha = AlphaDescription), | ||
onDismissRequest = onDismissRequest, | ||
dismissButton = { | ||
dismissText?.let { | ||
ActionButton( | ||
text = dismissText, | ||
onClick = onDismissClick, | ||
colors = | ||
ButtonDefaults.buttonColors( | ||
containerColor = MaterialTheme.colorScheme.error, | ||
contentColor = MaterialTheme.colorScheme.onError, | ||
) | ||
) | ||
} | ||
}, | ||
confirmButton = { | ||
ActionButton( | ||
colors = | ||
ButtonDefaults.buttonColors( | ||
containerColor = MaterialTheme.colorScheme.primary, | ||
contentColor = MaterialTheme.colorScheme.onPrimary, | ||
), | ||
text = confirmText, | ||
onClick = onConfirmClick | ||
) | ||
} | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
...p/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/PaymentVerificationErrorDialog.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,26 @@ | ||
package net.mullvad.mullvadvpn.compose.dialog | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import net.mullvad.mullvadvpn.R | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewPaymentVerificationErrorDialog() { | ||
PaymentVerificationErrorDialog(onTryAgain = {}, onClose = {}) | ||
} | ||
|
||
@Composable | ||
fun PaymentVerificationErrorDialog(onTryAgain: () -> Unit, onClose: () -> Unit) { | ||
PaymentDialog( | ||
title = stringResource(id = R.string.payment_verification_error_dialog_title), | ||
message = stringResource(id = R.string.payment_verification_error_dialog_message), | ||
icon = R.drawable.icon_fail, | ||
onConfirmClick = onClose, | ||
confirmText = stringResource(id = R.string.cancel), | ||
onDismissRequest = onClose, | ||
dismissText = stringResource(id = R.string.try_again), | ||
onDismissClick = onTryAgain | ||
) | ||
} |
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
Oops, something went wrong.