Skip to content

Commit d137a4a

Browse files
committed
合并列表
1 parent 15eebea commit d137a4a

File tree

4 files changed

+43
-114
lines changed

4 files changed

+43
-114
lines changed

SwiftPamphletApp.xcodeproj/project.pbxproj

-4
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@
265265
08ED80162B9C54DE0069B7EC /* SMNetwork in Frameworks */ = {isa = PBXBuildFile; productRef = 08ED80152B9C54DE0069B7EC /* SMNetwork */; };
266266
08ED801C2B9D1EEC0069B7EC /* SettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08ED801B2B9D1EEC0069B7EC /* SettingView.swift */; };
267267
08F1AB612BA0821900AEA0CA /* CodeEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 08F1AB602BA0821900AEA0CA /* CodeEditor */; };
268-
08F1AB662BA0A7E100AEA0CA /* InfosFilterWithCateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F1AB652BA0A7E100AEA0CA /* InfosFilterWithCateView.swift */; };
269268
08F4BE6028609D8700733F12 /* PlayCharts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F4BE5F28609D8600733F12 /* PlayCharts.swift */; };
270269
08F4BE6228616DC100733F12 /* PlayWeatherKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F4BE6128616DC100733F12 /* PlayWeatherKit.swift */; };
271270
08F51BC527A374A500693AB6 /* footer_js.html in Resources */ = {isa = PBXBuildFile; fileRef = 08F51BC427A374A500693AB6 /* footer_js.html */; };
@@ -525,7 +524,6 @@
525524
08CD61FC27758B8A008C0935 /* Lexer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Lexer.swift; sourceTree = "<group>"; };
526525
08CD61FD27758B8A008C0935 /* Token.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = "<group>"; };
527526
08ED801B2B9D1EEC0069B7EC /* SettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingView.swift; sourceTree = "<group>"; };
528-
08F1AB652BA0A7E100AEA0CA /* InfosFilterWithCateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfosFilterWithCateView.swift; sourceTree = "<group>"; };
529527
08F4BE5F28609D8600733F12 /* PlayCharts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayCharts.swift; sourceTree = "<group>"; };
530528
08F4BE6128616DC100733F12 /* PlayWeatherKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayWeatherKit.swift; sourceTree = "<group>"; };
531529
08F51BC427A374A500693AB6 /* footer_js.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = footer_js.html; sourceTree = "<group>"; };
@@ -1365,7 +1363,6 @@
13651363
children = (
13661364
08397E242B9EEE1300DFDD02 /* InfoListView.swift */,
13671365
0871C61C2BA05F44000B620D /* InfosView.swift */,
1368-
08F1AB652BA0A7E100AEA0CA /* InfosFilterWithCateView.swift */,
13691366
0871C6182BA040E5000B620D /* InfoRowView.swift */,
13701367
08397E282B9F0A9100DFDD02 /* EditInfoView.swift */,
13711368
);
@@ -1715,7 +1712,6 @@
17151712
086A5F3A2744EDA500FECE02 /* APIRequest.swift in Sources */,
17161713
086A5F522744EF4C00FECE02 /* ViewComponet.swift in Sources */,
17171714
086A5F672754C27900FECE02 /* DBHandler.swift in Sources */,
1718-
08F1AB662BA0A7E100AEA0CA /* InfosFilterWithCateView.swift in Sources */,
17191715
08BE637927CDCFD9002BC6A8 /* DataSortingListView.swift in Sources */,
17201716
08BE636E27C8D6FD002BC6A8 /* PlayLazyVGridAndLazyHGridView.swift in Sources */,
17211717
08522BE227CF52ED005FF059 /* PlayColor.swift in Sources */,

SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift

+39-69
Original file line numberDiff line numberDiff line change
@@ -18,81 +18,51 @@ struct InfoListView: View {
1818
@State private var filterCate = ""
1919

2020
var body: some View {
21-
if filterCate.isEmpty {
22-
InfosView(searchString: searchText, selectInfo: $selectInfo, sortOrder: sortOrder)
23-
.navigationTitle("资料列表")
24-
.toolbar {
25-
ToolbarItem(placement: .navigation) {
26-
Button("添加资料", systemImage: "plus", action: addInfo)
27-
}
28-
ToolbarItem(placement: .navigation) {
29-
Menu("Sort", systemImage: "tag") {
30-
31-
Picker("分类", selection: $filterCate) {
32-
Text("全部")
33-
.tag("")
34-
35-
ForEach(cates) { cate in
36-
Text(cate.name)
37-
.tag(cate.name)
38-
}
39-
}
40-
Picker("排序", selection: $sortOrder) {
41-
Text("正序")
42-
.tag([SortDescriptor(\IOInfo.updateDate)])
43-
Text("倒序")
44-
.tag([SortDescriptor(\IOInfo.updateDate, order: .reverse)])
45-
}
21+
InfosView(filterCateName: filterCate, searchString: searchText, selectInfo: $selectInfo, sortOrder: sortOrder)
22+
.navigationTitle("资料列表")
23+
.toolbar {
24+
ToolbarItem(placement: .navigation) {
25+
Button("添加资料", systemImage: "plus", action: addInfo)
26+
}
27+
ToolbarItem(placement: .navigation) {
28+
Picker("分类", selection: $filterCate) {
29+
Text("全部")
30+
.tag("")
31+
32+
ForEach(cates) { cate in
33+
Text(cate.name)
34+
.tag(cate.name)
4635
}
4736
}
48-
49-
ToolbarItem(placement: .primaryAction) {
50-
Button(action: {
51-
modelContext.undoManager?.undo()
52-
}, label: {
53-
Image(systemName: "arrow.left")
54-
})
55-
.disabled(modelContext.undoManager?.canUndo == false)
56-
}
57-
ToolbarItem(placement: .primaryAction) {
58-
Button(action: {
59-
modelContext.undoManager?.redo()
60-
}, label: {
61-
Image(systemName: "arrow.right")
62-
})
63-
.disabled(modelContext.undoManager?.canRedo == false)
64-
}
6537
}
66-
.searchable(text: $searchText)
67-
} else {
68-
InfosFilterWithCateView(filterCateName: filterCate, selectInfo: $selectInfo, sortOrder: sortOrder)
69-
.navigationTitle("分类 - \(filterCate)")
70-
.toolbar {
71-
ToolbarItem(placement: .navigation) {
72-
Button("添加资料", systemImage: "plus", action: addInfoWithCate)
73-
}
74-
ToolbarItem(placement: .navigation) {
75-
Menu("Sort", systemImage: "tag") {
76-
Picker("分类", selection: $filterCate) {
77-
Text("全部")
78-
.tag("")
79-
ForEach(cates) { cate in
80-
Text(cate.name)
81-
.tag(cate.name)
82-
}
83-
}
84-
Picker("排序", selection: $sortOrder) {
85-
Text("正序")
86-
.tag([SortDescriptor(\IOInfo.updateDate)])
87-
Text("倒序")
88-
.tag([SortDescriptor(\IOInfo.updateDate, order: .reverse)])
89-
}
90-
38+
ToolbarItem(placement: .navigation) {
39+
Menu("Sort", systemImage: "arrow.up.arrow.down.square") {
40+
Picker("排序", selection: $sortOrder) {
41+
Text("正序")
42+
.tag([SortDescriptor(\IOInfo.updateDate)])
43+
Text("倒序")
44+
.tag([SortDescriptor(\IOInfo.updateDate, order: .reverse)])
9145
}
9246
}
9347
}
94-
}
95-
48+
ToolbarItem(placement: .primaryAction) {
49+
Button(action: {
50+
modelContext.undoManager?.undo()
51+
}, label: {
52+
Image(systemName: "arrow.left")
53+
})
54+
.disabled(modelContext.undoManager?.canUndo == false)
55+
}
56+
ToolbarItem(placement: .primaryAction) {
57+
Button(action: {
58+
modelContext.undoManager?.redo()
59+
}, label: {
60+
Image(systemName: "arrow.right")
61+
})
62+
.disabled(modelContext.undoManager?.canRedo == false)
63+
}
64+
}
65+
.searchable(text: $searchText)
9666
}
9767

9868
func addInfo() {

SwiftPamphletApp/InfoOrganizer/Info/InfosFilterWithCateView.swift

-39
This file was deleted.

SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ struct InfosView: View {
1313
@Query var infos: [IOInfo]
1414
@Binding var selectInfo: IOInfo?
1515

16-
init(searchString: String = "", selectInfo: Binding<IOInfo?>, sortOrder: [SortDescriptor<IOInfo>] = []) {
16+
init(filterCateName: String = "", searchString: String = "", selectInfo: Binding<IOInfo?>, sortOrder: [SortDescriptor<IOInfo>] = []) {
1717
var fd = FetchDescriptor<IOInfo>(predicate: #Predicate { info in
18-
if searchString.isEmpty {
18+
if !filterCateName.isEmpty {
19+
info.category?.name == filterCateName
20+
} else if searchString.isEmpty {
1921
true
2022
} else {
2123
info.name.localizedStandardContains(searchString)

0 commit comments

Comments
 (0)