From b3f21b94cb20deeaf889ac7afd5082c95fa2bbce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Fri, 8 Sep 2023 08:52:35 +0200 Subject: [PATCH 1/5] Add dialog previews --- .../compose/dialog/CustomDnsInfoDialog.kt | 7 +++++++ .../compose/dialog/DeviceRemovalDialog.kt | 11 +++++++++++ .../mullvadvpn/compose/dialog/DnsDialog.kt | 16 +++++++++++++++- .../dialog/LocalNetworkSharingInfoDialog.kt | 7 +++++++ .../compose/dialog/MalwareInfoDialog.kt | 7 +++++++ .../mullvadvpn/compose/dialog/MtuDialog.kt | 12 ++++++++++++ .../compose/dialog/ObfuscationInfoDialog.kt | 7 +++++++ .../dialog/QuantumResistanceInfoDialog.kt | 7 +++++++ .../compose/dialog/UdpOverTcpPortInfoDialog.kt | 7 +++++++ .../compose/dialog/WireguardPortInfoDialog.kt | 7 +++++++ 10 files changed, 87 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt index ce3a3257807c..27c974cfa89a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt @@ -2,8 +2,15 @@ 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 PreviewCustomDnsInfoDialog() { + CustomDnsInfoDialog(onDismiss = {}) +} + @Composable fun CustomDnsInfoDialog(onDismiss: () -> Unit) { InfoDialog( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt index e7564d248f06..13460d664754 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt @@ -23,6 +23,7 @@ import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import net.mullvad.mullvadvpn.R @@ -31,6 +32,16 @@ import net.mullvad.mullvadvpn.compose.component.textResource import net.mullvad.mullvadvpn.lib.common.util.capitalizeFirstCharOfEachWord import net.mullvad.mullvadvpn.model.Device +@Preview +@Composable +fun PreviewShowDeviceRemovalDialog() { + ShowDeviceRemovalDialog( + onDismiss = {}, + onConfirm = {}, + device = Device("test", "test", byteArrayOf(), "test") + ) +} + @Composable fun ShowDeviceRemovalDialog(onDismiss: () -> Unit, onConfirm: () -> Unit, device: Device) { AlertDialog( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt index f49798b68d41..7d681f8520d7 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.window.Dialog @@ -33,9 +34,22 @@ import net.mullvad.mullvadvpn.lib.theme.MullvadRed import net.mullvad.mullvadvpn.lib.theme.MullvadWhite import net.mullvad.mullvadvpn.lib.theme.MullvadWhite20 import net.mullvad.mullvadvpn.lib.theme.MullvadWhite60 +import net.mullvad.mullvadvpn.viewmodel.CustomDnsItem import net.mullvad.mullvadvpn.viewmodel.StagedDns -@OptIn(ExperimentalComposeUiApi::class) +@Preview +@Composable +fun PreviewDnsDialog() { + DnsDialog( + stagedDns = StagedDns.NewDns(CustomDnsItem.default(), StagedDns.ValidationResult.Success), + isAllowLanEnabled = true, + onIpAddressChanged = {}, + onAttemptToSave = {}, + onRemove = {}, + onDismiss = {} + ) +} + @Composable fun DnsDialog( stagedDns: StagedDns, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt index 89ef3cb3a609..512a7aca8e38 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt @@ -2,9 +2,16 @@ 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 import net.mullvad.mullvadvpn.compose.component.textResource +@Preview +@Composable +fun PreviewLocalNetworkSharingInfoDialog() { + LocalNetworkSharingInfoDialog(onDismiss = {}) +} + @Composable fun LocalNetworkSharingInfoDialog(onDismiss: () -> Unit) { InfoDialog( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt index 985b63e5c58b..0ce97775c9a2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt @@ -2,8 +2,15 @@ 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 PreviewMalwareInfoDialog() { + MalwareInfoDialog(onDismiss = {}) +} + @Composable fun MalwareInfoDialog(onDismiss: () -> Unit) { InfoDialog(message = stringResource(id = R.string.malware_info), onDismiss = onDismiss) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt index 3bf23a49c6ef..3cd4fb039dd9 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties @@ -33,6 +34,17 @@ import net.mullvad.mullvadvpn.lib.theme.AlphaInactive import net.mullvad.mullvadvpn.lib.theme.Dimens import net.mullvad.mullvadvpn.util.isValidMtu +@Preview +@Composable +fun PreviewMtuDialog() { + MtuDialog( + mtuInitial = 1234, + onSave = {}, + onRestoreDefaultValue = {}, + onDismiss = {} + ) +} + @Composable fun MtuDialog( mtuInitial: Int?, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt index 323476a034b8..602d15ee8e05 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt @@ -2,8 +2,15 @@ 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 PreviewObfuscationInfoDialog() { + ObfuscationInfoDialog(onDismiss = {}) +} + @Composable fun ObfuscationInfoDialog(onDismiss: () -> Unit) { InfoDialog(message = stringResource(id = R.string.obfuscation_info), onDismiss = onDismiss) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt index faae3fd9f707..f824e2253439 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt @@ -2,8 +2,15 @@ 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 PreviewQuantumResistanceInfoDialog() { + QuantumResistanceInfoDialog(onDismiss = {}) +} + @Composable fun QuantumResistanceInfoDialog(onDismiss: () -> Unit) { InfoDialog( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt index 223791838ae9..2cd7828e9ab6 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt @@ -2,8 +2,15 @@ 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 PreviewUdpOverTcpPortInfoDialog() { + UdpOverTcpPortInfoDialog(onDismiss = {}) +} + @Composable fun UdpOverTcpPortInfoDialog(onDismiss: () -> Unit) { InfoDialog( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt index f8ab950ae42f..db529650082b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt @@ -2,10 +2,17 @@ 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 import net.mullvad.mullvadvpn.model.PortRange import net.mullvad.mullvadvpn.util.asString +@Preview +@Composable +fun PreviewWireguardPortInfoDialog() { + WireguardPortInfoDialog(portRanges = listOf(PortRange(1, 2)), onDismiss = {}) +} + @Composable fun WireguardPortInfoDialog(portRanges: List, onDismiss: () -> Unit) { InfoDialog( From e810ba02ad3c649fd10baa53f50171f410b4bab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Fri, 8 Sep 2023 08:57:06 +0200 Subject: [PATCH 2/5] Fix padding for dialogs --- .../mullvad/mullvadvpn/compose/component/List.kt | 3 +-- .../mullvadvpn/compose/dialog/ChangelogDialog.kt | 12 +++++++----- .../mullvad/mullvadvpn/compose/dialog/DnsDialog.kt | 1 - .../mullvad/mullvadvpn/compose/dialog/InfoDialog.kt | 13 ++++--------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/List.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/List.kt index d7b550a3d0ba..d94632650936 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/List.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/List.kt @@ -149,7 +149,6 @@ fun ListItem( @Composable fun ChangeListItem(text: String) { - val smallPadding = Dimens.smallPadding ConstraintLayout { val (bullet, changeLog) = createRefs() @@ -170,7 +169,7 @@ fun ChangeListItem(text: String) { modifier = Modifier.absolutePadding(left = Dimens.mediumPadding).constrainAs(changeLog) { top.linkTo(parent.top) - bottom.linkTo(parent.bottom, margin = smallPadding) + bottom.linkTo(parent.bottom) start.linkTo(parent.start) end.linkTo(parent.end) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt index 27cc1c221ba4..e7f786b5b6a9 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt @@ -1,9 +1,9 @@ package net.mullvad.mullvadvpn.compose.dialog +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button @@ -39,13 +39,16 @@ fun ChangelogDialog(changesList: List, version: String, onDismiss: () -> ) }, text = { - Column { + Column( + modifier = Modifier.fillMaxWidth(), + verticalArrangement = + Arrangement.spacedBy(dimensionResource(id = R.dimen.small_padding)) + ) { Text( text = stringResource(R.string.changes_dialog_subtitle), fontSize = 18.sp, color = Color.White, - modifier = - Modifier.padding(vertical = dimensionResource(id = R.dimen.medium_padding)) + modifier = Modifier.fillMaxWidth() ) changesList.forEach { changeItem -> ChangeListItem(text = changeItem) } @@ -55,7 +58,6 @@ fun ChangelogDialog(changesList: List, version: String, onDismiss: () -> Button( modifier = Modifier.wrapContentHeight() - .padding(all = dimensionResource(id = R.dimen.medium_padding)) .defaultMinSize(minHeight = dimensionResource(id = R.dimen.button_height)) .fillMaxWidth(), colors = diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt index 7d681f8520d7..cedc381724a4 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt @@ -14,7 +14,6 @@ import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InfoDialog.kt index c3420bad26eb..6f22d65fb139 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InfoDialog.kt @@ -1,10 +1,9 @@ package net.mullvad.mullvadvpn.compose.dialog import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.defaultMinSize +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button @@ -58,7 +57,6 @@ fun InfoDialog(message: String, additionalInfo: String? = null, onDismiss: () -> text = { Column( horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier.padding(top = verticalSpacing) ) { Text( text = message, @@ -66,9 +64,10 @@ fun InfoDialog(message: String, additionalInfo: String? = null, onDismiss: () -> fontSize = dimensionResource(id = R.dimen.text_small).value.sp, fontStyle = FontStyle.Normal, textAlign = TextAlign.Start, - modifier = Modifier.padding(bottom = verticalSpacing).fillMaxWidth() + modifier = Modifier.fillMaxWidth() ) if (additionalInfo != null) { + Spacer(modifier = Modifier.height(verticalSpacing)) HtmlText( htmlFormattedString = additionalInfo, textColor = colorResource(id = R.color.white).toArgb(), @@ -80,11 +79,7 @@ fun InfoDialog(message: String, additionalInfo: String? = null, onDismiss: () -> }, confirmButton = { Button( - modifier = - Modifier.wrapContentHeight() - .padding(all = dimensionResource(id = R.dimen.medium_padding)) - .defaultMinSize(minHeight = dimensionResource(id = R.dimen.button_height)) - .fillMaxWidth(), + modifier = Modifier.wrapContentHeight().fillMaxWidth(), colors = ButtonDefaults.buttonColors( containerColor = colorResource(id = R.color.blue), From 4cfe0071db7468b54dbec52617e2fe5e161496fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Fri, 8 Sep 2023 15:18:10 +0200 Subject: [PATCH 3/5] Fix scoping for previews --- .../mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt | 2 +- .../mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt | 2 +- .../kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt | 2 +- .../mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt | 2 +- .../net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt | 2 +- .../kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt | 2 +- .../mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt | 2 +- .../mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt | 2 +- .../mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt | 2 +- .../mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt index 27c974cfa89a..cf9233ec94ce 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomDnsInfoDialog.kt @@ -7,7 +7,7 @@ import net.mullvad.mullvadvpn.R @Preview @Composable -fun PreviewCustomDnsInfoDialog() { +private fun PreviewCustomDnsInfoDialog() { CustomDnsInfoDialog(onDismiss = {}) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt index 13460d664754..e27af82fbda4 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceRemovalDialog.kt @@ -34,7 +34,7 @@ import net.mullvad.mullvadvpn.model.Device @Preview @Composable -fun PreviewShowDeviceRemovalDialog() { +private fun PreviewShowDeviceRemovalDialog() { ShowDeviceRemovalDialog( onDismiss = {}, onConfirm = {}, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt index cedc381724a4..7aae763574e5 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt @@ -38,7 +38,7 @@ import net.mullvad.mullvadvpn.viewmodel.StagedDns @Preview @Composable -fun PreviewDnsDialog() { +private fun PreviewDnsDialog() { DnsDialog( stagedDns = StagedDns.NewDns(CustomDnsItem.default(), StagedDns.ValidationResult.Success), isAllowLanEnabled = true, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt index 512a7aca8e38..983d0c1e04be 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/LocalNetworkSharingInfoDialog.kt @@ -8,7 +8,7 @@ import net.mullvad.mullvadvpn.compose.component.textResource @Preview @Composable -fun PreviewLocalNetworkSharingInfoDialog() { +private fun PreviewLocalNetworkSharingInfoDialog() { LocalNetworkSharingInfoDialog(onDismiss = {}) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt index 0ce97775c9a2..378e95c98e61 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MalwareInfoDialog.kt @@ -7,7 +7,7 @@ import net.mullvad.mullvadvpn.R @Preview @Composable -fun PreviewMalwareInfoDialog() { +private fun PreviewMalwareInfoDialog() { MalwareInfoDialog(onDismiss = {}) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt index 3cd4fb039dd9..735757fe82da 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt @@ -36,7 +36,7 @@ import net.mullvad.mullvadvpn.util.isValidMtu @Preview @Composable -fun PreviewMtuDialog() { +private fun PreviewMtuDialog() { MtuDialog( mtuInitial = 1234, onSave = {}, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt index 602d15ee8e05..f54eabdbafb5 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ObfuscationInfoDialog.kt @@ -7,7 +7,7 @@ import net.mullvad.mullvadvpn.R @Preview @Composable -fun PreviewObfuscationInfoDialog() { +private fun PreviewObfuscationInfoDialog() { ObfuscationInfoDialog(onDismiss = {}) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt index f824e2253439..3a20e9c80576 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/QuantumResistanceInfoDialog.kt @@ -7,7 +7,7 @@ import net.mullvad.mullvadvpn.R @Preview @Composable -fun PreviewQuantumResistanceInfoDialog() { +private fun PreviewQuantumResistanceInfoDialog() { QuantumResistanceInfoDialog(onDismiss = {}) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt index 2cd7828e9ab6..f81412799063 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/UdpOverTcpPortInfoDialog.kt @@ -7,7 +7,7 @@ import net.mullvad.mullvadvpn.R @Preview @Composable -fun PreviewUdpOverTcpPortInfoDialog() { +private fun PreviewUdpOverTcpPortInfoDialog() { UdpOverTcpPortInfoDialog(onDismiss = {}) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt index db529650082b..58ddb00e2033 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/WireguardPortInfoDialog.kt @@ -9,7 +9,7 @@ import net.mullvad.mullvadvpn.util.asString @Preview @Composable -fun PreviewWireguardPortInfoDialog() { +private fun PreviewWireguardPortInfoDialog() { WireguardPortInfoDialog(portRanges = listOf(PortRange(1, 2)), onDismiss = {}) } From 7954be6efedc041544a803f602bd95d16fb8067b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Fri, 8 Sep 2023 15:18:50 +0200 Subject: [PATCH 4/5] Use Dimens --- .../net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt index e7f786b5b6a9..860845e2f17b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt @@ -23,6 +23,7 @@ import androidx.compose.ui.unit.sp import androidx.compose.ui.window.DialogProperties import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.compose.component.ChangeListItem +import net.mullvad.mullvadvpn.lib.theme.Dimens @Composable fun ChangelogDialog(changesList: List, version: String, onDismiss: () -> Unit) { @@ -42,7 +43,7 @@ fun ChangelogDialog(changesList: List, version: String, onDismiss: () -> Column( modifier = Modifier.fillMaxWidth(), verticalArrangement = - Arrangement.spacedBy(dimensionResource(id = R.dimen.small_padding)) + Arrangement.spacedBy(Dimens.smallPadding) ) { Text( text = stringResource(R.string.changes_dialog_subtitle), From ecc2326863a41151cf86e1f981f3c9f5609952b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Mon, 11 Sep 2023 10:18:14 +0200 Subject: [PATCH 5/5] Fix lint --- .../mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt | 3 +-- .../net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt index 860845e2f17b..df31400ca28c 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt @@ -42,8 +42,7 @@ fun ChangelogDialog(changesList: List, version: String, onDismiss: () -> text = { Column( modifier = Modifier.fillMaxWidth(), - verticalArrangement = - Arrangement.spacedBy(Dimens.smallPadding) + verticalArrangement = Arrangement.spacedBy(Dimens.smallPadding) ) { Text( text = stringResource(R.string.changes_dialog_subtitle), diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt index 735757fe82da..9af996c6849c 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt @@ -37,12 +37,7 @@ import net.mullvad.mullvadvpn.util.isValidMtu @Preview @Composable private fun PreviewMtuDialog() { - MtuDialog( - mtuInitial = 1234, - onSave = {}, - onRestoreDefaultValue = {}, - onDismiss = {} - ) + MtuDialog(mtuInitial = 1234, onSave = {}, onRestoreDefaultValue = {}, onDismiss = {}) } @Composable