mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: improve parameter naming and type in config constructors
This commit is contained in:
parent
85e62eaab4
commit
145988ad75
4 changed files with 23 additions and 28 deletions
|
|
@ -246,13 +246,12 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
|
|||
}
|
||||
composable("position") {
|
||||
PositionConfigItemList(
|
||||
locationInfo = location,
|
||||
location = location,
|
||||
positionConfig = radioConfig.position,
|
||||
enabled = connected,
|
||||
focusManager = focusManager,
|
||||
onSaveClicked = { positionPair ->
|
||||
onSaveClicked = { locationInput, positionInput ->
|
||||
focusManager.clearFocus()
|
||||
val (locationInput, positionInput) = positionPair
|
||||
if (locationInput != node.position && positionInput.fixedPosition) {
|
||||
locationInput?.let { viewModel.requestPosition(destNum, it) }
|
||||
location = locationInput
|
||||
|
|
@ -362,9 +361,8 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
|
|||
extNotificationConfig = moduleConfig.externalNotification,
|
||||
enabled = connected,
|
||||
focusManager = focusManager,
|
||||
onSaveClicked = { extNotificationPair ->
|
||||
onSaveClicked = { ringtoneInput, extNotificationInput ->
|
||||
focusManager.clearFocus()
|
||||
val (ringtoneInput, extNotificationInput) = extNotificationPair
|
||||
if (ringtoneInput != ringtone) {
|
||||
viewModel.setRingtone(destNum, ringtoneInput)
|
||||
ringtone = ringtoneInput
|
||||
|
|
@ -422,9 +420,8 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
|
|||
cannedMessageConfig = moduleConfig.cannedMessage,
|
||||
enabled = connected,
|
||||
focusManager = focusManager,
|
||||
onSaveClicked = { cannedMessagePair ->
|
||||
onSaveClicked = { messagesInput, cannedMessageInput ->
|
||||
focusManager.clearFocus()
|
||||
val (messagesInput, cannedMessageInput) = cannedMessagePair
|
||||
if (messagesInput != cannedMessageMessages) {
|
||||
viewModel.setCannedMessages(destNum, messagesInput)
|
||||
cannedMessageMessages = messagesInput
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ fun CannedMessageConfigItemList(
|
|||
cannedMessageConfig: CannedMessageConfig,
|
||||
enabled: Boolean,
|
||||
focusManager: FocusManager,
|
||||
onSaveClicked: (Pair<String, CannedMessageConfig>) -> Unit,
|
||||
onSaveClicked: (messages: String, config: CannedMessageConfig) -> Unit,
|
||||
) {
|
||||
var messagesInput by remember(messages) { mutableStateOf(messages) }
|
||||
var cannedMessageInput by remember(cannedMessageConfig) { mutableStateOf(cannedMessageConfig) }
|
||||
var messagesInput by remember { mutableStateOf(messages) }
|
||||
var cannedMessageInput by remember { mutableStateOf(cannedMessageConfig) }
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
|
|
@ -186,7 +186,7 @@ fun CannedMessageConfigItemList(
|
|||
messagesInput = messages
|
||||
cannedMessageInput = cannedMessageConfig
|
||||
},
|
||||
onSaveClicked = { onSaveClicked(Pair(messagesInput,cannedMessageInput)) }
|
||||
onSaveClicked = { onSaveClicked(messagesInput,cannedMessageInput) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -200,6 +200,6 @@ fun CannedMessageConfigPreview(){
|
|||
cannedMessageConfig = CannedMessageConfig.getDefaultInstance(),
|
||||
enabled = true,
|
||||
focusManager = LocalFocusManager.current,
|
||||
onSaveClicked = { },
|
||||
onSaveClicked = { _, _ -> },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,12 +30,10 @@ fun ExternalNotificationConfigItemList(
|
|||
extNotificationConfig: ExternalNotificationConfig,
|
||||
enabled: Boolean,
|
||||
focusManager: FocusManager,
|
||||
onSaveClicked: (Pair<String, ExternalNotificationConfig>) -> Unit,
|
||||
onSaveClicked: (ringtone: String, config: ExternalNotificationConfig) -> Unit,
|
||||
) {
|
||||
var ringtoneInput by remember(ringtone) { mutableStateOf(ringtone) }
|
||||
var externalNotificationInput by remember(extNotificationConfig) {
|
||||
mutableStateOf(extNotificationConfig)
|
||||
}
|
||||
var ringtoneInput by remember { mutableStateOf(ringtone) }
|
||||
var externalNotificationInput by remember { mutableStateOf(extNotificationConfig) }
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
|
|
@ -210,7 +208,7 @@ fun ExternalNotificationConfigItemList(
|
|||
ringtoneInput = ringtone
|
||||
externalNotificationInput = extNotificationConfig
|
||||
},
|
||||
onSaveClicked = { onSaveClicked(Pair(ringtoneInput, externalNotificationInput)) }
|
||||
onSaveClicked = { onSaveClicked(ringtoneInput, externalNotificationInput) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -224,6 +222,6 @@ fun ExternalNotificationConfigPreview(){
|
|||
extNotificationConfig = ExternalNotificationConfig.getDefaultInstance(),
|
||||
enabled = true,
|
||||
focusManager = LocalFocusManager.current,
|
||||
onSaveClicked = { },
|
||||
onSaveClicked = { _, _ -> },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ import com.geeksville.mesh.ui.components.SwitchPreference
|
|||
|
||||
@Composable
|
||||
fun PositionConfigItemList(
|
||||
locationInfo: Position?,
|
||||
location: Position?,
|
||||
positionConfig: PositionConfig,
|
||||
enabled: Boolean,
|
||||
focusManager: FocusManager,
|
||||
onSaveClicked: (Pair<Position?, PositionConfig>) -> Unit,
|
||||
onSaveClicked: (position: Position?, config: PositionConfig) -> Unit,
|
||||
) {
|
||||
var locationInput by remember(locationInfo) { mutableStateOf(locationInfo) }
|
||||
var positionInput by remember(positionConfig) { mutableStateOf(positionConfig) }
|
||||
var locationInput by remember { mutableStateOf(location) }
|
||||
var positionInput by remember { mutableStateOf(positionConfig) }
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
|
|
@ -175,13 +175,13 @@ fun PositionConfigItemList(
|
|||
|
||||
item {
|
||||
PreferenceFooter(
|
||||
enabled = positionInput != positionConfig || locationInput != locationInfo,
|
||||
enabled = positionInput != positionConfig || locationInput != location,
|
||||
onCancelClicked = {
|
||||
focusManager.clearFocus()
|
||||
locationInput = locationInfo
|
||||
locationInput = location
|
||||
positionInput = positionConfig
|
||||
},
|
||||
onSaveClicked = { onSaveClicked(Pair(locationInput, positionInput)) }
|
||||
onSaveClicked = { onSaveClicked(locationInput, positionInput) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -191,10 +191,10 @@ fun PositionConfigItemList(
|
|||
@Composable
|
||||
fun PositionConfigPreview(){
|
||||
PositionConfigItemList(
|
||||
locationInfo = null,
|
||||
location = null,
|
||||
positionConfig = PositionConfig.getDefaultInstance(),
|
||||
enabled = true,
|
||||
focusManager = LocalFocusManager.current,
|
||||
onSaveClicked = { },
|
||||
onSaveClicked = { _, _ -> },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue