Contents

shaps80/swiftuiplus

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

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"))

Package Metadata

Repository: shaps80/swiftuiplus

Default branch: main

README: README.md