ConfigurationPageScrollView.swift 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // ConfigurationPageScrollView.swift
  3. // LoopKitUI
  4. //
  5. // Created by Pete Schwamb on 12/30/22.
  6. // Copyright © 2022 LoopKit Authors. All rights reserved.
  7. //
  8. import SwiftUI
  9. // ConfigurationPageScrollView is a ScrollView (not List) based configuration page.
  10. // The optional action area is pinned to the bottom, but does not overlay any content
  11. public struct ConfigurationPageScrollView<Content: View, ActionArea: View>: View {
  12. var content: Content
  13. var actionArea: ActionArea?
  14. public init(@ViewBuilder content: () -> Content, @ViewBuilder actionArea: () -> ActionArea?) {
  15. self.content = content()
  16. self.actionArea = actionArea()
  17. }
  18. public var body: some View {
  19. GeometryReader { geometry in
  20. ScrollView {
  21. VStack {
  22. content
  23. Spacer()
  24. actionArea
  25. }
  26. .frame(minHeight: geometry.size.height)
  27. }
  28. .background(Color(.systemGroupedBackground))
  29. .background(ignoresSafeAreaEdges: .bottom)
  30. }
  31. }
  32. }