SwiftUIZ

main

Build incredible expansions to SwiftUI with this toolkit for framework developers.
SwiftUIX/SwiftUIZ

Warning

While a large portion of this package is production ready, the package and its documentation is still in alpha.

Directly contact @vmanot for any queries related to this package.

SwiftUIZ

A framework to support ambitious expansions to SwiftUI. Public API surface is production-ready.



Note

This section is incomplete and is in active iteration.

Usage

PreviewCatalogGroup

PreviewCatalogGroup is a Scene that automatically generates a navigated list of previews.

Screenshot 2024-06-12 at 10 17 10 AM

Simply import SwiftUIZ and add PreviewCatalogGroup() to your App:

import SwiftUIZ

@main
struct MyProjectApp: App {
    var body: some Scene {
         // replace the WidowsGroup code with PreviewCatalogGroup()
         // WindowGroup {
         //     ContentView()
         // }
        PreviewCatalogGroup()
    }
}

To make a SwiftUI view discoverable, annotate it with the @RuntimeDiscoverable macro.

Runtime discoverable conform to ViewPreview instead of View. For example:

import SwiftUIZ

@RuntimeDiscoverable // property wrapper
struct MyView1: ViewPreview { // conforms to ViewPreview instead of View
    // Optional - set custom title
    // Name of the view (e.g. MyView1) is default
    static var title: String {
        "Custom Title for My View 1"
    }
    
    var body: some View {
        Text("My View 1")
    }
}

@RuntimeDiscoverable
struct MyView2: ViewPreview {
    var body: some View {
        Text("My View 2")
    }
}

@RuntimeDiscoverable
struct MyView3: ViewPreview {
    var body: some View {
        Text("My View 3")
    }
}

Acknowledgments

This library wouldn't be possible without these incredible OSS projects that I'm building upon.

MarkdownUI by @gonzalezreal
  • Link: (swift-markdown-ui)[https://github.com/gonzalezreal/swift-markdown-ui]
  • License: MIT License
  • Authors: @gonzalezreal
  • Notes:
    • BlockSequence no longer uses a VStack, allowing for lazy loading of large Markdown content via LazyVStack { ... }.
    • Integration of SwiftUIX for advanced view caching and Nuke for efficient remote image loading.
    • The result builder DSL has been removed.
SwiftUI-Macros by @Wouter01
  • Link: SwiftUI-Macros-ui
  • License: MIT License
  • Authors: @Wouter01
  • Notes:
    • EnvironmentValues, EnvironmentKey, EnvironmentStorage and EnvironmentValues are used.
    • Rather than add Wouter01's (fantastic!) library to SwiftUIZ as a dependency, I chose to inline it for a couple of reasons:
      • swift-syntax does not have a stable API surface as of writing this, resulting in irreconcilable conflicts during dependency resolution.
      • SwiftPM is slow as f*** at package resolution, I'm going to avoid adding any dependencies for 1-3 file packages.
      • The implementation is going to fork ways and leverage SwiftSyntaxUtilities from Swallow to make it even more concise.

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

Last updated: Sat Jan 11 2025 04:22:54 GMT-1000 (Hawaii-Aleutian Standard Time)