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: