GBA001/DeltaFeatures/Views/OptionPickerView.swift
Riley Testut 6d95924145 [Features] Provides default picker view for @Options with pre-set values
To use, pass in a collection of values to `values` parameter in @Option initializer.
2023-04-14 18:10:55 -05:00

29 lines
622 B
Swift

//
// OptionPickerView.swift
// Delta
//
// Created by Riley Testut on 4/10/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
import SwiftUI
// Type must be public, but not its properties.
public struct OptionPickerView<Value: LocalizedOptionValue>: View
{
var name: LocalizedStringKey
var options: [Value]
@Binding
var selectedValue: Value
public var body: some View {
Picker(name, selection: $selectedValue) {
ForEach(options, id: \.self) { value in
value.localizedDescription
}
}
.pickerStyle(.inline)
}
}