From f1d80adf5727c7959b7cca82c402e1708b80508d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 12 Apr 2019 15:32:43 -0400 Subject: [PATCH 01/20] delegate object and simple deprecation --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ MVMCoreUI/BaseControllers/MFViewController.h | 1 + MVMCoreUI/BaseControllers/MFViewController.m | 4 ++++ MVMCoreUI/OtherHandlers/DelegateObject.swift | 18 ++++++++++++++++++ .../OtherHandlers/MVMCoreUILoggingHandler.h | 1 - MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h | 1 - MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h | 1 + 7 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 MVMCoreUI/OtherHandlers/DelegateObject.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8a2e4453..dea12c71 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -157,6 +157,7 @@ D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; + D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */; }; DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; }; DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; }; @@ -317,6 +318,7 @@ D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; + D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DelegateObject.swift; sourceTree = ""; }; DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = ""; }; DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = ""; }; DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = ""; }; @@ -634,6 +636,7 @@ D29DF27021E79B2C003B2FB9 /* OtherHandlers */ = { isa = PBXGroup; children = ( + D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */, D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */, D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */, D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */, @@ -865,6 +868,7 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, + D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/BaseControllers/MFViewController.h index 8d5c6678..8c1d5766 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.h +++ b/MVMCoreUI/BaseControllers/MFViewController.h @@ -31,6 +31,7 @@ @class MainMenuViewController; @class MVMCoreUITabBarPageControlViewController; @class MVMAnimationManager; +@class DelegateObject; @interface MFViewController : UIViewController diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index c4ee3756..6b27c7d9 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -180,6 +180,10 @@ return YES; } +- (nullable DelegateObject *)delegateObject { + return [MVMCoreUIDelegateObject createWithDelegateForAll:self]; +} + #pragma mark - Response Handling - (void)observeForResponseJSONUpdates { diff --git a/MVMCoreUI/OtherHandlers/DelegateObject.swift b/MVMCoreUI/OtherHandlers/DelegateObject.swift new file mode 100644 index 00000000..e6c13dd5 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/DelegateObject.swift @@ -0,0 +1,18 @@ +// +// DelegateObject.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 4/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objc(MVMCoreUIDelegateObject) +open class DelegateObject: MVMCore.DelegateObject { + public weak var formValidationProtocol: FormValidationProtocol? + + open override func setAll(withDelegate delegate: Any) { + formValidationProtocol = delegate as? FormValidationProtocol + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h index 56bb60a2..003d67f8 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h @@ -7,7 +7,6 @@ // @import MVMCore.MVMCoreLoggingHandler; -@class MVMCoreTopAlertObject; @class MFViewController; NS_ASSUME_NONNULL_BEGIN diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h index 9391356c..46b392b7 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h @@ -10,7 +10,6 @@ #import #import -@class MVMCoreTopAlertObject; @class MFCustomButton; @interface MVMCoreUITopAlertBaseView : MFView diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h index 6ebd1026..50dd9b26 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h @@ -11,6 +11,7 @@ #import @class PrimaryButton; +@class MVMCoreTopAlertObject; @interface MVMCoreUITopAlertMainView : MVMCoreUITopAlertBaseView From aa4da8f74f8cc4951cf6859d8fc3b8a828ce3de0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 11:14:29 -0400 Subject: [PATCH 02/20] deprecating --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 4 +- MVMCoreUI/Atoms/Buttons/MFCustomButton.h | 17 +++-- MVMCoreUI/Atoms/Buttons/MFCustomButton.m | 71 ++++++++++++++------ MVMCoreUI/OtherHandlers/DelegateObject.swift | 4 +- 4 files changed, 65 insertions(+), 31 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 7d67afb1..72c04900 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -106,14 +106,14 @@ open class CaretButton: MFCustomButton { //------------------------------------------------------ // Default values for view. - @objc open override func setAsMolecule() { + @objc open func setAsMolecule() { backgroundColor = .clear setTitleColor(enabledColor, for: .normal) setTitleColor(disabledColor, for: .disabled) } - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { + @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) guard let dictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h index 21236e70..47ac89e4 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h @@ -11,14 +11,14 @@ #import #import #import -@import MVMCore.MVMCoreViewProtocol; +@class MVMCoreUIDelegateObject; typedef void (^ButtonTapBlock)(id _Nonnull sender); extern CGFloat const CloseButtonHeight; extern CGFloat const CloseButtonWidth; -@interface MFCustomButton : UIButton +@interface MFCustomButton : UIButton @property (nullable, nonatomic, strong) NSDictionary *actionMap; @property (nullable, nonatomic, weak) id buttonDelegate; @@ -28,14 +28,19 @@ extern CGFloat const CloseButtonWidth; - (void)addBlock:(nonnull ButtonTapBlock)buttonTapBlock forControlEvents:(UIControlEvents)event; // Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. -- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; - -// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate -- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject *)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id )buttonDelegate; +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; //accessibility - (void)addAccessibilityForCameraControl; - (nonnull UIAccessibilityCustomAction *)accessibilityCustomAction; +#pragma mark - Deprecated + +// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData __deprecated; + +// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate +- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject *)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id )buttonDelegate __deprecated; + @end diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m index 0a78856c..45daebcc 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m @@ -13,6 +13,7 @@ @import MVMCore.NSDictionary_MFConvenience; #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" +#import CGFloat const CloseButtonHeight = 40.0f; CGFloat const CloseButtonWidth = 40.0f; @@ -37,6 +38,52 @@ CGFloat const CloseButtonWidth = 40.0f; } } +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { + + self.actionMap = actionMap; + self.titleLabel.numberOfLines = 0; + self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; + [self setTitle:[actionMap stringForKey:KeyTitle] forState:UIControlStateNormal]; + + [self setEnabled:![actionMap[KeyDisableButton]boolValue]]; + + self.buttonDelegate = delegateObject.buttonDelegate; + __weak MFCustomButton *weakSelf = self; + [self addBlock:^(id _Nonnull sender) { + + BOOL performAction = YES; + if (weakSelf.buttonDelegate && [weakSelf.buttonDelegate respondsToSelector:@selector(button:shouldPerformActionWithMap:additionalData:)]) { + performAction = [weakSelf.buttonDelegate button:weakSelf shouldPerformActionWithMap:actionMap additionalData:additionalData]; + } + + if (performAction) { + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject]; + } + } forControlEvents:UIControlEventTouchUpInside]; +} + +//accessibility +-(void)addAccessibilityForCameraControl{ + self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"]; + self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"]; + self.accessibilityTraits = UIAccessibilityTraitNone; +} + + +- (UIAccessibilityCustomAction *)accessibilityCustomAction { + NSString *name = self.accessibilityLabel ?: self.titleLabel.text; + return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)]; +} + +- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action { + if (self.buttonTapBlock) { + self.buttonTapBlock(self); + } + return YES; +} + +#pragma mark - Deprecated + - (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { self.actionMap = actionMap; @@ -53,11 +100,11 @@ CGFloat const CloseButtonWidth = 40.0f; } - (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject *)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id )buttonDelegate { - + if (!buttonDelegate) { [self setWithActionMap:actionMap delegate:actionDelegate additionalData:additionalData]; } else { - + self.actionMap = actionMap; self.titleLabel.numberOfLines = 0; self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; @@ -86,24 +133,4 @@ CGFloat const CloseButtonWidth = 40.0f; } } -//accessibility --(void)addAccessibilityForCameraControl{ - self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"]; - self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"]; - self.accessibilityTraits = UIAccessibilityTraitNone; -} - - -- (UIAccessibilityCustomAction *)accessibilityCustomAction { - NSString *name = self.accessibilityLabel ?: self.titleLabel.text; - return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)]; -} - -- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action { - if (self.buttonTapBlock) { - self.buttonTapBlock(self); - } - return YES; -} - @end diff --git a/MVMCoreUI/OtherHandlers/DelegateObject.swift b/MVMCoreUI/OtherHandlers/DelegateObject.swift index e6c13dd5..d7a2ac65 100644 --- a/MVMCoreUI/OtherHandlers/DelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/DelegateObject.swift @@ -11,8 +11,10 @@ import UIKit @objc(MVMCoreUIDelegateObject) open class DelegateObject: MVMCore.DelegateObject { public weak var formValidationProtocol: FormValidationProtocol? - + public weak var buttonDelegate: ButtonDelegateProtocol? + open override func setAll(withDelegate delegate: Any) { formValidationProtocol = delegate as? FormValidationProtocol + buttonDelegate = delegate as? ButtonDelegateProtocol } } From ad3c0f90b4db607c2dcf489a3f8f2b2c7686d3a3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 11:46:26 -0400 Subject: [PATCH 03/20] molecule view changes --- MVMCoreUI/Atoms/Views/MFLabel.m | 6 +++--- MVMCoreUI/Atoms/Views/MFView.m | 2 +- MVMCoreUI/Molecules/ButtonView.swift | 6 +++--- MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 66b434e5..3857cd8d 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -170,7 +170,7 @@ } } -+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { ++ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { if (label) { label.text = [json string:KeyText]; [self setLabel:label withHTML:[json string:@"html"]]; @@ -232,8 +232,8 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { - [MFLabel setUILabel:self withJSON:json delegate:delegate additionalData:additionalData]; +- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [MFLabel setUILabel:self withJSON:json delegateObject:delegateObject additionalData:additionalData]; self.originalAttributedString = self.attributedText; } diff --git a/MVMCoreUI/Atoms/Views/MFView.m b/MVMCoreUI/Atoms/Views/MFView.m index 1ab4cda1..6c0f8309 100644 --- a/MVMCoreUI/Atoms/Views/MFView.m +++ b/MVMCoreUI/Atoms/Views/MFView.m @@ -43,7 +43,7 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { self.json = json; } diff --git a/MVMCoreUI/Molecules/ButtonView.swift b/MVMCoreUI/Molecules/ButtonView.swift index f48044dd..5391640c 100644 --- a/MVMCoreUI/Molecules/ButtonView.swift +++ b/MVMCoreUI/Molecules/ButtonView.swift @@ -58,9 +58,9 @@ import UIKit primaryButton?.setAsMolecule() } - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) - primaryButton?.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUI.DelegateObject?, additionalData: [AnyHashable : Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - Constraining diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index 3dd8de67..19cc1e21 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -7,11 +7,12 @@ // #import +@class MVMCoreUIDelegateObject; @protocol MVMCoreUIMoleculeViewProtocol // Sets up the ui based on the json -- (void)setWithJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; +- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; @optional From 5ebcba15fa808f214f5ebdfced5d6a2150d34a2b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 12:59:27 -0400 Subject: [PATCH 04/20] molecule delegate object --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 4 +- MVMCoreUI/Atoms/Buttons/MFCustomButton.h | 4 +- MVMCoreUI/Atoms/Buttons/MFCustomButton.m | 6 +- MVMCoreUI/Atoms/Views/CaretView.swift | 7 +- MVMCoreUI/Atoms/Views/DashLine.swift | 4 +- MVMCoreUI/Atoms/Views/LabelView.m | 6 +- .../Atoms/Views/LabelWithInternalButton.swift | 3 +- MVMCoreUI/Atoms/Views/MFLabel.m | 4 +- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 4 +- MVMCoreUI/Atoms/Views/MFView.m | 3 +- MVMCoreUI/Atoms/Views/SeparatorView.m | 4 +- MVMCoreUI/Molecules/ButtonView.swift | 6 +- .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 4 +- MVMCoreUI/Molecules/MoleculeStackView.swift | 14 ++-- MVMCoreUI/Molecules/StandardFooterView.swift | 8 +- MVMCoreUI/Molecules/StandardHeaderView.swift | 10 +-- MVMCoreUI/Molecules/TwoButtonView.swift | 82 ++++++++++--------- ...ct.swift => MVMCoreUIDelegateObject.swift} | 3 +- .../MVMCoreUIMoleculeMappingObject.h | 3 +- .../MVMCoreUIMoleculeMappingObject.m | 4 +- .../MoleculeStackCenteredTemplate.swift | 6 +- .../Templates/MoleculeStackTemplate.swift | 6 +- 23 files changed, 106 insertions(+), 97 deletions(-) rename MVMCoreUI/OtherHandlers/{DelegateObject.swift => MVMCoreUIDelegateObject.swift} (85%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index dea12c71..1f3e1d53 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -157,7 +157,7 @@ D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; }; D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; }; - D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */; }; + D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; }; DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; }; DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; }; @@ -318,7 +318,7 @@ D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = ""; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = ""; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = ""; }; - D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DelegateObject.swift; sourceTree = ""; }; + D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = ""; }; DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = ""; }; DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = ""; }; @@ -636,7 +636,7 @@ D29DF27021E79B2C003B2FB9 /* OtherHandlers */ = { isa = PBXGroup; children = ( - D2E1FADA2260D3D200AEFD8C /* DelegateObject.swift */, + D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */, D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */, D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */, D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */, @@ -868,7 +868,7 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, - D2E1FADB2260D3D200AEFD8C /* DelegateObject.swift in Sources */, + D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 72c04900..0849ed26 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -113,8 +113,8 @@ open class CaretButton: MFCustomButton { setTitleColor(disabledColor, for: .disabled) } - @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData) guard let dictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h index 47ac89e4..9d08883d 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h @@ -11,7 +11,7 @@ #import #import #import -@class MVMCoreUIDelegateObject; +@class DelegateObject; typedef void (^ButtonTapBlock)(id _Nonnull sender); @@ -28,7 +28,7 @@ extern CGFloat const CloseButtonWidth; - (void)addBlock:(nonnull ButtonTapBlock)buttonTapBlock forControlEvents:(UIControlEvents)event; // Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. -- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; //accessibility - (void)addAccessibilityForCameraControl; diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m index 45daebcc..1610f42b 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.m @@ -38,7 +38,7 @@ CGFloat const CloseButtonWidth = 40.0f; } } -- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { self.actionMap = actionMap; self.titleLabel.numberOfLines = 0; @@ -47,7 +47,9 @@ CGFloat const CloseButtonWidth = 40.0f; [self setEnabled:![actionMap[KeyDisableButton]boolValue]]; - self.buttonDelegate = delegateObject.buttonDelegate; + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + self.buttonDelegate = ((MVMCoreUIDelegateObject *)delegateObject).buttonDelegate; + } __weak MFCustomButton *weakSelf = self; [self addBlock:^(id _Nonnull sender) { diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index 563dc2d1..eb3a4c4b 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -94,10 +94,9 @@ open class CaretView: MFView { defaultState() } - - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) - + + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) // Configure class properties with JSON values guard let jsonDictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Views/DashLine.swift b/MVMCoreUI/Atoms/Views/DashLine.swift index 9b3e7f52..82c05b27 100644 --- a/MVMCoreUI/Atoms/Views/DashLine.swift +++ b/MVMCoreUI/Atoms/Views/DashLine.swift @@ -68,8 +68,8 @@ open class DashLine: MFView { isHidden = false } - @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) // Configure class properties with JSON values guard let jsonDictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Views/LabelView.m b/MVMCoreUI/Atoms/Views/LabelView.m index f1d7b2f0..15915cec 100644 --- a/MVMCoreUI/Atoms/Views/LabelView.m +++ b/MVMCoreUI/Atoms/Views/LabelView.m @@ -72,9 +72,9 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegate:delegate additionalData:additionalData]; - [self.label setWithJSON:json delegate:delegate additionalData:additionalData]; +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; + [self.label setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; } - (void)alignLeft { diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index 3810294a..b749b41f 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -553,8 +553,7 @@ extension LabelWithInternalButton: MVMCoreUIMoleculeViewProtocol { } - @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - + @objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { // Configure class properties with JSON values guard let dictionary = json else { return } diff --git a/MVMCoreUI/Atoms/Views/MFLabel.m b/MVMCoreUI/Atoms/Views/MFLabel.m index 3857cd8d..5fb19037 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.m +++ b/MVMCoreUI/Atoms/Views/MFLabel.m @@ -170,7 +170,7 @@ } } -+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { ++ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData { if (label) { label.text = [json string:KeyText]; [self setLabel:label withHTML:[json string:@"html"]]; @@ -232,7 +232,7 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { [MFLabel setUILabel:self withJSON:json delegateObject:delegateObject additionalData:additionalData]; self.originalAttributedString = self.attributedText; } diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 257fe041..b08dc249 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -203,8 +203,8 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol functions - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = UIColor.mfGet(forHex: backgroundColorString) } diff --git a/MVMCoreUI/Atoms/Views/MFView.m b/MVMCoreUI/Atoms/Views/MFView.m index 6c0f8309..4bd73485 100644 --- a/MVMCoreUI/Atoms/Views/MFView.m +++ b/MVMCoreUI/Atoms/Views/MFView.m @@ -7,6 +7,7 @@ // #import "MFView.h" +@import MVMCore.Swift; @implementation MFView @@ -43,7 +44,7 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { self.json = json; } diff --git a/MVMCoreUI/Atoms/Views/SeparatorView.m b/MVMCoreUI/Atoms/Views/SeparatorView.m index 73cd84ff..95fe8bb8 100644 --- a/MVMCoreUI/Atoms/Views/SeparatorView.m +++ b/MVMCoreUI/Atoms/Views/SeparatorView.m @@ -95,8 +95,8 @@ } } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { - [super setWithJSON:json delegate:delegate additionalData:additionalData]; +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; if (json) { self.hidden = NO; NSString *type = [json string:KeyType]; diff --git a/MVMCoreUI/Molecules/ButtonView.swift b/MVMCoreUI/Molecules/ButtonView.swift index 5391640c..8958887c 100644 --- a/MVMCoreUI/Molecules/ButtonView.swift +++ b/MVMCoreUI/Molecules/ButtonView.swift @@ -33,9 +33,9 @@ import UIKit primaryButton?.isEnabled = enabled } - public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, actionDelegate: NSObject?, buttonDelegate: Any?) { + public init(withJSON json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { super.init(frame: .zero) - setWithJSON(json, delegate: actionDelegate, additionalData: additionalData) + setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - MVMCoreViewProtocol @@ -58,7 +58,7 @@ import UIKit primaryButton?.setAsMolecule() } - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUI.DelegateObject?, additionalData: [AnyHashable : Any]?) { + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) primaryButton?.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index 19cc1e21..ac92e0a1 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -7,12 +7,12 @@ // #import -@class MVMCoreUIDelegateObject; +@class DelegateObject; @protocol MVMCoreUIMoleculeViewProtocol // Sets up the ui based on the json -- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; +- (void)setWithJSON:(nullable NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; @optional diff --git a/MVMCoreUI/Molecules/MoleculeStackView.swift b/MVMCoreUI/Molecules/MoleculeStackView.swift index 1c70d6eb..57b0108c 100644 --- a/MVMCoreUI/Molecules/MoleculeStackView.swift +++ b/MVMCoreUI/Molecules/MoleculeStackView.swift @@ -17,13 +17,13 @@ public class MoleculeStackView: MFView { super.init(frame: frame) } - public init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { + public init(withJSON json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) { super.init(frame: CGRect.zero) - setWithJSON(json, delegate: delegate, additionalData: additionalData) + setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) } - public convenience init(withJSON json: [AnyHashable : Any]?, delegate: NSObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) { - self.init(withJSON: json, delegate: delegate, additionalData: nil) + public convenience init(withJSON json: [AnyHashable: Any]?, delegateObject: DelegateObject?, spacingBlock: ((Any) -> UIEdgeInsets)?) { + self.init(withJSON: json, delegateObject: delegateObject, additionalData: nil) self.spacingBlock = spacingBlock } @@ -48,8 +48,8 @@ public class MoleculeStackView: MFView { } } - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) guard let molecules = json?.arrayForKey("molecules") as? [[String: Any]] else { return } @@ -58,7 +58,7 @@ public class MoleculeStackView: MFView { var moleculesArray = [] as [UIView] for moleculeJSON in molecules { if let name = moleculeJSON.optionalStringForKey("moleculeName"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForName(name) { - molecule.setWithJSON(moleculeJSON, delegate: delegate, additionalData: additionalData) + molecule.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData) moleculesArray.append(molecule) } } diff --git a/MVMCoreUI/Molecules/StandardFooterView.swift b/MVMCoreUI/Molecules/StandardFooterView.swift index 99880b9b..a170d023 100644 --- a/MVMCoreUI/Molecules/StandardFooterView.swift +++ b/MVMCoreUI/Molecules/StandardFooterView.swift @@ -103,12 +103,12 @@ public class StandardFooterView: ViewConstrainingView { rightConstraintTextButton?.constant = constant } - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let colorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = .mfGet(forHex: colorString) } - twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegate: delegate, additionalData: additionalData) - textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegate: delegate, additionalData: additionalData) + twoButtonView.setWithJSON(json?.optionalDictionaryForKey("twoButtonView"), delegateObject: delegateObject, additionalData: additionalData) + textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 8c05a4c6..488e31c1 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -110,8 +110,8 @@ public class StandardHeaderView: ViewConstrainingView { separatorView?.rightPin?.constant = constant } - public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let colorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = .mfGet(forHex: colorString) } @@ -123,11 +123,11 @@ public class StandardHeaderView: ViewConstrainingView { } let headlineJSON = json?.optionalDictionaryForKey("headline") - headlineLabel.setWithJSON(headlineJSON, delegate: delegate, additionalData: additionalData) + headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) let bodyJSON = json?.optionalDictionaryForKey("body") - messageLabel.setWithJSON(bodyJSON, delegate: delegate, additionalData: additionalData) + messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) let separatorJSON = json?.optionalDictionaryForKey("separator") - separatorView?.setWithJSON(separatorJSON, delegate: delegate, additionalData: additionalData) + separatorView?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData) if separatorView?.isHidden ?? true { bottomPin?.constant = 0 diff --git a/MVMCoreUI/Molecules/TwoButtonView.swift b/MVMCoreUI/Molecules/TwoButtonView.swift index c56d82bf..58586126 100644 --- a/MVMCoreUI/Molecules/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/TwoButtonView.swift @@ -39,14 +39,14 @@ import UIKit } // MARK: - MVMCoreUIMoleculeViewProtocol - open override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) + open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { backgroundColor = UIColor.mfGet(forHex: backgroundColorString) } let primaryButtonMap = json?.optionalDictionaryForKey("primaryButton") let secondaryButtonMap = json?.optionalDictionaryForKey("secondaryButton") - set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, actionDelegate: delegate, additionalData: additionalData, buttonDelegate: delegate) + set(primaryButtonJSON: primaryButtonMap, secondaryButtonJSON: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - Constraining @@ -142,33 +142,14 @@ import UIKit } } - open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + open func set(primaryButtonJSON: [AnyHashable: Any]?, secondaryButtonJSON: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { setupUI(withPrimaryButtonMap: primaryButtonJSON, secondaryButtonMap: secondaryButtonJSON, legacy: false) setDefaultCustom() - primaryButton?.setWithJSON(primaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData) - secondaryButton?.setWithJSON(secondaryButtonJSON, delegate: actionDelegate as? NSObject, additionalData: additionalData) + primaryButton?.setWithJSON(primaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData) + secondaryButton?.setWithJSON(secondaryButtonJSON, delegateObject: delegateObject, additionalData: additionalData) } // MARK: - Legacy - open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { - let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton) - let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton) - setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) - } - - open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { - setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true) - if primaryButtonMap != nil, secondaryButtonMap != nil { - primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - secondaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - } else if primaryButtonMap != nil { - primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - primaryButton?.bordered = false - } else if secondaryButtonMap != nil { - primaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) - primaryButton?.bordered = true - } - } public convenience init(buttonSmall small: Bool, enabled: Bool) { self.init() @@ -178,18 +159,6 @@ import UIKit primaryButton?.isEnabled = enabled } - public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: AnyHashable]?, buttonDelegate: Any?) { - self.init() - setup(withButtonMap: buttonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) - primaryButton?.setAsSmall(small) - secondaryButton?.setAsSmall(small) - } - - public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { - self.init() - setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) - } - public func hidePrimaryLeftButton() { guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else { return @@ -229,3 +198,42 @@ import UIKit secondaryButton?.isHidden = true } } + +// MARK: - Deprecate +extension TwoButtonView { + @available(*, deprecated) + open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true) + if primaryButtonMap != nil, secondaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + secondaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + } else if primaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + primaryButton?.bordered = false + } else if secondaryButtonMap != nil { + primaryButton?.setWithActionMap(secondaryButtonMap, actionDelegate: actionDelegate as? MVMCoreActionDelegateProtocol & NSObjectProtocol, additionalData: additionalData, buttonDelegate: buttonDelegate as? ButtonDelegateProtocol) + primaryButton?.bordered = true + } + } + + @available(*, deprecated) + open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton) + let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton) + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) + } + + @available(*, deprecated) + public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: AnyHashable]?, buttonDelegate: Any?) { + self.init() + setup(withButtonMap: buttonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) + primaryButton?.setAsSmall(small) + secondaryButton?.setAsSmall(small) + } + + @available(*, deprecated) + public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, actionDelegate: NSObjectProtocol?, additionalData: [AnyHashable: Any]?, buttonDelegate: Any?) { + self.init() + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate) + } +} diff --git a/MVMCoreUI/OtherHandlers/DelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift similarity index 85% rename from MVMCoreUI/OtherHandlers/DelegateObject.swift rename to MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index d7a2ac65..91ce13c3 100644 --- a/MVMCoreUI/OtherHandlers/DelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -8,8 +8,7 @@ import UIKit -@objc(MVMCoreUIDelegateObject) -open class DelegateObject: MVMCore.DelegateObject { +open class MVMCoreUIDelegateObject: DelegateObject { public weak var formValidationProtocol: FormValidationProtocol? public weak var buttonDelegate: ButtonDelegateProtocol? diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h index 7d229bbe..a79ca208 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.h @@ -8,6 +8,7 @@ #import #import +@class DelegateObject; @interface MVMCoreUIMoleculeMappingObject : NSObject @@ -19,6 +20,6 @@ // Returns the molecule for the given name. - (nullable UIView *)getMoleculeForName:(nonnull NSString *)name; -- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegate:(nullable NSObject *)delegate; +- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject; @end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 0936f9df..c1d7a36d 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -55,13 +55,13 @@ return nil; } -- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegate:(nullable NSObject *)delegate { +- (nullable UIView *)getMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject { NSString *moleculeName = [json string:@"moleculeName"]; if (!moleculeName) { return nil; } UIView *molecule = [self getMoleculeForName:moleculeName]; - [molecule setWithJSON:json delegate:delegate additionalData:nil]; + [molecule setWithJSON:json delegateObject:delegateObject additionalData:nil]; return molecule; } diff --git a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift index ab7b6dec..bdd187fe 100644 --- a/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackCenteredTemplate.swift @@ -12,13 +12,13 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController { public override func viewForMiddle() -> UIView? { let molecule = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") - let moleculeStack = MoleculeStackView(withJSON: molecule, delegate: self, additionalData: nil) + let moleculeStack = MoleculeStackView(withJSON: molecule, delegateObject: delegateObject(), additionalData: nil) return moleculeStack } public override func viewForTop() -> UIView? { guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else { return nil } return molecule @@ -26,7 +26,7 @@ public class MoleculeStackCenteredTemplate: ThreeLayerViewController { override public func viewForBottom() -> UIView? { guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), - let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else { return nil } return molecule diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 2910782d..dfcef277 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -16,7 +16,7 @@ public class MoleculeStackTemplate: ThreeLayerViewController { } public override func viewForTop() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else { return nil } return molecule @@ -26,11 +26,11 @@ public class MoleculeStackTemplate: ThreeLayerViewController { guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("moleculeStack") else { return nil } - return MoleculeStackView(withJSON: moleculeJSON, delegate: self, additionalData: nil) + return MoleculeStackView(withJSON: moleculeJSON, delegateObject: delegateObject(), additionalData: nil) } override public func viewForBottom() -> UIView? { - guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegate: self) else { + guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("footer"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeForJSON(moleculeJSON, delegateObject: delegateObject()) else { return nil } return molecule From 8c19755ba87f42842d1248dda57b2d87daac1906 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 13:31:45 -0400 Subject: [PATCH 05/20] warning fix --- MVMCoreUI/Atoms/Buttons/MFTextButton.m | 4 +-- MVMCoreUI/Atoms/Buttons/PrimaryButton.m | 11 ++++--- MVMCoreUI/Atoms/Views/MFLabel.h | 3 +- MVMCoreUI/BaseControllers/MFViewController.m | 10 +++--- ...MVMCoreUITabBarPageControlViewController.m | 2 +- .../FormValidator+FormParams.swift | 4 +-- ...abelsAndBottomButtonsTableViewController.m | 2 +- .../TopLabelsAndBottomButtonsViewController.m | 2 +- MVMCoreUI/Molecules/TwoButtonView.swift | 31 +++++++++++++++++++ 9 files changed, 51 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index ff4c372c..0a72eee7 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.m @@ -128,12 +128,12 @@ #pragma mark - MVMCoreUIMoleculeViewProtocol -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData { +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { NSString *color = [json string:KeyTextColor]; if (color) { [self setTitleColor:[UIColor mfGetColorForHex:color] forState:UIControlStateNormal]; } - [self setWithActionMap:json actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject *)delegate : nil) additionalData:additionalData buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id )delegate : nil)]; + [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; if ([self titleForState:UIControlStateNormal].length == 0) { self.heightConstraint.constant = 0; } else { diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index fd7ad2b9..2085b5c8 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -648,10 +648,11 @@ [self setAsStandardCustom]; } -- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData { - - [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; - +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + [FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; + } + self.primaryButtonType = PrimaryButtonTypeCustom; NSString *color = [json string:@"fillColor"]; if (color) { @@ -676,7 +677,7 @@ self.validationRequired = [json boolForKey:@"validationRequired"]; [self setAsSmallButton:[json boolForKey:@"small"]]; - [self setWithActionMap:json actionDelegate:([delegate conformsToProtocol:@protocol(MVMCoreActionDelegateProtocol)] ? (NSObject *)delegate : nil) additionalData:additionalData buttonDelegate:([delegate conformsToProtocol:@protocol(ButtonDelegateProtocol)] ? (id )delegate : nil)]; + [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; } #pragma mark - Handling Validations diff --git a/MVMCoreUI/Atoms/Views/MFLabel.h b/MVMCoreUI/Atoms/Views/MFLabel.h index 22308465..7dc4fd8d 100644 --- a/MVMCoreUI/Atoms/Views/MFLabel.h +++ b/MVMCoreUI/Atoms/Views/MFLabel.h @@ -9,6 +9,7 @@ #import #import @class MFSizeObject; +@class DelegateObject; @interface MFLabel : UILabel @@ -49,7 +50,7 @@ // Setters + (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html; -+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData; ++ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegateObject:(nullable DelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData; - (void)styleH1:(BOOL)scale; - (void)styleH2:(BOOL)scale; diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 6b27c7d9..c378391a 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -138,7 +138,7 @@ // Creates an initial load object if needed. if (!self.loadObject) { - self.loadObject = [[MVMCoreLoadObject alloc] initWithDelegate:self]; + self.loadObject = [[MVMCoreLoadObject alloc] initWithDelegateObject:[self delegateObject]]; } // Avoid the setter so we are only setting the bool and wait for view will appear to update the navigation bar. @@ -343,7 +343,7 @@ if (rightPanelLinkDict) { [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:rightPanelLinkDict additionalData:nil - delegate:self]; + delegateObject:[self delegateObject]]; return YES; } else { return NO; @@ -607,7 +607,7 @@ [self.formValidator addFormParamsWithRequestParameters:requestParameters]; requestParameters.parentPageType = [self.loadObject.pageJSON stringForKey:@"parentPageType"]; - [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegate:self]; + [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:[self delegateObject]]; } - (void)handleBackAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { @@ -662,7 +662,7 @@ - (void)handleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { - [MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegate:self]; + [MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:[self delegateObject]]; } - (void)handleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { @@ -689,7 +689,7 @@ } - (nullable MVMCoreAlertObject *)alertObjectToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)errorObject { - return [MVMCoreAlertObject alertObjectForLoadObject:loadObject error:errorObject actionDelegate:self]; + return [MVMCoreAlertObject alertObjectForLoadObject:loadObject error:errorObject delegateObject:[self delegateObject]]; } - (void)handleFieldErrors:(nullable NSArray *)fieldErrors loadObject:(nonnull MVMCoreLoadObject *)loadObject { diff --git a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m index 489a4696..d06ca5f4 100644 --- a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m +++ b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m @@ -394,7 +394,7 @@ if (customAdditionalData) { [additionalData addEntriesFromDictionary:customAdditionalData]; } - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:self]; + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[self delegateObject]]; } } return NO; diff --git a/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift b/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift index 2f1e9f99..17da0e72 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator+FormParams.swift @@ -9,11 +9,11 @@ import Foundation @objc public extension FormValidator { - @objc public func addFormParams(requestParameters: MVMCoreRequestParameters) { + @objc func addFormParams(requestParameters: MVMCoreRequestParameters) { requestParameters.add(self.getFormParams()) } - @objc public func getFormParams() -> [String: Any] { + @objc func getFormParams() -> [String: Any] { var extraParam: [String: Any] = [:] MVMCoreDispatchUtility.performSyncBlock(onMainThread: { for molecule in self.molecules { diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m index 7a16405b..ca75b778 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsTableViewController.m @@ -117,7 +117,7 @@ // Sets up the buttons/button. NSDictionary *primaryButtonDictionary = [self primaryButtonMap]; NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap]; - TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self]; + TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary delegateObject:[self delegateObject] additionalData:nil]; self.secondaryButton = buttonView.secondaryButton; self.primaryButton = buttonView.primaryButton; diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index be14e149..149b399c 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -127,7 +127,7 @@ // Sets up the buttons/button. NSDictionary *primaryButtonDictionary = [self primaryButtonMap]; NSDictionary *secondaryButtonDictionary = [self secondaryButtonMap]; - TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary actionDelegate:self additionalData:nil buttonDelegate:self]; + TwoButtonView *buttonView = [[TwoButtonView alloc] initWithPrimaryButtonMap:primaryButtonDictionary secondaryButtonMap:secondaryButtonDictionary delegateObject:[self delegateObject] additionalData:nil]; self.secondaryButton = buttonView.secondaryButton; self.primaryButton = buttonView.primaryButton; bottomView = buttonView; diff --git a/MVMCoreUI/Molecules/TwoButtonView.swift b/MVMCoreUI/Molecules/TwoButtonView.swift index 58586126..66b7210a 100644 --- a/MVMCoreUI/Molecules/TwoButtonView.swift +++ b/MVMCoreUI/Molecules/TwoButtonView.swift @@ -150,6 +150,17 @@ import UIKit } // MARK: - Legacy + public convenience init(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + self.init() + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + } + + public convenience init(buttonSmall small: Bool, buttonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: AnyHashable]?) { + self.init() + setup(withButtonMap: buttonMap, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.setAsSmall(small) + secondaryButton?.setAsSmall(small) + } public convenience init(buttonSmall small: Bool, enabled: Bool) { self.init() @@ -159,6 +170,26 @@ import UIKit primaryButton?.isEnabled = enabled } + open func setup(primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + setupUI(withPrimaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, legacy: true) + if primaryButtonMap != nil, secondaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + secondaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + } else if primaryButtonMap != nil { + primaryButton?.setWithActionMap(primaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.bordered = false + } else if secondaryButtonMap != nil { + primaryButton?.setWithActionMap(secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + primaryButton?.bordered = true + } + } + + open func setup(withButtonMap buttonMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + let secondaryButtonMap = buttonMap?.optionalDictionaryForKey(KeySecondaryButton) + let primaryButtonMap = buttonMap?.optionalDictionaryForKey(KeyPrimaryButton) + setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, delegateObject: delegateObject, additionalData: additionalData) + } + public func hidePrimaryLeftButton() { guard let secondaryButton = secondaryButton, !secondaryButton.isHidden else { return From 01c5abc0272c776323003fc0825da8a8d5468e51 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 13:47:19 -0400 Subject: [PATCH 06/20] warning fix --- MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m index 4b19c49c..fe8d940b 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m @@ -19,6 +19,8 @@ #import "MVMCoreUICommonViewsUtility.h" #import "MFStyler.h" #import "MVMCoreUISession.h" +#import + @import MVMCore.MVMCoreTopAlertDelegateProtocol; @implementation MVMCoreUITopAlertBaseView @@ -35,7 +37,7 @@ } if (performAction) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:[MVMCoreUISession sharedGlobal].topAlertView]; + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:[MVMCoreUISession sharedGlobal].topAlertView]]; } } forControlEvents:UIControlEventTouchUpInside]; } From e2e6cbabf6f16e74db34f4f01f2440bf2632dbf7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 14:39:37 -0400 Subject: [PATCH 07/20] textfield delegate object fix --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 565e086c..77509325 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -116,7 +116,7 @@ + (nullable instancetype)mfTextFieldWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { MFTextField *textField = [self mfTextField]; textField.translatesAutoresizingMaskIntoConstraints = NO; - [textField setWithJSON:map delegate:delegate additionalData:nil]; + [textField setWithJSON:map delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:delegate] additionalData:nil]; return textField; } @@ -558,10 +558,12 @@ self.isMolecule = YES; } -- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { - [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; - FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; - [self setWithMap:json bothDelegates:formValidator]; +- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + [FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; + FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; + [self setWithMap:json bothDelegates:formValidator]; + } } #pragma mark - FormValidationProtocol From 9278ad75ea8d1511e71a1b074d9bd81bfb0db250 Mon Sep 17 00:00:00 2001 From: panxi Date: Mon, 15 Apr 2019 14:50:45 -0400 Subject: [PATCH 08/20] add override status bar function --- .../MVMCoreUIDetailViewProtocol.h | 3 +++ .../MVMCoreUISplitViewController.h | 3 +++ .../MVMCoreUISplitViewController.m | 20 ++++++++++++++++++- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 3 +++ MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 10 +++++++++- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 0c5a865d..5eeafc9f 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -30,6 +30,9 @@ NS_ASSUME_NONNULL_BEGIN // View Controller can override this method and do custom action instead of opening the left panel - (BOOL)isOverridingLeftButton; +//return desired status bar style based on different View Controller +- (UIStatusBarStyle)panelPreferredStatusBarStyle; + @end NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index 2ef7fa25..88b61188 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -105,6 +105,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { + (CGFloat)getApplicationViewWidth; + (CGFloat)getApplicationViewMaxSize; +// return subviewcontrollers' prefer status bar style +- (UIStatusBarStyle)getDefaultStatusBarStyle; + #pragma mark - Main Subclassables // Can subclass to set threshold for when the drawers are permanently extended. Default is 1000 for the left panel and 2000 for both. diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index d70bdb6e..dd76cc92 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -877,7 +877,25 @@ CGFloat const PanelAnimationDuration = 0.2; } - (UIStatusBarStyle)preferredStatusBarStyle { - return self.topAlertView.statusBarStyle; + if (self.topAlertView.topAlertObject) { + return self.topAlertView.statusBarStyle; + } else { + UIStatusBarStyle style = [self getDefaultStatusBarStyle]; + if (self.topAlertView.statusBarStyle != style) { + [self.topAlertView resetStatusBar]; + } + return style; + } +} + +- (UIStatusBarStyle)getDefaultStatusBarStyle { + UIViewController *viewController = [self getCurrentDetailViewController]; + if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] + && [viewController respondsToSelector:@selector(panelPreferredStatusBarStyle)] + && [((UIViewController *)viewController) panelPreferredStatusBarStyle]) { + return [((UIViewController *)viewController) panelPreferredStatusBarStyle]; + } + return UIStatusBarStyleDefault; } #pragma mark - Getters diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index 46d56cb6..f4de6d5b 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -41,6 +41,9 @@ - (void)expandStatusBarView; - (void)collapseStatusBarView; +//reset status bar color to default based on splitview +- (void)resetStatusBar; + // Can be subclassed for custom views. - (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 735f28d9..a582638c 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -189,7 +189,6 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; [weakSelf.superview layoutIfNeeded]; } completion:^(BOOL finished) { [weakSelf.animationDelegate topAlertViewFinishAnimation]; - [weakSelf setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault]; UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil); UIView *view = weakSelf.currentAlert; @@ -204,6 +203,9 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; [operation markAsFinished]; completionHandler(finished); weakSelf.topAlertObject = nil; + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [weakSelf resetStatusBar]; + }]; }]; }]; }]; @@ -242,4 +244,10 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; }]; } +- (void)resetStatusBar { + UIStatusBarStyle style = [[MVMCoreUISplitViewController mainSplitViewController] getDefaultStatusBarStyle]; + UIColor *backgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; + [self setStatusBarColor:backgroundColor statusBarStyle:style]; +} + @end From 7343f24e9bb4c5f1148b3eb6e06f72079878be24 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 15 Apr 2019 15:09:25 -0400 Subject: [PATCH 09/20] missed super --- MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index 91ce13c3..eaf892fb 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -13,6 +13,7 @@ open class MVMCoreUIDelegateObject: DelegateObject { public weak var buttonDelegate: ButtonDelegateProtocol? open override func setAll(withDelegate delegate: Any) { + super.setAll(withDelegate: delegate) formValidationProtocol = delegate as? FormValidationProtocol buttonDelegate = delegate as? ButtonDelegateProtocol } From 89427b1b7ad6799df911b06f49455d1a54bc205a Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 16 Apr 2019 11:46:53 -0400 Subject: [PATCH 10/20] update code based on comments --- .../MVMCoreUIDetailViewProtocol.h | 3 ++- .../MVMCoreUISplitViewController.h | 1 + .../MVMCoreUISplitViewController.m | 20 ++++++++++++------ MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 2 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 21 ++++++++++++++----- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 5eeafc9f..acb56ad1 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -31,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)isOverridingLeftButton; //return desired status bar style based on different View Controller -- (UIStatusBarStyle)panelPreferredStatusBarStyle; +- (UIStatusBarStyle)defaultStatusBarStyle; +- (nullable UIColor *)defaultStatusBarBackgroundColor; @end diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index 88b61188..0d4c9ea4 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -107,6 +107,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { // return subviewcontrollers' prefer status bar style - (UIStatusBarStyle)getDefaultStatusBarStyle; +- (nullable UIColor *)getDefaultStatusBarBackgroundColor; #pragma mark - Main Subclassables diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index dd76cc92..7f34de85 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -881,9 +881,7 @@ CGFloat const PanelAnimationDuration = 0.2; return self.topAlertView.statusBarStyle; } else { UIStatusBarStyle style = [self getDefaultStatusBarStyle]; - if (self.topAlertView.statusBarStyle != style) { - [self.topAlertView resetStatusBar]; - } + [self.topAlertView resetDefaultStatusBarStyle:style backgroundColor:[self getDefaultStatusBarBackgroundColor]]; return style; } } @@ -891,13 +889,23 @@ CGFloat const PanelAnimationDuration = 0.2; - (UIStatusBarStyle)getDefaultStatusBarStyle { UIViewController *viewController = [self getCurrentDetailViewController]; if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] - && [viewController respondsToSelector:@selector(panelPreferredStatusBarStyle)] - && [((UIViewController *)viewController) panelPreferredStatusBarStyle]) { - return [((UIViewController *)viewController) panelPreferredStatusBarStyle]; + && [viewController respondsToSelector:@selector(defaultStatusBarStyle)] + && [((UIViewController *)viewController) defaultStatusBarStyle]) { + return [((UIViewController *)viewController) defaultStatusBarStyle]; } return UIStatusBarStyleDefault; } +- (UIColor *)getDefaultStatusBarBackgroundColor { + UIViewController *viewController = [self getCurrentDetailViewController]; + if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] + && [viewController respondsToSelector:@selector(defaultStatusBarBackgroundColor)] + && [((UIViewController *)viewController) defaultStatusBarBackgroundColor]) { + return [((UIViewController *)viewController) defaultStatusBarBackgroundColor]; + } + return nil; +} + #pragma mark - Getters // Returns the desired view or falls back. Hot fix until we can get away from using these functions... diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index f4de6d5b..ac5219b0 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -42,7 +42,7 @@ - (void)collapseStatusBarView; //reset status bar color to default based on splitview -- (void)resetStatusBar; +- (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(nullable UIColor *)backgroundColor; // Can be subclassed for custom views. - (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index a582638c..3d2fb626 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -46,6 +46,9 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; @property (weak, nonatomic) MVMCoreUITopAlertExpandableView *topAlertClearspotView; @property (strong, nonatomic) NSString *time; +@property (nonatomic, assign) UIStatusBarStyle defaultStatusBarStyle; +@property (nonatomic, strong) UIColor *defaultStatusBarBackgroundColor; + @end @implementation MVMCoreUITopAlertView @@ -204,7 +207,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; completionHandler(finished); weakSelf.topAlertObject = nil; [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [weakSelf resetStatusBar]; + [weakSelf resetDefaultStatusBarStyle:weakSelf.defaultStatusBarStyle backgroundColor:weakSelf.defaultStatusBarBackgroundColor]; }]; }]; }]; @@ -244,10 +247,18 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; }]; } -- (void)resetStatusBar { - UIStatusBarStyle style = [[MVMCoreUISplitViewController mainSplitViewController] getDefaultStatusBarStyle]; - UIColor *backgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; - [self setStatusBarColor:backgroundColor statusBarStyle:style]; +- (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(UIColor *)backgroundColor { + self.defaultStatusBarStyle = style; + self.defaultStatusBarBackgroundColor = backgroundColor; + if (!backgroundColor) { + self.defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; + } + if (!self.topAlertObject) { + //style or color doens't match the current default value + if (style != self.statusBarStyle || !CGColorEqualToColor(self.defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { + [self setStatusBarColor:self.defaultStatusBarBackgroundColor statusBarStyle:style]; + } + } } @end From 1b5d423659c0cfd9d0ae81bd89d522f458f83822 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 16 Apr 2019 14:49:24 -0400 Subject: [PATCH 11/20] remove local default status bar style --- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 3d2fb626..6753e67c 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -46,9 +46,6 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; @property (weak, nonatomic) MVMCoreUITopAlertExpandableView *topAlertClearspotView; @property (strong, nonatomic) NSString *time; -@property (nonatomic, assign) UIStatusBarStyle defaultStatusBarStyle; -@property (nonatomic, strong) UIColor *defaultStatusBarBackgroundColor; - @end @implementation MVMCoreUITopAlertView @@ -207,7 +204,8 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; completionHandler(finished); weakSelf.topAlertObject = nil; [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [weakSelf resetDefaultStatusBarStyle:weakSelf.defaultStatusBarStyle backgroundColor:weakSelf.defaultStatusBarBackgroundColor]; + MVMCoreUISplitViewController *mainsplit = [MVMCoreUISplitViewController mainSplitViewController]; + [weakSelf resetDefaultStatusBarStyle:[mainsplit getDefaultStatusBarStyle] backgroundColor:[mainsplit getDefaultStatusBarBackgroundColor]]; }]; }]; }]; @@ -248,15 +246,14 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; } - (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(UIColor *)backgroundColor { - self.defaultStatusBarStyle = style; - self.defaultStatusBarBackgroundColor = backgroundColor; - if (!backgroundColor) { - self.defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; + UIColor *defaultStatusBarBackgroundColor = backgroundColor; + if (!defaultStatusBarBackgroundColor) { + defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; } if (!self.topAlertObject) { //style or color doens't match the current default value - if (style != self.statusBarStyle || !CGColorEqualToColor(self.defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { - [self setStatusBarColor:self.defaultStatusBarBackgroundColor statusBarStyle:style]; + if (style != self.statusBarStyle || !CGColorEqualToColor(defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { + [self setStatusBarColor:defaultStatusBarBackgroundColor statusBarStyle:style]; } } } From 76506a51b51c961be17c342a73e0c5a534ee1ddd Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 16 Apr 2019 15:33:34 -0400 Subject: [PATCH 12/20] ONVIK-14895 --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 565e086c..fb157764 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -561,7 +561,7 @@ - (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; - [self setWithMap:json bothDelegates:formValidator]; + [self setWithMap:json bothDelegates: formValidator ?: delegate ]; } #pragma mark - FormValidationProtocol From 3655b4af8d7ae3c6f2c29b14074891b6ffb096fc Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 16 Apr 2019 15:51:15 -0400 Subject: [PATCH 13/20] remove space --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index fb157764..fa5a1506 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -561,7 +561,7 @@ - (void)setWithJSON:(NSDictionary *)json delegate:(nullable id)delegate additionalData:(NSDictionary *)additionalData { [FormValidator setupValidationWithMolecule:self delegate:(id)delegate]; FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id)delegate]; - [self setWithMap:json bothDelegates: formValidator ?: delegate ]; + [self setWithMap:json bothDelegates:formValidator ?: delegate]; } #pragma mark - FormValidationProtocol From 53502a40c103cad5df8a2d1553ed4c4417acfc59 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 17 Apr 2019 10:59:16 -0400 Subject: [PATCH 14/20] merge --- MVMCoreUI/Atoms/TextFields/MFTextField.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 6fb728b2..065c1439 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -116,7 +116,7 @@ + (nullable instancetype)mfTextFieldWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id)delegate { MFTextField *textField = [self mfTextField]; textField.translatesAutoresizingMaskIntoConstraints = NO; - [textField setWithJSON:map delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:delegate] additionalData:nil]; + [textField setWithMap:map bothDelegates:delegate]; return textField; } @@ -562,7 +562,7 @@ if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { [FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; - [self setWithMap:json bothDelegates:formValidator ?: delegate]; + [self setWithMap:json bothDelegates:formValidator]; } } From a254e7d88286075ff8293eee6b135ac4fbe4b190 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 17 Apr 2019 11:17:44 -0400 Subject: [PATCH 15/20] only change the status bar background color --- MVMCoreUI/BaseControllers/MFScrollingViewController.m | 2 +- .../MVMCoreUISplitViewController.m | 2 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 4 ++-- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 11 +++++------ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFScrollingViewController.m b/MVMCoreUI/BaseControllers/MFScrollingViewController.m index f6e2c4d3..5486b54a 100644 --- a/MVMCoreUI/BaseControllers/MFScrollingViewController.m +++ b/MVMCoreUI/BaseControllers/MFScrollingViewController.m @@ -93,7 +93,7 @@ static NSTimeInterval const HandScrollAnimationTiming = 7.f; BOOL automaticInset = NO; if (@available(iOS 11.0, *)) { - automaticInset = self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic; + automaticInset = self.navigationController && self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic; } // Takes into account the navigation bar. diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 7f34de85..5509ca33 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -881,7 +881,7 @@ CGFloat const PanelAnimationDuration = 0.2; return self.topAlertView.statusBarStyle; } else { UIStatusBarStyle style = [self getDefaultStatusBarStyle]; - [self.topAlertView resetDefaultStatusBarStyle:style backgroundColor:[self getDefaultStatusBarBackgroundColor]]; + [self.topAlertView resetDefaultBackgroundColor:[self getDefaultStatusBarBackgroundColor] basedOnStatusBarStyle:[self getDefaultStatusBarStyle]]; return style; } } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index ac5219b0..04f8bc73 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -41,8 +41,8 @@ - (void)expandStatusBarView; - (void)collapseStatusBarView; -//reset status bar color to default based on splitview -- (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(nullable UIColor *)backgroundColor; +//reset status bar background color based on style +- (void)resetDefaultBackgroundColor:(nullable UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style; // Can be subclassed for custom views. - (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 6753e67c..0b1045a6 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -204,8 +204,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; completionHandler(finished); weakSelf.topAlertObject = nil; [MVMCoreDispatchUtility performBlockOnMainThread:^{ - MVMCoreUISplitViewController *mainsplit = [MVMCoreUISplitViewController mainSplitViewController]; - [weakSelf resetDefaultStatusBarStyle:[mainsplit getDefaultStatusBarStyle] backgroundColor:[mainsplit getDefaultStatusBarBackgroundColor]]; + [weakSelf setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault]; }]; }]; }]; @@ -245,15 +244,15 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; }]; } -- (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(UIColor *)backgroundColor { +- (void)resetDefaultBackgroundColor:(UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style { UIColor *defaultStatusBarBackgroundColor = backgroundColor; if (!defaultStatusBarBackgroundColor) { defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; } if (!self.topAlertObject) { - //style or color doens't match the current default value - if (style != self.statusBarStyle || !CGColorEqualToColor(defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { - [self setStatusBarColor:defaultStatusBarBackgroundColor statusBarStyle:style]; + //color doens't match the current default value + if (!CGColorEqualToColor(defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { + self.statusBarView.backgroundColor = defaultStatusBarBackgroundColor; } } } From 935b32ed6d01a6815cfd89b2fbc524ff007b27b1 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 17 Apr 2019 12:37:02 -0400 Subject: [PATCH 16/20] update status bar for presented view controller --- MVMCoreUI/BaseControllers/MFViewController.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index c378391a..0c3b3f3d 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -308,6 +308,8 @@ || self.manager || self.loadObject.requestParameters.tabWasPressed); } + } else { + [[MVMCoreUISession sharedGlobal].splitViewController.parentViewController setNeedsStatusBarAppearanceUpdate]; } } @@ -498,6 +500,15 @@ } } +//this method is needed for getting status bar style from present viewcotnroller +- (UIStatusBarStyle)preferredStatusBarStyle { + if ([self respondsToSelector:@selector(defaultStatusBarStyle)]) { + return [self defaultStatusBarStyle]; + } else { + return UIStatusBarStyleDefault; + } +} + - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; From f35b31b5b31648c5fed45f8bae51a1a95be63b4b Mon Sep 17 00:00:00 2001 From: "Robinson, Blake" Date: Wed, 17 Apr 2019 13:45:20 -0400 Subject: [PATCH 17/20] Makes a property public to allow for adding padding to the button accessory view --- .../LegacyControllers/TopLabelsAndBottomButtonsViewController.h | 1 + .../LegacyControllers/TopLabelsAndBottomButtonsViewController.m | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h index 7d15d543..c59918ea 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.h @@ -24,6 +24,7 @@ @property (nullable, weak, nonatomic) UIView *viewInScroll; @property (nullable, weak, nonatomic) UIView *viewOutOfScroll; @property (nullable, strong, nonatomic) UIView *safeAreaView; +@property (nullable, weak, nonatomic) ViewConstrainingView *bottomAccessoryView; // Set to overwrite which view is the top edge and/or bottom edge of the between view. must be added to the ui and constrained before buildViewsBetweenLabelsAndButtons. // Use these to create views that are pinned near the labels or buttons and are separate from any centered content. Add and set in buildInAdditionalViewsBeforeCenteredContent. diff --git a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m index be14e149..03679f2f 100644 --- a/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m +++ b/MVMCoreUI/LegacyControllers/TopLabelsAndBottomButtonsViewController.m @@ -30,7 +30,6 @@ @property (nullable, weak, nonatomic) NSArray *middleViews; @property (nullable, weak, nonatomic) UIView *betweenView; -@property (nullable, weak, nonatomic) ViewConstrainingView *bottomAccessoryView; // Adds the button view to the screen. Out of the scroll or in. - (void)addViewOutsideOfScrollView:(UIView *)bottomView; From 786d517517d478a780f3efb43e48c0e210f8d71a Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 17 Apr 2019 15:08:18 -0400 Subject: [PATCH 18/20] update comments --- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 2 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index 04f8bc73..5f49eb13 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -41,7 +41,7 @@ - (void)expandStatusBarView; - (void)collapseStatusBarView; -//reset status bar background color based on style +/// reset status bar background color, when backgroundColor is nil corresponding background color will be set based on style - (void)resetDefaultBackgroundColor:(nullable UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style; // Can be subclassed for custom views. diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 0b1045a6..02fb2ac6 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -250,7 +250,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; } if (!self.topAlertObject) { - //color doens't match the current default value + //color doesn't match the current default value if (!CGColorEqualToColor(defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { self.statusBarView.backgroundColor = defaultStatusBarBackgroundColor; } From 575721589a9f4856c91684539edaff6b329c0c37 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 17 Apr 2019 15:13:54 -0400 Subject: [PATCH 19/20] add missing style --- .../SplitViewController/MVMCoreUISplitViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 5509ca33..bdfd6ecd 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -881,7 +881,7 @@ CGFloat const PanelAnimationDuration = 0.2; return self.topAlertView.statusBarStyle; } else { UIStatusBarStyle style = [self getDefaultStatusBarStyle]; - [self.topAlertView resetDefaultBackgroundColor:[self getDefaultStatusBarBackgroundColor] basedOnStatusBarStyle:[self getDefaultStatusBarStyle]]; + [self.topAlertView resetDefaultBackgroundColor:[self getDefaultStatusBarBackgroundColor] basedOnStatusBarStyle:style]; return style; } } From e59adf7e470c300b0ddc5ba128bd8f0fe7aa2585 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 17 Apr 2019 15:20:56 -0400 Subject: [PATCH 20/20] change order of code --- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 02fb2ac6..b65f7423 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -245,11 +245,12 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; } - (void)resetDefaultBackgroundColor:(UIColor *)backgroundColor basedOnStatusBarStyle:(UIStatusBarStyle)style { - UIColor *defaultStatusBarBackgroundColor = backgroundColor; - if (!defaultStatusBarBackgroundColor) { - defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; - } if (!self.topAlertObject) { + UIColor *defaultStatusBarBackgroundColor = backgroundColor; + if (!defaultStatusBarBackgroundColor) { + defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor]; + } + //color doesn't match the current default value if (!CGColorEqualToColor(defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) { self.statusBarView.backgroundColor = defaultStatusBarBackgroundColor;