Skip to content

Commit 73f4eae

Browse files
committed
Rename Generic to FileBrowserSUIPreview.
Moved views into their own file
1 parent bd8b3e8 commit 73f4eae

File tree

3 files changed

+73
-52
lines changed

3 files changed

+73
-52
lines changed

Sources/FileBrowserSUI/FileBrowserSUI.swift

-52
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,6 @@ import SwiftUI
22
import Foundation
33

44
@available(iOS 13.0.0, *)
5-
6-
public struct FileBrowserGeneric: View {
7-
@State var fileList:[FBFile] = []
8-
internal var didAppear: ((Self) -> Void)?
9-
let validInitialPath: URL
10-
let extraInfo0: FileExtraInfo?
11-
let extraInfo1: FileExtraInfo?
12-
13-
public var body: some View {
14-
FileBrowserSUI(initialPath: validInitialPath,
15-
xInfo0: extraInfo0, xInfo1: extraInfo1) {
16-
fileUrl in
17-
PreviewController(url: fileUrl)
18-
}
19-
}
20-
21-
public init(initialPath: URL?, xInfo0:FileExtraInfo?, xInfo1: FileExtraInfo?) {
22-
validInitialPath = initialPath ?? FileParser.sharedInstance.documentsURL()
23-
extraInfo0 = xInfo0
24-
extraInfo1 = xInfo1
25-
26-
}
27-
public init() {
28-
validInitialPath = FileParser.sharedInstance.documentsURL()
29-
extraInfo0 = nil
30-
extraInfo1 = nil
31-
32-
}
33-
}
34-
35-
36-
public struct ThumbnailImageView: View {
37-
let fbFile: FBFile
38-
39-
@State private var thumbnail: UIImage? = nil
40-
41-
public var body: some View {
42-
43-
if thumbnail != nil {
44-
Image(uiImage: self.thumbnail!)
45-
} else {
46-
Image(uiImage: fbFile.type.image()).onAppear() {
47-
self.fbFile.generateImage() { image in
48-
self.thumbnail = image
49-
}
50-
}
51-
}
52-
}
53-
}
54-
555
public struct FileBrowserSUI<LinkView: View>: View {
566

577
let linkView:(URL)->LinkView
@@ -62,8 +12,6 @@ public struct FileBrowserSUI<LinkView: View>: View {
6212
let extraInfo0: FileExtraInfo?
6313
let extraInfo1: FileExtraInfo?
6414

65-
66-
6715
public var body: some View {
6816
HStack {
6917
List {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// File.swift
3+
//
4+
//
5+
// Created by Richard Legault on 2021-01-17.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
public struct FileBrowserSUIPreview: View {
12+
@State var fileList:[FBFile] = []
13+
internal var didAppear: ((Self) -> Void)?
14+
let validInitialPath: URL
15+
let extraInfo0: FileExtraInfo?
16+
let extraInfo1: FileExtraInfo?
17+
18+
public var body: some View {
19+
FileBrowserSUI(initialPath: validInitialPath,
20+
xInfo0: extraInfo0, xInfo1: extraInfo1) {
21+
fileUrl in
22+
PreviewController(url: fileUrl)
23+
}
24+
}
25+
26+
public init(initialPath: URL?, xInfo0:FileExtraInfo?, xInfo1: FileExtraInfo?) {
27+
validInitialPath = initialPath ?? FileParser.sharedInstance.documentsURL()
28+
extraInfo0 = xInfo0
29+
extraInfo1 = xInfo1
30+
31+
}
32+
public init() {
33+
validInitialPath = FileParser.sharedInstance.documentsURL()
34+
extraInfo0 = nil
35+
extraInfo1 = nil
36+
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// ThumbnailImageView.swift
3+
//
4+
//
5+
// Created by Richard Legault on 2021-01-17.
6+
//
7+
8+
import SwiftUI
9+
10+
public struct ThumbnailImageView: View {
11+
let fbFile: FBFile
12+
13+
@State private var thumbnail: UIImage? = nil
14+
15+
public var body: some View {
16+
17+
if thumbnail != nil {
18+
Image(uiImage: self.thumbnail!)
19+
} else {
20+
Image(uiImage: fbFile.type.image()).onAppear() {
21+
self.fbFile.generateImage() { image in
22+
self.thumbnail = image
23+
}
24+
}
25+
}
26+
}
27+
}
28+
29+
//struct ThumbnailImageView_Previews: PreviewProvider {
30+
// static var previews: some View {
31+
//
32+
// //ThumbnailImageView(fbFile: <#FBFile#>)
33+
// }
34+
//}
35+

0 commit comments

Comments
 (0)