Fix navigation view with dynamic items
This commit is contained in:
parent
8ec85b877f
commit
b5ee07485b
@ -1,6 +1,6 @@
|
||||
//
|
||||
// AlertDialog.swift
|
||||
// Adwaita
|
||||
// WinUI
|
||||
//
|
||||
// Created by david-swift on 12.11.24.
|
||||
//
|
||||
@ -18,10 +18,12 @@ public struct ContentDialog: WinUIWidget {
|
||||
var title: String
|
||||
/// The body text.
|
||||
var body: Body
|
||||
// swiftlint:disable large_tuple
|
||||
/// The primary response.
|
||||
var primary: (String, Bool, () -> Void)?
|
||||
/// The secondary response.
|
||||
var secondary: (String, Bool, () -> Void)?
|
||||
// swiftlint:enable large_tuple
|
||||
/// The close response.
|
||||
var close: (String, () -> Void)?
|
||||
/// The child view.
|
||||
|
@ -162,7 +162,7 @@ public struct NavigationView<Item>: WinUIWidget where Item: NavigationViewItem {
|
||||
}
|
||||
view.selectionChanged.addHandler { _, args in
|
||||
let name = (args?.selectedItem as? WinUI.NavigationViewItem)?.name ?? items.first?.description ?? ""
|
||||
if let item = items.first(where: { $0.description == name }) {
|
||||
if let item = (storage.fields["items"] as? [Item])?.first(where: { $0.description == name }) {
|
||||
if selectedItem != .custom(item: item) {
|
||||
selectedItem = .custom(item: item)
|
||||
}
|
||||
@ -222,6 +222,7 @@ public struct NavigationView<Item>: WinUIWidget where Item: NavigationViewItem {
|
||||
.first { ($0 as? WinUI.NavigationViewItem)?.name as? String == name.description } as Any?
|
||||
}
|
||||
navigationView.isBackEnabled = path.count > 1
|
||||
storage.fields["items"] = items
|
||||
storage.previousState = self
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user