Last active
July 9, 2020 03:09
-
-
Save yosshi4486/0ec065b5b4335d686f38d18f9ecefe90 to your computer and use it in GitHub Desktop.
Previews that apple showed in wwdc20 "Intdoduce SwiftUI" session. We can test dynamic-type, dark-mode, right-to-left language and location by using it.
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
import SwiftUI | |
/// Previews that apple show in wwdc20 "Intdoduce SwiftUI" session. We can test dynamic-type, dark-mode, right-to-left language and location by using it. | |
struct AppleStylePreviewView<Content : View>: View { | |
var childView: Content | |
init(@ViewBuilder builder: () -> (Content)) { | |
self.childView = builder() | |
} | |
var body: some View { | |
Group { | |
childView | |
childView | |
.environment(\.sizeCategory, .extraExtraExtraLarge) | |
childView | |
.preferredColorScheme(.dark) | |
.environment(\.sizeCategory, .extraExtraExtraLarge) | |
childView | |
.preferredColorScheme(.dark) | |
.environment(\.sizeCategory, .extraExtraExtraLarge) | |
.environment(\.layoutDirection, .rightToLeft) | |
.environment(\.locale, Locale(identifier: "ar")) | |
} | |
} | |
} | |
struct AppleStylePreviewView_Previews: PreviewProvider { | |
static var previews: some View { | |
AppleStylePreviewView { | |
Text("Hello world.") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment