Deprecates API that is now included in SwiftUIPlus

This commit is contained in:
Shaps Benkau 2023-05-06 22:12:58 +01:00
parent 556d42f391
commit afac0c36c4
4 changed files with 34 additions and 32 deletions

View File

@ -1,7 +1,10 @@
import SwiftBackports
import SwiftUI
/// A geometry reader that automatically sizes its height to 'fit' its content.
@available(iOS, unavailable, message: "This has been moved to SwiftUIPlus. You should move to the new package which automatically includes all backports as well 👍")
@available(macOS, unavailable, message: "This has been moved to SwiftUIPlus. You should move to the new package which automatically includes all backports as well 👍")
@available(tvOS, unavailable, message: "This has been moved to SwiftUIPlus. You should move to the new package which automatically includes all backports as well 👍")
@available(watchOS, unavailable, message: "This has been moved to SwiftUIPlus. You should move to the new package which automatically includes all backports as well 👍")
public struct FittingGeometryReader<Content>: View where Content: View {
@State private var height: CGFloat = 10 // must be non-zero

View File

@ -0,0 +1,30 @@
import SwiftBackports
import SwiftUI
@available(iOS, unavailable, message: "This has been moved to SwiftUIPlus and renamed to VScrollStack. You should move to the new package which automatically includes all backports as well 👍", renamed: "VScrollStack")
@available(macOS, unavailable, message: "This has been moved to SwiftUIPlus and renamed to VScrollStack. You should move to the new package which automatically includes all backports as well 👍", renamed: "VScrollStack")
@available(tvOS, unavailable, message: "This has been moved to SwiftUIPlus and renamed to VScrollStack. You should move to the new package which automatically includes all backports as well 👍", renamed: "VScrollStack")
@available(watchOS, unavailable, message: "This has been moved to SwiftUIPlus and renamed to VScrollStack. You should move to the new package which automatically includes all backports as well 👍", renamed: "VScrollStack")
public struct FittingScrollView<Content: View>: View {
private let content: Content
private let showsIndicators: Bool
public init(showsIndicators: Bool = true, @ViewBuilder content: () -> Content) {
self.showsIndicators = showsIndicators
self.content = content()
}
public var body: some View {
GeometryReader { geo in
SwiftUI.ScrollView(showsIndicators: showsIndicators) {
VStack(spacing: 10) {
content
}
.frame(
maxWidth: geo.size.width,
minHeight: geo.size.height
)
}
}
}
}

View File

@ -1,31 +0,0 @@
import SwiftBackports
import SwiftUI
/// A scrollview that behaves more similarly to a `VStack` when its content size is small enough.
public struct FittingScrollView<Content: View>: View {
private let content: Content
private let showsIndicators: Bool
/// A new scrollview
/// - Parameters:
/// - showsIndicators: If true, the scroll view will show indicators when necessary
/// - content: The content for this scroll view
public init(showsIndicators: Bool = true, @ViewBuilder content: () -> Content) {
self.showsIndicators = showsIndicators
self.content = content()
}
public var body: some View {
GeometryReader { geo in
SwiftUI.ScrollView(showsIndicators: showsIndicators) {
VStack(spacing: 10) {
content
}
.frame(
maxWidth: geo.size.width,
minHeight: geo.size.height
)
}
}
}
}