-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathControlPanelView.swift
More file actions
114 lines (105 loc) · 3.42 KB
/
ControlPanelView.swift
File metadata and controls
114 lines (105 loc) · 3.42 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
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
//
// ControlPanelView.swift
// SettingExample
//
// Created by A. Zheng (github.com/aheze) on 2/22/23.
// Copyright © 2023 A. Zheng. All rights reserved.
//
import Setting
import SwiftUI
struct ControlPanelView: View {
@State var volume = Double(8)
@State var airplane = false
@State var wifi = true
@State var bluetooth = true
var body: some View {
SettingStack {
SettingPage(title: "Control Panel") {
SettingCustomView(id: "Controls") {
controls
}
SettingGroup(header: "Volume") {
SettingSlider(
value: $volume,
range: 0 ... 10,
minimumImage: Image(systemName: "speaker.fill"),
maximumImage: Image(systemName: "speaker.wave.3.fill")
)
SettingButton(title: "Export Data") {
print("Data Exported!")
}
}
let a = Binding {
airplane
} set: { newValue in
airplane = newValue
if newValue {
wifi = false
bluetooth = false
}
}
let w = Binding {
wifi
} set: { newValue in
wifi = newValue
if newValue {
airplane = false
}
}
let b = Binding {
bluetooth
} set: { newValue in
bluetooth = newValue
if newValue {
airplane = false
}
}
SettingGroup {
SettingToggle(title: "Airplane Mode", isOn: a)
SettingToggle(title: "Wi-Fi", isOn: w)
SettingToggle(title: "Bluetooth", isOn: b)
}
}
}
}
var controls: some View {
VStack(spacing: 10) {
ForEach(0..<2) { row in
HStack(spacing: 10) {
ForEach(0..<4) { column in
LinearGradient(
colors: [
Color.white.opacity(0.5),
Color.white.opacity(0.2),
],
startPoint: .bottom,
endPoint: .top
)
.cornerRadius(8)
.aspectRatio(1, contentMode: .fill)
.reverseMask {
Text("\(row * 4 + column + 1)")
.foregroundColor(.black)
.font(.title)
.bold()
}
.shadow(color: .black.opacity(0.25), radius: 8, x: 0, y: 6)
}
}
}
}
.padding(16)
.background(
LinearGradient(
colors: [
Color.orange,
Color.pink,
],
startPoint: .bottomLeading,
endPoint: .topTrailing
)
)
.cornerRadius(12)
.padding(.horizontal, 16)
}
}