Skip to content

Commit dfb0727

Browse files
authored
Merge pull request Jinxiansen#3 from Jinxiansen/master
pr latest
2 parents 93c065f + 1a475e1 commit dfb0727

27 files changed

+217
-212
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@
4040
41E4DCCE22B4ADB000F78522 /* PopoverPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E4DCCD22B4ADB000F78522 /* PopoverPage.swift */; };
4141
41E4DCD022B4B4FF00F78522 /* ActionSheetPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41E4DCCF22B4B4FF00F78522 /* ActionSheetPage.swift */; };
4242
41F36F0A22AA84D600B9172D /* ButtonPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41F36F0922AA84D600B9172D /* ButtonPage.swift */; };
43-
41F36F0C22AA87AF00B9172D /* TabBarPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41F36F0B22AA87AF00B9172D /* TabBarPage.swift */; };
43+
41F36F0C22AA87AF00B9172D /* TableViewPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41F36F0B22AA87AF00B9172D /* TableViewPage.swift */; };
4444
41F36F0E22AA8AEC00B9172D /* WebViewPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41F36F0D22AA8AEC00B9172D /* WebViewPage.swift */; };
4545
41F36F1022AA915300B9172D /* ListPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41F36F0F22AA915300B9172D /* ListPage.swift */; };
4646
41FE99E722AAD08A008135A0 /* NavigationButtonPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41FE99E622AAD08A008135A0 /* NavigationButtonPage.swift */; };
4747
41FE99E922AAD7B0008135A0 /* EditButtonPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41FE99E822AAD7B0008135A0 /* EditButtonPage.swift */; };
4848
41FE99F022AADF9F008135A0 /* DatePickerPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41FE99EF22AADF9F008135A0 /* DatePickerPage.swift */; };
49+
BD99734E23B49BB800A3E3F0 /* FormPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD99734D23B49BB800A3E3F0 /* FormPage.swift */; };
4950
D74985BC231634DA00C4D46D /* Window+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74985BB231634DA00C4D46D /* Window+Ext.swift */; };
5051
/* End PBXBuildFile section */
5152

@@ -85,12 +86,13 @@
8586
41E4DCCD22B4ADB000F78522 /* PopoverPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopoverPage.swift; sourceTree = "<group>"; };
8687
41E4DCCF22B4B4FF00F78522 /* ActionSheetPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionSheetPage.swift; sourceTree = "<group>"; };
8788
41F36F0922AA84D600B9172D /* ButtonPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonPage.swift; sourceTree = "<group>"; };
88-
41F36F0B22AA87AF00B9172D /* TabBarPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarPage.swift; sourceTree = "<group>"; };
89+
41F36F0B22AA87AF00B9172D /* TableViewPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewPage.swift; sourceTree = "<group>"; };
8990
41F36F0D22AA8AEC00B9172D /* WebViewPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewPage.swift; sourceTree = "<group>"; };
9091
41F36F0F22AA915300B9172D /* ListPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPage.swift; sourceTree = "<group>"; };
9192
41FE99E622AAD08A008135A0 /* NavigationButtonPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationButtonPage.swift; sourceTree = "<group>"; };
9293
41FE99E822AAD7B0008135A0 /* EditButtonPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditButtonPage.swift; sourceTree = "<group>"; };
9394
41FE99EF22AADF9F008135A0 /* DatePickerPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerPage.swift; sourceTree = "<group>"; };
95+
BD99734D23B49BB800A3E3F0 /* FormPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormPage.swift; sourceTree = "<group>"; };
9496
D74985BB231634DA00C4D46D /* Window+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Window+Ext.swift"; sourceTree = "<group>"; };
9597
/* End PBXFileReference section */
9698

@@ -110,6 +112,7 @@
110112
children = (
111113
4132A45D22AD561500A8DBBE /* GroupPage.swift */,
112114
4132A45F22AD624700A8DBBE /* SectionPage.swift */,
115+
BD99734D23B49BB800A3E3F0 /* FormPage.swift */,
113116
);
114117
path = Container;
115118
sourceTree = "<group>";
@@ -128,7 +131,7 @@
128131
isa = PBXGroup;
129132
children = (
130133
4132A46722AE8D5200A8DBBE /* NavigationViewPage.swift */,
131-
41F36F0B22AA87AF00B9172D /* TabBarPage.swift */,
134+
41F36F0B22AA87AF00B9172D /* TableViewPage.swift */,
132135
);
133136
path = Navigation;
134137
sourceTree = "<group>";
@@ -365,11 +368,12 @@
365368
4161B33022AB6D2900CD5A1B /* ScrollViewPage.swift in Sources */,
366369
41FE99F022AADF9F008135A0 /* DatePickerPage.swift in Sources */,
367370
4161B33422AB83B700CD5A1B /* StepperPage.swift in Sources */,
368-
41F36F0C22AA87AF00B9172D /* TabBarPage.swift in Sources */,
371+
41F36F0C22AA87AF00B9172D /* TableViewPage.swift in Sources */,
369372
4132A46B22B00E6100A8DBBE /* PickerPage.swift in Sources */,
370373
4196ABCC22A97AB1008B8FD2 /* ContentView.swift in Sources */,
371374
4132A46622AD70D400A8DBBE /* View+Ext.swift in Sources */,
372375
415F044F22ABA1E3003E59FC /* TogglePage.swift in Sources */,
376+
BD99734E23B49BB800A3E3F0 /* FormPage.swift in Sources */,
373377
41F36F0E22AA8AEC00B9172D /* WebViewPage.swift in Sources */,
374378
4132A46022AD624700A8DBBE /* SectionPage.swift in Sources */,
375379
41C7E65E22B4A9680074D4F6 /* ModalPage.swift in Sources */,

Example/Example/ContentView.swift

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ 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-
// }
5551
NavigationLink(destination: EditButtonPage()) {
5652
PageRow(title: "EditButton",subTitle: "用于切换当前编辑模式的按钮")
5753
}
@@ -73,10 +69,7 @@ struct ContentView : View {
7369
NavigationLink(destination: StepperPage()) {
7470
PageRow(title: "Stepper",subTitle: "用以增加或减少数值")
7571
}
76-
// deprecated
77-
// NavigationLink(destination: SegmentedControlPage()) {
78-
// PageRow(title: "SegmentedControl", subTitle: "用以从一组选项中进行选择")
79-
// }
72+
8073
}
8174

8275
Section(header: Text("布局")) {
@@ -100,16 +93,19 @@ struct ContentView : View {
10093
}
10194
NavigationLink(destination: GroupPage()) {
10295
PageRow(title: "Group",subTitle: "用于集合多个视图,对 Group 设置的属性,将作用于每个子视图")
103-
}.frame(height: 80)
96+
}.frame(height: 80)
10497
NavigationLink(destination: SectionPage()) {
10598
PageRow(title: "Section",subTitle: "用于创建带头/尾部的视图内容,一般结合 `List` 组件使用")
106-
}.frame(height: 80)
99+
}.frame(height: 80)
100+
NavigationLink(destination: FormPage(firstName: "", lastName: "")) {
101+
PageRow(title: "Form",subTitle: "表单视图")
102+
}
107103
}
108104
Section(header: Text("导航视图")) {
109105
NavigationLink(destination: NavigationViewPage()) {
110106
PageRow(title: "NavigationView",subTitle: "用于创建包含顶部导航栏的视图容器")
111107
}
112-
NavigationLink(destination: TabBarPage()) {
108+
NavigationLink(destination: TableViewPage()) {
113109
PageRow(title: "TabBar",subTitle: "用于创建包含底部 TabBar 的视图容器")
114110
}
115111
}
@@ -127,15 +123,15 @@ struct ContentView : View {
127123
PageRow(title: "Popover",subTitle: "Pop 弹出一个视图")
128124
}
129125
}
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-
126+
}
127+
.listStyle(GroupedListStyle())
128+
.navigationBarTitle(Text("Example"), displayMode: .large)
129+
.navigationBarItems(trailing: Button(action: {
130+
print("Tap")
131+
}, label: {
132+
Text("Right").foregroundColor(.orange)
133+
}))
134+
139135
}
140136
}
141137

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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@ 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: {
27-
Alert(title: Text("确定要支付这100000000美元吗"),
25+
Alert(title: Text("确定要支付这100000美元吗"),
2826
message: Text("请谨慎操作\n一旦确认,钱款将立即转入对方账户"),
29-
primaryButton: .destructive(Text("确认")) { print("转出中...") },
27+
primaryButton: .destructive(Text("确认")) { print("已转出") },
3028
secondaryButton: .cancel())
3129
}).navigationBarTitle(Text("Alert"))
3230

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/Button/EditButtonPage.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ struct EditButtonPage : View {
3737
print(source,destination)
3838
}
3939

40-
4140
}
4241

4342
class dataSource: ObservableObject {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// FormPage.swift
3+
// Example
4+
//
5+
// Created by Chasel Li on 12/26/19.
6+
// Copyright © 2019 晋先森. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
struct FormPage: View {
12+
13+
@State var firstName: String
14+
@State var lastName: String
15+
16+
var body: some View {
17+
VStack {
18+
Form {
19+
TextField("First Name", text: $firstName)
20+
TextField("Last Name", text: $lastName)
21+
}
22+
}.navigationBarTitle(Text("Form"))
23+
24+
}
25+
}
26+
27+
struct FormPage_Previews: PreviewProvider {
28+
static var previews: some View {
29+
FormPage(firstName: "", lastName: "")
30+
}
31+
}

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import SwiftUI
1111
struct ForEachPage : View {
1212

1313
let data = (0..<5)
14-
14+
1515
var body: some View {
16-
17-
1816
ForEach(data) { e in
1917
Text("Hello \(e)")
2018
.bold()

Example/Example/Page/List/ListPage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SwiftUI
1010

1111
struct ListPage : View {
1212
var body: some View {
13-
List(0..<5) { item in
13+
List(0..<30) { item in
1414
Text("Hello World !")
1515
}.navigationBarTitle(Text("List"), displayMode: .large)
1616
}

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: {

0 commit comments

Comments
 (0)