diff --git a/enzevalos_iphone/SwiftUI/Inbox/Inbox.swift b/enzevalos_iphone/SwiftUI/Inbox/Inbox.swift index 077cdf12d76caf202018d4a00969e0f1969eb335..06e10bf34bb0f3d88047a25140bae54fbae44ca3 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/Inbox.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/Inbox.swift @@ -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 } diff --git a/enzevalos_iphone/SwiftUI/Inbox/KeyRecordRow.swift b/enzevalos_iphone/SwiftUI/Inbox/KeyRecordRow.swift index 87ec4a2526fa1966cf858407d5bac49942b4c39e..2efe5c1ab70597851af3a561fe86db16fe255e4c 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/KeyRecordRow.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/KeyRecordRow.swift @@ -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) diff --git a/enzevalos_iphone/SwiftUI/SupportingViews/MailView.swift b/enzevalos_iphone/SwiftUI/SupportingViews/MailView.swift index 2aa2587e4d9fed533c2374f1f4c3a2e5c0e9679e..8cac9ab0789bb6de69cee356bfdca3a4419d0943 100644 --- a/enzevalos_iphone/SwiftUI/SupportingViews/MailView.swift +++ b/enzevalos_iphone/SwiftUI/SupportingViews/MailView.swift @@ -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) + } } }