Skip to content

Commit

Permalink
Rename Generic to FileBrowserSUIPreview.
Browse files Browse the repository at this point in the history
Moved views into their own file
  • Loading branch information
rlegault3333 committed Jan 18, 2021
1 parent bd8b3e8 commit 73f4eae
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 52 deletions.
52 changes: 0 additions & 52 deletions Sources/FileBrowserSUI/FileBrowserSUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,6 @@ import SwiftUI
import Foundation

@available(iOS 13.0.0, *)

public struct FileBrowserGeneric: View {
@State var fileList:[FBFile] = []
internal var didAppear: ((Self) -> Void)?
let validInitialPath: URL
let extraInfo0: FileExtraInfo?
let extraInfo1: FileExtraInfo?

public var body: some View {
FileBrowserSUI(initialPath: validInitialPath,
xInfo0: extraInfo0, xInfo1: extraInfo1) {
fileUrl in
PreviewController(url: fileUrl)
}
}

public init(initialPath: URL?, xInfo0:FileExtraInfo?, xInfo1: FileExtraInfo?) {
validInitialPath = initialPath ?? FileParser.sharedInstance.documentsURL()
extraInfo0 = xInfo0
extraInfo1 = xInfo1

}
public init() {
validInitialPath = FileParser.sharedInstance.documentsURL()
extraInfo0 = nil
extraInfo1 = nil

}
}


public struct ThumbnailImageView: View {
let fbFile: FBFile

@State private var thumbnail: UIImage? = nil

public var body: some View {

if thumbnail != nil {
Image(uiImage: self.thumbnail!)
} else {
Image(uiImage: fbFile.type.image()).onAppear() {
self.fbFile.generateImage() { image in
self.thumbnail = image
}
}
}
}
}

public struct FileBrowserSUI<LinkView: View>: View {

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



public var body: some View {
HStack {
List {
Expand Down
38 changes: 38 additions & 0 deletions Sources/FileBrowserSUI/FileBrowserSUIPreview.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// File.swift
//
//
// Created by Richard Legault on 2021-01-17.
//

import Foundation
import SwiftUI

public struct FileBrowserSUIPreview: View {
@State var fileList:[FBFile] = []
internal var didAppear: ((Self) -> Void)?
let validInitialPath: URL
let extraInfo0: FileExtraInfo?
let extraInfo1: FileExtraInfo?

public var body: some View {
FileBrowserSUI(initialPath: validInitialPath,
xInfo0: extraInfo0, xInfo1: extraInfo1) {
fileUrl in
PreviewController(url: fileUrl)
}
}

public init(initialPath: URL?, xInfo0:FileExtraInfo?, xInfo1: FileExtraInfo?) {
validInitialPath = initialPath ?? FileParser.sharedInstance.documentsURL()
extraInfo0 = xInfo0
extraInfo1 = xInfo1

}
public init() {
validInitialPath = FileParser.sharedInstance.documentsURL()
extraInfo0 = nil
extraInfo1 = nil

}
}
35 changes: 35 additions & 0 deletions Sources/FileBrowserSUI/ThumbnailImageView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// ThumbnailImageView.swift
//
//
// Created by Richard Legault on 2021-01-17.
//

import SwiftUI

public struct ThumbnailImageView: View {
let fbFile: FBFile

@State private var thumbnail: UIImage? = nil

public var body: some View {

if thumbnail != nil {
Image(uiImage: self.thumbnail!)
} else {
Image(uiImage: fbFile.type.image()).onAppear() {
self.fbFile.generateImage() { image in
self.thumbnail = image
}
}
}
}
}

//struct ThumbnailImageView_Previews: PreviewProvider {
// static var previews: some View {
//
// //ThumbnailImageView(fbFile: <#FBFile#>)
// }
//}

0 comments on commit 73f4eae

Please sign in to comment.