Skip to content

Commit 2fa84a9

Browse files
committed
# Update Example.
1 parent b1e7217 commit 2fa84a9

19 files changed

+94
-167
lines changed

Example/Example/ContentView.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ struct ContentView : View {
4848
NavigationLink(destination: Text("I'm Text")) {
4949
PageRow(title: "PresentationButton",subTitle: "触发时显示内容的按钮控件")
5050
}
51-
// NavigationLink(PageRow(title: "PresentationButton", subTitle: "触发时显示内容的按钮控件"),
52-
// destination: Text("I'm Text")) {
53-
// print("Present 🦄")
54-
// }
51+
// NavigationLink(PageRow(title: "PresentationButton", subTitle: "触发时显示内容的按钮控件"),
52+
// destination: Text("I'm Text")) {
53+
// print("Present 🦄")
54+
// }
5555
NavigationLink(destination: EditButtonPage()) {
5656
PageRow(title: "EditButton",subTitle: "用于切换当前编辑模式的按钮")
5757
}
@@ -74,9 +74,9 @@ struct ContentView : View {
7474
PageRow(title: "Stepper",subTitle: "用以增加或减少数值")
7575
}
7676
// deprecated
77-
// NavigationLink(destination: SegmentedControlPage()) {
78-
// PageRow(title: "SegmentedControl", subTitle: "用以从一组选项中进行选择")
79-
// }
77+
// NavigationLink(destination: SegmentedControlPage()) {
78+
// PageRow(title: "SegmentedControl", subTitle: "用以从一组选项中进行选择")
79+
// }
8080
}
8181

8282
Section(header: Text("布局")) {
@@ -100,10 +100,10 @@ struct ContentView : View {
100100
}
101101
NavigationLink(destination: GroupPage()) {
102102
PageRow(title: "Group",subTitle: "用于集合多个视图,对 Group 设置的属性,将作用于每个子视图")
103-
}.frame(height: 80)
103+
}.frame(height: 80)
104104
NavigationLink(destination: SectionPage()) {
105105
PageRow(title: "Section",subTitle: "用于创建带头/尾部的视图内容,一般结合 `List` 组件使用")
106-
}.frame(height: 80)
106+
}.frame(height: 80)
107107
}
108108
Section(header: Text("导航视图")) {
109109
NavigationLink(destination: NavigationViewPage()) {
@@ -127,15 +127,15 @@ struct ContentView : View {
127127
PageRow(title: "Popover",subTitle: "Pop 弹出一个视图")
128128
}
129129
}
130-
}
131-
.listStyle(GroupedListStyle())
132-
.navigationBarTitle(Text("Example"), displayMode: .large)
133-
.navigationBarItems(trailing: Button(action: {
134-
print("Tap")
135-
}, label: {
136-
Text("Right").foregroundColor(.orange)
137-
}))
138-
130+
}
131+
.listStyle(GroupedListStyle())
132+
.navigationBarTitle(Text("Example"), displayMode: .large)
133+
.navigationBarItems(trailing: Button(action: {
134+
print("Tap")
135+
}, label: {
136+
Text("Right").foregroundColor(.orange)
137+
}))
138+
139139
}
140140
}
141141

Example/Example/Extension/Window+Ext.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ struct MainApp {
1616
// https://stackoverflow.com/questions/57134259/how-to-resolve-keywindow-was-deprecated-in-ios-13-0
1717
public static var keyWindow: UIWindow? {
1818
return UIApplication.shared.connectedScenes
19-
.filter({$0.activationState == .foregroundActive})
20-
.map({$0 as? UIWindowScene})
21-
.compactMap({$0})
22-
.first?.windows
19+
.filter({$0.activationState == .foregroundActive})
20+
.map({$0 as? UIWindowScene})
21+
.compactMap({$0})
22+
.first?.windows
2323
.filter({$0.isKeyWindow}).first ?? nil
2424
}
2525
}

Example/Example/Page/Alert/ActionSheetPage.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,24 @@ struct ActionSheetPage : View {
2323
}
2424
.actionSheet(isPresented: $showSheet, content: {sheet})
2525
}
26-
2726

2827
}
2928

3029
private var sheet: ActionSheet {
3130

32-
let action = ActionSheet(title: Text("Title"),
33-
message: Text("Message"),
34-
buttons:
35-
[.default(Text("Default"), action: {
36-
print("Default")
37-
self.showSheet = false
38-
}),.destructive(Text("destructive"), action: {
39-
print("destructive")
40-
self.showSheet = false
41-
}),.cancel({
42-
print("Cancel")
43-
self.showSheet = false
44-
})])
31+
let action = ActionSheet(title: Text("Title"),
32+
message: Text("Message"),
33+
buttons:
34+
[.default(Text("Default"), action: {
35+
print("Default")
36+
self.showSheet = false
37+
}),.destructive(Text("destructive"), action: {
38+
print("destructive")
39+
self.showSheet = false
40+
}),.cancel({
41+
print("Cancel")
42+
self.showSheet = false
43+
})])
4544

4645
return action
4746
}

Example/Example/Page/Alert/AlertPage.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ struct AlertPage : View {
1313
@State var showAlert = false
1414

1515
var body: some View {
16-
17-
1816
Button(action: {
1917
self.showAlert = true
2018
print("Tap")
2119
}) {
2220
Text("Click")
2321
.font(.system(size: 40,
2422
design: .rounded))
25-
}
23+
}
2624
.alert(isPresented: $showAlert, content: {
2725
Alert(title: Text("确定要支付这100000000美元吗?"),
2826
message: Text("请谨慎操作\n一旦确认,钱款将立即转入对方账户"),

Example/Example/Page/Alert/ModalPage.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ struct ModalPage : View {
1212

1313
@State var showModal = false
1414

15-
// var modal: Modal {
16-
// return Modal(PickerPage(),onDismiss: {
17-
// print("View Dismiss !")
18-
// self.showModal = false
19-
// })
20-
// }
21-
22-
23-
2415
var body: some View {
2516
VStack {
2617
Button(action: {
@@ -31,7 +22,7 @@ struct ModalPage : View {
3122
.font(.system(.largeTitle,
3223
design: .serif))
3324
}//.presentation(showModal ? modal:nil)
34-
// .sheet(isPresented: $showModal, content: PickerPage())
25+
// .sheet(isPresented: $showModal, content: PickerPage())
3526
}
3627
}
3728
}

Example/Example/Page/Alert/PopoverPage.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@ struct PopoverPage : View {
2525
})
2626
}
2727
}
28-
/*
29-
private var popView: PopImagePageover? {
30-
31-
// 以下 Dismiss 回调,按照官方文档说明是: Action which informs the caller when the popover has been dismissed.
32-
// 但实际上在pop消失后,下面 dismiss 回调始终无法触发,导致无法再次show,也许是个bug。
33-
let pop = Popover(content: ImagePage()) {
34-
print("Popover Dismiss !")
35-
self.showPop = false
36-
}
37-
return self.showPop ? pop:nil
38-
}
39-
*/
4028
}
4129

4230
#if DEBUG

Example/Example/Page/Container/GroupPage.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ struct GroupPage : View {
1515
Group {
1616
Text("Hello World !")
1717
Text("Hello World !")
18-
}
19-
.padding(5)
20-
.border(Color.orange.gradient,
21-
width: 1)
22-
.cornerRadius(5)
18+
}
19+
.padding(5)
20+
.border(Color.orange.gradient,
21+
width: 1)
22+
.cornerRadius(5)
2323
Group {
2424
Text("Hello World !")
2525
Text("Hello World !")
26-
}.padding(5)
26+
}.padding(5)
2727
.border(Color.black.gradient,
2828
width: 1)
29-
.cornerRadius(5)
29+
.cornerRadius(5)
3030
Group {
3131
Text("Hello World !")
3232
Text("Hello World !")
33-
}.padding(5)
33+
}.padding(5)
3434
.border(Color.purple.gradient,
3535
width: 1)
3636
.cornerRadius(5)
37-
}.navigationBarTitle(Text("Group"))
37+
}.navigationBarTitle(Text("Group"))
3838
}
3939
}
4040

Example/Example/Page/Container/SectionPage.swift

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct SectionPage : View {
2626
}
2727
.listStyle(GroupedListStyle())
2828
.background(Color.white)
29-
// .listStyle(.grouped)
3029

3130
Button(action: {
3231
print("Tap")
@@ -37,21 +36,10 @@ struct SectionPage : View {
3736
}
3837
.background(Color.orange)
3938
.cornerRadius(5)
40-
41-
/*
42-
Button(action: {
43-
print("Tap")
44-
}) {
45-
Text("SwiftUI")
46-
.foregroundColor(.white)
47-
.frame(width: UIScreen.main.bounds.width - 30,height: 45)
48-
}
49-
.background(Color.orange)
50-
.cornerRadius(5)
51-
*/
52-
}
53-
.background(Color.white)
54-
.navigationBarTitle(Text("Section"))
39+
40+
}
41+
.background(Color.white)
42+
.navigationBarTitle(Text("Section"))
5543

5644
}
5745
}

Example/Example/Page/List/ForEachPage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftUI
1111
struct ForEachPage : View {
1212

1313
let data = (0..<5)
14-
14+
1515
var body: some View {
1616

1717

Example/Example/Page/Navigation/NavigationViewPage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ struct NavigationViewPage : View {
1313
NavigationView {
1414
Text("🧚‍♂️🧚‍♀️🧜‍♂️🧜‍♀️🧞‍♂️🧞‍♀️").blur(radius: 5)
1515
Text("Swifter Swifter")
16-
.bold()
16+
.bold()
1717
.foregroundColor(.orange)
1818
.font(.largeTitle)
1919
}
20-
.navigationBarTitle(Text("NavigationView"))
20+
.navigationBarTitle(Text("NavigationView"))
2121
.navigationBarItems(trailing: Button(action: {
2222
print("Tap")
2323
}, label: {

Example/Example/Page/Navigation/TabBarPage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct TabBarPage : View {
2020
ForEach(0..<imgs.count) { item in
2121
TabItemPage(index: item)
2222
.tabItem({Image(self.imgs[item])})
23-
.tag(item)
23+
.tag(item)
2424
}
2525
}.navigationBarTitle("Tabbar")
2626

Example/Example/Page/Picker/DatePickerPage.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,19 @@ struct DatePickerPage : View {
1616

1717
init() {
1818
let soon = Calendar.current.date(byAdding: .year,
19-
value: -1,
20-
to: server.date) ?? Date()
19+
value: -1,
20+
to: server.date) ?? Date()
2121

2222
let later = Calendar.current.date(byAdding: .year,
23-
value: 1,
24-
to: server.date) ?? Date()
25-
speaceDate = soon..<later
23+
value: 1,
24+
to: server.date) ?? Date()
25+
speaceDate = soon..<later
2626
}
2727

2828
var body: some View {
29-
30-
3129
VStack {
3230
VStack(spacing: 10) {
3331
Text("日期选择").bold()
34-
3532
DatePicker(selection: $server.date, in: server.spaceDate, displayedComponents: .date, label: {
3633
Text("")
3734
})
@@ -40,7 +37,7 @@ struct DatePickerPage : View {
4037
.navigationBarTitle(Text("DatePicker"))
4138

4239
}
43-
40+
4441

4542
}
4643
}
@@ -58,12 +55,12 @@ class DateServer: ObservableObject {
5855

5956
var spaceDate: ClosedRange<Date> {
6057
let soon = Calendar.current.date(byAdding: .year,
61-
value: -1,
62-
to: date) ?? Date()
58+
value: -1,
59+
to: date) ?? Date()
6360

6461
let later = Calendar.current.date(byAdding: .year,
65-
value: 1,
66-
to: date) ?? Date()
62+
value: 1,
63+
to: date) ?? Date()
6764
let speaceDate = soon...later
6865
return speaceDate
6966
}

Example/Example/Page/Picker/PickerPage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct PickerPage : View {
2727
ForEach(0..<leftSource.count) {
2828
Text(self.leftSource[$0]).tag($0)
2929
}
30-
}.frame(width: UIScreen.main.bounds.width/2)
30+
}.frame(width: UIScreen.main.bounds.width/2)
3131
}
3232
VStack {
3333
Text("Right Value:")
@@ -39,9 +39,9 @@ struct PickerPage : View {
3939
ForEach(0..<rightSource.count) {
4040
Text(self.rightSource[$0]).tag($0)
4141
}
42-
}.frame(width: UIScreen.main.bounds.width/2)
42+
}.frame(width: UIScreen.main.bounds.width/2)
4343
}
44-
}//.navigationBarTitle(Text("Picker"))
44+
}
4545
.navigationBarTitle(Text("Picker"))
4646
}
4747
}

Example/Example/Page/Picker/SliderPage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import Combine
1212
struct SliderPage : View {
1313

1414
@State var rating = 0.5
15-
15+
1616
var body: some View {
1717
VStack {
1818
Text("Slider Value: \(self.rating)")
1919
Slider(value: $rating)
2020
.padding(30)
2121

22-
}.navigationBarTitle(Text("Slider"))
22+
}.navigationBarTitle(Text("Slider"))
2323
}
2424
}
2525

Example/Example/Page/Picker/StepperPage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct StepperPage : View {
1919
print(c)
2020
}) {
2121
Text("Stepper Value: \(self.value)")
22-
}.padding(50)
23-
}.navigationBarTitle(Text("Stepper"))
22+
}.padding(50)
23+
}.navigationBarTitle(Text("Stepper"))
2424
}
2525
}
2626

Example/Example/Page/Picker/TogglePage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ struct TogglePage : View {
1616
HStack {
1717
Toggle(isOn: $isOn) {
1818
Text("State: \(self.isOn == true ? "":"")")
19-
}.padding(20)
19+
}.padding(20)
2020
Spacer()
21-
}.navigationBarTitle(Text("Toggle"))
21+
}.navigationBarTitle(Text("Toggle"))
2222
}
2323
}
2424

0 commit comments

Comments
 (0)