@@ -19,6 +19,10 @@ struct FileListView: View {
19
19
@State private var isLoading = true
20
20
@State private var errorMessage : String ? = nil
21
21
22
+ @State private var previewFile : Bool = true
23
+ @State private var selectedFile : DFFile ? = nil
24
+ @State private var navigationPath = NavigationPath ( )
25
+
22
26
var body : some View {
23
27
ZStack {
24
28
if isLoading && files. isEmpty {
@@ -53,39 +57,31 @@ struct FileListView: View {
53
57
}
54
58
. padding ( )
55
59
} else {
56
- NavigationStack {
60
+ NavigationStack ( path : $navigationPath ) {
57
61
List {
58
62
ForEach ( files, id: \. id) { file in
59
- NavigationLink {
60
- ContentPreview ( mimeType: file. mime, fileURL: URL ( string: file. raw) )
61
- . toolbar {
62
- ToolbarItem ( placement: . navigationBarTrailing) {
63
- Menu {
64
- FileContextMenuButtons (
65
- onPreview: {
66
-
67
- } ,
68
- onCopyShareLink: {
69
- // Open Maps and center it on this item.
70
- } ,
71
- onCopyRawLink: {
72
- // Open Maps and center it on this item.
73
- } ,
74
- onSetPrivate: {
75
- // Add this item to a list of favorites.
76
- } ,
77
- onShowInMaps: {
78
- // Open Maps and center it on this item.
79
- }
80
- )
81
- } label: {
82
- Image ( systemName: " ellipsis.circle " )
63
+ NavigationLink ( value: file) {
64
+ FileRowView ( file: file)
65
+ . contextMenu {
66
+ FileContextMenuButtons (
67
+ isPreviewing: false ,
68
+ onPreview: {
69
+ selectedFile = file
70
+ } ,
71
+ onCopyShareLink: {
72
+ UIPasteboard . general. string = file. url
73
+ } ,
74
+ onCopyRawLink: {
75
+ UIPasteboard . general. string = file. raw
76
+ } ,
77
+ onTogglePrivate: {
78
+ // Add this item to a list of favorites.
79
+ } ,
80
+ onShowInMaps: {
81
+ // Open Maps and center it on this item.
83
82
}
84
- }
83
+ )
85
84
}
86
-
87
- } label: {
88
- FileRowView ( file: file)
89
85
}
90
86
. id ( file. id)
91
87
@@ -106,6 +102,35 @@ struct FileListView: View {
106
102
}
107
103
}
108
104
}
105
+ . navigationDestination ( for: DFFile . self) { file in
106
+ ContentPreview ( mimeType: file. mime, fileURL: URL ( string: file. raw) )
107
+ . toolbar {
108
+ ToolbarItem ( placement: . navigationBarTrailing) {
109
+ Menu {
110
+ FileContextMenuButtons (
111
+ isPreviewing: true ,
112
+ onPreview: {
113
+ // No action needed since this is already the preview screen.
114
+ } ,
115
+ onCopyShareLink: {
116
+ UIPasteboard . general. string = file. url
117
+ } ,
118
+ onCopyRawLink: {
119
+ UIPasteboard . general. string = file. raw
120
+ } ,
121
+ onTogglePrivate: {
122
+ // Add this item to a list of favorites.
123
+ } ,
124
+ onShowInMaps: {
125
+ // Open Maps and center it on this item.
126
+ }
127
+ )
128
+ } label: {
129
+ Image ( systemName: " ellipsis.circle " )
130
+ }
131
+ }
132
+ }
133
+ }
109
134
110
135
. listStyle ( . plain)
111
136
. refreshable {
@@ -132,7 +157,12 @@ struct FileListView: View {
132
157
}
133
158
}
134
159
}
135
-
160
+ . onChange ( of: selectedFile) { oldValue, newValue in
161
+ if let file = newValue {
162
+ navigationPath. append ( file)
163
+ selectedFile = nil // Reset after navigation
164
+ }
165
+ }
136
166
}
137
167
}
138
168
. onAppear {
@@ -219,9 +249,6 @@ struct CustomLabel: LabelStyle {
219
249
220
250
struct FileRowView : View {
221
251
let file : DFFile
222
-
223
- @State private var showPreview : Bool = false
224
-
225
252
private func getIcon( ) -> String {
226
253
switch file. mime {
227
254
case " image/jpeg " :
@@ -254,27 +281,8 @@ struct FileRowView: View {
254
281
. foregroundColor ( . secondary)
255
282
}
256
283
}
257
- . contextMenu {
258
- FileContextMenuButtons (
259
- onPreview: {
260
- showPreview = true
261
- } ,
262
- onCopyShareLink: {
263
- // Open Maps and center it on this item.
264
- } ,
265
- onCopyRawLink: {
266
- // Open Maps and center it on this item.
267
- } ,
268
- onSetPrivate: {
269
- // Add this item to a list of favorites.
270
- } ,
271
- onShowInMaps: {
272
- // Open Maps and center it on this item.
273
- }
274
- )
275
- }
276
- . sheet ( isPresented: $showPreview) {
277
- ContentPreview ( mimeType: file. mime, fileURL: URL ( string: file. raw) )
278
- }
284
+ // .sheet(isPresented: $showPreview) {
285
+ // ContentPreview(mimeType: file.mime, fileURL: URL(string: file.raw))
286
+ // }
279
287
}
280
288
}
0 commit comments