Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 743 Bytes

README.md

File metadata and controls

39 lines (29 loc) · 743 Bytes

HPicker

Horizontal picker for SwiftUI. The selected item is centered.

cover.gif

Feature

  • Tap to select specific item.
  • Swipe to select next/previous item.
  • Haptic feedback

Usage

// Struct which is passed to HPicker must conform to HPickeritem and Identifiable protocol.
enum Modes: String, CaseIterable, Identifiable, HPickerItem {
    case first = "First"
    case second = "Second"
    case third = "Third"

    var title: String {
        self.rawValue
    }

    var id: String {
        self.rawValue
    }
}

struct ContentView: View {
    @State var selected: Modes = .second

    var body: some View {
        // Initializer
        HPicker(items: Modes.allCases, selection: $selected)
    }
}