Commit 5b5618ee authored by Oliver Wiese's avatar Oliver Wiese

improve ReadViewSender

parent de83a1cf
......@@ -141,6 +141,7 @@
47A5D6E42294BFF50084F81D /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47A5D6E32294BFF50084F81D /* Logger.swift */; };
47C036FF2347C0F5006295E8 /* ImportKeyOverviewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C036FE2347C0F4006295E8 /* ImportKeyOverviewController.swift */; };
47C037032347D4D1006295E8 /* PasteKeyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C037022347D4D1006295E8 /* PasteKeyViewController.swift */; };
47C09C76243B3395007F74A2 /* SmallContactListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C09C75243B3395007F74A2 /* SmallContactListView.swift */; };
47C22281218AFD6300BD2C2B /* AutocryptTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C22280218AFD6300BD2C2B /* AutocryptTest.swift */; };
47C22283218B02C700BD2C2B /* autocryptSimpleExample1.eml in Resources */ = {isa = PBXBuildFile; fileRef = 47C22282218B02C700BD2C2B /* autocryptSimpleExample1.eml */; };
47C8225324379EAE005BCE73 /* AttachmentsViewMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224324379EAE005BCE73 /* AttachmentsViewMain.swift */; };
......@@ -587,6 +588,7 @@
47B2318A1F0D458100961B28 /* enzevalos_iphone 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "enzevalos_iphone 2.xcdatamodel"; sourceTree = "<group>"; };
47C036FE2347C0F4006295E8 /* ImportKeyOverviewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImportKeyOverviewController.swift; sourceTree = "<group>"; };
47C037022347D4D1006295E8 /* PasteKeyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteKeyViewController.swift; sourceTree = "<group>"; };
47C09C75243B3395007F74A2 /* SmallContactListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmallContactListView.swift; sourceTree = "<group>"; };
47C22280218AFD6300BD2C2B /* AutocryptTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutocryptTest.swift; sourceTree = "<group>"; };
47C22282218B02C700BD2C2B /* autocryptSimpleExample1.eml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = autocryptSimpleExample1.eml; sourceTree = "<group>"; };
47C8224324379EAE005BCE73 /* AttachmentsViewMain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentsViewMain.swift; sourceTree = "<group>"; };
......@@ -1299,6 +1301,7 @@
children = (
47C822672438A85C005BCE73 /* PhishingView.swift */,
47C822662438A85C005BCE73 /* SenderDetails.swift */,
47C09C75243B3395007F74A2 /* SmallContactListView.swift */,
);
path = SenderViewChildren;
sourceTree = "<group>";
......@@ -2222,6 +2225,7 @@
472F39861E1FA34E009260FB /* Record.swift in Sources */,
A1C3270E1DB907D900CE2ED5 /* TextFormatter.swift in Sources */,
F12041FD1DA409A5002E4940 /* ListViewCell.swift in Sources */,
47C09C76243B3395007F74A2 /* SmallContactListView.swift in Sources */,
A1EFF93321E6655C003BB240 /* IntroTableView.swift in Sources */,
47EABF272423BFDD00774A93 /* AuthenticationScreen.swift in Sources */,
4764069A2416B54D00C7D426 /* MailView.swift in Sources */,
......
......@@ -113,6 +113,18 @@ extension KeyRecord{
}
extension KeyRecord: DisplayContact {
var previousMails: Int {
return self.persistentMails?.count ?? 0
}
var previousResponses: Int {
return -1
}
var keyRecord: KeyRecord? {
return self
}
var addr: String {
return self.addresses.first?.mailAddress ?? "No address"
}
......@@ -147,6 +159,4 @@ extension KeyRecord: DisplayContact {
var similarContacts: [String] {
return [] // TODO!
}
}
......@@ -420,17 +420,22 @@ extension PersistentMail {
extension PersistentMail: DisplayMail {
typealias C = KeyRecord
var sender: DisplayContact {
var sender: C {
return self.record!
}
var ccs: [DisplayContact] {
return [] // TODO
var tos: [C] {
return [self.record!,self.record!,self.record!]
}
var bccs: [DisplayContact] {
return [] // TODO
var ccs: [C] {
return [self.record!,self.record!,self.record!] // TODO
}
var bccs: [C] {
return [self.record!,self.record!,self.record!] // TODO
}
var routingStops: [Landmark] {
......@@ -441,5 +446,9 @@ extension PersistentMail: DisplayMail {
return self.sigState
}
var persistentMail: PersistentMail? {
return self
}
}
......@@ -56,7 +56,7 @@ struct ReadMainView: View {
Tab(
image: Image(systemName: "person.fill"),
description: "sender",
content: AnyView(SenderViewMain(mail: mail))
content: AnyView(SenderViewMain<PersistentMail, KeyRecord>(mail: mail))
),
Tab(
image: Image(systemName: "text.bubble.fill"),
......
......@@ -81,6 +81,15 @@ class ReadViewCoordinator {
root.pushViewController(vc, animated: true)
}
func pushContactView(contact: KeyRecord) {
let vc = mainStoryboard.instantiateViewController(withIdentifier: ViewID.KeyRecordView.rawValue)
if let vc = vc as? ContactViewController {
vc.keyRecord = contact
}
root.isToolbarHidden = false
root.pushViewController(vc, animated: true)
}
func shareData(_ data:NSData){
//let shareText = "Hello, world!"
......
......@@ -21,23 +21,31 @@ protocol DisplayContact {
var keys: [String] { get }
// Phishing related
var hasPreviousMails: Bool { get }
var previousMails: Int { get }
var previousResponses: Int { get }
var hasSimilarContacts: Bool { get }
var similarContacts: [String] { get }
var keyRecord: KeyRecord? { get }
}
protocol DisplayMail {
associatedtype C: DisplayContact
var subject: String? { get }
var body: String? { get }
var sender: DisplayContact { get }
var ccs: [DisplayContact] { get }
var bccs: [DisplayContact] { get }
var sender: C { get }
var tos: [C] { get }
var ccs: [C] { get }
var bccs: [C] { get }
var routingStops: [Landmark] { get }
// Crypto
var signedState: SignatureState { get }
var encState: EncryptionState { get }
var persistentMail: PersistentMail? { get }
}
class ReadViewModel: ObservableObject {
......
//
// SmallContactListView.swift
// enzevalos_iphone
//
// Created by Oliver Wiese on 06.04.20.
// Copyright © 2020 fu-berlin. All rights reserved.
//
import SwiftUI
struct SmallContactListView <C: DisplayContact>: View {
let contacts: [C]
var title: String
@State var showList = true
var body: some View {
VStack (alignment: .leading, spacing: 10){
HStack {
Text(title)
.font(.headline)
Button (action: {
self.showList.toggle()
}) {
Image(systemName: showList ? "chevron.up" : "chevron.down")
.resizable()
.frame(width: 12.0, height: 7.0)
}
Spacer()
}
if showList {
ForEach(contacts, id: \.addr) {contact in
Group {
HStack {
CircleImage(image: contact.myImage, radius: 40)
VStack (alignment: .leading, spacing: 2){
Text(contact.name)
.font(.subheadline)
Text(contact.addr)
.foregroundColor(.gray)
}
Spacer()
Button(action: {self.goToContact(contact: contact)}){
Image(systemName: "chevron.right")
}
}
}
.onTapGesture {
self.goToContact(contact: contact)
}
}
}
}
.padding(10)
}
private func goToContact(contact: DisplayContact) {
guard let con = contact.keyRecord else {
return
}
AppDelegate.getAppDelegate().readViewCoordinator?.pushContactView(contact: con)
}
}
struct SmallContactListView_Previews: PreviewProvider {
static let alice = PseudoContact(name: "Alice", addr: "alice@example.com", myImage: PseudoContact.makeImg("Alice", color: .blue))
static let bob = PseudoContact(name: "Bob", addr: "Bob.lord.of.kingsbridge.and.king.of.england@huge.subdomain.with. a.long.long.long.domain.example.com", myImage: PseudoContact.makeImg("Bob", color: .red))
static let charlie = PseudoContact(name: "Charlie", addr: "charlie@example.com", myImage: PseudoContact.makeImg("Charlie", color: .green))
static var previews: some View {
VStack{
SmallContactListView(contacts: [alice,bob,charlie], title: "To")
SmallContactListView(contacts: [alice,bob,charlie], title: "To", showList: false)
}
}
}
......@@ -162,6 +162,8 @@
"ReadView.Attachments.No" = "Keine Anhänge vorhanden";
"ReadView.Attachments.Headline" = "Anhänge:";
"ReadView.Links.Future" = "a list of links contained in this mail will be visable here in a future update";
"ReadView.Sender.Previous" = "%d empfangene Mails";
"ReadView.Sender.Responses" = "%d gesendete Mails";
"Transportencryption" = "Transferverschlüsselung";
"Trash" = "Papierkorb";
"TwoDaysAgo" = "Vorgestern";
......
......@@ -159,6 +159,8 @@
"ReadView.Attachments.No" = "This mail doesn't contain any attachments";
"ReadView.Attachments.Headline" = "Attachments:";
"ReadView.Links.Future" = "A list of links contained in this mail will be visable here in a future update";
"ReadView.Sender.Previous" = "%d received emails";
"ReadView.Sender.Responses" = "%d sent emails";
"Sender" = "Sender";
"To" = "To";
"to" = "to";
......
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