Integrated the DocumentView view and the DocumentToolbar toolbar into the DocumentView view for the Browse module.

This commit is contained in:
Javier Cicchelli 2022-12-18 01:08:38 +01:00
parent d242171c6e
commit 21d6f2fb2a

View File

@ -24,6 +24,7 @@ struct DocumentView: View {
@State private var status: ViewStatus = .loading
@State private var loadedData: Data?
@State private var showDownloadFile: Bool = false
private let getData = GetDataUseCase()
@ -38,6 +39,20 @@ struct DocumentView: View {
content
.navigationTitle(document.name)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
DocumentToolbar(disabled: isToolbarDisabled) {
showDownloadFile = true
}
}
.sheet(isPresented: $showDownloadFile) {
DownloadView(
id: document.id,
name: document.name,
data: loadedData
) {
// downloaded closure.
}
}
.task {
await loadDataIfPossible()
}
@ -48,6 +63,8 @@ struct DocumentView: View {
// MARK: - UI
private extension DocumentView {
var isToolbarDisabled: Bool { loadedData == nil }
@ViewBuilder var content: some View {
switch status {
case .noCredentials: