Add availability annotations
This commit is contained in:
parent
4f6b6e9b54
commit
fea6a0d9dd
|
@ -5,9 +5,6 @@ import PackageDescription
|
|||
|
||||
let package = Package(
|
||||
name: "UIPreview",
|
||||
platforms: [
|
||||
.iOS(.v13)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension Binding {
|
||||
public static func mock(_ value: Value) -> Self {
|
||||
var value = value
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
Text("Hello, world!")
|
||||
|
@ -7,6 +8,7 @@ struct ContentView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
|
@ -14,6 +16,7 @@ struct ContentView_Previews: PreviewProvider {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct Demo_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension ForEach where Data.Element: Hashable, ID == Data.Element, Content: View {
|
||||
init(values: Data, content: @escaping (Data.Element) -> Content) {
|
||||
self.init(values, id: \.self, content: content)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension View {
|
||||
public func previewLightTheme() -> some View {
|
||||
ColorSchemePreview(scheme: .light) { self }
|
||||
|
@ -10,12 +11,14 @@ extension View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension ColorScheme {
|
||||
var previewName: String {
|
||||
String(describing: self).capitalized
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct ColorSchemePreview<Preview: View>: View {
|
||||
private let preview: Preview
|
||||
private let scheme: ColorScheme
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import SwiftUI
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension View {
|
||||
public func previewAsComponent() -> some View {
|
||||
ComponentPreview(component: self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension ContentSizeCategory {
|
||||
static let smallestAndLargest = [allCases.first!, allCases.last!]
|
||||
|
||||
|
@ -15,6 +16,7 @@ extension ContentSizeCategory {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct ComponentPreview<Component: View>: View {
|
||||
var component: Component
|
||||
|
||||
|
|
|
@ -10,12 +10,14 @@ public let defaultDeviceNames: [String] =
|
|||
"iPad Pro (12.9-inch) (4th generation)"
|
||||
]
|
||||
|
||||
@available(iOS 13, *)
|
||||
extension View {
|
||||
public func previewAsScreen(deviceNames: [String] = defaultDeviceNames) -> some View {
|
||||
ScreenPreview(screen: self, deviceNames: deviceNames)
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13, *)
|
||||
struct ScreenPreview<Screen: View>: View {
|
||||
var screen: Screen
|
||||
var deviceNames: [String]
|
||||
|
|
Loading…
Reference in New Issue