Skip to content

Commit 2a57ea5

Browse files
authored
Merge pull request Jinxiansen#22 from chasel/master
add form page
2 parents 33ee34d + 3a35a44 commit 2a57ea5

File tree

6 files changed

+76
-0
lines changed

6 files changed

+76
-0
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
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

@@ -91,6 +92,7 @@
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>";
@@ -370,6 +373,7 @@
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ struct ContentView : View {
9797
NavigationLink(destination: SectionPage()) {
9898
PageRow(title: "Section",subTitle: "用于创建带头/尾部的视图内容,一般结合 `List` 组件使用")
9999
}.frame(height: 80)
100+
NavigationLink(destination: FormPage(firstName: "", lastName: "")) {
101+
PageRow(title: "Form",subTitle: "表单视图")
102+
}
100103
}
101104
Section(header: Text("导航视图")) {
102105
NavigationLink(destination: NavigationViewPage()) {
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+
}

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ When learning and using `SwiftUI`, if you have any questions, you can join the S
7676
- [Group](#Group)
7777
- [GroupBox](#GroupBox)
7878
- [Section](#Section)
79+
- [Form](#Form)
7980

8081
* <span id="Architectural_D">Architectural Views</span>
8182
- [NavigationView](#NavigationView)
@@ -686,6 +687,24 @@ Section(header: Text("I'm header"), footer: Text("I'm footer")) {
686687
<img width="80%" src="images/example/Section.png"/>
687688
</details>
688689

690+
<h4 id="Form"> Form </h4>
691+
692+
`Form` A container for grouping controls used for data entry, such as in settings or inspectors.
693+
694+
Example:
695+
696+
```swift
697+
Form {
698+
TextField("First Name", text: $firstName)
699+
TextField("Last Name", text: $lastName)
700+
}
701+
```
702+
703+
<details close>
704+
<summary>View running results</summary>
705+
<img width="80%" src="images/example/Form.png"/>
706+
</details>
707+
689708
[🔝](#Layout_D)
690709

691710
<h4 id="NavigationView"> NavigationView </h4>

README_CN.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
- [Group](#Group)
8181
- [GroupBox](#GroupBox)
8282
- [Section](#Section)
83+
- [Form](#Form)
8384

8485
* <span id="Architectural_D">Architectural Views 导航、切换、排列</span>
8586
- [NavigationView](#NavigationView)
@@ -692,6 +693,24 @@ Section(header: Text("I'm header"), footer: Text("I'm footer")) {
692693
<img width="80%" src="images/example/Section.png"/>
693694
</details>
694695

696+
<h4 id="Form"> Form </h4>
697+
698+
`Form` 是对一组数据输入进行控制的容器
699+
700+
Example:
701+
702+
```swift
703+
Form {
704+
TextField("First Name", text: $firstName)
705+
TextField("Last Name", text: $lastName)
706+
}
707+
```
708+
709+
<details close>
710+
<summary>查看运行效果</summary>
711+
<img width="80%" src="images/example/Form.png"/>
712+
</details>
713+
695714
[🔝](#Layout_D)
696715

697716
<h4 id="NavigationView"> NavigationView </h4>

images/example/Form.png

587 KB
Loading

0 commit comments

Comments
 (0)