Skip to content
Snippets Groups Projects
Commit 5c25c632 authored by Aylin's avatar Aylin
Browse files

Figuring out the Navigation Link

parent e2332adb
Branches
No related tags found
1 merge request!79Resolve "Add comments to: AttachmentViewMain.swift"
...@@ -135,74 +135,64 @@ struct AttPrev:View{ ...@@ -135,74 +135,64 @@ struct AttPrev:View{
let QLV = QuickLookView(name: self.attachment.myName, data: self.attachment.myData, shallDL: self.isDownloaded) let QLV = QuickLookView(name: self.attachment.myName, data: self.attachment.myData, shallDL: self.isDownloaded)
return VStack{ return VStack{
Group{ Group{
CardV(title: self.attachment.myName, CardV(title: self.attachment.myName,
//these buttons are visable under the preview // these buttons are visable under the preview
// when users click on the preview // when users click on the preview
actions: self.isDownloaded||self.shouldBeDownloaded ? actions: self.isDownloaded||self.shouldBeDownloaded ?
// different combination of buttons // different combination of buttons
// according to downloading status // according to downloading status
[ [
// anyViewDeleteButton // anyViewDeleteButton
anyViewOpenButton, anyViewOpenButton,
anyViewShareButton anyViewShareButton
] ]
: :
[ [
anyViewDownloadButton, anyViewDownloadButton,
// both lists need same length // both lists need same length
// to make appearance the same // to make appearance the same
AnyView(EmptyView()), AnyView(EmptyView()),
AnyView(EmptyView()) AnyView(EmptyView())
] ]
){ ){
QLV/*TODO: QLV/*TODO:
.allowsHitTesting(false).disabled(true)*/ //this should make the whole view scrollable averywhere not just on the title .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 // preview should resemble the look of A4 format
.aspectRatio(100/141, contentMode: .fit) .aspectRatio(100/141, contentMode: .fit)
.frame(width: UIScreen.main.bounds.width*2/3)//, maxHeight: 500) .frame(width: UIScreen.main.bounds.width*2/3)//, maxHeight: 500)
//a hidden NavigationLink to open the preview in fullscreen //a hidden NavigationLink to open the preview in fullscreen
// seems not to work currently // seems not to work currently
NavigationLink(destination: QuickLookView(name: self.attachment.myName, data: self.attachment.myData) NavigationLink(
.navigationBarItems(trailing: shareButton), isActive: self.$isFullScreen){Text("loi")}.hidden() destination: QuickLookView(name: self.attachment.myName, data: self.attachment.myData)
.navigationBarItems(trailing: anyViewShareButton), isActive: self.$isFullScreen) {Text("loi")}.hidden()}
.onAppear(
perform: {
self.getDownloadedState()
} //download all functionality
.onAppear(perform: { if self.shouldBeDownloaded {self.isDownloaded=true; self.download()}
self.getDownloadedState() }
)
//download all functionality // remove file from documents directory
if self.shouldBeDownloaded {self.isDownloaded=true; self.download()} .onDisappear(
}) perform: {
// remove file from documents directory let filename = getDocumentsDirectory().appendingPathComponent(self.attachment.myName)
.onDisappear(perform: {
let filename = getDocumentsDirectory().appendingPathComponent(self.attachment.myName)
do { do {
try FileManager.default.removeItem(at: filename) try FileManager.default.removeItem(at: filename)
} catch let error as NSError { }
print("Error: \(error)") catch let error as NSError {print("Error: \(error)")}
} self.isDownloaded = false
self.isDownloaded = false print("======== Attachment DISAPPEAR -> REMOVE FILES ========")
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")
}
}
// an open button converted into an AnyView // an open button converted into an AnyView
// should open the view fullscreen // should open the view fullscreen
var anyViewOpenButton: AnyView { var anyViewOpenButton: AnyView {
...@@ -289,10 +279,5 @@ struct AttPrev:View{ ...@@ -289,10 +279,5 @@ struct AttPrev:View{
) )
) )
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment