feat: add feedback for configuration changes

This commit is contained in:
andrekir 2023-10-03 18:05:40 -03:00 committed by Andre K
parent 2dd0e1f1e2
commit 7c30d86e39
6 changed files with 138 additions and 143 deletions

View file

@ -28,10 +28,10 @@ import androidx.compose.material.icons.twotone.Add
import androidx.compose.material.icons.twotone.Close
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.toMutableStateList
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@ -94,9 +94,7 @@ fun ChannelSettingsItemList(
onPositiveClicked: (List<ChannelSettings>) -> Unit,
) {
val focusManager = LocalFocusManager.current
val settingsListInput = remember {
mutableStateListOf<ChannelSettings>().apply { addAll(settingsList) }
}
val settingsListInput = remember(settingsList) { settingsList.toMutableStateList() }
val isEditing: Boolean = settingsList.size != settingsListInput.size
|| settingsList.zip(settingsListInput).any { (item1, item2) -> item1 != item2 }
@ -172,10 +170,12 @@ fun ChannelSettingsItemList(
) {
FloatingActionButton(
onClick = {
settingsListInput.add(channelSettings {
psk = Channel.default.settings.psk
})
showEditChannelDialog = settingsListInput.lastIndex
if (maxChannels > settingsListInput.size) {
settingsListInput.add(channelSettings {
psk = Channel.default.settings.psk
})
showEditChannelDialog = settingsListInput.lastIndex
}
},
modifier = Modifier.padding(16.dp)
) { Icon(Icons.TwoTone.Add, stringResource(R.string.add)) }

View file

@ -51,7 +51,7 @@ fun <T> PacketResponseStateDialog(
if (state.total == state.completed) onComplete()
}
if (state is ResponseState.Success) {
Text("Success!")
Text("Delivery confirmed.")
}
if (state is ResponseState.Error) {
Text(text = "Error\n", textAlign = TextAlign.Center)
@ -67,13 +67,7 @@ fun <T> PacketResponseStateDialog(
Button(
onClick = onDismiss,
modifier = Modifier.padding(top = 16.dp)
) {
if (state is ResponseState.Loading) {
Text(stringResource(R.string.cancel))
} else {
Text(stringResource(R.string.close))
}
}
) { Text(stringResource(R.string.close)) }
}
}
)