fix(config): respect enabled parameter for Send button

This commit is contained in:
andrekir 2024-11-11 17:27:03 -03:00
parent 683b354dd4
commit 5480174ec9
22 changed files with 26 additions and 27 deletions

View file

@ -106,7 +106,7 @@ fun AmbientLightingConfigItemList(
item {
PreferenceFooter(
enabled = ambientLightingInput != ambientLightingConfig,
enabled = enabled && ambientLightingInput != ambientLightingConfig,
onCancelClicked = {
focusManager.clearFocus()
ambientLightingInput = ambientLightingConfig

View file

@ -122,7 +122,7 @@ fun AudioConfigItemList(
item {
PreferenceFooter(
enabled = audioInput != audioConfig,
enabled = enabled && audioInput != audioConfig,
onCancelClicked = {
focusManager.clearFocus()
audioInput = audioConfig

View file

@ -94,7 +94,7 @@ fun BluetoothConfigItemList(
item {
PreferenceFooter(
enabled = bluetoothInput != bluetoothConfig,
enabled = enabled && bluetoothInput != bluetoothConfig,
onCancelClicked = {
focusManager.clearFocus()
bluetoothInput = bluetoothConfig

View file

@ -212,7 +212,7 @@ fun CannedMessageConfigItemList(
item {
PreferenceFooter(
enabled = cannedMessageInput != cannedMessageConfig || messagesInput != messages,
enabled = enabled && cannedMessageInput != cannedMessageConfig || messagesInput != messages,
onCancelClicked = {
focusManager.clearFocus()
messagesInput = messages

View file

@ -251,7 +251,7 @@ fun ChannelSettingsItemList(
item {
PreferenceFooter(
enabled = isEditing,
enabled = enabled && isEditing,
negativeText = R.string.cancel,
onNegativeClicked = {
focusManager.clearFocus()

View file

@ -157,7 +157,7 @@ fun DetectionSensorConfigItemList(
item {
PreferenceFooter(
enabled = detectionSensorInput != detectionSensorConfig,
enabled = enabled && detectionSensorInput != detectionSensorConfig,
onCancelClicked = {
focusManager.clearFocus()
detectionSensorInput = detectionSensorConfig

View file

@ -168,7 +168,7 @@ fun DisplayConfigItemList(
item {
PreferenceFooter(
enabled = displayInput != displayConfig,
enabled = enabled && displayInput != displayConfig,
onCancelClicked = {
focusManager.clearFocus()
displayInput = displayConfig

View file

@ -244,7 +244,7 @@ fun ExternalNotificationConfigItemList(
item {
PreferenceFooter(
enabled = externalNotificationInput != extNotificationConfig || ringtoneInput != ringtone,
enabled = enabled && externalNotificationInput != extNotificationConfig || ringtoneInput != ringtone,
onCancelClicked = {
focusManager.clearFocus()
ringtoneInput = ringtone

View file

@ -244,7 +244,7 @@ fun LoRaConfigItemList(
item {
PreferenceFooter(
enabled = loraInput != loraConfig,
enabled = enabled && loraInput != loraConfig,
onCancelClicked = {
focusManager.clearFocus()
loraInput = loraConfig

View file

@ -186,7 +186,7 @@ fun MQTTConfigItemList(
item {
PreferenceFooter(
enabled = mqttInput != mqttConfig,
enabled = enabled && mqttInput != mqttConfig,
onCancelClicked = {
focusManager.clearFocus()
mqttInput = mqttConfig

View file

@ -82,7 +82,7 @@ fun NeighborInfoConfigItemList(
item {
PreferenceFooter(
enabled = neighborInfoInput != neighborInfoConfig,
enabled = enabled && neighborInfoInput != neighborInfoConfig,
onCancelClicked = {
focusManager.clearFocus()
neighborInfoInput = neighborInfoConfig

View file

@ -73,6 +73,10 @@ fun NetworkConfigScreen(
)
}
private fun extractWifiCredentials(qrCode: String) = Regex("""WIFI:S:(.*?);.*?P:(.*?);""")
.find(qrCode)?.destructured
?.let { (ssid, password) -> ssid to password } ?: (null to null)
@Composable
fun NetworkConfigItemList(
networkConfig: NetworkConfig,
@ -87,11 +91,6 @@ fun NetworkConfigItemList(
ScanErrorDialog { showScanErrorDialog = false }
}
fun extractWifiCredentials(qrCode: String) = Regex("""WIFI:S:(.*?);.*?P:(.*?);""")
.find(qrCode)?.destructured
?.let { (ssid, password) -> ssid to password }
?: (null to null)
val barcodeLauncher = rememberLauncherForActivityResult(ScanContract()) { result ->
if (result.contents != null) {
val (ssid, psk) = extractWifiCredentials(result.contents)
@ -258,7 +257,7 @@ fun NetworkConfigItemList(
item {
PreferenceFooter(
enabled = networkInput != networkConfig,
enabled = enabled && networkInput != networkConfig,
onCancelClicked = {
focusManager.clearFocus()
networkInput = networkConfig

View file

@ -102,7 +102,7 @@ fun PaxcounterConfigItemList(
item {
PreferenceFooter(
enabled = paxcounterInput != paxcounterConfig,
enabled = enabled && paxcounterInput != paxcounterConfig,
onCancelClicked = {
focusManager.clearFocus()
paxcounterInput = paxcounterConfig

View file

@ -227,7 +227,7 @@ fun PositionConfigItemList(
item {
PreferenceFooter(
enabled = positionInput != positionConfig || locationInput != location,
enabled = enabled && positionInput != positionConfig || locationInput != location,
onCancelClicked = {
focusManager.clearFocus()
locationInput = location

View file

@ -128,7 +128,7 @@ fun PowerConfigItemList(
item {
PreferenceFooter(
enabled = powerInput != powerConfig,
enabled = enabled && powerInput != powerConfig,
onCancelClicked = {
focusManager.clearFocus()
powerInput = powerConfig

View file

@ -86,7 +86,7 @@ fun RangeTestConfigItemList(
item {
PreferenceFooter(
enabled = rangeTestInput != rangeTestConfig,
enabled = enabled && rangeTestInput != rangeTestConfig,
onCancelClicked = {
focusManager.clearFocus()
rangeTestInput = rangeTestConfig

View file

@ -96,7 +96,7 @@ fun RemoteHardwareConfigItemList(
item {
PreferenceFooter(
enabled = remoteHardwareInput != remoteHardwareConfig,
enabled = enabled && remoteHardwareInput != remoteHardwareConfig,
onCancelClicked = {
focusManager.clearFocus()
remoteHardwareInput = remoteHardwareConfig

View file

@ -146,7 +146,7 @@ fun SecurityConfigItemList(
item {
PreferenceFooter(
enabled = securityInput != securityConfig,
enabled = enabled && securityInput != securityConfig,
onCancelClicked = {
focusManager.clearFocus()
securityInput = securityConfig

View file

@ -135,7 +135,7 @@ fun SerialConfigItemList(
item {
PreferenceFooter(
enabled = serialInput != serialConfig,
enabled = enabled && serialInput != serialConfig,
onCancelClicked = {
focusManager.clearFocus()
serialInput = serialConfig

View file

@ -117,7 +117,7 @@ fun StoreForwardConfigItemList(
item {
PreferenceFooter(
enabled = storeForwardInput != storeForwardConfig,
enabled = enabled && storeForwardInput != storeForwardConfig,
onCancelClicked = {
focusManager.clearFocus()
storeForwardInput = storeForwardConfig

View file

@ -162,7 +162,7 @@ fun TelemetryConfigItemList(
item {
PreferenceFooter(
enabled = telemetryInput != telemetryConfig,
enabled = enabled && telemetryInput != telemetryConfig,
onCancelClicked = {
focusManager.clearFocus()
telemetryInput = telemetryConfig

View file

@ -117,7 +117,7 @@ fun UserConfigItemList(
item {
PreferenceFooter(
enabled = userInput != userConfig,
enabled = enabled && userInput != userConfig,
onCancelClicked = {
focusManager.clearFocus()
userInput = userConfig