Skip to content

PreviewDevice - library with elegant syntax for Preview Device in SwiftUI

License

Notifications You must be signed in to change notification settings

AppleSwiftUI/PreviewDevice

 
 

Repository files navigation

PreviewDevice

Platforms Version SPM Xcode Twitter

Requirements

  • Xcode 13.x
  • iOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+

Usage

Example:

import PreviewDevice

struct ContentView_Previews: PreviewProvider {
    
    static var previews: some View {
        ContentView()
            .previewDevice(device: .iphone12, colorSchemes: ColorScheme.allCases)
    }
}

Result

Preview on device

.previewDevice(device: .iphone12)

Preview on devices

.previewDevices(device: [.iphone8, .iphone11Pro .iphone12, .iphone12ProMax])

Preview on device with color scheme (light, dark)

.previewDevice(device: .iphone12, colorScheme: .light)

Preview on device with ColorSchemes

.previewDevice(device: .iphone12, colorScheme: [.light, .dark])

Preview on device with orientation (InterfaceOrientation)

.previewDevice(device: .iphone12, orientation: .portrait)

Preview on device with orientations

.previewDevice(device: .iphone12, orientations: [.portrait, .landscapeLeft, .landscapeRight])

Preview on device with orientation and color schemes

    previewDevice(device: Device, orientation: InterfaceOrientation, colorSchemes: [ColorScheme])

Installation

Specify next line in Podfile:

pod PreviewDevice

Open Xcode, File -> Swift Packages -> Add Packages.. and paste library git url:

https://github.com/Toni77777/PreviewDevice.git

Articles

Meet PreviewDevice 0.7.0

License

PreviewDevice is released under the MIT license.

About

PreviewDevice - library with elegant syntax for Preview Device in SwiftUI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 95.8%
  • Ruby 4.2%