Skip to content

Latest commit

 

History

History
106 lines (71 loc) · 3.42 KB

README.md

File metadata and controls

106 lines (71 loc) · 3.42 KB

RadioButton

Platforms Swift Package Manager License: MIT

RadioButton is the missing SwiftUI Radio Button view. It uses the same approach as SwiftUI's Picker radioGroup style only available on macOS.

🔷 Requirements

     ✅ macOS 10.15+
     ✅ Xcode 11.0
     ✅ Swift 5+
     ✅ iOS 14+
     ✅ tvOS 14+
     ✅ watchOS 7+

🔷 Installation

RadioButton is available via Swift Package Manager.

Using Xcode 11, go to File -> Swift Packages -> Add Package Dependency and enter https://github.com/lukluca/RadioButton

or add manually the dependency

dependencies: [
    .package(url: "https://github.com/lukluca/RadioButton", from: "1.1.0")
]

🔷 Usage

It's very simple to use RadioButton, expecially with Swift's enum type:

enum City: String, CaseIterable, Identifiable {
    case milano
    case roma
    case palermo
    
    var id: RawValue {
        rawValue
    }
} 

struct ContentView: View {
    
    @State private var city = City.milano
    
    var body: some View {
        RadioButton(title: "Cities:",
                    itemTitle: \.rawValue,
                    isSelected: $city)
    }
}

It's a requirement that your model must implement CaseIterable, Hashable and Identifiable protocol.

For furter configurations, please see RadioButtonExample folder, it contains a very simple app with all the possible scenario.

🔷 Last version

Last version is 1.2.0.

Starting from this version, you can use a vertical or an horizontal alignment.

🔷 Roadmap / TODOs

Version 1.0.0 of RadioButton contains a very limited set of features, basically no particular feature 😄.

It could be extended by implementing the following tasks:

     ☘️ Add unit/UI tests;
     ☘️ Make view modifier to set common configuration (font, colors, etc);      ☘️ ... many other improvements.

🔷 Contributing

👨🏻‍🔧 Feel free to contribute to RadioButton by creating a pull request, following these guidelines:

  1. Fork RadioButton
  2. Create your feature branch
  3. Commit your changes, along with unit tests
  4. Push to the branch
  5. Create pull request

🔷 Author

     👨‍💻 @lukluca

🔷 License

     📄 RadioButton is available under the MIT license. See the LICENSE file for more info.