Commit b3db6282 authored by Oliver Wiese's avatar Oliver Wiese

add new readView

parent d6e06aed
......@@ -31,8 +31,12 @@ import UserNotifications
class AppDelegate: UIResponder, UIApplicationDelegate {
var newOnboarding=true
var newOnboarding = true
var newReadView = true
var inboxCoordinator: InboxCoordinator? = nil
var readViewCoordinator: ReadViewCoordinator? = nil
var window: UIWindow?
var contactStore = CNContactStore()
var mailHandler = MailHandler()
......@@ -321,6 +325,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
fatalError("No rootViewController!")
}
inboxCoordinator = InboxCoordinator(root: vc)
readViewCoordinator = ReadViewCoordinator(root: vc) // TODO: Improve Coordinators and init
guard let coord = inboxCoordinator else {
fatalError("No Coordinator")
}
......@@ -328,6 +333,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return
}
func presentReadViewController(mail: PersistentMail) {
//presentSwiftUIReadView()
guard let vc = self.window?.rootViewController as? UINavigationController else {
fatalError("No rootViewController!")
}
readViewCoordinator = ReadViewCoordinator(root: vc)
guard let coord = readViewCoordinator else {
fatalError("No Coordinator")
}
coord.pushReadView(mail: mail)
return
}
// Support for background fetch
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
......
......@@ -56,12 +56,16 @@ class InboxCoordinator {
}
func pushReadView(mail: PersistentMail) {
let vc = mainStoryboard.instantiateViewController(withIdentifier: ViewID.ReadView.rawValue)
if let vc = vc as? ReadViewController {
vc.mail = mail
if AppDelegate.getAppDelegate().newReadView, let readCoord = AppDelegate.getAppDelegate().readViewCoordinator {
readCoord.pushReadView(mail: mail)
} else {
let vc = mainStoryboard.instantiateViewController(withIdentifier: ViewID.ReadView.rawValue)
if let vc = vc as? ReadViewController {
vc.mail = mail
}
root.isToolbarHidden = false
root.pushViewController(vc, animated: true)
}
root.isToolbarHidden = false
root.pushViewController(vc, animated: true)
}
func pushRecordView(record: KeyRecord){
......
......@@ -25,16 +25,14 @@ class ReadViewCoordinator {
private let mainStoryboard: UIStoryboard
private var readView: UIViewController?
private var mail:PersistentMail
init(root: UINavigationController, mail:PersistentMail) {
self.mail = mail
init(root: UINavigationController) {
self.root = root
mainStoryboard = UIStoryboard(name: self.mainStoryboardName, bundle: nil)
}
func pushReadView(){
func pushReadView(mail: PersistentMail){
root.isToolbarHidden = true
......@@ -60,13 +58,13 @@ class ReadViewCoordinator {
}
}
func delete(){
func delete(mail: PersistentMail){
//TODO: make this work
Logger.log(delete: mail, toTrash: true)
AppDelegate.getAppDelegate().mailHandler.move(mails: [mail], from: mail.folder.path, to: UserManager.backendTrashFolderPath)
}
func archive(){
func archive(mail: PersistentMail){
//TODO: make this work
Logger.log(archive: mail)
AppDelegate.getAppDelegate().mailHandler.move(mails: [mail], from: mail.folder.path, to: UserManager.backendArchiveFolderPath)
......
......@@ -230,7 +230,7 @@ struct MessageViewMain: View {
FloatingActionButton(
radius: innerPadding*extraButtonFactor,
onShortPress: {
self.coord.delete();
self.coord.delete(mail: self.mail);
self.presentationMode.wrappedValue.dismiss()}/*TODO: fill in stuff*/
){
VStack{
......
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