Skip to content

Instantly share code, notes, and snippets.

@yosshi4486
Last active July 9, 2020 03:09
Show Gist options
  • Save yosshi4486/0ec065b5b4335d686f38d18f9ecefe90 to your computer and use it in GitHub Desktop.
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.
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