Skip to content
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0f34e8a
Modified access control for methods to open.
Nov 10, 2020
5275731
Removed duplicate code.
petrovichppp Nov 10, 2020
ab5e1ee
Modified MUEmptyModel access control from public to open.
petrovichppp Nov 10, 2020
3b39fa2
Renamed instantiate to instance.
petrovichppp Nov 10, 2020
3e3f096
Fixed using getInstance method.
petrovichppp Nov 10, 2020
a4cf96d
View localization.
petrovichppp Nov 11, 2020
2ef48a6
Modified access control for view extensions.
petrovichppp Nov 11, 2020
3081d22
Modified access control for methods and properties in network manager.
petrovichppp Nov 11, 2020
5c5c8ac
Modified access control for init in popup control.
petrovichppp Nov 11, 2020
7b475b5
Fixed access control.
petrovichppp Nov 11, 2020
34ca85e
Hide bottomBarWhenPushed if needed.
petrovichppp Nov 11, 2020
fc77985
Added should deselect row.
petrovichppp Nov 12, 2020
7148968
Fixed access control for init method in MUEnvironment.
petrovichppp Nov 12, 2020
f8a7e6d
Modified access control for init method in MUNetworkManager.
petrovichppp Nov 12, 2020
87e283a
Added popupName parameter to show popup method.
petrovichppp Nov 12, 2020
57124bf
Modified user defaults.
petrovichppp Nov 12, 2020
23772fb
Localize.
petrovichppp Nov 13, 2020
79b383c
Fixed bundle for custom view.
petrovichppp Nov 13, 2020
cad3997
Fixed bundle for developerToolsController.
petrovichppp Nov 13, 2020
43f328f
Create refresh control only one time.
petrovichppp Nov 13, 2020
f136cc4
Fixed display of the activity indicator.
petrovichppp Nov 13, 2020
d0391d9
Hide empty models if skeleton animation is finished.
petrovichppp Nov 20, 2020
28cd663
Fix load control delay for update loading.
petrovichppp Nov 25, 2020
9872538
Add response log.
petrovichppp Nov 25, 2020
a9a9f36
deselect row logic.
petrovichppp Dec 3, 2020
b374c5e
Added failure block for error with 999 code.
petrovichppp Dec 9, 2020
5ceba8c
Added publicKeys method to MUServerTrustPolicy.
petrovichppp Dec 9, 2020
170609a
Fixed access control.
petrovichppp Dec 9, 2020
ed504be
publicKeys method as static.
petrovichppp Dec 9, 2020
19b3df0
added status bar attribute to controller presentation
Dec 15, 2020
9a46747
Merge pull request #2 from MobileUpLLC/fixes/status_bar
petrovichppp Dec 15, 2020
39e5b9e
Show only no empty models.
petrovichppp Dec 16, 2020
625099a
fixed calling completion in close() method
Dec 18, 2020
c737cc9
Merge pull request #3 from MobileUpLLC/fixes/close_method
petrovichppp Mar 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Source/Components/Controllers/MUFormController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -309,7 +309,7 @@ extension MUFormController: MUTextFieldViewDelegate {
}
}

public func textFieldViewBackwardDidTap(_ textFieldView: UIView) {
open func textFieldViewBackwardDidTap(_ textFieldView: UIView) {

deleteBackward(textFieldView)
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Components/Controllers/MUListController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
148 changes: 92 additions & 56 deletions Source/Components/Controllers/MUViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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() {

Expand All @@ -73,8 +82,10 @@ open class MUViewController: UIViewController {
popupControl.setup(with: self)

loadControl.setup(with: self)

subscribeOnCustomNotifications()

localize()

subscribeOnLanguageNotifications()
}

open override func viewWillAppear(_ animated: Bool) {
Expand All @@ -85,8 +96,6 @@ open class MUViewController: UIViewController {

updateViewControllersArray()

configureNavigatioBar()

configureInteractivePopGestureRecognizer()

subscribeOnNotifications()
Expand Down Expand Up @@ -126,7 +135,7 @@ open class MUViewController: UIViewController {

// MARK: - Public methods

func subscribeOnNotifications() {
open func subscribeOnNotifications() {

guard isVisible, isNotificationSubscribed == false else { return }

Expand All @@ -139,39 +148,40 @@ open class MUViewController: UIViewController {
subscribeOnAppNotifications()
}

func unsubscribeFromNotifications() {
open func unsubscribeFromNotifications() {

isNotificationSubscribed = false

keyboardControl.unsubscribeOnNotifications()

NotificationCenter.default.removeObserver(self)

unsubscribeOnErrorNotifications()

unsubscribeOnAppNotification()
}

func subscribeOnCustomNotifications() {
open func appDidBecomeActive() {

}

func appDidBecomeActive() {
open func appWillResignActive() {

}

func appWillResignActive() {

}

func appErrorDidBecome(error: Error) {
open func appErrorDidBecome(error: Error) {

isLoading = false
}

func appErrorDidClear() {
open func appErrorDidClear() {

}

@objc open func localize() {

view.localize()
}

// 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()

Expand All @@ -192,14 +202,23 @@ open class MUViewController: UIViewController {
}
}
}

deinit {

NotificationCenter.default.removeObserver(self)
}

// MARK: - Private methods

private func configureNavigatioBar() {

guard let hasNavigationBar = hasNavigationBar else { return }

navigationController?.setNavigationBarHidden(hasNavigationBar == false, animated: true)

private func subscribeOnLanguageNotifications() {

NotificationCenter.default.addObserver(

self,
selector : #selector(localize),
name : .languageDidChange,
object : nil
)
}

private func configureInteractivePopGestureRecognizer() {
Expand Down Expand Up @@ -238,6 +257,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() {

Expand Down Expand Up @@ -307,7 +332,7 @@ public extension MUViewController {
return MUViewController.viewControllersArray["\(T.self)"]?.controller as? T
}

static func getInstantiate<T: MUViewController>(with type: T.Type) -> T? {
static func getInstance<T: MUViewController>(with type: T.Type) -> T? {

switch T.initMethod {
case .fromNib : return T.instantiate()
Expand All @@ -316,7 +341,7 @@ public extension MUViewController {
}
}

static func getInstantiate<T: MUViewController>() -> T? {
static func getInstance<T: MUViewController>() -> T? {

guard storyboardName != "" else {

Expand Down Expand Up @@ -348,16 +373,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
)
Expand All @@ -373,18 +398,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 {
Expand All @@ -405,16 +430,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
)
Expand All @@ -431,26 +456,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)
}
}

Expand All @@ -471,40 +496,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) {
Expand Down Expand Up @@ -595,6 +620,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)
}
}

Expand All @@ -606,6 +641,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
Expand Down
Loading