Swiftpack.co - AlmightyBeaver/MultiPicker as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by AlmightyBeaver.
AlmightyBeaver/MultiPicker 1.0.1
SwiftUI Picker for up to three values which conform to LosslessStringConvertible (e.g. String, Int, Double).
⭐️ 7
🕓 2 years ago
iOS
.package(url: "https://github.com/AlmightyBeaver/MultiPicker.git", from: "1.0.1")

MultiPicker

SwiftUI Picker for up to three values which conform to LosslessStringConvertible (e.g. String, Int, Double).

Example Code

 struct MultiPickerExample: View {
     var values1: [String] = ["A", "B", "C", "D", "E", "F"]
     var values2: [Int] = Array(0...23)
     var values3: [Int] = Array(0...59)
     @State var selection1: Int = 1
     @State var selection2: Int = 1
     @State var selection3: Int = 0
     @State var hidePicker: Bool = false
     
     var body: some View {
         Group{
             Toggle("Hide Picker", isOn: $hidePicker)
             if !hidePicker{
                 Button(action: {
                     withAnimation{
                         self.selection1 = 0
                         self.selection2 = 5
                         self.selection3 = 30
                     }
                 }) {
                     Text("Set to A 5 30")
                 }
                 MultiPicker(selection1: $selection1,
                             selection2: $selection2,
                             selection3: $selection3,
                             values1: values1,
                             values2: values2,
                             values3: values3,
                             values1Prefix: ">",
                             values3Suffix: "<",
                             middleText1: "-",
                             middleText2: "-")
                 VStack(alignment: .leading){
                     Text("Value 1: \(self.values1[selection1])")
                     Text("Value 2: \(self.values2[selection2])")
                     Text("Value 3: \(self.values3[selection3])")
                 }
             }
         }
     }
 }

Here is an example of use: https://github.com/AlmightyBeaver/HourPicker

GitHub

link
Stars: 7
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics