From 21d6f2fb2a4492f01e2dd433ab59a1e1976b9607 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 18 Dec 2022 01:08:38 +0100 Subject: [PATCH] Integrated the DocumentView view and the DocumentToolbar toolbar into the DocumentView view for the Browse module. --- .../Sources/Browse/UI/Views/DocumentView.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Modules/Sources/Browse/UI/Views/DocumentView.swift b/Modules/Sources/Browse/UI/Views/DocumentView.swift index 740247a..8a4e5e8 100644 --- a/Modules/Sources/Browse/UI/Views/DocumentView.swift +++ b/Modules/Sources/Browse/UI/Views/DocumentView.swift @@ -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: