Added basic proxy UI components in settings
This commit is contained in:
parent
2cc4ca18b5
commit
cc4e9700e8
@ -12,6 +12,8 @@ import androidx.compose.ui.platform.LocalDensity
|
|||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
|
import androidx.compose.ui.text.input.VisualTransformation
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.jetpackduba.gitnuro.AppIcons
|
import com.jetpackduba.gitnuro.AppIcons
|
||||||
@ -45,13 +47,79 @@ val settings = listOf(
|
|||||||
SettingsEntry.Entry(AppIcons.CLOUD, "Remote actions") { RemoteActions(it) },
|
SettingsEntry.Entry(AppIcons.CLOUD, "Remote actions") { RemoteActions(it) },
|
||||||
|
|
||||||
SettingsEntry.Section("Network"),
|
SettingsEntry.Section("Network"),
|
||||||
SettingsEntry.Entry(AppIcons.NETWORK, "Proxy") { },
|
SettingsEntry.Entry(AppIcons.NETWORK, "Proxy") { Proxy() },
|
||||||
SettingsEntry.Entry(AppIcons.PASSWORD, "Authentication") { Authentication(it) },
|
SettingsEntry.Entry(AppIcons.PASSWORD, "Authentication") { Authentication(it) },
|
||||||
|
|
||||||
SettingsEntry.Section("Tools"),
|
SettingsEntry.Section("Tools"),
|
||||||
SettingsEntry.Entry(AppIcons.TERMINAL, "Terminal") { Terminal(it) },
|
SettingsEntry.Entry(AppIcons.TERMINAL, "Terminal") { Terminal(it) },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Proxy() {
|
||||||
|
var useProxy by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
var hostName by remember { mutableStateOf("") }
|
||||||
|
var portNumber by remember { mutableStateOf(80) }
|
||||||
|
var login by remember { mutableStateOf("") }
|
||||||
|
var password by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
val proxyTypes = listOf(ProxyType.HTTP, ProxyType.SOCKS)
|
||||||
|
val proxyTypesDropDownOptions = proxyTypes.map { DropDownOption(it, it.name) }
|
||||||
|
var currentProxyType by remember { mutableStateOf(proxyTypesDropDownOptions.first()) }
|
||||||
|
|
||||||
|
Column {
|
||||||
|
SettingToggle(
|
||||||
|
title = "Use proxy",
|
||||||
|
subtitle = "Set up your proxy configuration if needed",
|
||||||
|
value = useProxy,
|
||||||
|
onValueChanged = { useProxy = it },
|
||||||
|
)
|
||||||
|
|
||||||
|
SettingDropDown(
|
||||||
|
title = "Proxy type",
|
||||||
|
subtitle = "Pick between HTTP or SOCKS",
|
||||||
|
dropDownOptions = proxyTypesDropDownOptions,
|
||||||
|
currentOption = currentProxyType,
|
||||||
|
onOptionSelected = { currentProxyType = it }
|
||||||
|
)
|
||||||
|
|
||||||
|
SettingTextInput(
|
||||||
|
title = "Host name",
|
||||||
|
subtitle = "",
|
||||||
|
value = hostName,
|
||||||
|
onValueChanged = { hostName = it },
|
||||||
|
enabled = useProxy,
|
||||||
|
)
|
||||||
|
|
||||||
|
SettingIntInput(
|
||||||
|
title = "Port number",
|
||||||
|
subtitle = "",
|
||||||
|
value = portNumber,
|
||||||
|
onValueChanged = { portNumber = it },
|
||||||
|
enabled = useProxy,
|
||||||
|
)
|
||||||
|
|
||||||
|
SettingTextInput(
|
||||||
|
title = "Login",
|
||||||
|
subtitle = "",
|
||||||
|
value = login,
|
||||||
|
onValueChanged = { login = it },
|
||||||
|
enabled = useProxy,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
SettingTextInput(
|
||||||
|
title = "Password",
|
||||||
|
subtitle = "",
|
||||||
|
value = password,
|
||||||
|
onValueChanged = { password = it },
|
||||||
|
isPassword = true,
|
||||||
|
enabled = useProxy,
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsDialog(
|
fun SettingsDialog(
|
||||||
settingsViewModel: SettingsViewModel = gitnuroViewModel(),
|
settingsViewModel: SettingsViewModel = gitnuroViewModel(),
|
||||||
@ -550,6 +618,7 @@ fun SettingTextInput(
|
|||||||
subtitle: String,
|
subtitle: String,
|
||||||
value: String,
|
value: String,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
|
isPassword: Boolean = false,
|
||||||
onValueChanged: (String) -> Unit,
|
onValueChanged: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
@ -573,6 +642,7 @@ fun SettingTextInput(
|
|||||||
text = it
|
text = it
|
||||||
onValueChanged(it)
|
onValueChanged(it)
|
||||||
},
|
},
|
||||||
|
visualTransformation = if (isPassword) PasswordVisualTransformation() else VisualTransformation.None,
|
||||||
colors = outlinedTextFieldColors(),
|
colors = outlinedTextFieldColors(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
)
|
)
|
||||||
@ -620,3 +690,8 @@ private fun isValidFloat(value: String): Boolean {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class ProxyType {
|
||||||
|
HTTP,
|
||||||
|
SOCKS,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user