Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new SwiftIU preview struct
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import SwiftUI | ||
|
||
/// Preview content on iPhone 12 pro in light mode, iPhone 12 mini in dark mode | ||
public struct Preview<Content: View>: View { | ||
let content: Content | ||
|
||
/// Create a preview for iPhone 12 pro and iPhone 12 mini | ||
/// - Parameter content: Content | ||
public init(@ViewBuilder _ content: () -> Content) { | ||
self.content = content() | ||
} | ||
|
||
public var body: some View { | ||
Group { | ||
self.content | ||
.environment(\.colorScheme, .light) | ||
.preferredColorScheme(.light) | ||
.navigationBarHidden(true) | ||
.previewDevice("iPhone 12 Pro") | ||
.previewDisplayName("Pro, light mode") | ||
|
||
self.content | ||
.environment(\.colorScheme, .dark) | ||
.preferredColorScheme(.dark) | ||
.navigationBarHidden(true) | ||
.previewDevice("iPhone 12 mini") | ||
.previewDisplayName("Mini, dark mode") | ||
} | ||
} | ||
} |