diff --git a/Sources/Core/View/ViewSwitcher.swift b/Sources/Core/View/ViewSwitcher.swift index 6311b63..0c4a1f3 100644 --- a/Sources/Core/View/ViewSwitcher.swift +++ b/Sources/Core/View/ViewSwitcher.swift @@ -74,7 +74,7 @@ public struct ViewSwitcher: 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) - } diff --git a/Sources/Demo/ViewSwitcherDemo.swift b/Sources/Demo/ViewSwitcherDemo.swift index 728c494..84fb02b 100644 --- a/Sources/Demo/ViewSwitcherDemo.swift +++ b/Sources/Demo/ViewSwitcherDemo.swift @@ -90,10 +90,6 @@ struct ViewSwitcherDemo: View { }()) } - init?(title: String) { - self.init(rawValue: title.lowercased()) - } - } }