GitXplorerGitXplorer
m

EnvironmentVariationPreview

public
2 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
39412996d225104c4f80773babe42a7460acd3f5

Merge pull request #6 from mackoj/feat/fixVisionBuildSupport

mmackoj committed 9 months ago
Unverified
5b9fb0b04d367d9a42eaf3956e67536f1eb6e574

fix: now compile for vision os

mmackoj committed 9 months ago
Verified
f35b2d40df4f9d087b62959b3db57cb7a9d9c694

Merge pull request #5 from mackoj/feat/appleWatchTV

mmackoj committed a year ago
Unverified
587105a90e89591522110171f0ca295925c0e6a8

Fix Apple TV Apple Watch support

mmackoj committed a year ago
Verified
3611c54e86c109402d29c867fc04d6f993d3676d

Merge pull request #4 from mackoj/feat/ios14

mmackoj committed a year ago
Unverified
095d3dddc0ce7972df654bb07d8b5d41e29774b3

Fix ios14 support

mmackoj committed a year ago

README

The README file for this repository.

EnvironmentVariationPreview

EnvironmentVariationPreview is a SwiftUI library designed to simplify the process of previewing your SwiftUI views in a variety of environments. The code of this library work exclusively with the simulator.

video image
Capture d’écran 2023-03-28 à 22 28 09

Why

Maintaining an app that must work across diverse environments (such as varying dynamic sizes, appearances, accessibility settings, locales, screen sizes, etc.) can be challenging. One way to address this issue is through snapshot testing, which enables you to capture snapshots of all possible configurations and compare them to expected results to prevent regressions. EnvironmentVariationPreview was created to facilitate snapshot testing for your UI library and to provide a streamlined approach for testing your UI against different environment settings.

Capture d’écran 2023-03-28 à 22 29 38

Features

  • Effortlessly modify the rendering of SwiftUI previews with a wide range of environment values.
  • Extensive support for various environment values, including accessibility settings, color schemes, fonts, layout direction, and more.
  • Seamless integration with your SwiftUI projects, enhancing your development workflow.

Installation

Swift Package Manager

To add SwiftUI Environment Value Preview to your project using Swift Package Manager, add the following dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/mackoj/EnvironmentVariationPreview.git", from: "1.0.0")
]

Usage

To use EnvironmentVariationPreview in your SwiftUI project, follow these steps:

  • Import the library in your SwiftUI file: import EnvironmentVariationPreview
  • Apply the .environmentVariations() view modifier to your preview.
  • Provide an array of environment values you wish to preview, such as [.colorScheme(.light), .colorScheme(.dark), .layoutDirection(.rightToLeft), .dynamicTypeSize(.xSmall), .dynamicTypeSize(.large), .dynamicTypeSize(.xxxLarge)].

For example:

import Foundation
import SwiftUI
import EnvironmentVariationPreview

struct MyView_Previews: PreviewProvider {
  static var previews: some View {
    MyView()
      .environmentVariations([
        .colorScheme(.light),
        .colorScheme(.dark),
        .layoutDirection(.rightToLeft),
        .dynamicTypeSize(.xSmall),
        .dynamicTypeSize(.large),
        .dynamicTypeSize(.xxxLarge)
      ])
  }
}

In order to make it work you just have to add a view modifier in your SwiftUI preview.

License

SwiftUI Environment Value Preview is released under the MIT License. See LICENSE for details.

Contributing

We welcome contributions from the community to help improve and expand EnvironmentVariationPreview. If you'd like to contribute, please follow these steps:

  • Fork the repository on GitHub.
  • Create a new branch with a descriptive name, e.g., feature/new-environment-value.
  • Implement your changes or bug fixes, ensuring that your code is clean and well-documented.
  • Submit a pull request, detailing your changes and the purpose behind them.
  • Make sure to keep your pull request up-to-date with the base branch, resolving any conflicts that may arise.
  • By contributing, you agree that your contributions will be licensed under the same license as the original project.

If you have any questions or need help, feel free to open an issue or reach out to the maintainers. We appreciate your support!