Swiftpack.co - apparata/SwiftUIToolbox as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by apparata.
apparata/SwiftUIToolbox SwiftUI-2
A toolbox of various SwiftUI related code.
⭐️ 9
🕓 12 weeks ago
iOS macOS tvOS
.package(url: "https://github.com/apparata/SwiftUIToolbox.git", from: "SwiftUI-2")

SwiftUIToolbox

The SwiftUIToolbox framework consists of a number of convenience views and utilities for use with SwiftUI.

License

See the LICENSE file for licensing information.

Table of Contents

Button Styles

ActionButtonStyle

The ActionButtonStyle is a ButtonStyle that looks like the "Open" button in the App Store or TestFlight apps.

Example

Button(action: { }) {
    Text("Open")
}.buttonStyle(ActionButtonStyle())

PrimaryButtonStyle

The primary button style has a back plate with rounded corners.

SecondaryButtonStyle

The secondary button style has a light back plate with rounded corners.

Colors

SystemColors

A Color extension that adds the iOS system colors from UIColor.

Example

Color.systemRed
Color.systemGreen
Color.secondaryLabel
Color.systemFill

Controls

DimView

A black view with 30% opacity (by default) that dims views behind it.

Example

ZStack {
    SomeContentView()
    DimView(opacity: 0.3)
}

EnumPicker

A convenience wrapper for Picker that makes it easier to use an enum for as the options.

The enum must conform to the Pickable protocol.

public typealias Pickable = CaseIterable
                          & Identifiable
                          & Hashable
                          & CustomStringConvertible

Example

enum Fruit: Pickable {
    case apple
    case banana
    case mango
    case orange
    case pear
    
    var id: Self { self }
    
    var description: String {
        switch self {
        case .apple: return "🍎 Apple"
        case .banana: return "🍌 Banana"
        case .mango: return "🥭 Mango"
        case .orange: return "🍊 Orange"
        case .pear: return "🍐 Pear"
        }
    }
}

struct ExampleView: View {
    @State var selectedFruit: Fruit = .apple

    var body: some View {
        EnumPicker("Fruit", selection: $selectedFruit)
            .pickerStyle(SegmentedPickerStyle())
            .padding()
    }
}

HSeparator

A 1 pixel horizontal separator view.

Example

HSeparator(color: .separator)

PageDots

Emulates the UIKit page control.

Example

PageDots(currentPage: 0, pageCount: 3)

PrimaryButton

The primary button has a back plate with rounded corners.

SecondaryButton

The secondary button has a light back plate with rounded corners.

VSeparator

A 1 pixel vertical separator view.

VSeparator(color: .separator)

Fonts

AllFontsView

The AllFontsView is a list view that is available in DEBUG builds that displays all the available system fonts.

Example

AllFontsView()

Modifiers

inverseMask(...)

Same as the mask modifier, only inverted.

debugPrint(...)

Prints a value and returns the unmodified view.

Shapes

Triangle

Triangle shape that points upwards.

UIKit Previews

UIViewPreview

Allows for objects that inherit from UIView to be previewed in the SwiftUI preview window in Xcode.

UIViewControllerPreview

Allows for objects that inherit from UIViewController to be previewed in the SwiftUI preview window in Xcode.

Utilities

SearchFilter

Object that conforms to ObservableObject for making simple search filters.

Utility Views

Placeholder

The Placeholder view is a rounded rectangle with an optional title and the size of the view as a text label.

Example

Placeholder()
    .frame(width: 150, height: 100)

Wrapped AppKit Views

MacSearchField

Wrapper view for NSSearchField.

SidebarSearchField

Wrapper view for NSSearchField specifically for use in the main siderbar.

Wrapped UIKit Views

Blur

Wrapper view for UIVisualEffectView with blur effect

Example

Blur(isPresented: $showBlur, style: .systemThinMaterial, animated: true)

GitHub

link
Stars: 9
Last commit: 12 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.6.0: Added View+SmoothCornerRadius
12 weeks ago
  • Added View+SmoothCornerRadius

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