-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor tunnel options/edit to multiple screens
- Loading branch information
1 parent
d4bfe1a
commit ffd0b80
Showing
14 changed files
with
326 additions
and
134 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
29 changes: 0 additions & 29 deletions
29
app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigUiState.kt
This file was deleted.
Oops, something went wrong.
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
166 changes: 166 additions & 0 deletions
166
.../java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/TunnelOptionsScreen.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,166 @@ | ||
package com.zaneschepke.wireguardautotunnel.ui.screens.tunneloptions | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.outlined.CallSplit | ||
import androidx.compose.material.icons.outlined.Bolt | ||
import androidx.compose.material.icons.outlined.Edit | ||
import androidx.compose.material.icons.outlined.NetworkPing | ||
import androidx.compose.material.icons.outlined.PhoneAndroid | ||
import androidx.compose.material.icons.outlined.Security | ||
import androidx.compose.material.icons.outlined.SettingsEthernet | ||
import androidx.compose.material.icons.outlined.Star | ||
import androidx.compose.material.icons.outlined.VpnKeyOff | ||
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.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.input.ImeAction | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.unit.dp | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import com.zaneschepke.wireguardautotunnel.R | ||
import com.zaneschepke.wireguardautotunnel.ui.AppUiState | ||
import com.zaneschepke.wireguardautotunnel.ui.Route | ||
import com.zaneschepke.wireguardautotunnel.ui.common.button.ScaledSwitch | ||
import com.zaneschepke.wireguardautotunnel.ui.common.button.surface.SelectionItem | ||
import com.zaneschepke.wireguardautotunnel.ui.common.button.surface.SurfaceSelectionGroupButton | ||
import com.zaneschepke.wireguardautotunnel.ui.common.config.SubmitConfigurationTextBox | ||
import com.zaneschepke.wireguardautotunnel.ui.common.label.GroupLabel | ||
import com.zaneschepke.wireguardautotunnel.ui.common.navigation.LocalNavController | ||
import com.zaneschepke.wireguardautotunnel.ui.common.navigation.TopNavBar | ||
import com.zaneschepke.wireguardautotunnel.ui.screens.settings.autotunnel.components.TrustedNetworkTextBox | ||
import com.zaneschepke.wireguardautotunnel.ui.screens.settings.autotunnel.components.WildcardsLabel | ||
import com.zaneschepke.wireguardautotunnel.ui.screens.settings.components.ForwardButton | ||
import com.zaneschepke.wireguardautotunnel.ui.theme.iconSize | ||
import com.zaneschepke.wireguardautotunnel.util.Constants | ||
import com.zaneschepke.wireguardautotunnel.util.extensions.isValidIpv4orIpv6Address | ||
import com.zaneschepke.wireguardautotunnel.util.extensions.scaledHeight | ||
import com.zaneschepke.wireguardautotunnel.util.extensions.scaledWidth | ||
|
||
@Composable | ||
fun OptionsScreen(tunnelOptionsViewModel: TunnelOptionsViewModel = hiltViewModel(), appUiState: AppUiState, tunnelId: Int) { | ||
val navController = LocalNavController.current | ||
val config = remember { appUiState.tunnels.first { it.id == tunnelId } } | ||
|
||
var currentText by remember { mutableStateOf("") } | ||
|
||
LaunchedEffect(config.tunnelNetworks) { | ||
currentText = "" | ||
} | ||
Scaffold( | ||
topBar = { | ||
TopNavBar(config.name) | ||
}, | ||
) { | ||
Column( | ||
horizontalAlignment = Alignment.Start, | ||
verticalArrangement = Arrangement.spacedBy(24.dp.scaledHeight(), Alignment.Top), | ||
modifier = | ||
Modifier | ||
.fillMaxSize() | ||
.padding(it) | ||
.verticalScroll(rememberScrollState()) | ||
.padding(top = 24.dp.scaledHeight()) | ||
.padding(horizontal = 24.dp.scaledWidth()), | ||
) { | ||
SurfaceSelectionGroupButton( | ||
listOf( | ||
SelectionItem( | ||
Icons.Outlined.Star, | ||
title = { | ||
Text( | ||
stringResource(R.string.primary_tunnel), | ||
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface), | ||
) | ||
}, | ||
description = { | ||
Text( | ||
stringResource(R.string.set_primary_tunnel), | ||
style = MaterialTheme.typography.bodySmall.copy(MaterialTheme.colorScheme.outline), | ||
) | ||
}, | ||
trailing = { | ||
ScaledSwitch( | ||
config.isPrimaryTunnel, | ||
onClick = { tunnelOptionsViewModel.onTogglePrimaryTunnel(config) }, | ||
) | ||
}, | ||
onClick = { tunnelOptionsViewModel.onTogglePrimaryTunnel(config) }, | ||
), | ||
SelectionItem( | ||
Icons.Outlined.Bolt, | ||
title = { | ||
Text( | ||
stringResource(R.string.auto_tunneling), | ||
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface), | ||
) | ||
}, | ||
description = { | ||
Text( | ||
stringResource(R.string.tunnel_specific_settings), | ||
style = MaterialTheme.typography.bodySmall.copy(MaterialTheme.colorScheme.outline), | ||
) | ||
}, | ||
onClick = { | ||
navController.navigate(Route.TunnelAutoTunnel(id = tunnelId)) | ||
}, | ||
trailing = { | ||
ForwardButton { navController.navigate(Route.TunnelAutoTunnel(id = tunnelId)) } | ||
}, | ||
), | ||
SelectionItem( | ||
Icons.Outlined.Edit, | ||
title = { | ||
Text( | ||
stringResource(R.string.edit_tunnel), | ||
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface), | ||
) | ||
}, | ||
onClick = { | ||
navController.navigate(Route.Config(id = tunnelId)) | ||
}, | ||
trailing = { | ||
ForwardButton { navController.navigate(Route.Config(id = tunnelId)) } | ||
}, | ||
), | ||
SelectionItem( | ||
Icons.AutoMirrored.Outlined.CallSplit, | ||
title = { | ||
Text( | ||
stringResource(R.string.splt_tunneling), | ||
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onSurface), | ||
) | ||
}, | ||
onClick = { | ||
navController.navigate(Route.Config(id = tunnelId)) | ||
}, | ||
trailing = { | ||
ForwardButton { navController.navigate(Route.Config(id = tunnelId)) } | ||
}, | ||
) | ||
) | ||
) | ||
GroupLabel(stringResource(R.string.quick_actions)) | ||
} | ||
} | ||
} |
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
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.