diff --git a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/Children/FilesPreviewer.swift b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/Children/FilesPreviewer.swift index 403e63f790f4bbdcce3d4c039328806a6dc87021..87ff539cc8cd19027822fd047b0210c9a9927b17 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/Children/FilesPreviewer.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/Children/FilesPreviewer.swift @@ -18,28 +18,37 @@ struct FilesPreviewer: View { var body: some View { ScrollView(.horizontal,showsIndicators:false){HStack{ForEach(0..<filesCategoryVM.mailsAttachments.count){ mailIndex -> AnyView in guard let mailAttachments = filesCategoryVM.mailsAttachments[safe: mailIndex] else {return AnyView(EmptyView())} - return AnyView(VStack{ - Text(filesCategoryVM.mails[mailIndex].subject) - ForEach(0..<mailAttachments.count){ attachmentIndex in let attachment = mailAttachments[attachmentIndex] - AttPrev( - attachment: attachment, - additionalActions:[ - AttPrev.Action( - icon: AnyView(Image(systemName: "mail")), - description: NSLocalizedString("open mail in standard view", comment: ""), - onClick: { - openOrigView(filesCategoryVM.mails[mailIndex]) - } - ) - ], - preload: false - ) //TODO: make this have the exact aspect ratio ? - .frame(width: 200) - .padding(.horizontal, 40).padding(.bottom, -25).padding(.top, -7) - } - }) + return + filesCategoryVM.isFullscreen ? + AnyView(ScrollView(.vertical, showsIndicators:false){attachmentColumn(filesCategoryVM.mails[mailIndex],attachments:mailAttachments)}) : + AnyView(attachmentColumn(filesCategoryVM.mails[mailIndex],attachments:mailAttachments)) }}.padding(.horizontal)} } + + func attachmentColumn(_ mail: eMail, attachments:[DisplayAttachment])->some View{ + let height = filesCategoryVM.attachmentsize(attachments.count) + return VStack{ + Text(mail.subject) + ForEach(0..<attachments.count){ attachmentIndex in let attachment = attachments[attachmentIndex] + AttPrev( + attachment: attachment, + additionalActions:[ + AttPrev.Action( + icon: AnyView(Image(systemName: "mail")), + description: NSLocalizedString("open mail in standard view", comment: ""), + onClick: { + openOrigView(mail) + } + ) + ], + preload: false + ) //TODO: make this have the exact aspect ratio ? + .frame(width: 200).frame(height: height) + .padding(.horizontal, 40).padding(.bottom, -25).padding(.top, -7) + } + } + } + func openOrigView(_ mail: eMail){ //TODO : open the readView //navigate(to: ReadMainView(mail: mail), when: $openEmail) diff --git a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/FilesCategoryModel.swift b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/FilesCategoryModel.swift index c9a674e63f4846a64cbb311a857651b22d1b35e5..8ebc5914ac464bb8c39d30040eebbf3b3cd0b053 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/FilesCategoryModel.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Categories/Files/FilesCategoryModel.swift @@ -30,4 +30,10 @@ class FilesCategoryVM: ObservableObject { mails.map{$0.displayAttachments} } + + var isFullscreen : Bool {categoryBaseModel.size == nil} + func attachmentsize(_ attachmentCount:Int)->CGFloat { + return isFullscreen ? 250 : ((categoryBaseModel.size! - 50) / CGFloat(attachmentCount)) + } + } diff --git a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/UI/CategoryViewInner.swift b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/UI/CategoryViewInner.swift index b0a49e2d69ce7ec2b0a619ce54a1acd2690e80fe..3002871b49e6c4c354e477a612860a7313cf9607 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/UI/CategoryViewInner.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/UI/CategoryViewInner.swift @@ -78,6 +78,7 @@ struct CategoryCardAlike<Content: View> : View { Divider() content() .frame(height:_size) + //.clipped() Spacer() }//TODO disable scrolling .gesture(DragGesture()) diff --git a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/ViewModels/HomeModel.swift b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/ViewModels/HomeModel.swift index e9182037084b462f923dae744430b35e3d6326ab..2930e11587b251c94aa0e82e590abd4242c562fc 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/ViewModels/HomeModel.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/Thesis Inbox/Helpers/ViewModels/HomeModel.swift @@ -62,7 +62,10 @@ class HomeModel : ObservableObject{ @Published var scrollAmount:CGFloat = 0 - private var allCats : [CategoryViewModel] {allCategorieModels.array} + private var allCats : [CategoryViewModel] { + //allCategorieModels.array.sort{($0.lastMailTimestamp ?? Date.distantPast) > ($1.lastMailTimestamp ?? Date.distantPast)} + return allCategorieModels.array + } private func updateSearch(){ allCats.forEach{category in