From 0ca77eadc21b45187ee8e06dcfeb6f06b2d7c894 Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Thu, 9 Jan 2020 18:24:18 +0530 Subject: [PATCH 1/8] Chatbot disable to BD users --- MVMCoreUI/BaseControllers/MFViewController.m | 2 +- MVMCoreUI/OtherHandlers/MVMCoreUISession.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 2c8e3997..6484c7ec 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -146,7 +146,7 @@ // Avoid the setter so we are only setting the bool and wait for view will appear to update the navigation bar. _masterShouldBeAccessible = [self isMasterInitiallyAccessible]; - _supportShouldBeAccessible = [self isSupportInitiallyAccessible]; + _supportShouldBeAccessible = ![MVMCoreUISession sharedGlobal].disableSupport && [self isSupportInitiallyAccessible]; // Observe for cache updates if desired. [self observeForResponseJSONUpdates]; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h index ca2db26e..ac7b2dbc 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h @@ -31,6 +31,9 @@ NS_ASSUME_NONNULL_BEGIN //indicates if the app launched successfully @property (assign, nonatomic) BOOL launchAppLoadedSuccessfully; +//indicates if support is enabled +@property (assign, nonatomic) BOOL disableSupport; + // Allows a global overload of the title view of navigation item. - (nullable UIView *)titleViewForController:(nonnull MFViewController *)controller; From c8fcbeaefd82fd50f101b167e62ee89b62129d76 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 9 Jan 2020 12:47:03 -0500 Subject: [PATCH 2/8] update right panel view controller --- MVMCoreUI/BaseControllers/MFViewController.m | 2 +- .../MVMCoreUISplitViewController.h | 4 ++++ .../MVMCoreUISplitViewController.m | 20 +++++++++++++++++++ MVMCoreUI/OtherHandlers/MVMCoreUISession.h | 3 --- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/BaseControllers/MFViewController.m index 6484c7ec..2c8e3997 100644 --- a/MVMCoreUI/BaseControllers/MFViewController.m +++ b/MVMCoreUI/BaseControllers/MFViewController.m @@ -146,7 +146,7 @@ // Avoid the setter so we are only setting the bool and wait for view will appear to update the navigation bar. _masterShouldBeAccessible = [self isMasterInitiallyAccessible]; - _supportShouldBeAccessible = ![MVMCoreUISession sharedGlobal].disableSupport && [self isSupportInitiallyAccessible]; + _supportShouldBeAccessible = [self isSupportInitiallyAccessible]; // Observe for cache updates if desired. [self observeForResponseJSONUpdates]; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index af02281d..8c1a7715 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -120,6 +120,10 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { - (nullable UIViewController *)createLeftPanelViewController; - (nullable UIViewController *)createRightPanelViewController; +//replace gloabl panel +- (void)updateGlobalLeftPanelViewController:(nullable UIViewController *)leftPanelController; +- (void)updateGlobalRightPanelViewController:(nullable UIViewController *)rightPanelController; + // subclass to change image of back button - (nullable UIImage *)imageForBackButton; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index b5177b9b..15dfba04 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -114,6 +114,14 @@ CGFloat const PanelAnimationDuration = 0.2; return nil; } +- (void)updateGlobalLeftPanelViewController:(nullable UIViewController *)leftPanelController { + self.globalLeftPanel = leftPanelController; +} + +- (void)updateGlobalRightPanelViewController:(nullable UIViewController *)rightPanelController { + self.globalRightPanel = rightPanelController; +} + - (nullable NSArray *)additionalLeftButtons { return nil; } @@ -316,6 +324,9 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)hideLeftPanelAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { + if (!self.globalLeftPanel) { + return; + } [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewLeading.constant > .1) { if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.leftPanel) { @@ -355,6 +366,9 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict { + if (!self.globalLeftPanel) { + return; + } [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewLeading.constant < .1) { BOOL shouldExtendLeftPanel = [self shouldExtendLeftPanel]; @@ -509,6 +523,9 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)hideRightPanelAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { + if (!self.globalRightPanel) { + return; + } [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewTrailing.constant > .1) { if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.rightPanel) { @@ -548,6 +565,9 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict { + if (!self.globalRightPanel) { + return; + } [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewTrailing.constant < .1) { BOOL shouldExtendRightPanel = [self shouldExtendRightPanel]; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h index ac7b2dbc..ca2db26e 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUISession.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUISession.h @@ -31,9 +31,6 @@ NS_ASSUME_NONNULL_BEGIN //indicates if the app launched successfully @property (assign, nonatomic) BOOL launchAppLoadedSuccessfully; -//indicates if support is enabled -@property (assign, nonatomic) BOOL disableSupport; - // Allows a global overload of the title view of navigation item. - (nullable UIView *)titleViewForController:(nonnull MFViewController *)controller; From cedcc6b0998bfc94152f6b223708986877c3953d Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 21 Jan 2020 10:24:20 -0500 Subject: [PATCH 3/8] AccessibilityCustomAction requires more than an empty string. --- MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index 070cc0f7..c8484829 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -66,7 +66,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt } else { guard let label = label else { return } - let accessibleAction = UIAccessibilityCustomAction(name: actionText ?? "", target: label, selector: #selector(label.accessibilityCustomAction(_:))) + let accessibleAction = UIAccessibilityCustomAction(name: actionText ?? "label", target: label, selector: #selector(label.accessibilityCustomAction(_:))) label.clauses = [Label.ActionableClause(range: actionRange, actionBlock: newActionBlock, accessibilityID: accessibleAction.hash)] label.accessibilityCustomActions = [accessibleAction] From 8816a06fe5c7eea7412cfbf60cdc84a950fb157d Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 21 Jan 2020 11:58:08 -0500 Subject: [PATCH 4/8] public globalLeftPanel/globalRightPanel --- .../MVMCoreUISplitViewController.h | 15 +++++---- .../MVMCoreUISplitViewController.m | 33 ++++++------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index 8c1a7715..1a72a190 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -24,8 +24,12 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { @interface MVMCoreUISplitViewController : UIViewController // Reference to the panels. -@property (nullable, weak, nonatomic, readonly) UIViewController *leftPanel; -@property (nullable, weak, nonatomic, readonly) UIViewController *rightPanel; +@property (nullable, weak, nonatomic) UIViewController *leftPanel; +@property (nullable, weak, nonatomic) UIViewController *rightPanel; + +// For keeping +@property (nullable, strong, nonatomic) UIViewController *globalLeftPanel; +@property (nullable, strong, nonatomic) UIViewController *globalRightPanel; // Can be of protocol MVMCoreUIPanelButtonProtocol @property (nullable, strong, nonatomic) UIBarButtonItem *leftPanelButton; @@ -79,6 +83,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { // contains speicaly logic to set the icon color - (void)setNavigationIconColor:(nullable UIColor *)color; +///create right and left panel. if left and right panel is already created, will replace them +- (void)createPanels; + /// Updates the panels that are used. - (void)setupPanels; @@ -120,10 +127,6 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { - (nullable UIViewController *)createLeftPanelViewController; - (nullable UIViewController *)createRightPanelViewController; -//replace gloabl panel -- (void)updateGlobalLeftPanelViewController:(nullable UIViewController *)leftPanelController; -- (void)updateGlobalRightPanelViewController:(nullable UIViewController *)rightPanelController; - // subclass to change image of back button - (nullable UIImage *)imageForBackButton; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 15dfba04..cd36d2a7 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -44,12 +44,6 @@ typedef NS_OPTIONS(NSInteger, MFExtendedDrawer) { @property (weak, nonatomic) UIView *leftPanelSeparator; @property (weak, nonatomic) UIView *rightPanelSeparator; -// For keeping -@property (strong, nonatomic, readwrite) UIViewController *globalLeftPanel; -@property (strong, nonatomic, readwrite) UIViewController *globalRightPanel; - -@property (weak, nonatomic, readwrite) UIViewController *leftPanel; -@property (weak, nonatomic, readwrite) UIViewController *rightPanel; @property (weak, nonatomic, readwrite) NavigationController *navigationController; // A view that covers the detail view when the master is out. @@ -114,14 +108,6 @@ CGFloat const PanelAnimationDuration = 0.2; return nil; } -- (void)updateGlobalLeftPanelViewController:(nullable UIViewController *)leftPanelController { - self.globalLeftPanel = leftPanelController; -} - -- (void)updateGlobalRightPanelViewController:(nullable UIViewController *)rightPanelController { - self.globalRightPanel = rightPanelController; -} - - (nullable NSArray *)additionalLeftButtons { return nil; } @@ -366,7 +352,7 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict { - if (!self.globalLeftPanel) { + if (!self.leftPanel) { return; } [MVMCoreDispatchUtility performBlockOnMainThread:^{ @@ -523,9 +509,6 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)hideRightPanelAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { - if (!self.globalRightPanel) { - return; - } [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewTrailing.constant > .1) { if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.rightPanel) { @@ -565,7 +548,7 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict { - if (!self.globalRightPanel) { + if (!self.rightPanel) { return; } [MVMCoreDispatchUtility performBlockOnMainThread:^{ @@ -786,6 +769,13 @@ CGFloat const PanelAnimationDuration = 0.2; } } +- (void)createPanels { + // Create panels + self.globalLeftPanel = [self createLeftPanelViewController]; + self.globalRightPanel = [self createRightPanelViewController]; + [self setupPanels]; +} + - (void)setupPanels { [self forceHideBothDrawers]; [self setupLeftPanel]; @@ -882,10 +872,7 @@ CGFloat const PanelAnimationDuration = 0.2; [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0].active = YES; [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0].active = YES; - // Create panels - self.globalLeftPanel = [self createLeftPanelViewController]; - self.globalRightPanel = [self createRightPanelViewController]; - [self setupPanels]; + [self createPanels]; } - (void)viewDidLoad { From 2de914296971535b04922faa30c3401a6199555c Mon Sep 17 00:00:00 2001 From: "Xinlei(Ryan) Pan" Date: Tue, 21 Jan 2020 12:00:28 -0500 Subject: [PATCH 5/8] remove one more line --- .../SplitViewController/MVMCoreUISplitViewController.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index cd36d2a7..93aeb6fd 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -310,9 +310,6 @@ CGFloat const PanelAnimationDuration = 0.2; } - (void)hideLeftPanelAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { - if (!self.globalLeftPanel) { - return; - } [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.mainViewLeading.constant > .1) { if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.leftPanel) { From 117c112b6ba089e77d4a392e8bf73e967bf360c0 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 21 Jan 2020 18:13:42 -0500 Subject: [PATCH 6/8] color --- MVMCoreUI/Atoms/Views/LineModel.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LineModel.swift b/MVMCoreUI/Atoms/Views/LineModel.swift index 8f16d22e..f481d4d5 100644 --- a/MVMCoreUI/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atoms/Views/LineModel.swift @@ -43,6 +43,7 @@ import UIKit public static var identifier: String = "line" public var type: Style = .standard public var frequency: Frequency? = .allExceptTop + public var color: Color? public var backgroundColor: Color? public init(type: Style) { @@ -53,6 +54,7 @@ import UIKit case moleculeName case type case backgroundColor + case color case frequency } @@ -64,7 +66,7 @@ import UIKit if let frequency = try typeContainer.decodeIfPresent(Frequency.self, forKey: .frequency) { self.frequency = frequency } - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) } public func encode(to encoder: Encoder) throws { @@ -72,6 +74,6 @@ import UIKit try container.encode(moleculeName, forKey: .moleculeName) try container.encode(type, forKey: .type) try container.encodeIfPresent(frequency, forKey: .frequency) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(color, forKey: .color) } } From 4d155b9f97aceda27904a1d0a90f20e35948e3cc Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 21 Jan 2020 18:23:32 -0500 Subject: [PATCH 7/8] ActionModelProtocol --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/LinkModel.swift | 4 ++-- MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift | 2 +- MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift | 2 +- MVMCoreUI/Atoms/Views/ToggleModel.swift | 2 +- MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift | 4 ++-- MVMCoreUI/Molecules/Items/ListItemModel.swift | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 531859c0..c9a7f2f8 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -22,13 +22,13 @@ public class ButtonModel: MoleculeModelProtocol { public static var identifier: String = "button" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var style: ButtonStyle? public var size: ButtonSize? = .standard public var required: Bool? public var requiredGroups: [String]? - init(with title: String, action: ActionProtocol) { + init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift index 3612c1fc..04b5aa07 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretLinkModel.swift @@ -13,12 +13,12 @@ public class CaretLinkModel: MoleculeModelProtocol { public static var identifier: String = "caretLink" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var enabledColor: Color = Color(uiColor: .black) public var disabledColor: Color? = Color(uiColor: .mfSilver()) public var enabled: Bool = true - public init(title: String, action: ActionProtocol) { + public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/LinkModel.swift b/MVMCoreUI/Atoms/Buttons/LinkModel.swift index 27cbd6c6..0c797b21 100644 --- a/MVMCoreUI/Atoms/Buttons/LinkModel.swift +++ b/MVMCoreUI/Atoms/Buttons/LinkModel.swift @@ -12,11 +12,11 @@ public class LinkModel: MoleculeModelProtocol { public static var identifier: String = "link" public var backgroundColor: Color? public var title: String - public var action: ActionProtocol + public var action: ActionModelProtocol public var enabled = true public var textColor = Color(uiColor: .mfTextButton()) - public init(title: String, action: ActionProtocol) { + public init(title: String, action: ActionModelProtocol) { self.title = title self.action = action } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift index b967db48..d008a7fb 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift @@ -9,7 +9,7 @@ import Foundation public extension MFCustomButton { - func set(with action: ActionProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + func set(with action: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { buttonDelegate = delegateObject?.buttonDelegate add({ [weak self] sender in guard let self = self else { return } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift index 8dd5c562..2ebcb4b4 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeActionModel.swift @@ -12,7 +12,7 @@ class LabelAttributeActionModel: LabelAttributeModel { override public class var identifier: String { return "action" } - var action: ActionProtocol + var action: ActionModelProtocol required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 12706a49..75fddd28 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -13,7 +13,7 @@ public class ToggleModel: MoleculeModelProtocol { public var moleculeName: String? public var backgroundColor: Color? public var state: Bool = true - public var action: ActionProtocol? + public var action: ActionModelProtocol? public var required: Bool? public var fieldKey: String? diff --git a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift index 857bd060..9d424a2b 100644 --- a/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/ListItemModelProtocol.swift @@ -10,14 +10,14 @@ import Foundation public protocol ListItemModelProtocol: ContainerModelProtocol, MoleculeModelProtocol { var line: LineModel? { get set } - var action: ActionProtocol? { get set } + var action: ActionModelProtocol? { get set } var hideArrow: Bool? { get set } var style: String? { get set } } // Not a strict requirement. extension ListItemModelProtocol { - public var action: ActionProtocol? { + public var action: ActionModelProtocol? { get { return nil } diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 97fef586..5356ce25 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -12,7 +12,7 @@ import MVMCore @objcMembers public class ListItemModel: MoleculeContainerModel, ListItemModelProtocol { public static var identifier: String = "listItem" public var backgroundColor: Color? - public var action: ActionProtocol? + public var action: ActionModelProtocol? public var hideArrow: Bool? public var line: LineModel? public var style: String? = "standard" From 943799d462372e20184f07e03150a06c221acab9 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 21 Jan 2020 23:33:24 -0500 Subject: [PATCH 8/8] more models --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ MVMCoreUI/Atoms/Views/ToggleModel.swift | 4 ++++ .../SwitchMolecules/HeadlineBodySwitch.swift | 20 ++++++++++------- .../HeadlineBodyToggleModel.swift | 22 +++++++++++++++++++ .../HeadlineBodyModel.swift | 3 +-- .../OtherHandlers/MoleculeObjectMapping.swift | 1 + 6 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d9591c22..65129935 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; }; + 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */; }; 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; }; 0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; }; @@ -310,6 +311,7 @@ /* Begin PBXFileReference section */ 01004F2F22721C3800991ECC /* RadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = ""; }; + 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyToggleModel.swift; sourceTree = ""; }; 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = ""; }; 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = ""; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = ""; }; @@ -809,6 +811,7 @@ 01C851D223CF9E740021F976 /* LabelToggleModel.swift */, D22479892314445E003FCCF9 /* LabelSwitch.swift */, D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */, + 0103B84D23D7E33A009C315C /* HeadlineBodyToggleModel.swift */, ); path = SwitchMolecules; sourceTree = ""; @@ -1540,6 +1543,7 @@ D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, + 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 75fddd28..9cd96f45 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -14,6 +14,7 @@ public class ToggleModel: MoleculeModelProtocol { public var backgroundColor: Color? public var state: Bool = true public var action: ActionModelProtocol? + public var alternateAction: ActionModelProtocol? public var required: Bool? public var fieldKey: String? @@ -24,6 +25,7 @@ public class ToggleModel: MoleculeModelProtocol { case backgroundColor case required case fieldKey + case alternateAction } public init(_ state: Bool) { @@ -36,6 +38,7 @@ public class ToggleModel: MoleculeModelProtocol { self.state = state } action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) + alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction, typeCodingKey: ActionCodingKey.actionType) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) @@ -45,6 +48,7 @@ public class ToggleModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(action, forKey: .action) + try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(state, forKey: .state) try container.encodeIfPresent(required, forKey: .required) diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift index 79e2a9ec..09432dce 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodySwitch.swift @@ -10,18 +10,18 @@ import UIKit @objcMembers open class HeadlineBodySwitch: View { public let headlineBody = HeadlineBody(frame: .zero) - public let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault() + public let toggle = Toggle() // MARK: - MVMCoreViewProtocol open override func updateView(_ size: CGFloat) { super.updateView(size) headlineBody.updateView(size) - mvmSwitch.updateView(size) + toggle.updateView(size) } open override func setupView() { super.setupView() - guard mvmSwitch.superview == nil else { + guard toggle.superview == nil else { return } headlineBody.styleListItem() @@ -30,8 +30,8 @@ import UIKit NSLayoutConstraint.constraintPinSubview(toSuperview: view) view.addSubview(headlineBody) - view.addSubview(mvmSwitch) - NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: mvmSwitch) + view.addSubview(toggle) + NSLayoutConstraint.pinSubviewsCenter(leftView: headlineBody, rightView: toggle) } @@ -39,6 +39,10 @@ import UIKit open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.setWithModel(model, delegateObject, additionalData) + guard let headlineBodyToggleModel = model as? HeadlineBodyToggleModel else { + return + } + setWithJSON(headlineBodyToggleModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } public class override func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -50,7 +54,7 @@ import UIKit open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData) - mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) + toggle.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData) } open class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { @@ -59,14 +63,14 @@ import UIKit open override func setAsMolecule() { headlineBody.setAsMolecule() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() + (toggle as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() headlineBody.styleListItem() } open override func reset() { super.reset() headlineBody.reset() - (mvmSwitch as MVMCoreUIMoleculeViewProtocol).reset?() + (toggle as MVMCoreUIMoleculeViewProtocol).reset?() headlineBody.styleListItem() } } diff --git a/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift new file mode 100644 index 00000000..dd7c2b1c --- /dev/null +++ b/MVMCoreUI/Molecules/LeftRightViews/SwitchMolecules/HeadlineBodyToggleModel.swift @@ -0,0 +1,22 @@ +// +// HeadlineBodyToggleModel.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 1/21/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +open class HeadlineBodyToggleModel: MoleculeModelProtocol { + public static var identifier: String = "headlineBodyToggle" + open var backgroundColor: Color? + open var headlineBody: HeadlineBodyModel + open var toggle: ToggleModel + + public init(_ headlineBody: HeadlineBodyModel, _ toggle: ToggleModel) { + self.headlineBody = headlineBody + self.toggle = toggle + } +} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 86151cb6..fc22f864 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -15,9 +15,8 @@ import Foundation public var style: String? public var backgroundColor: Color? - public init(headline: LabelModel, body: LabelModel) { + public init(headline: LabelModel) { self.headline = headline - self.body = body } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index b12145f2..2e31a757 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -70,5 +70,6 @@ import Foundation ModelRegistry.register(DoughnutChartModel.self) ModelRegistry.register(NumberedListModel.self) ModelRegistry.register(UnOrderedListModel.self) + ModelRegistry.register(HeadlineBodyToggleModel.self) } }