Swiftpack.co - Package - heckj/PreviewBackground

PreviewBackground

SwiftUI component that provides a flat background color for Preview based on the environment setting.

This allows it to be used to provide background shadings appropriate to the mode, regardless of device:

#if DEBUG
struct PreviewBackground_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            ForEach(ColorScheme.allCases, id: \.self) { colorScheme in

                PreviewBackground(content: {
                    Text("hi")
                })
                    .environment(\.colorScheme, colorScheme)
                    .frame(width: 100, height: 100, alignment: .center)
                    .previewDisplayName("\(colorScheme)")
            }
        }
    }
}
#endif

swift-5.1 swiftpm @heckj codecov

Build and test

git clone https://github.com/heckj/PreviewBackground
cd PreviewBackground
swift test -v
swiftformat --lint . && swiftlint

Github

link
Stars: 3

Dependencies

Used By

Total: 0

Releases

fixing (I hope) public accessors for consumption of package - 2020-03-16 16:21:40