Skip to content

Commit

Permalink
Merge branch 'add-previewbackground'
Browse files Browse the repository at this point in the history
  • Loading branch information
finestructure committed Mar 20, 2020
2 parents 33d40e3 + 7a8a071 commit 5c29859
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Sources/Gala/Gala.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ import SwiftUI

public func NightAndDay<A: View>(_ name: String? = nil, @ViewBuilder items: @escaping () -> A) -> some View {
ForEach(ColorScheme.allCases, id: \.self) { scheme in
items()
.previewDisplayName(name.map { "\($0) \(scheme)" } ?? "\(scheme)")
.environment(\.colorScheme, scheme)
// Credit https://twitter.com/heckj/status/1239968146682863618
ZStack {
if scheme == .dark {
Color.black
} else {
Color.white
}
items()
}
.previewDisplayName(name.map { "\($0) \(scheme)" } ?? "\(scheme)")
.environment(\.colorScheme, scheme)
}
}

Expand Down

0 comments on commit 5c29859

Please sign in to comment.