Skip to content

Commit 6923e0d

Browse files
committed
# Update Example.
1 parent 7cd15c4 commit 6923e0d

File tree

8 files changed

+41
-39
lines changed

8 files changed

+41
-39
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
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 */; };
@@ -85,7 +85,7 @@
8585
41E4DCCD22B4ADB000F78522 /* PopoverPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopoverPage.swift; sourceTree = "<group>"; };
8686
41E4DCCF22B4B4FF00F78522 /* ActionSheetPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionSheetPage.swift; sourceTree = "<group>"; };
8787
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>"; };
88+
41F36F0B22AA87AF00B9172D /* TableViewPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewPage.swift; sourceTree = "<group>"; };
8989
41F36F0D22AA8AEC00B9172D /* WebViewPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewPage.swift; sourceTree = "<group>"; };
9090
41F36F0F22AA915300B9172D /* ListPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPage.swift; sourceTree = "<group>"; };
9191
41FE99E622AAD08A008135A0 /* NavigationButtonPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationButtonPage.swift; sourceTree = "<group>"; };
@@ -128,7 +128,7 @@
128128
isa = PBXGroup;
129129
children = (
130130
4132A46722AE8D5200A8DBBE /* NavigationViewPage.swift */,
131-
41F36F0B22AA87AF00B9172D /* TabBarPage.swift */,
131+
41F36F0B22AA87AF00B9172D /* TableViewPage.swift */,
132132
);
133133
path = Navigation;
134134
sourceTree = "<group>";
@@ -365,7 +365,7 @@
365365
4161B33022AB6D2900CD5A1B /* ScrollViewPage.swift in Sources */,
366366
41FE99F022AADF9F008135A0 /* DatePickerPage.swift in Sources */,
367367
4161B33422AB83B700CD5A1B /* StepperPage.swift in Sources */,
368-
41F36F0C22AA87AF00B9172D /* TabBarPage.swift in Sources */,
368+
41F36F0C22AA87AF00B9172D /* TableViewPage.swift in Sources */,
369369
4132A46B22B00E6100A8DBBE /* PickerPage.swift in Sources */,
370370
4196ABCC22A97AB1008B8FD2 /* ContentView.swift in Sources */,
371371
4132A46622AD70D400A8DBBE /* View+Ext.swift in Sources */,

Example/Example/ContentView.swift

Lines changed: 2 additions & 9 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("布局")) {
@@ -109,7 +102,7 @@ struct ContentView : View {
109102
NavigationLink(destination: NavigationViewPage()) {
110103
PageRow(title: "NavigationView",subTitle: "用于创建包含顶部导航栏的视图容器")
111104
}
112-
NavigationLink(destination: TabBarPage()) {
105+
NavigationLink(destination: TableViewPage()) {
113106
PageRow(title: "TabBar",subTitle: "用于创建包含底部 TabBar 的视图容器")
114107
}
115108
}

Example/Example/Page/Alert/AlertPage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ struct AlertPage : View {
2222
design: .rounded))
2323
}
2424
.alert(isPresented: $showAlert, content: {
25-
Alert(title: Text("确定要支付这100000000美元吗"),
25+
Alert(title: Text("确定要支付这100000美元吗"),
2626
message: Text("请谨慎操作\n一旦确认,钱款将立即转入对方账户"),
27-
primaryButton: .destructive(Text("确认")) { print("转出中...") },
27+
primaryButton: .destructive(Text("确认")) { print("已转出") },
2828
secondaryButton: .cancel())
2929
}).navigationBarTitle(Text("Alert"))
3030

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/TabBarPage.swift renamed to Example/Example/Page/Navigation/TableViewPage.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// TabBarPage.swift
2+
// TabViewPage.swift
33
// Example
44
//
55
// Created by 晋先森 on 2019/6/7.
@@ -8,7 +8,7 @@
88

99
import SwiftUI
1010

11-
struct TabBarPage : View {
11+
struct TableViewPage : View {
1212

1313
@State private var index = 0 // 默认选中索引
1414

@@ -19,10 +19,13 @@ struct TabBarPage : View {
1919
TabView(selection: $index) {
2020
ForEach(0..<imgs.count) { item in
2121
TabItemPage(index: item)
22-
.tabItem({Image(self.imgs[item])})
23-
.tag(item)
22+
.tabItem{
23+
Image(self.imgs[item])
24+
Text("\(item)")
25+
}
26+
.tag(item)
2427
}
25-
}.navigationBarTitle("Tabbar")
28+
}.navigationBarTitle("TabViewPage")
2629

2730
}
2831
}
@@ -49,9 +52,9 @@ fileprivate struct TabItemPage: View {
4952

5053

5154
#if DEBUG
52-
struct TabBarPage_Previews : PreviewProvider {
55+
struct TableViewPage_Previews : PreviewProvider {
5356
static var previews: some View {
54-
TabBarPage()
57+
TableViewPage()
5558
}
5659
}
5760
#endif

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ When learning and using `SwiftUI`, if you have any questions, you can join the S
7979

8080
* <span id="Architectural_D">Architectural Views</span>
8181
- [NavigationView](#NavigationView)
82-
- [TabbedView](#TabbedView)
82+
- [TableView](#TableView)
8383
- [HSplitView](#HSplitView)
8484
- [VSplitView](#VSplitView)
8585

@@ -712,25 +712,28 @@ NavigationView {
712712

713713
[🔝](#Layout_D)
714714

715-
<h4 id="TabBar"> TabBar </h4>
715+
<h4 id="TableView"> TableView </h4>
716716

717-
`TabBar` is used to create a view container that contains the bottom **TabBar**.
717+
`TableView` is used to create a view container that contains the bottom ** TabBar**.
718718

719719
Example:
720720

721721
```swift
722-
TabbedView(selection: $index) {
723-
ForEach(0 ..< imgs.count) { item in
722+
TabView(selection: $index) {
723+
ForEach(0..<imgs.count) { item in
724724
TabItemPage(index: item)
725-
.tabItemLabel(Image(self.imgs[item]))
726-
.tag(item)
725+
.tabItem{
726+
Image(self.imgs[item])
727+
Text("\(item)")
728+
}
729+
.tag(item)
727730
}
728731
}
729732
```
730733

731734
<details close>
732735
<summary>View running results</summary>
733-
<img width="80%" src="images/example/TabBar.png"/>
736+
<img width="80%" src="images/example/TableView.png"/>
734737
</details>
735738

736739
[🔝](#Layout_D)

README_CN.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
* <span id="Architectural_D">Architectural Views 导航、切换、排列</span>
8585
- [NavigationView](#NavigationView)
86-
- [TabbedView](#TabbedView)
86+
- [TableView](#TableView)
8787
- [HSplitView](#HSplitView)
8888
- [VSplitView](#VSplitView)
8989

@@ -718,25 +718,28 @@ NavigationView {
718718

719719
[🔝](#Layout_D)
720720

721-
<h4 id="TabbedView"> TabbedView </h4>
721+
<h4 id="TableView"> TableView </h4>
722722

723-
`TabBar` 用于创建包含底部 **TabBar** 的视图容器
723+
`TableView` 用于创建包含底部 ** TabBar** 的视图容器
724724

725725
示例:
726726

727727
```swift
728-
TabbedView(selection: $index) {
729-
ForEach(0 ..< imgs.count) { item in
728+
TabView(selection: $index) {
729+
ForEach(0..<imgs.count) { item in
730730
TabItemPage(index: item)
731-
.tabItemLabel(Image(self.imgs[item]))
732-
.tag(item)
731+
.tabItem{
732+
Image(self.imgs[item])
733+
Text("\(item)")
734+
}
735+
.tag(item)
733736
}
734737
}
735738
```
736739

737740
<details close>
738741
<summary>查看运行效果</summary>
739-
<img width="80%" src="images/example/TabBar.png"/>
742+
<img width="80%" src="images/example/TableView.png"/>
740743
</details>
741744

742745
[🔝](#Layout_D)
File renamed without changes.

0 commit comments

Comments
 (0)