From e5e9104094feeea84d3451a30120ff19d53c0bfe Mon Sep 17 00:00:00 2001 From: Oleg Tverdokhleb Date: Fri, 25 Jan 2019 21:51:53 +0300 Subject: [PATCH] Revert "[BIOS-825] Fix height for ContractTemplate with fast rendering" This reverts commit a3ac733c --- .../PaymentMethods/PaymentMethodsViewIO.swift | 1 - .../Presenter/PaymentMethodsPresenter.swift | 2 - .../View/PaymentMethodsViewController.swift | 5 --- .../Assembly/TokenizationAssembly.swift | 13 +++++++ .../Presenter/TokenizationPresenter.swift | 1 - .../View/TokenizationViewController.swift | 37 +++++++++++++++++++ .../Presenter/YandexAuthPresenter.swift | 1 - 7 files changed, 50 insertions(+), 10 deletions(-) diff --git a/YandexCheckoutPayments/Modules/PaymentMethods/PaymentMethodsViewIO.swift b/YandexCheckoutPayments/Modules/PaymentMethods/PaymentMethodsViewIO.swift index 66b60c80..15653e23 100644 --- a/YandexCheckoutPayments/Modules/PaymentMethods/PaymentMethodsViewIO.swift +++ b/YandexCheckoutPayments/Modules/PaymentMethods/PaymentMethodsViewIO.swift @@ -49,7 +49,6 @@ protocol PaymentMethodsViewInput: ActivityIndicatorFullViewPresenting { protocol PaymentMethodsViewOutput: ActionTextDialogDelegate { func setupView() - func viewDidAppear() func didSelectViewModel(_ viewModel: PaymentMethodViewModel, at indexPath: IndexPath) func logoutDidPress(at indexPath: IndexPath) } diff --git a/YandexCheckoutPayments/Modules/PaymentMethods/Presenter/PaymentMethodsPresenter.swift b/YandexCheckoutPayments/Modules/PaymentMethods/Presenter/PaymentMethodsPresenter.swift index 0c3cc865..9d93e87b 100644 --- a/YandexCheckoutPayments/Modules/PaymentMethods/Presenter/PaymentMethodsPresenter.swift +++ b/YandexCheckoutPayments/Modules/PaymentMethods/Presenter/PaymentMethodsPresenter.swift @@ -27,9 +27,7 @@ extension PaymentMethodsPresenter: PaymentMethodsViewOutput { view.showActivity() view.setLogoVisible(isLogoVisible) view.setPlaceholderViewButtonTitle(§Localized.PlaceholderView.buttonTitle) - } - func viewDidAppear() { DispatchQueue.global().async { [weak self] in self?.interactor.fetchPaymentMethods() } diff --git a/YandexCheckoutPayments/Modules/PaymentMethods/View/PaymentMethodsViewController.swift b/YandexCheckoutPayments/Modules/PaymentMethods/View/PaymentMethodsViewController.swift index bced2739..8ce4bf77 100644 --- a/YandexCheckoutPayments/Modules/PaymentMethods/View/PaymentMethodsViewController.swift +++ b/YandexCheckoutPayments/Modules/PaymentMethods/View/PaymentMethodsViewController.swift @@ -94,11 +94,6 @@ final class PaymentMethodsViewController: UIViewController, PlaceholderProvider output.setupView() } - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - output.viewDidAppear() - } - private func loadSubviews() { titleView.contentView.addSubview(headerView) diff --git a/YandexCheckoutPayments/Modules/Tokenization/Assembly/TokenizationAssembly.swift b/YandexCheckoutPayments/Modules/Tokenization/Assembly/TokenizationAssembly.swift index 3fa9404c..ea91751d 100644 --- a/YandexCheckoutPayments/Modules/Tokenization/Assembly/TokenizationAssembly.swift +++ b/YandexCheckoutPayments/Modules/Tokenization/Assembly/TokenizationAssembly.swift @@ -33,6 +33,17 @@ public enum TokenizationAssembly { clientApplicationKey: inputData.clientApplicationKey, amount: inputData.amount) + let paymentMethodsModuleInputData + = PaymentMethodsModuleInputData(clientApplicationKey: inputData.clientApplicationKey, + gatewayId: inputData.gatewayId, + amount: inputData.amount, + tokenizationSettings: inputData.tokenizationSettings, + testModeSettings: inputData.testModeSettings, + isLoggingEnabled: inputData.isLoggingEnabled) + + let paymentMethods = PaymentMethodsAssembly.makeModule(inputData: paymentMethodsModuleInputData, + moduleOutput: presenter) + viewController.output = presenter viewController.transitioningDelegate = router viewController.modalPresentationStyle = .custom @@ -45,6 +56,8 @@ public enum TokenizationAssembly { router.transitionHandler = viewController + viewController.show(paymentMethods, sender: nil) + return viewController } } diff --git a/YandexCheckoutPayments/Modules/Tokenization/Presenter/TokenizationPresenter.swift b/YandexCheckoutPayments/Modules/Tokenization/Presenter/TokenizationPresenter.swift index 0caf3130..a64de76c 100644 --- a/YandexCheckoutPayments/Modules/Tokenization/Presenter/TokenizationPresenter.swift +++ b/YandexCheckoutPayments/Modules/Tokenization/Presenter/TokenizationPresenter.swift @@ -270,7 +270,6 @@ extension TokenizationPresenter: TokenizationViewOutput { func setupView() { interactor.startAnalyticsService() - presentPaymentMethodsModule() } } diff --git a/YandexCheckoutPayments/Modules/Tokenization/View/TokenizationViewController.swift b/YandexCheckoutPayments/Modules/Tokenization/View/TokenizationViewController.swift index ad0406d7..a91a6e76 100644 --- a/YandexCheckoutPayments/Modules/Tokenization/View/TokenizationViewController.swift +++ b/YandexCheckoutPayments/Modules/Tokenization/View/TokenizationViewController.swift @@ -33,6 +33,12 @@ class TokenizationViewController: UIViewController { private var containerConstraints: [NSLayoutConstraint] = [] + // MARK: - Managing Child View Controllers in a Custom Container + + override var shouldAutomaticallyForwardAppearanceMethods: Bool { + return false + } + // MARK: - Configuring the View Rotation Settings override var supportedInterfaceOrientations: UIInterfaceOrientationMask { @@ -251,6 +257,8 @@ class TokenizationViewController: UIViewController { view.addSubview(actionSheetTemplate.view) actionSheetTemplate.dummyView.addSubview(vc.view) + actionSheetTemplate.beginAppearanceTransition(true, animated: false) + actionSheetTemplate.view.translatesAutoresizingMaskIntoConstraints = false vc.view.translatesAutoresizingMaskIntoConstraints = false @@ -275,6 +283,8 @@ class TokenizationViewController: UIViewController { actionSheetTemplate.didMove(toParent: self) vc.didMove(toParent: actionSheetTemplate) + actionSheetTemplate.endAppearanceTransition() + appendIfNeeded(vc) self.actionSheetTemplate = actionSheetTemplate } @@ -291,6 +301,8 @@ class TokenizationViewController: UIViewController { vc.view.translatesAutoresizingMaskIntoConstraints = false modalTemplate.setContentView(vc.view) + modalTemplate.beginAppearanceTransition(true, animated: true) + let modalTemplateConstraints = [ view.leading.constraint(equalTo: modalTemplate.view.leading), view.trailing.constraint(equalTo: modalTemplate.view.trailing), @@ -306,6 +318,8 @@ class TokenizationViewController: UIViewController { modalTemplate.didMove(toParent: self) vc.didMove(toParent: modalTemplate) + modalTemplate.endAppearanceTransition() + let hasNavigationBar = (vc as? Presentable)?.hasNavigationBar ?? true modalTemplate.setNavigationBarHidden(hasNavigationBar == false, animated: false) modalTemplate.setNavigationItems(modules.map { $0.navigationItem }, animated: false) @@ -368,15 +382,20 @@ class TokenizationViewController: UIViewController { private func hideContainer(_ vc: UIViewController) { vc.willMove(toParent: nil) + vc.beginAppearanceTransition(false, animated: false) + containerConstraints = [] vc.view.removeFromSuperview() vc.removeFromParent() + + vc.endAppearanceTransition() } // MARK: - Hide view controller animated private func hideAnimated(actionSheet: ActionSheetTemplate, completion: (() -> Void)? = nil) { + actionSheet.beginAppearanceTransition(false, animated: true) actionSheet.willMove(toParent: nil) NSLayoutConstraint.deactivate(containerConstraints) @@ -394,6 +413,7 @@ class TokenizationViewController: UIViewController { self.view.layoutIfNeeded() }, completion: { _ in + actionSheet.endAppearanceTransition() actionSheet.view.removeFromSuperview() actionSheet.removeFromParent() self.actionSheetTemplate = nil @@ -402,6 +422,7 @@ class TokenizationViewController: UIViewController { } private func hideAnimated(pageSheet: PageSheetTemplate, completion: (() -> Void)? = nil) { + pageSheet.beginAppearanceTransition(false, animated: true) pageSheet.willMove(toParent: nil) NSLayoutConstraint.deactivate(containerConstraints) @@ -418,6 +439,7 @@ class TokenizationViewController: UIViewController { self.view.layoutIfNeeded() }, completion: { _ in + pageSheet.endAppearanceTransition() pageSheet.view.removeFromSuperview() pageSheet.removeFromParent() self.pageSheetTemplate = nil @@ -426,6 +448,7 @@ class TokenizationViewController: UIViewController { } private func hideAnimated(modalTemplate: ModalTemplate, completion: (() -> Void)? = nil) { + modalTemplate.beginAppearanceTransition(false, animated: true) modalTemplate.willMove(toParent: nil) NSLayoutConstraint.deactivate(containerConstraints) @@ -442,6 +465,7 @@ class TokenizationViewController: UIViewController { self.view.layoutIfNeeded() }, completion: { _ in + modalTemplate.endAppearanceTransition() modalTemplate.view.removeFromSuperview() modalTemplate.removeFromParent() self.modalTemplate = nil @@ -465,6 +489,8 @@ class TokenizationViewController: UIViewController { modalTemplate.addChild(vc) modalTemplate.setContentView(vc.view) + modalTemplate.beginAppearanceTransition(true, animated: true) + let startConstraints = [ modalTemplate.view.leading.constraint(equalTo: view.leading), modalTemplate.view.top.constraint(equalTo: view.bottom), @@ -497,6 +523,8 @@ class TokenizationViewController: UIViewController { modalTemplate.didMove(toParent: self) vc.didMove(toParent: modalTemplate) + modalTemplate.endAppearanceTransition() + self.modalTemplate = modalTemplate completion?() }) @@ -514,6 +542,8 @@ class TokenizationViewController: UIViewController { vc.view.translatesAutoresizingMaskIntoConstraints = false pageSheet.setContentView(vc.view) + pageSheet.beginAppearanceTransition(true, animated: true) + let startConstraints = [ pageSheet.view.leading.constraint(equalTo: view.leading), pageSheet.view.top.constraint(equalTo: view.bottom), @@ -546,6 +576,8 @@ class TokenizationViewController: UIViewController { pageSheet.didMove(toParent: self) vc.didMove(toParent: pageSheet) + pageSheet.endAppearanceTransition() + vc.removeKeyboardObservers() self.pageSheetTemplate = pageSheet @@ -563,6 +595,8 @@ class TokenizationViewController: UIViewController { actionSheetTemplate.addChild(vc) vc.didMove(toParent: actionSheetTemplate) + actionSheetTemplate.beginAppearanceTransition(true, animated: true) + view.addSubview(actionSheetTemplate.view) actionSheetTemplate.dummyView.addSubview(vc.view) @@ -604,6 +638,9 @@ class TokenizationViewController: UIViewController { }, completion: { _ in actionSheetTemplate.didMove(toParent: self) + + actionSheetTemplate.endAppearanceTransition() + completion?() }) diff --git a/YandexCheckoutPayments/Modules/YandexAuth/Presenter/YandexAuthPresenter.swift b/YandexCheckoutPayments/Modules/YandexAuth/Presenter/YandexAuthPresenter.swift index af7c0001..795264cc 100644 --- a/YandexCheckoutPayments/Modules/YandexAuth/Presenter/YandexAuthPresenter.swift +++ b/YandexCheckoutPayments/Modules/YandexAuth/Presenter/YandexAuthPresenter.swift @@ -31,7 +31,6 @@ extension YandexAuthPresenter: PaymentMethodsViewOutput { } } - func viewDidAppear() {} func didSelectViewModel(_ viewModel: PaymentMethodViewModel, at indexPath: IndexPath) {} func logoutDidPress(at indexPath: IndexPath) {} }