diff --git a/enzevalos_iphone/ContactHandler.swift b/enzevalos_iphone/ContactHandler.swift index 7c652f9cbb63b0b13f5f830f7df5b1d61da9a192..6f0351d1df35e0cbc4bdb5f17b8b89c6e899a4bb 100644 --- a/enzevalos_iphone/ContactHandler.swift +++ b/enzevalos_iphone/ContactHandler.swift @@ -24,7 +24,7 @@ import SwiftUI // TODO: Mark displayname as from CNContact class ContactHandler { - static var cartoons = false + static var cartoons = StudySettings.useAvatars private let store = CNContactStore() static let handler = ContactHandler() diff --git a/enzevalos_iphone/StudySettings.swift b/enzevalos_iphone/StudySettings.swift index e335b092e9b76eac3a83dfe9c67afc0eca805ef3..0256810b081847672f8c1946d020c4fcdc35a65d 100644 --- a/enzevalos_iphone/StudySettings.swift +++ b/enzevalos_iphone/StudySettings.swift @@ -53,7 +53,8 @@ class StudySettings { static var securityIndicator: SecurityIndicator = SecurityIndicator.load() as! SecurityIndicator static var invitationsmode: Inviation = Inviation.load() as! Inviation - static var showCategorizedInterface = true + static var showCategorizedInterface = false + static var useAvatars = true public static var invitationEnabled: Bool { get { diff --git a/enzevalos_iphone/SwiftUI/Inbox/simple/MailRowView.swift b/enzevalos_iphone/SwiftUI/Inbox/simple/MailRowView.swift index 236c419c0b964a584971dcac3eaa36a2d11cd4ef..5ae7e8492cca082051f281f1c34f9be133b3fee5 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/simple/MailRowView.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/simple/MailRowView.swift @@ -28,25 +28,54 @@ struct MailRowView <M: DisplayMail>: View { var activateOnTap: Bool = true var body: some View { - body_v2 + body_v3 } private var content: String { get { let max = 500 if mail.subject.count < max { - return mail.subject + "\n" + mail.body.prefix(max - mail.subject.count) + return mail.subject + "\n" + mail.body.prefix(max - mail.subject.count).replacingOccurrences(of: "\n", with: " ") } return mail.subject } } + private var body_v3: some View { + HStack(alignment:.center){ + avatar + .padding(StudySettings.useAvatars ? -15 : 0) + .frame(width: 60, height: 60, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) + VStack (alignment: .leading){ + HStack{ + // Sender name + sender + + Spacer() + if !mail.displayAttachments.isEmpty { + Image(systemName: "paperclip") + .font(.caption) + .foregroundColor(.secondary) + } + // Arrival time + Text(mail.date.timeAgoText()) + .font(.caption) + } + // Subject + Text(content) + .font(.caption) + .lineLimit(3) + } + } + .foregroundColor(mail.isRead ? .secondary : .primary) + } + private var body_v2: some View { VStack(alignment: .leading) { HStack{ // Sender name Text(mail.sender.name) - .fontWeight(mail.isRead ? .regular : .medium) + .fontWeight(mail.isRead ? .regular : .light) .lineLimit(2) Spacer() @@ -64,7 +93,7 @@ struct MailRowView <M: DisplayMail>: View { } HStack { avatar - + .padding(StudySettings.useAvatars ? -15 : 0) // Subject Text(content) .font(.caption) @@ -132,6 +161,15 @@ struct MailRowView <M: DisplayMail>: View { .hidden() ) } + + private var sender: some View { + Text(mail.sender.name) + .font(mail.sender.name.contains("@") ? .callout : .body) + .fontWeight(mail.isRead ? .regular : .light) + .lineLimit(1) + .truncationMode(.head) + .minimumScaleFactor(0.5) + } } struct MailRowView_Previews: PreviewProvider {