forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuidePage.swift
More file actions
62 lines (55 loc) · 1.72 KB
/
GuidePage.swift
File metadata and controls
62 lines (55 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// GuidePage.swift
// LoopKitUI
//
// Created by Pete Schwamb on 2020-03-04.
// Copyright © 2020 LoopKit Authors. All rights reserved.
//
import SwiftUI
public struct GuidePage<Content, ActionAreaContent>: View where Content: View, ActionAreaContent: View {
let content: Content
let actionAreaContent: ActionAreaContent
@Environment(\.horizontalSizeClass) var horizontalSizeClass
public init(@ViewBuilder content: @escaping () -> Content,
@ViewBuilder actionAreaContent: @escaping () -> ActionAreaContent)
{
self.content = content()
self.actionAreaContent = actionAreaContent()
}
public var body: some View {
VStack(spacing: 0) {
List {
if self.horizontalSizeClass == .compact {
Section(header: EmptyView(), footer: EmptyView()) {
self.content
}
} else {
self.content
}
}
.insetGroupedListStyle()
VStack {
self.actionAreaContent
}
.padding(self.horizontalSizeClass == .regular ? .bottom : [])
.background(Color(UIColor.secondarySystemGroupedBackground).shadow(radius: 5))
}
.edgesIgnoringSafeArea(.bottom)
}
}
struct GuidePage_Previews: PreviewProvider {
static var previews: some View {
GuidePage(content: {
Text("content")
Text("more content")
Image(systemName: "circle")
}) {
Button(action: {
print("Button tapped")
}) {
Text("Action Button")
.actionButtonStyle()
}
}
}
}