Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heckj/previewbackground
SwiftUI library component for displaying environment background based in PreviewProvider
https://github.com/heckj/previewbackground
swift swiftui swiftui-components
Last synced: 3 months ago
JSON representation
SwiftUI library component for displaying environment background based in PreviewProvider
- Host: GitHub
- URL: https://github.com/heckj/previewbackground
- Owner: heckj
- License: mit
- Created: 2020-03-16T15:37:49.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-02T23:55:37.000Z (almost 5 years ago)
- Last Synced: 2024-10-10T19:41:14.973Z (4 months ago)
- Topics: swift, swiftui, swiftui-components
- Language: Swift
- Size: 12.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PreviewBackground
[![Actions Status](https://github.com/heckj/PreviewBackground/workflows/CI/badge.svg)](https://github.com/heckj/PreviewBackground/actions)
![swift-5.1](https://img.shields.io/badge/Swift-5.1-orange.svg "Swift 5.1")
![swiftpm](https://img.shields.io/badge/swiftpm-compatible-brightgreen.svg?style=flat "SwiftPM Compatible")
![@heckj](https://img.shields.io/badge/[email protected]?style=flat "Twitter: @heckj")
[![codecov](https://codecov.io/gh/heckj/PreviewBackground/branch/master/graph/badge.svg)](https://codecov.io/gh/heckj/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:
```swift
#if DEBUG
struct PreviewBackground_Previews: PreviewProvider {
static var previews: some View {
Group {
ForEach(ColorScheme.allCases, id: \.self) { colorScheme inPreviewBackground(content: {
Text("hi")
})
.environment(\.colorScheme, colorScheme)
.frame(width: 100, height: 100, alignment: .center)
.previewDisplayName("\(colorScheme)")
}
}
}
}
#endif
```## Build and test
git clone https://github.com/heckj/PreviewBackground
cd PreviewBackground
swift test -v
swiftformat --lint . && swiftlint