Update view switcher option protocol
This commit is contained in:
parent
c893a8f0c6
commit
4913c0a382
@ -74,7 +74,7 @@ public struct ViewSwitcher<Element>: AdwaitaWidget where Element: ViewSwitcherOp
|
||||
let stack = switcher.fields["stack"] as? ViewStorage
|
||||
stack?.notify(name: "visible-child") {
|
||||
if let title = adw_view_stack_get_visible_child_name(stack?.opaquePointer),
|
||||
let option = Element(title: .init(cString: title)) {
|
||||
let option = elements.first(where: { $0.title == .init(cString: title) }) {
|
||||
selectedElement = option
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,4 @@ public protocol ViewSwitcherOption {
|
||||
/// A symbolic representation in the view switcher.
|
||||
var icon: Icon { get }
|
||||
|
||||
/// Get the element from the title.
|
||||
init?(title: String)
|
||||
|
||||
}
|
||||
|
||||
@ -90,10 +90,6 @@ struct ViewSwitcherDemo: View {
|
||||
}())
|
||||
}
|
||||
|
||||
init?(title: String) {
|
||||
self.init(rawValue: title.lowercased())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user