Gemini/GeminiRenderer/MaybeLazyVStack.swift

41 lines
974 B
Swift

//
// MaybeLazyVStack.swift
// GeminiRenderer
//
// Created by Shadowfacts on 7/12/20.
//
import SwiftUI
struct MaybeLazyVStack<Content: View>: View {
private let alignment: HorizontalAlignment
private let spacing: CGFloat?
private let content: Content
init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> Content) {
self.alignment = alignment
self.spacing = spacing
self.content = content()
}
@ViewBuilder
var body: some View {
if #available(macOS 16.0, iOS 14.0, *) {
LazyVStack(alignment: alignment, spacing: spacing) {
content
}
} else {
VStack(alignment: alignment, spacing: spacing) {
content
}
}
}
}
struct MaybeLazyVStack_Previews: PreviewProvider {
static var previews: some View {
// MaybeLazyVStack()
EmptyView()
}
}