forked from AparokshaUI/adwaita-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Page.swift
161 lines (150 loc) · 4.25 KB
/
Page.swift
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//
// Page.swift
// Adwaita
//
// Created by david-swift on 25.09.23.
//
// swiftlint:disable missing_docs implicitly_unwrapped_optional
import Adwaita
import Foundation
enum Page: String, Identifiable, CaseIterable, Codable, CustomStringConvertible {
case welcome
case counter
case windows
case toolbar
case transition
case dice
case dialog
case alertDialog
case toast
case list
case carousel
case viewSwitcher
case form
case passwordChecker
case popover
case flowBox
case navigationView
case picture
case idle
case fixed
var id: Self {
self
}
var label: String {
switch self {
case .viewSwitcher:
return "View Switcher"
case .flowBox:
return "Flow Box"
case .navigationView:
return "Navigation View"
case .alertDialog:
return "Alert Dialog"
case .passwordChecker:
return "Password Checker"
default:
return rawValue.capitalized
}
}
var icon: Icon? {
switch self {
case .welcome:
return .default(icon: .emojiNature)
default:
return nil
}
}
var description: String {
switch self {
case .welcome:
return "This is a collection of examples for the Swift Adwaita package"
case .counter:
return "A simple sample view"
case .windows:
return "Showcase window management"
case .toolbar:
return "Toggle the bottom toolbar"
case .transition:
return "A slide transition between two views"
case .dice:
return "Roll the dice"
case .dialog:
return "A window on top of another window"
case .alertDialog:
return "A dialog presenting a message or question"
case .toast:
return "Show a notification inside of your app"
case .list:
return "Organize content in multiple rows"
case .carousel:
return "Scroll horizontally on a touchpad or touchscreen, or scroll down on your mouse wheel"
case .viewSwitcher:
return "Switch the window's view"
case .form:
return "Group controls used for data entry"
case .passwordChecker:
return "Check the validity of a password"
case .popover:
return "Present content in a bubble-like context popup"
case .flowBox:
return "Display views in a reflowing grid"
case .navigationView:
return "A page-based navigation container"
case .picture:
return "Display an image"
case .idle:
return "Update UI from an asynchronous context"
case .fixed:
return "Place widgets in a coordinate system"
}
}
// swiftlint:disable cyclomatic_complexity
@ViewBuilder
func view(app: GTUIApp!, window: GTUIApplicationWindow, toast: Signal, pictureURL: URL?) -> Body {
switch self {
case .welcome:
[]
case .counter:
CounterDemo()
case .windows:
WindowsDemo(app: app)
case .toolbar:
ToolbarDemo(app: app)
case .transition:
TransitionDemo()
case .dice:
DiceDemo()
case .dialog:
DialogDemo()
case .alertDialog:
AlertDialogDemo()
case .toast:
ToastDemo(toast: toast)
case .list:
ListDemo()
case .carousel:
CarouselDemo()
case .viewSwitcher:
ViewSwitcherDemo(app: app)
case .form:
FormDemo(app: app)
case .passwordChecker:
PasswordCheckerDemo(app: app)
case .popover:
PopoverDemo()
case .flowBox:
FlowBoxDemo()
case .navigationView:
NavigationViewDemo(app: app)
case .picture:
PictureDemo(url: pictureURL, app: app, window: window)
case .idle:
IdleDemo()
case .fixed:
FixedDemo()
}
}
// swiftlint:enable cyclomatic_complexity
}
// swiftlint:enable missing_docs implicitly_unwrapped_optional