forked from aparoksha/adwaita-swift
Make the entry row a bit safer
This commit is contained in:
parent
eea842891e
commit
853555a9fc
@ -28,6 +28,9 @@ public struct EntryRow: Widget {
|
|||||||
/// The identifier for the suffix content.
|
/// The identifier for the suffix content.
|
||||||
let suffixID = "suffix"
|
let suffixID = "suffix"
|
||||||
|
|
||||||
|
/// The identifier for the title.
|
||||||
|
let titleID = "title"
|
||||||
|
|
||||||
/// Initialize an entry row.
|
/// Initialize an entry row.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - title: The row's title.
|
/// - title: The row's title.
|
||||||
@ -72,7 +75,9 @@ public struct EntryRow: Widget {
|
|||||||
_ = row.addSuffix(suffixContent.view)
|
_ = row.addSuffix(suffixContent.view)
|
||||||
}
|
}
|
||||||
_ = row.changeHandler {
|
_ = row.changeHandler {
|
||||||
text = row.contents()
|
if row.contents() != text {
|
||||||
|
text = row.contents()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
update(row: row)
|
update(row: row)
|
||||||
return .init(row, content: [prefixID: [prefixContent], suffixID: [suffixContent]])
|
return .init(row, content: [prefixID: [prefixContent], suffixID: [suffixContent]])
|
||||||
@ -81,7 +86,10 @@ public struct EntryRow: Widget {
|
|||||||
/// Update the entry row.
|
/// Update the entry row.
|
||||||
/// - Parameter row: The entry row.
|
/// - Parameter row: The entry row.
|
||||||
func update(row: Libadwaita.EntryRow) {
|
func update(row: Libadwaita.EntryRow) {
|
||||||
_ = row.title(title)
|
if row.fields[titleID] as? String != title {
|
||||||
|
_ = row.title(title)
|
||||||
|
row.fields[titleID] = title
|
||||||
|
}
|
||||||
if row.contents() != text {
|
if row.contents() != text {
|
||||||
row.setContents(text)
|
row.setContents(text)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user