Update view switcher option protocol
Some checks failed
Deploy Docs / publish (push) Successful in 20m36s
SwiftLint / SwiftLint (push) Failing after 1s

This commit is contained in:
david-swift 2024-10-19 20:36:19 +02:00
parent c893a8f0c6
commit 4913c0a382
2 changed files with 1 additions and 8 deletions

View File

@ -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)
}

View File

@ -90,10 +90,6 @@ struct ViewSwitcherDemo: View {
}())
}
init?(title: String) {
self.init(rawValue: title.lowercased())
}
}
}