-
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.
- Loading branch information
Showing
37 changed files
with
1,290 additions
and
15 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
20 changes: 20 additions & 0 deletions
20
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/InfoIconButton.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,20 @@ | ||
package net.mullvad.mullvadvpn.compose.button | ||
|
||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import net.mullvad.mullvadvpn.R | ||
|
||
@Composable | ||
fun InfoIconButton(onClick: () -> Unit, modifier: Modifier = Modifier) { | ||
IconButton(modifier = modifier, onClick = onClick) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.icon_info), | ||
contentDescription = null, | ||
tint = MaterialTheme.colorScheme.onPrimary | ||
) | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/ServerIpOverridesCell.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,81 @@ | ||
package net.mullvad.mullvadvpn.compose.cell | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.wrapContentHeight | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.alpha | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import net.mullvad.mullvadvpn.R | ||
import net.mullvad.mullvadvpn.lib.theme.AppTheme | ||
import net.mullvad.mullvadvpn.lib.theme.Dimens | ||
import net.mullvad.mullvadvpn.lib.theme.color.AlphaInactive | ||
import net.mullvad.mullvadvpn.lib.theme.color.AlphaVisible | ||
import net.mullvad.mullvadvpn.lib.theme.color.selected | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewServerIpOverridesCell() { | ||
AppTheme { ServerIpOverridesCell(active = true) } | ||
} | ||
|
||
@Composable | ||
fun ServerIpOverridesCell( | ||
active: Boolean, | ||
modifier: Modifier = Modifier, | ||
activeColor: Color = MaterialTheme.colorScheme.selected, | ||
inactiveColor: Color = MaterialTheme.colorScheme.error, | ||
) { | ||
Row( | ||
modifier = | ||
modifier | ||
.wrapContentHeight() | ||
.height(IntrinsicSize.Min) | ||
.background(MaterialTheme.colorScheme.primary) | ||
.padding(horizontal = Dimens.sideMargin) | ||
.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Box( | ||
modifier = | ||
Modifier.size(Dimens.relayCircleSize) | ||
.background( | ||
color = | ||
when { | ||
active -> activeColor | ||
else -> inactiveColor | ||
}, | ||
shape = CircleShape | ||
) | ||
) | ||
Text( | ||
text = | ||
if (active) stringResource(id = R.string.server_ip_overrides_active) | ||
else stringResource(id = R.string.server_ip_overrides_inactive), | ||
color = MaterialTheme.colorScheme.onPrimary, | ||
modifier = | ||
Modifier.weight(1f) | ||
.alpha( | ||
if (active) { | ||
AlphaVisible | ||
} else { | ||
AlphaInactive | ||
} | ||
) | ||
.padding(horizontal = Dimens.smallPadding, vertical = Dimens.mediumPadding) | ||
) | ||
} | ||
} |
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
66 changes: 66 additions & 0 deletions
66
.../kotlin/net/mullvad/mullvadvpn/compose/dialog/ResetServerIpOverridesConfirmationDialog.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,66 @@ | ||
package net.mullvad.mullvadvpn.compose.dialog | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.ramcosta.composedestinations.annotation.Destination | ||
import com.ramcosta.composedestinations.result.EmptyResultBackNavigator | ||
import com.ramcosta.composedestinations.result.ResultBackNavigator | ||
import com.ramcosta.composedestinations.spec.DestinationStyle | ||
import net.mullvad.mullvadvpn.R | ||
import net.mullvad.mullvadvpn.compose.button.NegativeButton | ||
import net.mullvad.mullvadvpn.compose.button.PrimaryButton | ||
import net.mullvad.mullvadvpn.lib.theme.AppTheme | ||
import net.mullvad.mullvadvpn.lib.theme.Dimens | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewResetServerIpOverridesConfirmationDialog() { | ||
AppTheme { ResetServerIpOverridesConfirmationDialog(EmptyResultBackNavigator()) } | ||
} | ||
|
||
@Destination(style = DestinationStyle.Dialog::class) | ||
@Composable | ||
fun ResetServerIpOverridesConfirmationDialog( | ||
resultNavigator: ResultBackNavigator<Boolean>, | ||
) { | ||
AlertDialog( | ||
containerColor = MaterialTheme.colorScheme.background, | ||
confirmButton = { | ||
Column(verticalArrangement = Arrangement.spacedBy(Dimens.buttonSpacing)) { | ||
NegativeButton( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = stringResource(id = R.string.server_ip_overrides_reset_reset_button), | ||
onClick = { resultNavigator.navigateBack(result = true) } | ||
) | ||
|
||
PrimaryButton( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = stringResource(R.string.cancel), | ||
onClick = resultNavigator::navigateBack | ||
) | ||
} | ||
}, | ||
title = { | ||
Text( | ||
text = stringResource(id = R.string.server_ip_overrides_reset_title), | ||
color = MaterialTheme.colorScheme.onPrimary | ||
) | ||
}, | ||
text = { | ||
Text( | ||
text = stringResource(id = R.string.server_ip_overrides_reset_body), | ||
color = MaterialTheme.colorScheme.onPrimary, | ||
style = MaterialTheme.typography.bodySmall, | ||
) | ||
}, | ||
onDismissRequest = resultNavigator::navigateBack | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
.../app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ServerIpOverridesInfoDialog.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,32 @@ | ||
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 com.ramcosta.composedestinations.annotation.Destination | ||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator | ||
import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator | ||
import com.ramcosta.composedestinations.spec.DestinationStyle | ||
import net.mullvad.mullvadvpn.R | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewServerIpOverridesInfoDialog() { | ||
ServerIpOverridesInfoDialog(EmptyDestinationsNavigator) | ||
} | ||
|
||
@Destination(style = DestinationStyle.Dialog::class) | ||
@Composable | ||
fun ServerIpOverridesInfoDialog(navigator: DestinationsNavigator) { | ||
InfoDialog( | ||
message = | ||
buildString { | ||
appendLine(stringResource(id = R.string.server_ip_overrides_info_first_paragraph)) | ||
appendLine() | ||
appendLine(stringResource(id = R.string.server_ip_overrides_info_second_paragraph)) | ||
appendLine() | ||
append(stringResource(id = R.string.server_ip_overrides_info_third_paragraph)) | ||
}, | ||
onDismiss = navigator::navigateUp | ||
) | ||
} |
92 changes: 92 additions & 0 deletions
92
.../app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ImportOverridesByTextScreen.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,92 @@ | ||
package net.mullvad.mullvadvpn.compose.screen | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Close | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.material3.TextField | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.ramcosta.composedestinations.annotation.Destination | ||
import com.ramcosta.composedestinations.result.ResultBackNavigator | ||
import net.mullvad.mullvadvpn.R | ||
import net.mullvad.mullvadvpn.compose.component.MullvadSmallTopBar | ||
import net.mullvad.mullvadvpn.compose.textfield.mullvadWhiteTextFieldColors | ||
import net.mullvad.mullvadvpn.compose.transitions.DefaultTransition | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewImportOverridesByText() { | ||
ImportOverridesByTextScreen({}, {}) | ||
} | ||
|
||
@Destination(style = DefaultTransition::class) | ||
@Composable | ||
fun ImportOverridesByText( | ||
resultNavigator: ResultBackNavigator<String>, | ||
) { | ||
ImportOverridesByTextScreen( | ||
onNavigateBack = resultNavigator::navigateBack, | ||
onImportClicked = { resultNavigator.navigateBack(result = it) } | ||
) | ||
} | ||
|
||
@Composable | ||
fun ImportOverridesByTextScreen( | ||
onNavigateBack: () -> Unit, | ||
onImportClicked: (String) -> Unit, | ||
) { | ||
var text by remember { mutableStateOf("") } | ||
|
||
Scaffold( | ||
topBar = { | ||
MullvadSmallTopBar( | ||
title = stringResource(R.string.import_overrides_text_title), | ||
navigationIcon = { | ||
IconButton(onClick = onNavigateBack) { | ||
Icon(imageVector = Icons.Default.Close, contentDescription = null) | ||
} | ||
}, | ||
actions = { | ||
TextButton( | ||
enabled = text.isNotEmpty(), | ||
colors = | ||
ButtonDefaults.textButtonColors() | ||
.copy(contentColor = MaterialTheme.colorScheme.onPrimary), | ||
onClick = { onImportClicked(text) } | ||
) { | ||
Text( | ||
text = stringResource(R.string.import_overrides_import), | ||
) | ||
} | ||
} | ||
) | ||
}, | ||
) { | ||
Column(modifier = Modifier.padding(it)) { | ||
TextField( | ||
modifier = Modifier.fillMaxSize(), | ||
value = text, | ||
onValueChange = { text = it }, | ||
placeholder = { | ||
Text(text = stringResource(R.string.import_override_textfield_placeholder)) | ||
}, | ||
colors = mullvadWhiteTextFieldColors() | ||
) | ||
} | ||
} | ||
} |
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.