From c012472db53a84ce56bc08ff826512dd5134a276 Mon Sep 17 00:00:00 2001 From: hicka04 Date: Sat, 17 Aug 2024 22:40:36 +0900 Subject: [PATCH] Remove workshop day from search filter options --- app-ios/Sources/Model/Selectable.swift | 7 +++++++ app-ios/Sources/SearchFeature/SearchView.swift | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app-ios/Sources/Model/Selectable.swift b/app-ios/Sources/Model/Selectable.swift index 3d75302e0..21aa641f0 100644 --- a/app-ios/Sources/Model/Selectable.swift +++ b/app-ios/Sources/Model/Selectable.swift @@ -1,3 +1,10 @@ public protocol Selectable: CaseIterable, Equatable, Identifiable, Hashable { + associatedtype Options: RandomAccessCollection = [Self] where Self == Self.Options.Element + static var options: Options { get } var caseTitle: String { get } + +} + +public extension Selectable { + static var options: Options { allCases as! Options } } diff --git a/app-ios/Sources/SearchFeature/SearchView.swift b/app-ios/Sources/SearchFeature/SearchView.swift index a31942f1c..e0c09d253 100644 --- a/app-ios/Sources/SearchFeature/SearchView.swift +++ b/app-ios/Sources/SearchFeature/SearchView.swift @@ -123,9 +123,9 @@ public struct SearchView: View { selection: T?, defaultTitle: String, onSelect: @escaping (T) -> Void - ) -> some View where T.AllCases: RandomAccessCollection { + ) -> some View { Menu { - ForEach(T.allCases, id: \.id) { menuSelection in + ForEach(T.options, id: \.id) { menuSelection in Button { onSelect(menuSelection) } label: { @@ -171,6 +171,10 @@ extension DroidKaigi2024Day { String(localized: "9/13", bundle: .module) } } + + public static var options: [DroidKaigi2024Day] { + [.conferenceDay1, .conferenceDay2] + } } #if hasFeature(RetroactiveAttribute)