Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dialogs padding and spacing #5129

Merged
merged 5 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ fun ListItem(

@Composable
fun ChangeListItem(text: String) {
val smallPadding = Dimens.smallPadding

ConstraintLayout {
val (bullet, changeLog) = createRefs()
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<String>, version: String, onDismiss: () -> Unit) {
Expand All @@ -39,13 +40,15 @@ fun ChangelogDialog(changesList: List<String>, version: String, onDismiss: () ->
)
},
text = {
Column {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(Dimens.smallPadding)
) {
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) }
Expand All @@ -55,7 +58,6 @@ fun ChangelogDialog(changesList: List<String>, 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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
private fun PreviewCustomDnsInfoDialog() {
CustomDnsInfoDialog(onDismiss = {})
}

@Composable
fun CustomDnsInfoDialog(onDismiss: () -> Unit) {
InfoDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
private fun PreviewShowDeviceRemovalDialog() {
ShowDeviceRemovalDialog(
onDismiss = {},
onConfirm = {},
device = Device("test", "test", byteArrayOf(), "test")
)
}

@Composable
fun ShowDeviceRemovalDialog(onDismiss: () -> Unit, onConfirm: () -> Unit, device: Device) {
AlertDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ 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
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
Expand All @@ -33,9 +33,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
private fun PreviewDnsDialog() {
DnsDialog(
stagedDns = StagedDns.NewDns(CustomDnsItem.default(), StagedDns.ValidationResult.Success),
isAllowLanEnabled = true,
onIpAddressChanged = {},
onAttemptToSave = {},
onRemove = {},
onDismiss = {}
)
}

@Composable
fun DnsDialog(
stagedDns: StagedDns,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -58,17 +57,17 @@ fun InfoDialog(message: String, additionalInfo: String? = null, onDismiss: () ->
text = {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(top = verticalSpacing)
) {
Text(
text = message,
color = colorResource(id = R.color.white),
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(),
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
private fun PreviewLocalNetworkSharingInfoDialog() {
LocalNetworkSharingInfoDialog(onDismiss = {})
}

@Composable
fun LocalNetworkSharingInfoDialog(onDismiss: () -> Unit) {
InfoDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
private fun PreviewMalwareInfoDialog() {
MalwareInfoDialog(onDismiss = {})
}

@Composable
fun MalwareInfoDialog(onDismiss: () -> Unit) {
InfoDialog(message = stringResource(id = R.string.malware_info), onDismiss = onDismiss)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,6 +34,12 @@ import net.mullvad.mullvadvpn.lib.theme.AlphaInactive
import net.mullvad.mullvadvpn.lib.theme.Dimens
import net.mullvad.mullvadvpn.util.isValidMtu

@Preview
@Composable
private fun PreviewMtuDialog() {
MtuDialog(mtuInitial = 1234, onSave = {}, onRestoreDefaultValue = {}, onDismiss = {})
}

@Composable
fun MtuDialog(
mtuInitial: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
private fun PreviewObfuscationInfoDialog() {
ObfuscationInfoDialog(onDismiss = {})
}

@Composable
fun ObfuscationInfoDialog(onDismiss: () -> Unit) {
InfoDialog(message = stringResource(id = R.string.obfuscation_info), onDismiss = onDismiss)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
private fun PreviewQuantumResistanceInfoDialog() {
QuantumResistanceInfoDialog(onDismiss = {})
}

@Composable
fun QuantumResistanceInfoDialog(onDismiss: () -> Unit) {
InfoDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
private fun PreviewUdpOverTcpPortInfoDialog() {
UdpOverTcpPortInfoDialog(onDismiss = {})
}

@Composable
fun UdpOverTcpPortInfoDialog(onDismiss: () -> Unit) {
InfoDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
private fun PreviewWireguardPortInfoDialog() {
WireguardPortInfoDialog(portRanges = listOf(PortRange(1, 2)), onDismiss = {})
}

@Composable
fun WireguardPortInfoDialog(portRanges: List<PortRange>, onDismiss: () -> Unit) {
InfoDialog(
Expand Down
Loading