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