feat: Cleaning up shared models.

This commit is contained in:
2024-06-10 09:03:54 -04:00
parent 68da203164
commit 51f7a30701
19 changed files with 383 additions and 339 deletions

View File

@@ -0,0 +1,40 @@
import SwiftUI
public struct CaseIterablePicker<Label, Content>: View
where Content: CaseIterable,
Content: CustomStringConvertible,
Content: Hashable,
Content: Identifiable,
Content.AllCases: RandomAccessCollection,
Label: View
{
let label: () -> Label
@Binding<Content> var selection: Content
public init(
selection: Binding<Content>,
@ViewBuilder label: @escaping () -> Label
) {
self.label = label
self._selection = selection
}
public var body: some View {
Picker(selection: $selection, label: label()) {
ForEach(Content.allCases) {
Text($0.description)
.tag($0)
}
}
}
}
extension CaseIterablePicker where Label == Text {
public init<S: StringProtocol>(_ title: S, selection: Binding<Content>) {
self.init(selection: selection) {
Text(title)
}
}
}