Skip to content

danielsaidi/StandardActions

Repository files navigation

Project Icon

Version Swift 6.0 Documentation MIT License Sponsor my work

StandardActions

StandardActions is a SwiftUI library that defines standard action types, with localized titles, icons, shortcuts, etc.

StandardActions preview

StandardActions has a StandardActionType enum with 130+ common actions like .add, .remove, etc., as well as a StandardToggleType enum with common values, a StandardAction with common actions, etc.

Each StandardActionType has a localized .title, an .image, a .role, and an optional .keyboardShortcut. These properties will automatically be applied when you create type-based buttons, labels, links, and toggles.

Installation

StandardActions can be installed with the Swift Package Manager:

https://github.com/danielsaidi/StandardActions.git

Support My Work

You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.

Getting Started

You can create Button, Label and Link views for any StandardActionType. This will automatically apply a localized title, icon, etc.

Button(.add) { ... }
Label(.add) { ... }
Link(.email, destination: .email(...))

You can create Toggle views for any StandardToggleType and a boolean binding. This automatically applies the localized title, icon, role, shortcut, accessibility, etc. for the provided toggle type, based on the toggle state:

Toggle(.isVisible, isOn: $isVisible)

You can use StandardAction to generate a standard control for common actions, like .call(phoneNumber:), .copy(_:), .email(address:), and .openUrl(_:).

/// Render a control for the provided action
StandardActionControl(.email(address: "[email protected]"))

/// Render a list item with the action as a trailing action
StandardActionListItem(
    actoin: .email(address: "[email protected]"),
    title: ..., 
    text: ...
)

You can also use URL extensions like .call(number:) and .email(address:) to generate URLs for common URL-based actions.

Localization

This library is localized in the following languages:

  • 🇩🇰 Danish
  • 🇺🇸 English (US)
  • 🇫🇷 French
  • 🇬🇪 Georgian
  • 🇩🇪 German
  • 🇳🇴 Norwegian Bokmål
  • 🇪🇸 Spanish
  • 🇸🇪 Swedish

You can add more locales to the Localizable.xcstrings file in the Resources folder, then localize them as described in this blog post.

Documentation

The online documentation has more information, articles, code examples, etc.

Demo Application

This repository will get a demo app after it reaches 100 stars.

Contact

Feel free to reach out if you have questions, or want to contribute in any way:

License

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

About

A SwiftUI library with standard button types that have localized titles & icons.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors 4

  •  
  •  
  •  
  •