Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Make spin row and switch row safer
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Jan 4, 2024
1 parent 2ac37b3 commit ead8886
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Sources/Adwaita/View/Forms/SpinRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
Expand Down
4 changes: 3 additions & 1 deletion Sources/Adwaita/View/Forms/SwitchRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
Expand Down

0 comments on commit ead8886

Please sign in to comment.