Commit 1aea56ff authored by Oliver Wiese's avatar Oliver Wiese

remove sec state. Create an extension.

parent e9b90994
This diff is collapsed.
......@@ -466,17 +466,6 @@ extension PersistentMail: DisplayMail {
return .Other // TODO FIX
}
var warnings: [DialogOption] {
var result = [DialogOption]()
if self.unableToDecrypt {
result.append(.couldNotDecrypt)
}
else if self.trouble {
result.append(.corrupted)
}
return result
}
func markAsRead(isRead: Bool) {
self.isRead = isRead
}
......
......@@ -40,6 +40,11 @@ struct ReadMainView <M: DisplayMail>: View {
var Tabs:[Tab] {
get {
return [
Tab(
image: Image(systemName: "shield"),
description: "security",
content:AnyView(AttachmentsViewMain(attachments: mail.displayAttachments, dlAll: true))
),
Tab(
image: Image(systemName: "person.fill"),
description: "sender",
......@@ -54,7 +59,7 @@ struct ReadMainView <M: DisplayMail>: View {
image: Image(systemName: "rectangle.and.paperclip"),
description: "attachments",
content: AnyView(AttachmentsViewMain(attachments: mail.displayAttachments, dlAll: true))
)
)
]
}
}
......@@ -72,7 +77,7 @@ struct ReadMainView <M: DisplayMail>: View {
}
var detailInfo: some View {
let dialog = SecurityState(mail: mail).dialog
let dialog = mail.dialog
return DialogView(option: dialog, ctaAction: {
self.isSecIndExpanded = false
}, additionalAction: nil, dismissAction: nil, extend: false)
......@@ -91,8 +96,16 @@ struct Tab {
#if DEBUG
struct Layout_Previews: PreviewProvider {
static var previews: some View {
ReadMainView(mail: mail)
static let deviceNames: [String] = [
"iPhone SE",
"iPhone 11 Pro Max"
]
static var previews: some View {
ForEach(Layout_Previews.deviceNames, id: \.self) {deviceName in
ReadMainView<PseuoMail>(mail: mail)
.previewDisplayName(deviceName)
.previewDevice(.init(rawValue: deviceName))
}
}
}
#endif
......
......@@ -43,8 +43,7 @@ class ReadViewCoordinator {
try? AppDelegate.getAppDelegate().mailHandler.startIMAPIdleIfSupported()
AppDelegate.getAppDelegate().mailHandler.updateFolder(folder: Folder.inbox, completionCallback: {_ in
})
let secState = SecurityState.init(mail: mail)
let icon = secState.titleIcon
let icon = mail.titleIcon
let view = UIImageView(image: icon)
let vc = UIHostingController(rootView: ReadMainView(mail: mail))
readView = vc
......
......@@ -25,22 +25,20 @@ import CoreLocation
struct SenderViewMain <M: DisplayMail>: View {
let mail: M
let secState: SecurityState<M>
@State var selectedLandmark: Landmark? = nil
@State var showingLandmarkDetails = false
init(mail: M) {
self.mail = mail
secState = SecurityState(mail: mail)
}
var body: some View {
ScrollView {
if secState.warnings.count > 0 {
ForEach(0..<secState.warnings.count) { index in
DialogView(option: self.secState.warnings[index], ctaAction: {print("Hello")}, additionalAction: {print("Hello")}, dismissAction: {print("Hello")}, extend: (index == (self.secState.warnings.count - 1)))
if mail.warnings.count > 0 {
ForEach(0..<mail.warnings.count) { index in
DialogView(option: self.mail.warnings[index], ctaAction: {print("Hello")}, additionalAction: {print("Hello")}, dismissAction: {print("Hello")}, extend: (index == (self.mail.warnings.count - 1)))
}
} else {
......@@ -188,6 +186,5 @@ struct SenderView_Previews: PreviewProvider {
.previewDisplayName(deviceName)
.previewDevice(.init(rawValue: deviceName))
}
}
}
......@@ -80,10 +80,10 @@ struct DialogView <D: Dialog> : View {
}
struct DialogView_Previews: PreviewProvider {
static let options = SecurityState.init(mail: mail)
static let options = mail.dialog
static var previews: some View {
ScrollView{
DialogView(option: options.dialog, ctaAction: action, additionalAction: action, dismissAction: action, extend: false)
DialogView(option: options, ctaAction: action, additionalAction: action, dismissAction: action, extend: false)
DialogView(option: DialogOption.corrupted, ctaAction: action, additionalAction: action, dismissAction: action, extend: false)
DialogView(option: DialogOption.couldNotDecrypt, ctaAction: action, additionalAction: action, dismissAction: action, extend: false)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment