diff --git a/enzevalos_iphone/SwiftUI/Data/DisplayProtocols.swift b/enzevalos_iphone/SwiftUI/Data/DisplayProtocols.swift index bb477420629e903d93be216ae9418d41036433f9..74cc34e991db663bf08555741c380d75f755afd9 100644 --- a/enzevalos_iphone/SwiftUI/Data/DisplayProtocols.swift +++ b/enzevalos_iphone/SwiftUI/Data/DisplayProtocols.swift @@ -296,3 +296,16 @@ extension DisplayMail { } + +struct DisplayProtocols_Previews: PreviewProvider { + static let mails = DummyData.mails + static let deviceName = "iPhone 11 Pro Max" + + static var previews: some View { + ForEach(0..<mails.count) { index in + ReadMainView(mail: mails[index]) + .previewDisplayName(mails[index].previewName) + .previewDevice(.init(rawValue: deviceName)) + } + } +} diff --git a/enzevalos_iphone/SwiftUI/Data/SimulatorData.swift b/enzevalos_iphone/SwiftUI/Data/SimulatorData.swift index ec53d1661ad3cdb989fc63fc835aa9becb59a9b8..d5e46ee7deb2c91252d65802c8828715016078bd 100644 --- a/enzevalos_iphone/SwiftUI/Data/SimulatorData.swift +++ b/enzevalos_iphone/SwiftUI/Data/SimulatorData.swift @@ -21,6 +21,16 @@ struct Simulators <V: View> { .previewDisplayName(deviceName) .previewDevice(.init(rawValue: deviceName)) } + } +} + +/// Example +struct SimulatorData_Previews: PreviewProvider { + static var previews: some View { + let sim = Simulators<ReadMainView<PseuoMail>>() + let mail = DummyData.MissingPKMail + let view = ReadMainView(mail: mail) + return sim.previews(view: view) } } @@ -37,13 +47,16 @@ struct DummyData { Landmark(name: "Sydney", domain: "thirdexampledomain.de", location: .init(latitude: -33.865143, longitude: 151.209900)) ] + /// A list of all dummy mails + static let mails = [DummyData.SecureMail, DummyData.PlainMail, DummyData.SignedOnlyMail, DummyData.MissingPKMail, DummyData.NotDecryptedMail, DummyData.CorruptedMail] + /// Different Mails - static let SecureMail = PseuoMail(folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.ValidSignature, encState: .ValidedEncryptedWithCurrentKey) - static let NotDecryptedMail = PseuoMail(folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.ValidSignature, encState: .UnableToDecrypt) - static let PlainMail = PseuoMail(folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.NoSignature, encState: .NoEncryption) - static let SignedOnlyMail = PseuoMail(folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.ValidSignature, encState: .NoEncryption) - static let CorruptedMail = PseuoMail(folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.InvalidSignature, encState: .ValidedEncryptedWithCurrentKey) - static let MissingPKMail = PseuoMail(folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.NoPublicKey, encState: .ValidedEncryptedWithCurrentKey) + static let SecureMail = PseuoMail(previewName: "Secure mail", folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.ValidSignature, encState: .ValidedEncryptedWithCurrentKey) + static let NotDecryptedMail = PseuoMail(previewName: "Can not decrypt", folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.ValidSignature, encState: .UnableToDecrypt) + static let PlainMail = PseuoMail(previewName: "Plain mail", folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.NoSignature, encState: .NoEncryption) + static let SignedOnlyMail = PseuoMail(previewName: "Signed only mail", folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.ValidSignature, encState: .NoEncryption) + static let CorruptedMail = PseuoMail(previewName: "Corrupted mail", folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.InvalidSignature, encState: .ValidedEncryptedWithCurrentKey) + static let MissingPKMail = PseuoMail(previewName: "Mising public key", folderType: .Inbox, sender: Alice, tos: [Bob, Charlie], ccs: [Bob, Charlie, Bob, Charlie, Bob], bccs: [Bob], routingStops: Landmarks, signedState: SignatureState.NoPublicKey, encState: .ValidedEncryptedWithCurrentKey) static let Attachment = PseudoAttachment() } @@ -125,6 +138,8 @@ struct PseudoContact: DisplayContact { struct PseuoMail: DisplayMail { typealias U = PseudoContact typealias D = DialogStruct + + var previewName: String var displayAttachments: [DisplayAttachment] = [] @@ -171,3 +186,5 @@ JVBERi0xLjUKJdDUxdgKMTI1IDAgb2JqCjw8Ci9MZW5ndGggNTM1NCAgICAgIAovRmlsdGVyIC9GbGF0 """ } + +