forked from aheze/Setting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlaygroundView.swift
More file actions
44 lines (38 loc) · 1.38 KB
/
PlaygroundView.swift
File metadata and controls
44 lines (38 loc) · 1.38 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
//
// PlaygroundView.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 PlaygroundView: View {
/// Settings supports `@State`, `@AppStorage`, `@Published`, and more!
@AppStorage("isOn") var isOn = true
var body: some View {
/// Start things off with `SettingStack`.
SettingStack {
/// This is the main settings page.
SettingPage(title: "Playground") {
/// Use groups to group components together.
SettingGroup(header: "Main Group") {
/// Use any of the pre-made components...
SettingToggle(title: "This value is persisted!", isOn: $isOn)
/// ...or define your own ones!
SettingCustomView {
Image("Logo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 160)
.padding(20)
}
/// Nest `SettingPage` inside other `SettingPage`s!
SettingPage(title: "Advanced Settings") {
SettingText(title: "I show up on the next page!")
}
}
}
}
}
}