Integrated the DownloadView view into the BrowseView view for the Browse module.
This commit is contained in:
parent
49b9b78f57
commit
e78a326595
@ -23,7 +23,7 @@ public struct BrowseView: View {
|
|||||||
@State private var stack: Stack?
|
@State private var stack: Stack?
|
||||||
@State private var itemToDelete: (any FileSystemItem)?
|
@State private var itemToDelete: (any FileSystemItem)?
|
||||||
@State private var showCreateFolder: Bool = false
|
@State private var showCreateFolder: Bool = false
|
||||||
@State private var showUploadFile: Bool = false
|
@State private var showSheet: SheetView?
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
@ -56,14 +56,24 @@ public struct BrowseView: View {
|
|||||||
showCreateFolder = true
|
showCreateFolder = true
|
||||||
},
|
},
|
||||||
uploadFile: {
|
uploadFile: {
|
||||||
showUploadFile = true
|
showSheet = .upload(id: folder.id)
|
||||||
},
|
},
|
||||||
showProfile: showProfile
|
showProfile: showProfile
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.sheet(isPresented: $showUploadFile) {
|
.sheet(item: $showSheet) { sheet in
|
||||||
UploadView(id: folder.id) {
|
switch sheet {
|
||||||
Task { await loadItems() }
|
case let .upload(id):
|
||||||
|
UploadView(id: id) {
|
||||||
|
Task { await loadItems() }
|
||||||
|
}
|
||||||
|
case let .download(id, name):
|
||||||
|
DownloadView(
|
||||||
|
id: id,
|
||||||
|
name: name
|
||||||
|
) {
|
||||||
|
Task { await loadItems() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.createFolder(
|
.createFolder(
|
||||||
@ -118,7 +128,7 @@ private extension BrowseView {
|
|||||||
MessageView(
|
MessageView(
|
||||||
type: .empty,
|
type: .empty,
|
||||||
action: {
|
action: {
|
||||||
showUploadFile = true
|
showSheet = .upload(id: folder.id)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
case .error:
|
case .error:
|
||||||
@ -162,7 +172,10 @@ private extension BrowseView {
|
|||||||
DocumentItem(item: item) {
|
DocumentItem(item: item) {
|
||||||
stack = .open(document)
|
stack = .open(document)
|
||||||
} download: {
|
} download: {
|
||||||
// TODO: download the item id from the backend.
|
showSheet = .download(
|
||||||
|
id: document.id,
|
||||||
|
name: document.name
|
||||||
|
)
|
||||||
} delete: {
|
} delete: {
|
||||||
itemToDelete = item
|
itemToDelete = item
|
||||||
}
|
}
|
||||||
@ -211,6 +224,17 @@ private extension BrowseView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Enumerations
|
||||||
|
|
||||||
|
private extension BrowseView {
|
||||||
|
enum SheetView: Identifiable {
|
||||||
|
case upload(id: String)
|
||||||
|
case download(id: String, name: String)
|
||||||
|
|
||||||
|
var id: String { UUID().uuidString }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
struct BrowseView_Previews: PreviewProvider {
|
struct BrowseView_Previews: PreviewProvider {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user