RadioButton

1.2.0

A RadioButton view written as SwiftUI developer
lukluca/RadioButton

What's New

1.2.0

2023-12-10T18:10:54Z

Added

  • Now the package supports vertical and horizontal alignment.

Fixed

  • Solved warning "shadows generic parameter" on Item struct.

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.1.0. This version fixes a build error on the package 😭 for watchOS. Please use this version as minimum version if your project supports watchOS.

Starting from this version, you can also customise the item's view.

🔷 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.

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Mar 14 2024 14:40:52 GMT-0900 (Hawaii-Aleutian Daylight Time)