Integrated the DocumentView view and the DocumentToolbar toolbar into the DocumentView view for the Browse module.
This commit is contained in:
parent
d242171c6e
commit
21d6f2fb2a
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user