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

remove cycle bug

parent caa7b7c0
No related branches found
No related tags found
2 merge requests!59Onboarding screens swift ui merge dev,!58Onboarding screens swift ui merge dev
...@@ -27,7 +27,7 @@ struct Inbox: View { ...@@ -27,7 +27,7 @@ struct Inbox: View {
SearchView(searchText: $searchText, searchField: $searchField, searchNow: $searchNow) SearchView(searchText: $searchText, searchField: $searchField, searchNow: $searchNow)
.padding(6) .padding(6)
// Mails // Mails
// mailList mailList
// Toolbar // Toolbar
HStack { HStack {
self.idButton self.idButton
...@@ -48,7 +48,8 @@ struct Inbox: View { ...@@ -48,7 +48,8 @@ struct Inbox: View {
private var mailList: some View { private var mailList: some View {
List (self.keyrecords.filter(filterKeyRecord), id: \.self){ List (self.keyrecords.filter(filterKeyRecord), id: \.self){
record in record in
KeyRecordRow(keyrecord: record, coord: self.coord) //KeyRecordRow(keyrecord: record, coord: self.coord)
KeyRecordRow(keyrecord: record)
} }
.resignKeyboardOnDragGesture() // hide keyboard when dragging .resignKeyboardOnDragGesture() // hide keyboard when dragging
} }
......
...@@ -9,15 +9,14 @@ ...@@ -9,15 +9,14 @@
import SwiftUI import SwiftUI
struct KeyRecordRow: View { struct KeyRecordRow: View {
private static let coord = AppDelegate.getAppDelegate().inboxCoordinator
var keyrecord: KeyRecord var keyrecord: KeyRecord
let coord: InboxCoordinator
var first: PersistentMail? var first: PersistentMail?
var second: PersistentMail? var second: PersistentMail?
init(keyrecord: KeyRecord, coord: InboxCoordinator) { init(keyrecord: KeyRecord) {
self.keyrecord = keyrecord self.keyrecord = keyrecord
self.coord = coord
first = keyrecord.firstMail first = keyrecord.firstMail
second = keyrecord.secondMail second = keyrecord.secondMail
} }
...@@ -49,13 +48,13 @@ struct KeyRecordRow: View { ...@@ -49,13 +48,13 @@ struct KeyRecordRow: View {
if let first = self.first { if let first = self.first {
if let second = self.second { if let second = self.second {
return AnyView(VStack(alignment: .leading, spacing: spacing) { return AnyView(VStack(alignment: .leading, spacing: spacing) {
MailView(mail: first, coord: coord) MailView(mail: first)
MailView(mail: second, coord: coord) MailView(mail: second)
.background(Stroke(offsetY: offset)) .background(Stroke(offsetY: offset))
}) })
} else { } else {
return AnyView(VStack(alignment: .leading,spacing: spacing) { return AnyView(VStack(alignment: .leading,spacing: spacing) {
MailView(mail: first, coord: coord) MailView(mail: first)
Text(NSLocalizedString("NoFurtherMessages", comment: "No more Mails")) Text(NSLocalizedString("NoFurtherMessages", comment: "No more Mails"))
.background(Stroke(offsetY: offset)) .background(Stroke(offsetY: offset))
}) })
...@@ -71,7 +70,9 @@ struct KeyRecordRow: View { ...@@ -71,7 +70,9 @@ struct KeyRecordRow: View {
.frame(width: 60, height: 60) .frame(width: 60, height: 60)
.shadow(radius: 5) .shadow(radius: 5)
.onTapGesture { .onTapGesture {
self.coord.pushRecordView(record: self.keyrecord) if let coord = KeyRecordRow.coord {
coord.pushRecordView(record: self.keyrecord)
}
} }
} }
...@@ -80,13 +81,17 @@ struct KeyRecordRow: View { ...@@ -80,13 +81,17 @@ struct KeyRecordRow: View {
.frame(maxWidth: 300, alignment: .leading) .frame(maxWidth: 300, alignment: .leading)
.lineLimit(1) .lineLimit(1)
.onTapGesture { .onTapGesture {
self.coord.pushRecordView(record: self.keyrecord) if let coord = KeyRecordRow.coord {
coord.pushRecordView(record: self.keyrecord)
}
} }
} }
private var moreMails: some View { private var moreMails: some View {
Button(action: { Button(action: {
self.coord.pushMailListView(record: self.keyrecord) if let coord = KeyRecordRow.coord {
coord.pushMailListView(record: self.keyrecord)
}
}, label: { }, label: {
Text(NSLocalizedString("MailView.MoreMails", comment: "More mails")) Text(NSLocalizedString("MailView.MoreMails", comment: "More mails"))
.foregroundColor(.gray) .foregroundColor(.gray)
......
...@@ -11,13 +11,12 @@ import SwiftUI ...@@ -11,13 +11,12 @@ import SwiftUI
struct MailView: View { struct MailView: View {
private static let coord = AppDelegate.getAppDelegate().inboxCoordinator
var mail: PersistentMail var mail: PersistentMail
let coord: InboxCoordinator // We need this to move to the mail.
init(mail: PersistentMail){
init(mail: PersistentMail, coord: InboxCoordinator) {
self.mail = mail self.mail = mail
self.coord = coord
} }
var body: some View { var body: some View {
...@@ -32,7 +31,9 @@ struct MailView: View { ...@@ -32,7 +31,9 @@ struct MailView: View {
} }
} }
.onTapGesture { .onTapGesture {
self.coord.pushReadView(mail: self.mail) if let coord = MailView.coord {
coord.pushReadView(mail: self.mail)
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment