Make spin row and switch row safer

This commit is contained in:
david-swift 2024-01-04 20:21:33 +01:00
parent 2ac37b3f9c
commit ead88864df
2 changed files with 7 additions and 2 deletions

View File

@ -85,7 +85,10 @@ public struct SpinRow: Widget {
_ = row.addSuffix(suffixContent.view)
}
_ = row.onChange {
value = .init(row.getValue().rounded())
let value = Int(row.getValue().rounded())
if self.value != value {
self.value = value
}
}
update(row: row)
return .init(row, content: [prefixID: [prefixContent], suffixID: [suffixContent]])

View File

@ -65,7 +65,9 @@ public struct SwitchRow: Widget {
_ = row.addSuffix(suffixContent.view)
}
_ = row.onChange {
isOn = row.getActive()
if row.getActive() != isOn {
isOn = row.getActive()
}
}
update(row: row)
return .init(row, content: [prefixID: [prefixContent], suffixID: [suffixContent]])