diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 8a2e4453..83b51092 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -96,8 +96,6 @@ D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */; }; D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF28921E7AC2B003B2FB9 /* MFLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28521E7AC2B003B2FB9 /* MFLabel.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28621E7AC2B003B2FB9 /* MFLabel.m */; }; D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */; }; D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */; }; @@ -157,10 +155,15 @@ 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 /* MVMCoreUIDelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */; }; + D2E1FADD2268B25E00AEFD8C /* MoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */; }; + D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; }; + D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.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 */; }; DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */; }; + DBEFFA04225A829700230692 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -262,8 +265,6 @@ D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIDetailViewProtocol.h; sourceTree = ""; }; D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICommonViewsUtility.m; sourceTree = ""; }; D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICommonViewsUtility.h; sourceTree = ""; }; - D29DF28521E7AC2B003B2FB9 /* MFLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLabel.h; sourceTree = ""; }; - D29DF28621E7AC2B003B2FB9 /* MFLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLabel.m; sourceTree = ""; }; D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewConstrainingView.h; sourceTree = ""; }; D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewConstrainingView.m; sourceTree = ""; }; D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProgrammaticScrollViewController.m; sourceTree = ""; }; @@ -317,6 +318,11 @@ 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 /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = ""; }; + DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; + D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = ""; }; + D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = ""; }; + D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.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 = ""; }; @@ -405,6 +411,7 @@ 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */, + D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */, ); path = Templates; sourceTree = ""; @@ -440,6 +447,7 @@ D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */, D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */, D274CA322236A78900B01B62 /* StandardFooterView.swift */, + D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */, ); path = Molecules; sourceTree = ""; @@ -460,6 +468,7 @@ D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */, D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */, + D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */, ); path = BaseControllers; sourceTree = ""; @@ -562,8 +571,6 @@ DBC4391722442197001AB423 /* DashLine.swift */, D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17F21E69E2E003B2FB9 /* MFView.m */, - D29DF28521E7AC2B003B2FB9 /* MFLabel.h */, - D29DF28621E7AC2B003B2FB9 /* MFLabel.m */, D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */, @@ -588,6 +595,7 @@ D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */, D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */, DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */, + DB891E822253FA8500022516 /* Label.swift */, 0198F7A02256A80A0066C936 /* MFRadioButton.h */, 0198F7A22256A80A0066C936 /* MFRadioButton.m */, ); @@ -634,6 +642,7 @@ D29DF27021E79B2C003B2FB9 /* OtherHandlers */ = { isa = PBXGroup; children = ( + D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */, D28B4F8821FF967C00712C7A /* MVMCoreUIObject.h */, D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */, D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */, @@ -742,7 +751,6 @@ D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */, D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */, D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */, - D29DF28921E7AC2B003B2FB9 /* MFLabel.h in Headers */, D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */, D29DF25021E6A177003B2FB9 /* MFDigitTextBox.h in Headers */, D29DF2C621E7BF57003B2FB9 /* MFTabBarInteractor.h in Headers */, @@ -865,6 +873,7 @@ D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, + D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */, D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, @@ -887,12 +896,14 @@ D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */, + DBEFFA04225A829700230692 /* Label.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */, + D2E1FADD2268B25E00AEFD8C /* MoleculeTableViewCell.swift in Sources */, D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */, D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, @@ -900,7 +911,6 @@ D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, - D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */, D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, @@ -909,6 +919,7 @@ D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, + D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, @@ -916,6 +927,7 @@ 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */, D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */, D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */, + D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 7d67afb1..0176b147 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -8,13 +8,14 @@ // -open class CaretButton: MFCustomButton { +open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol { //------------------------------------------------------ // MARK: - Constants //------------------------------------------------------ - private let CaretViewHeight: Float = 10.8 - private let CaretViewWidth: Float = 6.6 + private let CARET_VIEW_HEIGHT: Float = 10.5 + private let CARET_VIEW_WIDTH: Float = 6.5 + //------------------------------------------------------ // MARK: - Properties @@ -25,17 +26,11 @@ open class CaretButton: MFCustomButton { @objc public var rightViewWidth: NSNumber? @objc public var enabledColor: UIColor = .black { - didSet { - setTitleColor(enabledColor, for: .normal) - changeCaretColor() - } + didSet { changeCaretColor() } } @objc public var disabledColor: UIColor = .mfSilver() { - didSet { - setTitleColor(disabledColor, for: .disabled) - changeCaretColor() - } + didSet { changeCaretColor() } } private var caretSpacingConstraint: NSLayoutConstraint? @@ -61,9 +56,11 @@ open class CaretButton: MFCustomButton { //------------------------------------------------------ private func changeCaretColor() { - + setTitleColor(enabledColor, for: .normal) + setTitleColor(disabledColor, for: .disabled) + if let rightCaretView = rightView as? CaretView { - rightCaretView.tintColor = isEnabled ? enabledColor : disabledColor + rightCaretView.setLineColor(isEnabled ? enabledColor : disabledColor) } } @@ -71,8 +68,8 @@ open class CaretButton: MFCustomButton { rightView?.removeFromSuperview() - let width = CGFloat(rightViewWidth?.floatValue ?? CaretViewWidth) - let height = CGFloat(rightViewHeight?.floatValue ?? CaretViewHeight) + let width = CGFloat(rightViewWidth?.floatValue ?? CARET_VIEW_WIDTH) + let height = CGFloat(rightViewHeight?.floatValue ?? CARET_VIEW_HEIGHT) let edgeInsets: UIEdgeInsets = contentEdgeInsets contentEdgeInsets = UIEdgeInsets(top: edgeInsets.top, left: edgeInsets.left, bottom: edgeInsets.bottom, right: 4 + width) @@ -106,15 +103,15 @@ 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]?) { - setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) + @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData) guard let dictionary = json else { return } @@ -130,4 +127,12 @@ open class CaretButton: MFCustomButton { disabledColor = UIColor.mfGet(forHex: disabledColorHex) } } + + public func needsToBeConstrained() -> Bool { + return true + } + + open func moleculeAlignment() -> UIStackView.Alignment { + return UIStackView.Alignment.leading; + } } diff --git a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h index 21236e70..9d08883d 100644 --- a/MVMCoreUI/Atoms/Buttons/MFCustomButton.h +++ b/MVMCoreUI/Atoms/Buttons/MFCustomButton.h @@ -11,14 +11,14 @@ #import #import #import -@import MVMCore.MVMCoreViewProtocol; +@class DelegateObject; 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 DelegateObject *)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..1610f42b 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,54 @@ CGFloat const CloseButtonWidth = 40.0f; } } +- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable DelegateObject *)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]]; + + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + self.buttonDelegate = ((MVMCoreUIDelegateObject *)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 +102,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 +135,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/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index ff4c372c..d78df33d 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 { @@ -141,4 +141,12 @@ } } +- (BOOL)needsToBeConstrained { + return YES; +} + +- (UIStackViewAlignment)moleculeAlignment { + return UIStackViewAlignmentLeading; +} + @end 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/TextFields/MFTextField.h b/MVMCoreUI/Atoms/TextFields/MFTextField.h index 81b4059f..27dd8414 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.h @@ -11,7 +11,7 @@ @class PrimaryButton; @class MFTextField; -@class MFLabel; +@class Label; @protocol MFTextFieldDelegate @@ -34,7 +34,7 @@ @property (nullable, weak, nonatomic) IBOutlet UIView *textFieldContainerView; @property (nullable, weak, nonatomic) IBOutlet UITextField *textField; -@property (nullable, weak, nonatomic) IBOutlet MFLabel *formLabel; +@property (nullable, weak, nonatomic) IBOutlet Label *formLabel; @property (nullable, weak, nonatomic) IBOutlet UIView *separatorView;//make it public so outsider class can know the posistion of it. @property (nullable, weak, nonatomic) IBOutlet NSLayoutConstraint *heightConstraint; diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.m b/MVMCoreUI/Atoms/TextFields/MFTextField.m index 565e086c..33224f8a 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.m @@ -7,12 +7,10 @@ // #import "MFTextField.h" -#import #import "MFTextFieldSubclassExtension.h" #import "MFStyler.h" #import "UIColor+MFConvenience.h" #import "MVMCoreUICommonViewsUtility.h" -#import "MFLabel.h" #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" #import @@ -116,7 +114,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 setWithMap:map bothDelegates:delegate]; return textField; } @@ -326,7 +324,7 @@ } // key used to send text value to server - string = [map string:@"fieldKey"]; + string = [map string:KeyFieldKey]; if (string.length > 0) { self.fieldKey = string; } @@ -558,10 +556,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 diff --git a/MVMCoreUI/Atoms/TextFields/MFTextField.xib b/MVMCoreUI/Atoms/TextFields/MFTextField.xib index b60f1ff3..e839533f 100644 --- a/MVMCoreUI/Atoms/TextFields/MFTextField.xib +++ b/MVMCoreUI/Atoms/TextFields/MFTextField.xib @@ -1,11 +1,11 @@ - + - + @@ -98,7 +98,7 @@ -