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

active avatars

parent bc141754
Branches
Tags
1 merge request!85Thesis Hannes Staging
......@@ -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()
......
......@@ -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 {
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment