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

Finished?

parent 8f01b38a
Branches
Tags
1 merge request!79Resolve "Add comments to: AttachmentViewMain.swift"
...@@ -93,8 +93,10 @@ struct AttPrev:View{ ...@@ -93,8 +93,10 @@ struct AttPrev:View{
// by default false // by default false
var shouldBeDownloaded = false var shouldBeDownloaded = false
// whether this attachment is downloaded to the documents directory // whether this attachment is already downloaded to the documents directory
@State var isDownloaded: Bool = false @State var isDownloaded: Bool = false
// used togehter with 'open' button to
// open a fullScreenView of a file
@State var isFullScreen: Bool = false @State var isFullScreen: Bool = false
/// a func to find the documents directory /// a func to find the documents directory
...@@ -124,16 +126,23 @@ struct AttPrev:View{ ...@@ -124,16 +126,23 @@ struct AttPrev:View{
} }
var body: some View{ var body: some View{
if shouldBeDownloaded {self.download()} if shouldBeDownloaded {
self.download()
}
//this QuickLookView has to be defined here so it reloads on every state-change // QuickLookView creates the preview of the file
// it has to be defined here to update correctly
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 clicked preview //these buttons are visable under the preview
// when users click on the preview
actions: self.isDownloaded||self.shouldBeDownloaded ? actions: self.isDownloaded||self.shouldBeDownloaded ?
// different combination of buttons
// according to downloading status
[ [
// anyViewDeleteButton // anyViewDeleteButton
anyViewOpenButton, anyViewOpenButton,
...@@ -147,19 +156,20 @@ struct AttPrev:View{ ...@@ -147,19 +156,20 @@ struct AttPrev:View{
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 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)
//an invisable NavigationLink to open the preview in fullscreen //a hidden NavigationLink to open the preview in fullscreen
NavigationLink(destination: QuickLookView(name: self.attachment.myName, data: self.attachment.myData) // seems not to work currently
.navigationBarItems(trailing: shareButton), isActive: self.$isFullScreen){Text("loi")}.hidden() NavigationLink(destination: QuickLookView(name: self.attachment.myName, data: self.attachment.myData)
.navigationBarItems(trailing: shareButton), isActive: self.$isFullScreen){Text("loi")}.hidden()
} }
.onAppear(perform: { .onAppear(perform: {
...@@ -168,6 +178,7 @@ struct AttPrev:View{ ...@@ -168,6 +178,7 @@ struct AttPrev:View{
//download all functionality //download all functionality
if self.shouldBeDownloaded {self.isDownloaded=true; self.download()} if self.shouldBeDownloaded {self.isDownloaded=true; self.download()}
}) })
// remove file from documents directory
.onDisappear(perform: { .onDisappear(perform: {
let filename = getDocumentsDirectory().appendingPathComponent(self.attachment.myName) let filename = getDocumentsDirectory().appendingPathComponent(self.attachment.myName)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment