Swiftpack.co - jasonhawkins/SwiftUIExtensions as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jasonhawkins.
jasonhawkins/SwiftUIExtensions v0.2.0
A Swift package for useful extensions to SwiftUI.
⭐️ 2
🕓 3 years ago
.package(url: "https://github.com/jasonhawkins/SwiftUIExtensions.git", from: "v0.2.0")

SwiftUIExtensions

Availability

This package is compatible with Xcode 11, macOS 10.15, iOS 13, tvOS 13, and watchOS 6.0.

Example

This example shows how to generate a preview for all of the cases defined in the ColorScheme extension.

By accessing its static property, allCasesIdentifiableBySelf, we'll generate previews for both the .light and .dark variants. MyView is then modified with a custom ViewModifier called AdaptingColorScheme which provides padding, sets an appropriate background color, and applies the appearance environment modifier.

struct MyView_Previews: PreviewProvider {

static var previews: some View {
    ForEach(ColorScheme.allCasesIdentifiableBySelf) { appearance in
        MyView()
            .previewLayout(.sizeThatFits)                    
            .modifier(AdaptingColorScheme(appearance))
    }
}

GitHub

link
Stars: 2
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Release 0.2.0
4 years ago

Renamed common to allCases and creates a new static property called commonCases. The latter of which returns small, medium, large, and extra large ContentSizeCategories.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics