@@ -18,81 +18,51 @@ struct InfoListView: View {
18
18
@State private var filterCate = " "
19
19
20
20
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)
46
35
}
47
36
}
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
- }
65
37
}
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) ] )
91
45
}
92
46
}
93
47
}
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)
96
66
}
97
67
98
68
func addInfo( ) {
0 commit comments