From 0f34e8a524117d70cc471ca82511637f2747d898 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Tue, 10 Nov 2020 15:15:11 +0300 Subject: [PATCH 01/32] Modified access control for methods to open. --- .../Controllers/MUViewController.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Components/Controllers/MUViewController.swift b/Source/Components/Controllers/MUViewController.swift index b708114..c0e53e4 100644 --- a/Source/Components/Controllers/MUViewController.swift +++ b/Source/Components/Controllers/MUViewController.swift @@ -126,7 +126,7 @@ open class MUViewController: UIViewController { // MARK: - Public methods - func subscribeOnNotifications() { + open func subscribeOnNotifications() { guard isVisible, isNotificationSubscribed == false else { return } @@ -139,7 +139,7 @@ open class MUViewController: UIViewController { subscribeOnAppNotifications() } - func unsubscribeFromNotifications() { + open func unsubscribeFromNotifications() { isNotificationSubscribed = false @@ -148,30 +148,30 @@ open class MUViewController: UIViewController { NotificationCenter.default.removeObserver(self) } - func subscribeOnCustomNotifications() { + open func subscribeOnCustomNotifications() { } - func appDidBecomeActive() { + open func appDidBecomeActive() { } - func appWillResignActive() { + open func appWillResignActive() { } - func appErrorDidBecome(error: Error) { + open func appErrorDidBecome(error: Error) { isLoading = false } - func appErrorDidClear() { + open func appErrorDidClear() { } // MARK: - Public methods - func close(animated: Bool = true, toRoot: Bool = false, popOnly: Bool = false, completion: (() -> Void)? = nil) { + open func close(animated: Bool = true, toRoot: Bool = false, popOnly: Bool = false, completion: (() -> Void)? = nil) { popupControl.dismiss() From 5275731ed47ab30677cd6edd6b29067bc8c4cb2c Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Tue, 10 Nov 2020 16:09:19 +0300 Subject: [PATCH 02/32] Removed duplicate code. --- Source/Components/Controllers/MUViewController.swift | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Source/Components/Controllers/MUViewController.swift b/Source/Components/Controllers/MUViewController.swift index c0e53e4..d1bc624 100644 --- a/Source/Components/Controllers/MUViewController.swift +++ b/Source/Components/Controllers/MUViewController.swift @@ -85,8 +85,6 @@ open class MUViewController: UIViewController { updateViewControllersArray() - configureNavigatioBar() - configureInteractivePopGestureRecognizer() subscribeOnNotifications() @@ -195,13 +193,6 @@ open class MUViewController: UIViewController { // MARK: - Private methods - private func configureNavigatioBar() { - - guard let hasNavigationBar = hasNavigationBar else { return } - - navigationController?.setNavigationBarHidden(hasNavigationBar == false, animated: true) - } - private func configureInteractivePopGestureRecognizer() { navigationController?.interactivePopGestureRecognizer?.delegate = self From ab5e1eef4d5657040a3b28ef5d3ff7df948a2572 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Tue, 10 Nov 2020 18:07:11 +0300 Subject: [PATCH 03/32] Modified MUEmptyModel access control from public to open. --- Source/Components/Controls/MULoadControl.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Components/Controls/MULoadControl.swift b/Source/Components/Controls/MULoadControl.swift index 7bb117e..33cf3e8 100644 --- a/Source/Components/Controls/MULoadControl.swift +++ b/Source/Components/Controls/MULoadControl.swift @@ -194,6 +194,6 @@ public extension UIView { // MARK: - MUEmptyModel -public class MUEmptyModel: MUModel { +open class MUEmptyModel: MUModel { } From 3b39fa2399e8f414e59b98f33940d618d3053193 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Tue, 10 Nov 2020 19:02:12 +0300 Subject: [PATCH 04/32] Renamed instantiate to instance. --- .../Controllers/MUViewController.swift | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Source/Components/Controllers/MUViewController.swift b/Source/Components/Controllers/MUViewController.swift index d1bc624..4337278 100644 --- a/Source/Components/Controllers/MUViewController.swift +++ b/Source/Components/Controllers/MUViewController.swift @@ -298,7 +298,7 @@ public extension MUViewController { return MUViewController.viewControllersArray["\(T.self)"]?.controller as? T } - static func getInstantiate(with type: T.Type) -> T? { + static func getInstance(with type: T.Type) -> T? { switch T.initMethod { case .fromNib : return T.instantiate() @@ -307,7 +307,7 @@ public extension MUViewController { } } - static func getInstantiate() -> T? { + static func getInstance() -> T? { guard storyboardName != "" else { @@ -339,16 +339,16 @@ public extension MUViewController { setup : ((T) -> Void)? = nil ) { - guard let instantiate = T.getInstantiate(with: T.self) else { + guard let instance = T.getInstance(with: T.self) else { return } - setup?(instantiate) + setup?(instance) push( - with : instantiate, + with : instance, animated : animated, pushCompletion : pushCompletion ) @@ -364,18 +364,18 @@ public extension MUViewController { ) { - guard let instantiate = T.getInstantiate(with: T.self) else { + guard let instance = T.getInstance(with: T.self) else { return } - setup?(instantiate) + setup?(instance) - var presentedController: UIViewController = instantiate + var presentedController: UIViewController = instance if withNavigation { - presentedController = instantiate.addNavigation() + presentedController = instance.addNavigation() } if let style = style { @@ -396,16 +396,16 @@ public extension MUViewController { setup : ((T) -> Void)? = nil) { - guard let instantiate: T = getInstantiate() as? T else { + guard let instance: T = getInstance() as? T else { - return Log.error("failed to create instantiate for \(self)") + return Log.error("failed to create instance for \(self)") } - setup?(instantiate) + setup?(instance) controller?.push( - with : instantiate, + with : instance, animated : animated, pushCompletion : pushCompletion ) @@ -422,26 +422,26 @@ public extension MUViewController { ) { - guard let instantiate: T = getInstantiate() else { + guard let instance: T = getInstance() else { return } - setup?(instantiate) + setup?(instance) - var presentedController: UIViewController = instantiate + var presentedController: UIViewController = instance if asRoot { if let navigationController = findNavigationController(storyboardName: storyboardName) { - navigationController.setViewControllers([instantiate], animated: false) + navigationController.setViewControllers([instance], animated: false) presentedController = navigationController } else { - presentedController = createNavigationController(with: instantiate) + presentedController = createNavigationController(with: instance) } } @@ -462,40 +462,40 @@ public extension MUViewController { setup : ((T) -> Void)? = nil ) { - guard let instantiate: T = screen.getInstantiate() else { + guard let instance: T = screen.getInstance() else { return } - setup?(instantiate) + setup?(instance) - addChild(instantiate) + addChild(instance) - instantiate.didMove(toParent: self) + instance.didMove(toParent: self) if let appendTargetView = appendTargetView { - instantiate.view.frame = appendTargetView.frame + instance.view.frame = appendTargetView.frame - view.insertSubview(instantiate.view, aboveSubview: appendTargetView) + view.insertSubview(instance.view, aboveSubview: appendTargetView) } else { - (insertTargetView ?? view).addSubview(instantiate.view) + (insertTargetView ?? view).addSubview(instance.view) } - instantiate.view.appendConstraints(to: insertTargetView ?? view) + instance.view.appendConstraints(to: insertTargetView ?? view) } - func insert(controller instantiate: UIViewController, into insertTargetView: UIView? = nil) { + func insert(controller instance: UIViewController, into insertTargetView: UIView? = nil) { - addChild(instantiate) + addChild(instance) - (insertTargetView ?? view).addSubview(instantiate.view) + (insertTargetView ?? view).addSubview(instance.view) - instantiate.view.appendConstraints(to: insertTargetView ?? view) + instance.view.appendConstraints(to: insertTargetView ?? view) - instantiate.didMove(toParent: self) + instance.didMove(toParent: self) } func remove(child controller: UIViewController) { From 3e3f096c3fbf3dc3702c319276b97c58830673b0 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Tue, 10 Nov 2020 21:00:01 +0300 Subject: [PATCH 05/32] Fixed using getInstance method. --- Source/Components/Protocols/MUReusableControllerProvider.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Components/Protocols/MUReusableControllerProvider.swift b/Source/Components/Protocols/MUReusableControllerProvider.swift index 0d16320..09ee6cf 100644 --- a/Source/Components/Protocols/MUReusableControllerProvider.swift +++ b/Source/Components/Protocols/MUReusableControllerProvider.swift @@ -57,7 +57,7 @@ public extension MUReusableControllerProvider { let type = getControllerClass(forIdentifier: id) - guard let controller = type.getInstantiate() else { + guard let controller = type.getInstance() else { fatalError("Unable to initialize controller with class: \(type) for reuse identifier: \(id)") } From a4cf96dc103fe6059385f19d1b7762adbd245b2b Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 11 Nov 2020 10:16:39 +0300 Subject: [PATCH 06/32] View localization. --- .../Controllers/MUViewController.swift | 52 +++++++++++++++---- Source/Extension/UIView.swift | 19 +++++-- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/Source/Components/Controllers/MUViewController.swift b/Source/Components/Controllers/MUViewController.swift index 4337278..db3bb36 100644 --- a/Source/Components/Controllers/MUViewController.swift +++ b/Source/Components/Controllers/MUViewController.swift @@ -73,8 +73,6 @@ open class MUViewController: UIViewController { popupControl.setup(with: self) loadControl.setup(with: self) - - subscribeOnCustomNotifications() } open override func viewWillAppear(_ animated: Bool) { @@ -142,12 +140,10 @@ open class MUViewController: UIViewController { isNotificationSubscribed = false keyboardControl.unsubscribeOnNotifications() - - NotificationCenter.default.removeObserver(self) - } - - open func subscribeOnCustomNotifications() { - + + unsubscribeOnErrorNotifications() + + unsubscribeOnAppNotification() } open func appDidBecomeActive() { @@ -166,8 +162,11 @@ open class MUViewController: UIViewController { open func appErrorDidClear() { } - - // MARK: - Public methods + + @objc open func localize() { + + view.localize() + } open func close(animated: Bool = true, toRoot: Bool = false, popOnly: Bool = false, completion: (() -> Void)? = nil) { @@ -190,8 +189,24 @@ open class MUViewController: UIViewController { } } } + + deinit { + + NotificationCenter.default.removeObserver(self) + } // MARK: - Private methods + + private func subscribeOnLanguageNotifications() { + + NotificationCenter.default.addObserver( + + self, + selector : #selector(localize), + name : .languageDidChange, + object : nil + ) + } private func configureInteractivePopGestureRecognizer() { @@ -229,6 +244,12 @@ extension MUViewController: UIGestureRecognizerDelegate { // MARK: - Errors public extension MUViewController { + + func unsubscribeOnErrorNotifications() { + + NotificationCenter.default.removeObserver(self, name: .appErrorDidCome, object: nil) + NotificationCenter.default.removeObserver(self, name: .appErrorDidClear, object: nil) + } func updateErrorRecipient() { @@ -586,6 +607,16 @@ extension MUViewController { NotificationCenter.addObserver(self, selector: #selector(appNotification), name: .appDidBecomeActive) NotificationCenter.addObserver(self, selector: #selector(appNotification), name: .appWillResignActive) + NotificationCenter.addObserver(self, selector: #selector(appNotification), name: .appDidEnterBackground) + NotificationCenter.addObserver(self, selector: #selector(appNotification), name: .appWillEnterBackground) + } + + private func unsubscribeOnAppNotification() { + + NotificationCenter.default.removeObserver(self, name: .appDidBecomeActive, object: nil) + NotificationCenter.default.removeObserver(self, name: .appWillResignActive, object: nil) + NotificationCenter.default.removeObserver(self, name: .appDidEnterBackground, object: nil) + NotificationCenter.default.removeObserver(self, name: .appWillEnterBackground, object: nil) } } @@ -597,6 +628,7 @@ public extension Notification.Name { static let appWillResignActive = Notification.Name("appWillResignActive") static let appDidEnterBackground = Notification.Name("appDidEnterBackground") static let appWillEnterBackground = Notification.Name("appWillEnterBackground") + static let languageDidChange = Notification.Name("languageDidChange") } // MARK: - MUViewControllerContainer diff --git a/Source/Extension/UIView.swift b/Source/Extension/UIView.swift index 2d2bd4f..e00b260 100755 --- a/Source/Extension/UIView.swift +++ b/Source/Extension/UIView.swift @@ -104,7 +104,7 @@ public extension UIView { static private var viewDataStorage: [String: [String: Any?]] = [:] - // MARK :- Visibility + // MARK: - Visibility func masked(corners: UIRectCorner, radius: CGFloat) { @@ -130,7 +130,7 @@ public extension UIView { layer.mask = maskLayer } - // MARK :- Subviews + // MARK: - Subviews func getSubview(id: String) -> UIView? { @@ -382,7 +382,7 @@ public extension UIView { self.layer.add(animation, forKey: "position") } - // MARK :- Private methods + // MARK: - Private methods private func updateDefaultShadow() { @@ -422,3 +422,16 @@ public extension UIView { return image ?? UIImage() } } + +extension UIView { + + // MARK: - Localization + + @objc open func localize() { + + for subview in subviews { + + subview.localize() + } + } +} From 2ef48a6cf5abf9f0492662dae0f342e39cf2dab6 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 11 Nov 2020 11:37:51 +0300 Subject: [PATCH 07/32] Modified access control for view extensions. --- Source/Extension/UIView+Constraints.swift | 45 ++++++++++++++--------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/Source/Extension/UIView+Constraints.swift b/Source/Extension/UIView+Constraints.swift index fdf0f43..7782b97 100644 --- a/Source/Extension/UIView+Constraints.swift +++ b/Source/Extension/UIView+Constraints.swift @@ -8,11 +8,11 @@ import UIKit -// MARK: LayoutInsets +// MARK: - LayoutInsets public struct LayoutInsets { - // MARK: Public properites + // MARK: - Public properites static var zero: LayoutInsets { self.init(top: 0, left: 0, bottom: 0, right: 0) } @@ -24,9 +24,9 @@ public struct LayoutInsets { public var right: CGFloat? - // MARK: Public methods + // MARK: - Public methods - static func insets( + public static func insets( top : CGFloat? = 0, left : CGFloat? = 0, bottom : CGFloat? = 0, @@ -37,22 +37,31 @@ public struct LayoutInsets { } } -// MARK: LayoutDimension +// MARK: - LayoutDimension -struct LayoutDimension: OptionSet { +public struct LayoutDimension: OptionSet { - let rawValue: Int + // MARK: - Public properties + + public let rawValue: Int - static let height = LayoutDimension(rawValue: 1) + public static let height = LayoutDimension(rawValue: 1) - static let width = LayoutDimension(rawValue: 2) + public static let width = LayoutDimension(rawValue: 2) + + // MARK: - Public methods + + public init(rawValue: Int) { + + self.rawValue = rawValue + } } -// MARK: AutoLayout Extensions +// MARK: - AutoLayout Extensions -extension UIView { +public extension UIView { - // MARK: Layout Subview + // MARK: - Layout Subview func layoutCenter(_ view: UIView, xOffset: CGFloat = 0, yOffset: CGFloat = 0) { @@ -141,7 +150,7 @@ extension UIView { } } - // MARK: Find Constraint + // MARK: - Find Constraint func findConstraint(byId id: String) -> NSLayoutConstraint? { @@ -196,7 +205,7 @@ extension UIView { return nil } - // MARK: Set Constraint + // MARK: - Set Constraint func setConstraint(type: NSLayoutConstraint.Attribute, value: CGFloat, updateSuperview: Bool = true) { @@ -260,10 +269,10 @@ extension UIView { } } -// MARK: Anchors +// MARK: - Anchors @available(iOS 11.0, *) -extension UIView { +public extension UIView { func getTopAnchor(safe: Bool) -> NSLayoutYAxisAnchor { @@ -286,9 +295,9 @@ extension UIView { } } -// MARK: NSLayoutAnchor +// MARK: - NSLayoutAnchor -extension NSLayoutAnchor { +public extension NSLayoutAnchor { @objc func makeConstraint(equalTo anchor: NSLayoutAnchor, constant: CGFloat) { From 3081d22497e12e4598033299006197a2b43a283a Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 11 Nov 2020 12:11:10 +0300 Subject: [PATCH 08/32] Modified access control for methods and properties in network manager. --- Source/Helpers/MUNetworkManager.swift | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Helpers/MUNetworkManager.swift b/Source/Helpers/MUNetworkManager.swift index e48b44f..e444768 100755 --- a/Source/Helpers/MUNetworkManager.swift +++ b/Source/Helpers/MUNetworkManager.swift @@ -46,7 +46,7 @@ open class MUNetworkManager: NSObject { // MARK: - Override methods - init(serverTrustPolicies: [String: MUServerTrustPolicy]? = nil) { + public init(serverTrustPolicies: [String: MUServerTrustPolicy]? = nil) { let configuration = URLSessionConfiguration.default @@ -318,14 +318,14 @@ public extension MUNetworkManager { public struct MUNetworkRequest { - var url : String - var method : MUNetworkHttpMethod - var headers : [String : String]? = nil - var params : [String : Any]? = nil - var body : Any? = nil - var encoding : MUNetworkEncoding = .url - var success : ((Any) -> Void)? = nil - var failure : ((Error?) -> Void)? = nil + public var url : String + public var method : MUNetworkHttpMethod + public var headers : [String : String]? = nil + public var params : [String : Any]? = nil + public var body : Any? = nil + public var encoding : MUNetworkEncoding = .url + public var success : ((Any) -> Void)? = nil + public var failure : ((Error?) -> Void)? = nil } // MARK: - MUNetworkManager From 5c5c8ac4f10763bc5978a45382724f773cd6ce87 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 11 Nov 2020 12:29:52 +0300 Subject: [PATCH 09/32] Modified access control for init in popup control. --- Source/Components/Controls/MUPopupControl.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Components/Controls/MUPopupControl.swift b/Source/Components/Controls/MUPopupControl.swift index 88df884..765ddca 100644 --- a/Source/Components/Controls/MUPopupControl.swift +++ b/Source/Components/Controls/MUPopupControl.swift @@ -5,7 +5,6 @@ // Created by Ilya B Macmini on 22.05.2019. // Copyright © 2019 MobileUp LLC. All rights reserved. // -// Pods: SwiftEntryKit import UIKit import SwiftEntryKit @@ -118,6 +117,8 @@ open class MUPopupControl { // MARK: - Public methods + public init() { } + open func setup(with controller: MUViewController) { self.controller = controller From 7b475b57e3403a27194866335595aeb3999394da Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 11 Nov 2020 15:22:46 +0300 Subject: [PATCH 10/32] Fixed access control. --- .../Components/Controllers/MUFormController.swift | 10 +++++----- .../MUDeveloperToolsController.swift | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/Components/Controllers/MUFormController.swift b/Source/Components/Controllers/MUFormController.swift index 0dc448f..3a56842 100644 --- a/Source/Components/Controllers/MUFormController.swift +++ b/Source/Components/Controllers/MUFormController.swift @@ -259,28 +259,28 @@ open class MUFormController: MUViewController { extension MUFormController: MUTextFieldViewDelegate { - public func textFieldViewChanged(_ textFieldView: UIView) { + open func textFieldViewChanged(_ textFieldView: UIView) { validateWhenEditing() fieldChanged(textFieldView) } - public func textFieldViewBeginEditing(_ textFieldView: UIView) { + open func textFieldViewBeginEditing(_ textFieldView: UIView) { activeEditedField = textFieldView fieldBeginEditing(textFieldView) } - public func textFieldViewDidEndEditing(_ textFieldView: UIView) { + open func textFieldViewDidEndEditing(_ textFieldView: UIView) { activeEditedField = nil validate() } - public func textFieldViewShouldReturn(_ textFieldView: UIView) { + open func textFieldViewShouldReturn(_ textFieldView: UIView) { for (index, object) in verifyObjects.enumerated() { @@ -309,7 +309,7 @@ extension MUFormController: MUTextFieldViewDelegate { } } - public func textFieldViewBackwardDidTap(_ textFieldView: UIView) { + open func textFieldViewBackwardDidTap(_ textFieldView: UIView) { deleteBackward(textFieldView) } diff --git a/Source/Components/DeveloperTools/MUDeveloperToolsController.swift b/Source/Components/DeveloperTools/MUDeveloperToolsController.swift index 5897f21..c596e12 100644 --- a/Source/Components/DeveloperTools/MUDeveloperToolsController.swift +++ b/Source/Components/DeveloperTools/MUDeveloperToolsController.swift @@ -12,8 +12,18 @@ import UIKit public struct MUEnvironment { - let index: String - let title: String + // MARK: - Public properties + + public let index: String + public let title: String + + // MARK: - Public methods + + init(index: String, title: String) { + + self.index = index + self.title = title + } } // MARK: - MUDeveloperToolsDelegate From 34ca85eb9b89286eeb7fcf82627643789a412644 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 11 Nov 2020 16:23:06 +0300 Subject: [PATCH 11/32] Hide bottomBarWhenPushed if needed. --- Source/Components/Controllers/MUViewController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Components/Controllers/MUViewController.swift b/Source/Components/Controllers/MUViewController.swift index db3bb36..7f386a6 100644 --- a/Source/Components/Controllers/MUViewController.swift +++ b/Source/Components/Controllers/MUViewController.swift @@ -41,6 +41,8 @@ open class MUViewController: UIViewController { open var shouldRemoveFromNavigation: Bool { return false } open var hasNavigationBar: Bool? { return nil } + + open var hasBottomBarWhenPushed: Bool { return true } open var hasScroll: Bool { return false } @@ -63,6 +65,13 @@ open class MUViewController: UIViewController { private static var viewControllersArray: [String: MUViewControllerContainer] = [:] // MARK: Override methods + + open override func awakeFromNib() { + + super.awakeFromNib() + + hidesBottomBarWhenPushed = hasBottomBarWhenPushed == false + } open override func viewDidLoad() { From fc7798598ac4b453ef75175f82e375464a892f97 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Thu, 12 Nov 2020 10:02:58 +0300 Subject: [PATCH 12/32] Added should deselect row. --- Source/Components/Controllers/MUListController.swift | 2 ++ Source/Components/Controls/MUTableControl.swift | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Components/Controllers/MUListController.swift b/Source/Components/Controllers/MUListController.swift index 9086ea9..7ef40a6 100644 --- a/Source/Components/Controllers/MUListController.swift +++ b/Source/Components/Controllers/MUListController.swift @@ -76,6 +76,8 @@ open class MUListController: MUViewController, MUListControlDelegate, MUReusable open var emptyStateStyle: MUEmptyStateControl.Style { .none } + open var shouldDeselectRow: Bool { return true } + open var hasCache: Bool { return false } open var cacheKey: String? { return nil } diff --git a/Source/Components/Controls/MUTableControl.swift b/Source/Components/Controls/MUTableControl.swift index 1681fc3..324cadf 100644 --- a/Source/Components/Controls/MUTableControl.swift +++ b/Source/Components/Controls/MUTableControl.swift @@ -709,7 +709,10 @@ extension MUTableControl: UITableViewDelegate, UITableViewDataSource { delegate?.cellDidSelected(for: object, at: indexPath) } - tableView.deselectRow(at: indexPath, animated: true) + if controller?.shouldDeselectRow ?? false { + + tableView.deselectRow(at: indexPath, animated: true) + } } public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { From 7148968793a27b3ca819cf9bf7521c4fdeddebc1 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Thu, 12 Nov 2020 12:33:52 +0300 Subject: [PATCH 13/32] Fixed access control for init method in MUEnvironment. --- .../Components/DeveloperTools/MUDeveloperToolsController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Components/DeveloperTools/MUDeveloperToolsController.swift b/Source/Components/DeveloperTools/MUDeveloperToolsController.swift index c596e12..fcc725b 100644 --- a/Source/Components/DeveloperTools/MUDeveloperToolsController.swift +++ b/Source/Components/DeveloperTools/MUDeveloperToolsController.swift @@ -19,7 +19,7 @@ public struct MUEnvironment { // MARK: - Public methods - init(index: String, title: String) { + public init(index: String, title: String) { self.index = index self.title = title From f8a7e6d38a987307ace80980314e7453d6942c1f Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Thu, 12 Nov 2020 13:04:31 +0300 Subject: [PATCH 14/32] Modified access control for init method in MUNetworkManager. --- Source/Helpers/MUNetworkManager.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Helpers/MUNetworkManager.swift b/Source/Helpers/MUNetworkManager.swift index e444768..19323bd 100755 --- a/Source/Helpers/MUNetworkManager.swift +++ b/Source/Helpers/MUNetworkManager.swift @@ -77,7 +77,8 @@ open class MUNetworkManager: NSObject { super.init() } - convenience init(serverUrl: String, serverTrustPolicies: [String: MUServerTrustPolicy]? = nil) { + public convenience init(serverUrl: String, serverTrustPolicies: [String: MUServerTrustPolicy]? = nil) { + self.init(serverTrustPolicies: serverTrustPolicies) self.serverUrl = serverUrl From 87e283a3c0cae2cfeedcc93e07c2199a81861762 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Thu, 12 Nov 2020 15:06:50 +0300 Subject: [PATCH 15/32] Added popupName parameter to show popup method. --- Source/Components/Controls/MUPopupControl.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Components/Controls/MUPopupControl.swift b/Source/Components/Controls/MUPopupControl.swift index 765ddca..53573e7 100644 --- a/Source/Components/Controls/MUPopupControl.swift +++ b/Source/Components/Controls/MUPopupControl.swift @@ -304,6 +304,7 @@ open class MUPopupControl { arrowIcon : UIImage? = nil, arrowIconOffset : CGFloat = 12, priority : Priority = .normal, + popupName : String? = nil, onDisappear : (() -> Void)? = nil ) { @@ -327,6 +328,7 @@ open class MUPopupControl { arrowIcon : arrowIcon, arrowIconOffset : arrowIconOffset, priority : priority, + popupName : popupName, onDisappear : onDisappear ) } @@ -387,11 +389,14 @@ open class MUPopupControl { arrowIcon : UIImage? = nil, arrowIconOffset : CGFloat = 12, priority : Priority = .normal, + popupName : String? = nil, onDisappear : (() -> Void)? = nil ) { var attributes = getAttributes(position: position) + attributes.name = popupName + attributes.positionConstraints.size = size attributes.positionConstraints.verticalOffset = 0 From 57124bfde1a87a67637c291f4a8e4e576ce2f302 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Thu, 12 Nov 2020 16:43:58 +0300 Subject: [PATCH 16/32] Modified user defaults. --- Source/Extension/UserDefaults.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Extension/UserDefaults.swift b/Source/Extension/UserDefaults.swift index 15cddda..70e28fc 100644 --- a/Source/Extension/UserDefaults.swift +++ b/Source/Extension/UserDefaults.swift @@ -23,7 +23,12 @@ public extension UserDefaults { // MARK: - Public methods - class func set(_ value: Any, forKey key: String, timeout: TimeInterval? = nil) { + class func set(_ value: Any?, forKey key: String, timeout: TimeInterval? = nil) { + + guard let value = value else { + + return UserDefaults.standard.removeObject(forKey: key) + } UserDefaults.standard.set(value, forKey: key) From 23772fb79f277af9b59a1decb95193a7149274ab Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Fri, 13 Nov 2020 07:47:32 +0300 Subject: [PATCH 17/32] Localize. --- Source/Components/Controllers/MUViewController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Components/Controllers/MUViewController.swift b/Source/Components/Controllers/MUViewController.swift index 7f386a6..65f3171 100644 --- a/Source/Components/Controllers/MUViewController.swift +++ b/Source/Components/Controllers/MUViewController.swift @@ -82,6 +82,10 @@ open class MUViewController: UIViewController { popupControl.setup(with: self) loadControl.setup(with: self) + + localize() + + subscribeOnLanguageNotifications() } open override func viewWillAppear(_ animated: Bool) { From 79b383c8aa2cb4b25bd51f03b35b4a081e9f9e8b Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Fri, 13 Nov 2020 07:59:08 +0300 Subject: [PATCH 18/32] Fixed bundle for custom view. --- Source/Components/Views/MUCustomView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Components/Views/MUCustomView.swift b/Source/Components/Views/MUCustomView.swift index 0c517a9..033beeb 100755 --- a/Source/Components/Views/MUCustomView.swift +++ b/Source/Components/Views/MUCustomView.swift @@ -131,7 +131,7 @@ open class MUCustomView: MUView { if nib == nil { - nib = UINib(nibName: nibName, bundle: Bundle(for: MUCustomView.self)) + nib = UINib(nibName: nibName, bundle: Bundle(for: type(of: self))) MUCustomView.nibCache[nibName] = nib } From cad399761cd9d4c8d0bced47999f0b4d8909d071 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Fri, 13 Nov 2020 08:00:26 +0300 Subject: [PATCH 19/32] Fixed bundle for developerToolsController. --- .../MUDeveloperToolsController.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Components/DeveloperTools/MUDeveloperToolsController.swift b/Source/Components/DeveloperTools/MUDeveloperToolsController.swift index fcc725b..dea1026 100644 --- a/Source/Components/DeveloperTools/MUDeveloperToolsController.swift +++ b/Source/Components/DeveloperTools/MUDeveloperToolsController.swift @@ -236,14 +236,21 @@ public extension MUDeveloperToolsManager { topController.dismiss(animated: true, completion: nil) } else { - - guard let controller = MUDeveloperToolsController.instantiate(storyboardName: "DeveloperTools", identifier: "MUDeveloperToolsController", bundle: Bundle(for: self)) else { return } + + let controller = MUDeveloperToolsController.instantiate( + + storyboardName : "DeveloperTools", + identifier : "MUDeveloperToolsController", + bundle : Bundle(for: MUDeveloperToolsController.self) + ) + + guard let developerToolsController = controller else { return } MUPopupControl.closeAll() - controller.modalPresentationStyle = .overCurrentContext + developerToolsController.modalPresentationStyle = .overCurrentContext - topController.present(controller, animated: true, completion: nil) + topController.present(developerToolsController, animated: true, completion: nil) } } } From 43f328f20403d2c681a34d66bc2de72b2b5c432e Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Fri, 13 Nov 2020 13:25:40 +0300 Subject: [PATCH 20/32] Create refresh control only one time. --- Source/Components/Controls/MURefreshControl.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Components/Controls/MURefreshControl.swift b/Source/Components/Controls/MURefreshControl.swift index 516b498..0bcea0c 100644 --- a/Source/Components/Controls/MURefreshControl.swift +++ b/Source/Components/Controls/MURefreshControl.swift @@ -84,14 +84,17 @@ open class MURefreshControl: NSObject { } private func configure(with tintColor: UIColor? = nil) { + + if refreshControl == nil { - refreshControl = UIRefreshControl() - - refreshControl!.tintColor = tintColor ?? refreshControl!.tintColor - - refreshControl!.addTarget(self, action: #selector(startAnimation), for: .valueChanged) + refreshControl = UIRefreshControl() + + refreshControl?.addTarget(self, action: #selector(startAnimation), for: .valueChanged) + + scrollView?.addSubview(refreshControl!) + } - scrollView?.addSubview(refreshControl!) + refreshControl?.tintColor = tintColor ?? refreshControl?.tintColor } private func resetTopContentInset() { From f136cc428dbd6d34fe5e5c2246f260af16bd081c Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Fri, 13 Nov 2020 15:39:48 +0300 Subject: [PATCH 21/32] Fixed display of the activity indicator. --- Source/Components/Controls/MUPaginationControl.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Components/Controls/MUPaginationControl.swift b/Source/Components/Controls/MUPaginationControl.swift index 7314aa5..c95e164 100644 --- a/Source/Components/Controls/MUPaginationControl.swift +++ b/Source/Components/Controls/MUPaginationControl.swift @@ -178,13 +178,13 @@ open class MUPaginationControl: NSObject { @objc private func createIndicator(with timer: Timer? = nil) { - guard let targetView = targetView, self.bottomActivityIndicator == nil else { return } + guard let targetView = targetView, bottomActivityIndicator == nil, hasMoreObjects == true else { return } guard isDeleting == false else { return } bottomActivityIndicator?.containerView?.removeFromSuperview() - self.bottomActivityIndicator = getIndicator(in: targetView) + bottomActivityIndicator = getIndicator(in: targetView) makeBottomInset(in: targetView) } From d0391d95eb4f382dc204c718d66117b87f2abdff Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Fri, 20 Nov 2020 13:37:43 +0300 Subject: [PATCH 22/32] Hide empty models if skeleton animation is finished. --- Source/Components/Controls/MULoadControl.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Components/Controls/MULoadControl.swift b/Source/Components/Controls/MULoadControl.swift index 33cf3e8..0d2eca3 100644 --- a/Source/Components/Controls/MULoadControl.swift +++ b/Source/Components/Controls/MULoadControl.swift @@ -170,7 +170,12 @@ open class MULoadControl: NSObject { view.hideSkeleton(transition: .none) - controller?.objects = controller?.objects ?? [] + if let objects = controller?.objects, objects.contains(where: { $0 is MUEmptyModel }) { + + controller?.objects = [] + } else { + controller?.objects = controller?.objects ?? [] + } } private func createEmptyItems() -> [MUModel] { From 28cd663e18681caa0eb3609d8c126566ca1b14e9 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 25 Nov 2020 11:15:40 +0300 Subject: [PATCH 23/32] Fix load control delay for update loading. --- Source/Components/Controls/MULoadControl.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Components/Controls/MULoadControl.swift b/Source/Components/Controls/MULoadControl.swift index 0d2eca3..f931ce8 100644 --- a/Source/Components/Controls/MULoadControl.swift +++ b/Source/Components/Controls/MULoadControl.swift @@ -90,7 +90,7 @@ open class MULoadControl: NSObject { updateEmptyEmptyItems() - DispatchQueue.main.asyncAfter(deadline: .now() + (isLoading ? 0.01 : 0.3)) { [weak self] in + DispatchQueue.main.asyncAfter(deadline: .now() + (isLoading ? 0.1 : 0.3)) { [weak self] in self?.updateLoading() } From 98725387f9afbaadd67e69c6bc8bffd50232d03b Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 25 Nov 2020 11:16:10 +0300 Subject: [PATCH 24/32] Add response log. --- Source/Helpers/MUNetworkManager.swift | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Source/Helpers/MUNetworkManager.swift b/Source/Helpers/MUNetworkManager.swift index 19323bd..45dc0c3 100755 --- a/Source/Helpers/MUNetworkManager.swift +++ b/Source/Helpers/MUNetworkManager.swift @@ -191,6 +191,8 @@ open class MUNetworkManager: NSObject { failure : @escaping (MUNetworkError?,Any?) -> Void ) { + logResponse(with: responseObject, requestId: requestId) + if responseObject.response?.statusCode == nil, let error = responseObject.result.error as NSError? { switch error.code { @@ -255,6 +257,23 @@ open class MUNetworkManager: NSObject { // MARK: - Log methods + private func logResponse(with responseObject: DataResponse, requestId: Int) { + + let body = responseObject.result.value as? NSDictionary ?? responseObject.result.value as? NSArray + + let logDictionary = [ + + "Body" : body ?? responseObject.result.value ?? "" + ] + + let statusCode = responseObject.response?.statusCode ?? -1 + + DispatchQueue.global().async { + + Log.event("\n[\(requestId)] Response (code: \(statusCode)):\n\(logDictionary)\n".unescapingUnicodeCharacters) + } + } + private func getRequestId() -> Int { numberOfRequests += 1 @@ -412,3 +431,20 @@ public enum MUServerTrustPolicy { case disableEvaluation case customEvaluation((_ serverTrust: SecTrust, _ host: String) -> Bool) } + +// MARK: - String + +extension String { + + var unescapingUnicodeCharacters: String { + + let string = self.replace(pattern: "\\\\U", with: "\\\\u") + + let mutableString = NSMutableString(string: string as NSString) + + CFStringTransform(mutableString, nil, "Any-Hex/Java" as NSString, true) + + return mutableString as String + } +} + From a9a9f36d5b930867314f7501a45a85441dd0e4ab Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Thu, 3 Dec 2020 20:05:27 +0300 Subject: [PATCH 25/32] deselect row logic. --- Source/Components/Controls/MUCollectionControl.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Components/Controls/MUCollectionControl.swift b/Source/Components/Controls/MUCollectionControl.swift index 7aa44ee..53e4469 100644 --- a/Source/Components/Controls/MUCollectionControl.swift +++ b/Source/Components/Controls/MUCollectionControl.swift @@ -115,7 +115,10 @@ extension MUCollectionControl: delegate?.cellDidSelected(for: object, at: indexPath) } - collectionView.deselectItem(at: indexPath, animated: true) + if controller?.shouldDeselectRow ?? false { + + collectionView.deselectItem(at: indexPath, animated: true) + } } public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { From b374c5ef5c3d7decfa89eb1874d2fb967d388418 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 9 Dec 2020 16:55:25 +0300 Subject: [PATCH 26/32] Added failure block for error with 999 code. --- Source/Helpers/MUNetworkManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Helpers/MUNetworkManager.swift b/Source/Helpers/MUNetworkManager.swift index 45dc0c3..d8a6208 100755 --- a/Source/Helpers/MUNetworkManager.swift +++ b/Source/Helpers/MUNetworkManager.swift @@ -196,7 +196,7 @@ open class MUNetworkManager: NSObject { if responseObject.response?.statusCode == nil, let error = responseObject.result.error as NSError? { switch error.code { - case -999 : return + case -999 : failure(MUNetworkError.unknownError, nil) case -1009, -1005 : failure(MUNetworkError.connectionError, nil) default : failure(MUNetworkError.serverError, nil) } From 5ceba8cf86ef3117eac493b12432765aa66b0f54 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 9 Dec 2020 16:56:09 +0300 Subject: [PATCH 27/32] Added publicKeys method to MUServerTrustPolicy. --- Source/Helpers/MUNetworkManager.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Helpers/MUNetworkManager.swift b/Source/Helpers/MUNetworkManager.swift index d8a6208..12e47f9 100755 --- a/Source/Helpers/MUNetworkManager.swift +++ b/Source/Helpers/MUNetworkManager.swift @@ -430,6 +430,13 @@ public enum MUServerTrustPolicy { case pinPublicKeys(publicKeys: [SecKey], validateCertificateChain: Bool, validateHost: Bool) case disableEvaluation case customEvaluation((_ serverTrust: SecTrust, _ host: String) -> Bool) + + // MARK: - Public methods + + func publicKeys() -> [SecKey] { + + return ServerTrustPolicy.publicKeys() + } } // MARK: - String From 170609a0c2740e800dfdf9caaffa53a00ebcbff3 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 9 Dec 2020 16:59:43 +0300 Subject: [PATCH 28/32] Fixed access control. --- Source/Helpers/MUNetworkManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Helpers/MUNetworkManager.swift b/Source/Helpers/MUNetworkManager.swift index 12e47f9..38cafa6 100755 --- a/Source/Helpers/MUNetworkManager.swift +++ b/Source/Helpers/MUNetworkManager.swift @@ -433,7 +433,7 @@ public enum MUServerTrustPolicy { // MARK: - Public methods - func publicKeys() -> [SecKey] { + public func publicKeys() -> [SecKey] { return ServerTrustPolicy.publicKeys() } From ed504be063c820288df90ec7bce031b71254db99 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 9 Dec 2020 17:02:27 +0300 Subject: [PATCH 29/32] publicKeys method as static. --- Source/Helpers/MUNetworkManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Helpers/MUNetworkManager.swift b/Source/Helpers/MUNetworkManager.swift index 38cafa6..c8fddc0 100755 --- a/Source/Helpers/MUNetworkManager.swift +++ b/Source/Helpers/MUNetworkManager.swift @@ -433,7 +433,7 @@ public enum MUServerTrustPolicy { // MARK: - Public methods - public func publicKeys() -> [SecKey] { + public static func publicKeys() -> [SecKey] { return ServerTrustPolicy.publicKeys() } From 19b3df0cb3f164132d86f70c7c419faeeba16b7f Mon Sep 17 00:00:00 2001 From: Denis Sushkov Date: Tue, 15 Dec 2020 17:08:44 +0300 Subject: [PATCH 30/32] added status bar attribute to controller presentation --- .../Components/Controls/MUPopupControl.swift | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Source/Components/Controls/MUPopupControl.swift b/Source/Components/Controls/MUPopupControl.swift index 53573e7..de22c65 100644 --- a/Source/Components/Controls/MUPopupControl.swift +++ b/Source/Components/Controls/MUPopupControl.swift @@ -23,6 +23,17 @@ open class MUPopupControl { case scale } + // MARK: - StatusBar + + public enum StatusBar { + + case ignored + case hidden + case dark + case light + case inferred + } + //MARK: - ScreenInteraction public enum ScreenInteractionType { @@ -299,6 +310,7 @@ open class MUPopupControl { isClosedOnBackgroundTouch : Bool, isClosedOnSwipe : Bool, isShadowEnabled : Bool, + statusBar : StatusBar = .inferred, widthRatio : CGFloat, heightRatio : CGFloat, arrowIcon : UIImage? = nil, @@ -324,6 +336,7 @@ open class MUPopupControl { isClosedOnBackgroundTouch : isClosedOnBackgroundTouch, isClosedOnSwipe : isClosedOnSwipe, isShadowEnabled : isShadowEnabled, + statusBar : statusBar, size : size, arrowIcon : arrowIcon, arrowIconOffset : arrowIconOffset, @@ -343,6 +356,7 @@ open class MUPopupControl { isClosedOnBackgroundTouch : Bool, isClosedOnSwipe : Bool, isShadowEnabled : Bool, + statusBar : StatusBar, widthRatio : CGFloat, topOffset : CGFloat, arrowIcon : UIImage? = nil, @@ -367,6 +381,7 @@ open class MUPopupControl { isClosedOnBackgroundTouch : isClosedOnBackgroundTouch, isClosedOnSwipe : isClosedOnSwipe, isShadowEnabled : isShadowEnabled, + statusBar : statusBar, size : size, arrowIcon : arrowIcon, arrowIconOffset : arrowIconOffset, @@ -385,6 +400,7 @@ open class MUPopupControl { isClosedOnBackgroundTouch : Bool, isClosedOnSwipe : Bool, isShadowEnabled : Bool, + statusBar : StatusBar, size : EKAttributes.PositionConstraints.Size, arrowIcon : UIImage? = nil, arrowIconOffset : CGFloat = 12, @@ -397,6 +413,8 @@ open class MUPopupControl { attributes.name = popupName + attributes.statusBar = getStatusBarStyle(statusBar: statusBar) + attributes.positionConstraints.size = size attributes.positionConstraints.verticalOffset = 0 @@ -463,6 +481,18 @@ open class MUPopupControl { } } + private func getStatusBarStyle(statusBar: StatusBar) -> EKAttributes.StatusBar { + + switch statusBar { + + case .ignored : return .ignored + case .hidden : return .hidden + case .dark : return .dark + case .light : return .light + case .inferred : return .inferred + } + } + private func getAnimations(type: AnimationType) -> (entrance: EKAttributes.Animation, exit: EKAttributes.Animation){ switch type { @@ -636,6 +666,7 @@ public extension MUViewController { isClosedOnBackgroundTouch : Bool = true, isClosedOnSwipe : Bool = false, isShadowEnabled : Bool = true, + statusBar : MUPopupControl.StatusBar = .inferred, widthRatio : CGFloat = 1.0, heightRatio : CGFloat = 0.6, arrowIcon : UIImage? = nil, @@ -652,6 +683,7 @@ public extension MUViewController { isClosedOnBackgroundTouch : isClosedOnBackgroundTouch, isClosedOnSwipe : isClosedOnSwipe, isShadowEnabled : isShadowEnabled, + statusBar : statusBar, widthRatio : widthRatio, heightRatio : heightRatio, arrowIcon : arrowIcon, From 39e5b9e504453bc5679d4c6d1f7878f62c2f3df1 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Wed, 16 Dec 2020 13:46:55 +0800 Subject: [PATCH 31/32] Show only no empty models. --- Source/Components/Controls/MULoadControl.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/Components/Controls/MULoadControl.swift b/Source/Components/Controls/MULoadControl.swift index f931ce8..e964c78 100644 --- a/Source/Components/Controls/MULoadControl.swift +++ b/Source/Components/Controls/MULoadControl.swift @@ -170,12 +170,7 @@ open class MULoadControl: NSObject { view.hideSkeleton(transition: .none) - if let objects = controller?.objects, objects.contains(where: { $0 is MUEmptyModel }) { - - controller?.objects = [] - } else { - controller?.objects = controller?.objects ?? [] - } + controller?.objects = controller?.objects.filter { ($0 is MUEmptyModel) == false } ?? [] } private func createEmptyItems() -> [MUModel] { From 625099a6d57187c6fca10564a55a78c95664a1b6 Mon Sep 17 00:00:00 2001 From: Denis Sushkov Date: Fri, 18 Dec 2020 17:20:53 +0300 Subject: [PATCH 32/32] fixed calling completion in close() method --- .../Controllers/MUViewController.swift | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Components/Controllers/MUViewController.swift b/Source/Components/Controllers/MUViewController.swift index 65f3171..de62670 100644 --- a/Source/Components/Controllers/MUViewController.swift +++ b/Source/Components/Controllers/MUViewController.swift @@ -182,23 +182,31 @@ open class MUViewController: UIViewController { } open func close(animated: Bool = true, toRoot: Bool = false, popOnly: Bool = false, completion: (() -> Void)? = nil) { + + var completionMethod = completion - popupControl.dismiss() + popupControl.dismiss(with: { + + completionMethod?() + + completionMethod = nil + + }) if let presentingMUViewController = presentingViewController, popOnly == false { presentingMUViewController.dismiss(animated: animated) - completion?() + completionMethod?() } else if let navigationController = navigationController, navigationController.viewControllers.count > 1 { if toRoot { - navigationController.popToRootViewController(animated: animated, completion: completion) + navigationController.popToRootViewController(animated: animated, completion: completionMethod) } else { - navigationController.popViewController(animated: animated, completion: completion) + navigationController.popViewController(animated: animated, completion: completionMethod) } } }