Update navigation titles in navigation split view
All checks were successful
Deploy Docs / publish (push) Successful in 18m15s
SwiftLint / SwiftLint (push) Successful in 5s

This commit is contained in:
david-swift 2024-10-15 22:46:43 +02:00
parent 7900a4cb77
commit 079fa02755

View File

@ -60,6 +60,9 @@ public struct NavigationSplitView: AdwaitaWidget {
let storage = ViewStorage(splitView?.opaque(), content: content)
update(storage, data: data, updateProperties: true, type: type)
storage.fields["sidebar-page"] = sidebarPage?.opaque()
storage.fields["main-page"] = mainPage?.opaque()
storage.notify(name: "show-content") {
showContent?.wrappedValue = adw_navigation_split_view_get_show_content(storage.opaquePointer) != 0
}
@ -79,13 +82,19 @@ public struct NavigationSplitView: AdwaitaWidget {
updateProperties: Bool,
type: Data.Type
) where Data: ViewRenderData {
if let storage = storage.content[contentID]?[safe: 0] {
if let cStorage = storage.content[contentID]?[safe: 0] {
content
.updateStorage(storage, data: data, updateProperties: updateProperties, type: type)
.updateStorage(cStorage, data: data, updateProperties: updateProperties, type: type)
if updateProperties, let mainPage = storage.fields["main-page"] as? OpaquePointer {
adw_navigation_page_set_title(mainPage.cast(), cStorage.fields[.navigationLabel] as? String ?? "")
}
}
if let storage = storage.content[sidebarID]?[safe: 0] {
if let sStorage = storage.content[sidebarID]?[safe: 0] {
sidebar
.updateStorage(storage, data: data, updateProperties: updateProperties, type: type)
.updateStorage(sStorage, data: data, updateProperties: updateProperties, type: type)
if updateProperties, let sidebarPage = storage.fields["sidebar-page"] as? OpaquePointer {
adw_navigation_page_set_title(sidebarPage.cast(), sStorage.fields[.navigationLabel] as? String ?? "")
}
}
guard updateProperties else {
return