Coder Social home page Coder Social logo

swiftuiselector's Introduction

SwiftUISelector

A perfect option picker. Great for navigation. Simple to use.

Example 1 Usage with SwiftUIPager

Try it out with @fermoya's package SwiftUIPager!

Swift Package Manager

SwiftUISelector is available through Swift Package Manager.

Add it to an existing Xcode project as a package dependency:

  1. From the File menu, select Swift Packages › Add Package Dependency…
  2. Enter "https://github.com/p-larson/SwiftUISelector" into the package repository URL text field

or

Copy and Paste SwiftUIPager.swift into your project!

Features ✨

  • Smooth Selection
  • User Control
  • Dynamic Options
  • Simple Animations

Requirements

  • iOS 14, macOS 10.15
  • Swift 5.3

Initialization

Important to note:

SelectorView<Option, OptionView>: View where Option: Hashable, OptionView: View
  1. Use Strings for Options (Intended Initializer)
// SelectorView(selectedOption: Binding<Int>, options: [String])
SelectorView(
    selectedOption: $selectedOption,
    options: ["Classial", "Star", "Zodiac", "Text Art"]
)
  1. Custom Options and Option View. (This is to give you a lot of freedom to make the SelectorView fit your needs)
/*
    SelectorView(
        selectedOption: Binding<Int>, 
        options: [Option], 
        @ViewBuilder content: @escaping (Option) -> OptionView
    )
 **/
SelectorView(selectedOption: $selectedOption, options: [1, 2, 3, 4]) { (option) in
    Text(option.description)
        .italic()
        .padding()
        .background(
            Rectangle()
            .fill(Color.clear)
            .border(Color.black, width: 2)
            .padding(.bottom, 4)
        )
}
.font(
    .system(
        size: 24,
        weight: Font.Weight.black,
        design: Font.Design.monospaced
    )
)

License

I'm not good with legal stuff, use my code as you wish, feel free to keep the credit tag in the code, idk.

Open Source, do what ever you want. Maybe follow me on Instagram I guess.

swiftuiselector's People

Contributors

p-larson avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.