From 5c25c632b1a3b1ba709b2bf028052f52d65d4878 Mon Sep 17 00:00:00 2001 From: Aylin <a.akkus@fu-berlin.de> Date: Fri, 26 Mar 2021 13:45:32 +0100 Subject: [PATCH] Figuring out the Navigation Link --- .../Tabbed Views/AttachmentsViewMain.swift | 117 ++++++++---------- 1 file changed, 51 insertions(+), 66 deletions(-) diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentsViewMain.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentsViewMain.swift index 660c5f9c..70b1dbf3 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentsViewMain.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentsViewMain.swift @@ -135,74 +135,64 @@ struct AttPrev:View{ let QLV = QuickLookView(name: self.attachment.myName, data: self.attachment.myData, shallDL: self.isDownloaded) return VStack{ - Group{ - CardV(title: self.attachment.myName, + Group{ + CardV(title: self.attachment.myName, - //these buttons are visable under the preview - // when users click on the preview - actions: self.isDownloaded||self.shouldBeDownloaded ? - // different combination of buttons - // according to downloading status - [ - // anyViewDeleteButton - anyViewOpenButton, - anyViewShareButton - ] - : - [ - anyViewDownloadButton, - // both lists need same length - // to make appearance the same - AnyView(EmptyView()), - AnyView(EmptyView()) - ] - ){ - QLV/*TODO: - .allowsHitTesting(false).disabled(true)*/ //this should make the whole view scrollable averywhere not just on the title - - } - } + // these buttons are visable under the preview + // when users click on the preview + actions: self.isDownloaded||self.shouldBeDownloaded ? + // different combination of buttons + // according to downloading status + [ + // anyViewDeleteButton + anyViewOpenButton, + anyViewShareButton + ] + : + [ + anyViewDownloadButton, + // both lists need same length + // to make appearance the same + AnyView(EmptyView()), + AnyView(EmptyView()) + ] + ){ + QLV/*TODO: + .allowsHitTesting(false).disabled(true)*/ //this should make the whole view scrollable averywhere not just on the title + } + } // preview should resemble the look of A4 format .aspectRatio(100/141, contentMode: .fit) .frame(width: UIScreen.main.bounds.width*2/3)//, maxHeight: 500) - //a hidden NavigationLink to open the preview in fullscreen - // seems not to work currently - NavigationLink(destination: QuickLookView(name: self.attachment.myName, data: self.attachment.myData) - .navigationBarItems(trailing: shareButton), isActive: self.$isFullScreen){Text("loi")}.hidden() + //a hidden NavigationLink to open the preview in fullscreen + // seems not to work currently + NavigationLink( + destination: QuickLookView(name: self.attachment.myName, data: self.attachment.myData) + .navigationBarItems(trailing: anyViewShareButton), isActive: self.$isFullScreen) {Text("loi")}.hidden()} + .onAppear( + perform: { + self.getDownloadedState() - } - .onAppear(perform: { - self.getDownloadedState() - - //download all functionality - if self.shouldBeDownloaded {self.isDownloaded=true; self.download()} - }) - // remove file from documents directory - .onDisappear(perform: { - let filename = getDocumentsDirectory().appendingPathComponent(self.attachment.myName) + //download all functionality + if self.shouldBeDownloaded {self.isDownloaded=true; self.download()} + } + ) + // remove file from documents directory + .onDisappear( + perform: { + let filename = getDocumentsDirectory().appendingPathComponent(self.attachment.myName) - do { - try FileManager.default.removeItem(at: filename) - } catch let error as NSError { - print("Error: \(error)") - } - self.isDownloaded = false - print("======== Attachment DISAPPEAR -> REMOVE FILES ========") - }) - } - - var shareButton: some View { - return Button(action:{ - //popover the standart apple sharing stuff - /* if let coord = AppDelegate.getAppDelegate().readViewCoordinator { - coord.shareData(self.attachment.myData as NSData) - }*/ - }){ - Image(systemName: "square.and.arrow.up") - } - } - + do { + try FileManager.default.removeItem(at: filename) + } + catch let error as NSError {print("Error: \(error)")} + self.isDownloaded = false + print("======== Attachment DISAPPEAR -> REMOVE FILES ========") + } + ) +} + // an open button converted into an AnyView // should open the view fullscreen var anyViewOpenButton: AnyView { @@ -289,10 +279,5 @@ struct AttPrev:View{ ) ) } - - - - - } -- GitLab