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

Commit

Permalink
Make the entry row a bit safer
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Jan 4, 2024
1 parent eea8428 commit 853555a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/Adwaita/View/Forms/EntryRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public struct EntryRow: Widget {
/// The identifier for the suffix content.
let suffixID = "suffix"

/// The identifier for the title.
let titleID = "title"

/// Initialize an entry row.
/// - Parameters:
/// - title: The row's title.
Expand Down Expand Up @@ -72,7 +75,9 @@ public struct EntryRow: Widget {
_ = row.addSuffix(suffixContent.view)
}
_ = row.changeHandler {
text = row.contents()
if row.contents() != text {
text = row.contents()
}
}
update(row: row)
return .init(row, content: [prefixID: [prefixContent], suffixID: [suffixContent]])
Expand All @@ -81,7 +86,10 @@ public struct EntryRow: Widget {
/// Update the entry row.
/// - Parameter row: The entry row.
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 {
row.setContents(text)
}
Expand Down

0 comments on commit 853555a

Please sign in to comment.