Commit 7b34ea1b authored by Oliver Wiese's avatar Oliver Wiese

remove cycle bug

parent caa7b7c0
......@@ -27,7 +27,7 @@ struct Inbox: View {
SearchView(searchText: $searchText, searchField: $searchField, searchNow: $searchNow)
.padding(6)
// Mails
// mailList
mailList
// Toolbar
HStack {
self.idButton
......@@ -48,7 +48,8 @@ struct Inbox: View {
private var mailList: some View {
List (self.keyrecords.filter(filterKeyRecord), id: \.self){
record in
KeyRecordRow(keyrecord: record, coord: self.coord)
//KeyRecordRow(keyrecord: record, coord: self.coord)
KeyRecordRow(keyrecord: record)
}
.resignKeyboardOnDragGesture() // hide keyboard when dragging
}
......
......@@ -9,15 +9,14 @@
import SwiftUI
struct KeyRecordRow: View {
private static let coord = AppDelegate.getAppDelegate().inboxCoordinator
var keyrecord: KeyRecord
let coord: InboxCoordinator
var first: PersistentMail?
var second: PersistentMail?
init(keyrecord: KeyRecord, coord: InboxCoordinator) {
init(keyrecord: KeyRecord) {
self.keyrecord = keyrecord
self.coord = coord
first = keyrecord.firstMail
second = keyrecord.secondMail
}
......@@ -49,13 +48,13 @@ struct KeyRecordRow: View {
if let first = self.first {
if let second = self.second {
return AnyView(VStack(alignment: .leading, spacing: spacing) {
MailView(mail: first, coord: coord)
MailView(mail: second, coord: coord)
MailView(mail: first)
MailView(mail: second)
.background(Stroke(offsetY: offset))
})
} else {
return AnyView(VStack(alignment: .leading,spacing: spacing) {
MailView(mail: first, coord: coord)
MailView(mail: first)
Text(NSLocalizedString("NoFurtherMessages", comment: "No more Mails"))
.background(Stroke(offsetY: offset))
})
......@@ -71,7 +70,9 @@ struct KeyRecordRow: View {
.frame(width: 60, height: 60)
.shadow(radius: 5)
.onTapGesture {
self.coord.pushRecordView(record: self.keyrecord)
if let coord = KeyRecordRow.coord {
coord.pushRecordView(record: self.keyrecord)
}
}
}
......@@ -80,13 +81,17 @@ struct KeyRecordRow: View {
.frame(maxWidth: 300, alignment: .leading)
.lineLimit(1)
.onTapGesture {
self.coord.pushRecordView(record: self.keyrecord)
if let coord = KeyRecordRow.coord {
coord.pushRecordView(record: self.keyrecord)
}
}
}
private var moreMails: some View {
Button(action: {
self.coord.pushMailListView(record: self.keyrecord)
if let coord = KeyRecordRow.coord {
coord.pushMailListView(record: self.keyrecord)
}
}, label: {
Text(NSLocalizedString("MailView.MoreMails", comment: "More mails"))
.foregroundColor(.gray)
......
......@@ -11,13 +11,12 @@ import SwiftUI
struct MailView: View {
private static let coord = AppDelegate.getAppDelegate().inboxCoordinator
var mail: PersistentMail
let coord: InboxCoordinator // We need this to move to the mail.
init(mail: PersistentMail, coord: InboxCoordinator) {
init(mail: PersistentMail){
self.mail = mail
self.coord = coord
}
var body: some View {
......@@ -32,7 +31,9 @@ struct MailView: View {
}
}
.onTapGesture {
self.coord.pushReadView(mail: self.mail)
if let coord = MailView.coord {
coord.pushReadView(mail: self.mail)
}
}
}
......
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