Skip to content
Snippets Groups Projects
Commit d7e7bd1d authored by Oliver Wiese's avatar Oliver Wiese
Browse files

active avatars

parent bc141754
No related branches found
No related tags found
1 merge request!85Thesis Hannes Staging
...@@ -24,7 +24,7 @@ import SwiftUI ...@@ -24,7 +24,7 @@ import SwiftUI
// TODO: Mark displayname as from CNContact // TODO: Mark displayname as from CNContact
class ContactHandler { class ContactHandler {
static var cartoons = false static var cartoons = StudySettings.useAvatars
private let store = CNContactStore() private let store = CNContactStore()
static let handler = ContactHandler() static let handler = ContactHandler()
......
...@@ -53,7 +53,8 @@ class StudySettings { ...@@ -53,7 +53,8 @@ class StudySettings {
static var securityIndicator: SecurityIndicator = SecurityIndicator.load() as! SecurityIndicator static var securityIndicator: SecurityIndicator = SecurityIndicator.load() as! SecurityIndicator
static var invitationsmode: Inviation = Inviation.load() as! Inviation 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 { public static var invitationEnabled: Bool {
get { get {
......
...@@ -28,25 +28,54 @@ struct MailRowView <M: DisplayMail>: View { ...@@ -28,25 +28,54 @@ struct MailRowView <M: DisplayMail>: View {
var activateOnTap: Bool = true var activateOnTap: Bool = true
var body: some View { var body: some View {
body_v2 body_v3
} }
private var content: String { private var content: String {
get { get {
let max = 500 let max = 500
if mail.subject.count < max { 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 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 { private var body_v2: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack{ HStack{
// Sender name // Sender name
Text(mail.sender.name) Text(mail.sender.name)
.fontWeight(mail.isRead ? .regular : .medium) .fontWeight(mail.isRead ? .regular : .light)
.lineLimit(2) .lineLimit(2)
Spacer() Spacer()
...@@ -64,7 +93,7 @@ struct MailRowView <M: DisplayMail>: View { ...@@ -64,7 +93,7 @@ struct MailRowView <M: DisplayMail>: View {
} }
HStack { HStack {
avatar avatar
.padding(StudySettings.useAvatars ? -15 : 0)
// Subject // Subject
Text(content) Text(content)
.font(.caption) .font(.caption)
...@@ -132,6 +161,15 @@ struct MailRowView <M: DisplayMail>: View { ...@@ -132,6 +161,15 @@ struct MailRowView <M: DisplayMail>: View {
.hidden() .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 { struct MailRowView_Previews: PreviewProvider {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment