// // PopupNotificationWireframe.swift // GME Remit // // Created by InKwon James Kim on 12/07/2019. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. // import UIKit class PopupNotificationWireframe { weak var view: UIViewController! } extension PopupNotificationWireframe: PopupNotificationWireframeInput { var storyboardName: String {return "PopupNotification"} func getMainView() -> UIViewController { let service = PopupNotificationService() let interactor = PopupNotificationInteractor(service: service) let presenter = PopupNotificationPresenter() let viewController = viewControllerFromStoryboard(of: PopupNotificationViewController.self) viewController.presenter = presenter interactor.output = presenter presenter.interactor = interactor presenter.wireframe = self presenter.view = viewController view = viewController return viewController } func show(source: UIViewController) { let now = Date() // FIXME: Temporary expire date if let expireDate = GMEDB.shared.app.object(.dateOfExpireNotification) as? Date { if let remindDate = expireDate - now, remindDate <= 0 { return } } if let date = GMEDB.shared.app.object(.dateOfDontShowNotification) as? Date { // TODO: if now - date == 0 then don't show notification else show notification and delete dateOfDontShowNotification if let remindDate = now - date, remindDate == 0 { return } GMEDB.shared.app.remove(.dateOfDontShowNotification) } if !GMEDB.shared.app.bool(.isOpenedPopupNotification) { source.present(getMainView(), animated: true, completion: nil) } } }