Contents

lukluca/radiobutton

`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 :smile:.

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.

[license-url]: LICENSE [user-url]: https://github.com/lukluca [project-url]: https://github.com/lukluca/RadioButton

Package Metadata

Repository: lukluca/radiobutton

Default branch: main

README: README.md