Skip to content

SwiftUI additions and helpers that are missing from the official implementation.

License

Notifications You must be signed in to change notification settings

shaps80/SwiftUIPlus

Repository files navigation

watchOS macOS tvOS ios swift

SwiftUI Plus

Introducing a collection of SwiftUI additions to make your projects easier to build.

Additionally, I hope this repo also serves as a great resource for how you to implement SwiftUI features 👍

Sponsor

Building useful libraries like these, takes time away from my family. I build these tools in my spare time because I feel its important to give back to the community. Please consider Sponsoring me as it helps keep me working on useful libraries like these 😬

You can also give me a follow and a 'thanks' anytime.

Twitter

Additions

FittingGeometryReader

A GeometryReader that auto-sizes itself, enabling you to size your content automatically, while still gaining access to the proxy's values like its runtime size.

Scrollable Stacks

  • VScrollStack – Wraps a VStack in a ScrollView while still respecting elements like Spacer
  • HScrollStack – Wraps an HStack in a ScrollView while still respecting elements like Spacer

TextSlider

A new text-based slider that provides gestural interactions via drag operations, as well as direct keyboard entry for more specific values. In addition it supports a styling API for custom designs.

VFlowStack

A vertical line-based stack view that lays out its children horizontally until they no longer fit at which point it begins “wrapping” the children onto a new line.

Similar to UICollectionViewFlowLayout

Haptics and Feedback

Supports various familiar animation-inspired APIs for attaching haptics and other feedback (audio, flash, etc) to state changes.

As a convenience the API provides haptic focused APIs.

  • withHaptic(.selection) { }
  • body.haptic(.selection) { }

However you can also use the withFeedback and feedback APIs to gain more control and access to other feedback methods. In particular you can combine methods to provide more complex feedback to the user.

withFeedback(
    .haptic(.selection)
    .combined(with: 
        .audio(.focusChangeSmall)
    )
)

This example will play a short audio file, while providing haptic feedback (where supported)

Also note, the Feedback Audio APIs provide simplified access to almost all built-in audio files for your convenience.

Dependencies

This package automatically includes SwiftBackports and SwiftUIBackports to provide a richer set of APIs for all SwiftUI clients.

  • If you only want SwiftUI additions, you can use the SwiftUIBackports package directly.
  • If instead you only need the Swift additions, you can use SwiftBackports, which also includes support for olders operating systems.

Installation

You can install manually (by copying the files in the Sources directory) or using Swift Package Manager (preferred)

To install using Swift Package Manager, add this to the dependencies section of your Package.swift file:

.package(url: "https://github.com/shaps80/SwiftUIPlus.git", .upToNextMinor(from: "1.0.0"))

About

SwiftUI additions and helpers that are missing from the official implementation.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages