Commit 4c7ef70 1 parent 43e7a97 commit 4c7ef70 Copy full SHA for 4c7ef70
File tree 4 files changed +38
-5
lines changed
SwiftPamphletApp/InfoOrganizer/Info
4 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ struct EditInfoView: View {
21
21
@State var cate : IOCategory ? = nil
22
22
23
23
@State var urlContent = " "
24
+ @State var selectedTab = 1
24
25
25
26
var body : some View {
26
27
VStack {
@@ -102,13 +103,27 @@ struct EditInfoView: View {
102
103
}
103
104
}
104
105
105
- Section ( footer: Text ( " 支持 markdown 格式的文本 " ) ) {
106
+ Section ( footer: Text ( " 文本支持 markdown 格式 " ) ) {
106
107
// TODO: markdown 获取图片链接,并能显示
107
- TabView {
108
+ TabView ( selection : $selectedTab ) {
108
109
TextEditor ( text: $info. des)
109
110
. tabItem { Label ( " 文本 " , systemImage: " circle " ) }
111
+ . tag ( 1 )
110
112
WebUIView ( html: wrapperHtmlContent ( content: MarkdownParser ( ) . html ( from: info. des) ) , baseURLStr: " " )
111
113
. tabItem { Label ( " 预览 " , systemImage: " circle " ) }
114
+ . tag ( 2 )
115
+ if !info. url. isEmpty {
116
+ WebUIView ( urlStr: info. url)
117
+ . tabItem { Label ( " 网页 " , systemImage: " circle " ) }
118
+ . tag ( 3 )
119
+ }
120
+ }
121
+ . onChange ( of: info. url) { oldValue, newValue in
122
+ if newValue. isEmpty {
123
+ selectedTab = 0
124
+ } else {
125
+ selectedTab = 3
126
+ }
112
127
}
113
128
}
114
129
} // end form
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ struct InfoListView: View {
16
16
17
17
@Query ( IOCategory . allOrderByName) var cates : [ IOCategory ]
18
18
@State private var filterCate = " "
19
- @State var limit : Int = 100
19
+ @State var limit : Int = 300
20
20
@State var filterStar : Bool = false
21
21
22
22
var body : some View {
@@ -33,7 +33,7 @@ struct InfoListView: View {
33
33
Text ( " 全部 " )
34
34
}
35
35
. tag ( " " )
36
-
36
+ Divider ( )
37
37
ForEach ( cates) { cate in
38
38
HStack {
39
39
if cate. pin == 1 {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import SwiftUI
10
10
struct InfoRowView : View {
11
11
@State var info : IOInfo
12
12
let selectedInfo : IOInfo ?
13
+ @State private var showAlert = false
13
14
14
15
var infoColor : Color {
15
16
selectedInfo == info ? Color . white : Color . accentColor
@@ -25,23 +26,40 @@ struct InfoRowView: View {
25
26
Text ( info. category? . name ?? " " )
26
27
}
27
28
Spacer ( )
29
+
28
30
}
29
31
. foregroundColor ( light: . secondary, dark: . secondary)
30
32
Text ( info. name)
33
+ HStack {
34
+ Text ( dateString ( date: info. updateDate) )
35
+ . font ( . footnote)
36
+ Spacer ( )
37
+ }
38
+ . foregroundColor ( light: . secondary, dark: . secondary)
31
39
}
32
40
. swipeActions {
33
41
Button ( role: . destructive) {
34
42
IOInfo . delete ( info)
35
43
} label: {
36
44
Label ( " 删除 " , systemImage: " trash " )
37
45
}
46
+
38
47
}
39
48
. contextMenu {
40
49
Button ( " 删除 " ) {
41
50
IOInfo . delete ( info)
42
51
}
43
52
}
44
53
}
54
+
55
+ func dateString( date: Date ) -> String {
56
+ var re = " "
57
+ if date. year != Date . now. year {
58
+ re += date. year. description + " . "
59
+ }
60
+ re += date. month. description + " . " + date. day. description
61
+ return re
62
+ }
45
63
}
46
64
47
65
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ struct InfosView: View {
45
45
. onAppear {
46
46
if info == infos. last {
47
47
if limit <= infos. count {
48
- limit += 100
48
+ limit += 300
49
49
}
50
50
}
51
51
}
You can’t perform that action at this time.
0 commit comments