diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 24108276..ca3ea276 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -40,7 +40,6 @@ D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */; }; D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D296E143229729C30051EBE7 /* MoleculeMappingObject+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D296E142229729C30051EBE7 /* MoleculeMappingObject+Extension.swift */; }; D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; }; D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -50,6 +49,7 @@ D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */; }; D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */; }; D29770FD21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */; }; D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */; }; D29DF11521E6805F003B2FB9 /* UIColor+MFConvenience.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -209,7 +209,6 @@ D28B4F8921FF967C00712C7A /* MVMCoreUIObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIObject.m; sourceTree = ""; }; D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = ""; }; D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = ""; }; - D296E142229729C30051EBE7 /* MoleculeMappingObject+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MoleculeMappingObject+Extension.swift"; sourceTree = ""; }; D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = ""; }; D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = ""; }; D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = ""; }; @@ -219,6 +218,7 @@ D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsAndBottomButtonsViewController.m; sourceTree = ""; }; D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUITextFieldView.m; sourceTree = ""; }; D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUITextFieldView.h; sourceTree = ""; }; + D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleMolecule.swift; sourceTree = ""; }; D29DF0CC21E404D4003B2FB9 /* MVMCoreUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MVMCoreUI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D29DF0CF21E404D4003B2FB9 /* MVMCoreUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUI.h; sourceTree = ""; }; D29DF0D021E404D4003B2FB9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -473,6 +473,7 @@ D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */, B8200E142280C4CF007245F4 /* ProgressBar.swift */, B8200E182281DC1A007245F4 /* ProgressBarWithLabel.swift */, + D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */, ); path = Molecules; sourceTree = ""; @@ -682,7 +683,6 @@ D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */, D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */, D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */, - D296E142229729C30051EBE7 /* MoleculeMappingObject+Extension.swift */, ); path = OtherHandlers; sourceTree = ""; @@ -904,6 +904,7 @@ D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, + D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, DBC4391922442197001AB423 /* DashLine.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, @@ -947,7 +948,6 @@ D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */, D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, - D296E143229729C30051EBE7 /* MoleculeMappingObject+Extension.swift in Sources */, 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 46c6d3f4..4ca750c6 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -139,4 +139,8 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI open func alignment() -> UIStackView.Alignment { return UIStackView.Alignment.leading; } + + public static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 10 + } } diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index 336db92a..e1a6c504 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.m @@ -146,6 +146,10 @@ } } ++ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { + return 31; +} + #pragma mark - MVMCoreUIViewConstrainingProtocol - (BOOL)needsToBeConstrained { diff --git a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m index 74a1e41a..57470bf9 100644 --- a/MVMCoreUI/Atoms/Buttons/PrimaryButton.m +++ b/MVMCoreUI/Atoms/Buttons/PrimaryButton.m @@ -669,6 +669,13 @@ [FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol]; self.primaryButtonType = PrimaryButtonTypeCustom; + NSString *style = [json string:@"style"]; + if ([style isEqualToString:@"primary"]) { + [self setAsStandardCustom]; + } else if ([style isEqualToString:@"secondary"]) { + [self setAsSecondaryCustom]; + } + NSString *color = [json string:@"fillColor"]; if (color) { self.fillColor = [UIColor mfGetColorForHex:color]; @@ -691,7 +698,14 @@ } self.validationRequired = [json boolForKey:@"validationRequired"]; - [self setAsSmallButton:[json boolForKey:@"small"]]; + NSString *size = [json string:@"size"]; + if ([size isEqualToString:@"small"]) { + [self setAsSmallButton:YES]; + } else if ([size isEqualToString:@"tiny"]) { + [self setAsTiny:YES]; + } else { + [self setAsSmallButton:NO]; + } [self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData]; } diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h index 4be970da..377418db 100644 --- a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h +++ b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.h @@ -15,8 +15,6 @@ + (nullable instancetype)mfDigitTextFieldWithNumberOfDigits:(NSUInteger)numberOfDigits withBothDelegates:(nullable id)delegate; + (nullable instancetype)mfDigitTextFieldWithNumberOfDigits:(NSUInteger)numberOfDigits withBothDelegates:(nullable id)delegate size:(CGFloat)size; -- (void)setMessage:(nullable NSString *)message; - - (void)setAsSecureTextEntry:(BOOL)secureTextEntry; @property (nullable, nonatomic, strong) NSArray *textFields; diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m index 084ba338..5f76e88b 100644 --- a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m +++ b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.m @@ -18,33 +18,24 @@ #import "MVMCoreUISplitViewController.h" #import "MVMCoreUIUtility.h" #import "MVMCoreUIConstants.h" +#import @import MVMCore.MVMCoreDispatchUtility; @interface MFDigitTextField () @property (nonatomic) NSUInteger numberOfDigits; -@property (nullable, nonatomic, weak) IBOutlet UILabel *messageLabel; @property (nullable, nonatomic, weak) IBOutlet UIView *textFieldsView; @property (nullable, nonatomic, weak) IBOutlet NSLayoutConstraint *messageToTextFieldPin; @property (nullable, nonatomic, weak) IBOutlet NSLayoutConstraint *labelToTextFieldPin; - @property (nonatomic) BOOL switchedAutomatically; @end @implementation MFDigitTextField -+ (nullable instancetype)mfTextField { - MFDigitTextField *view = [super mfTextField]; - [MFStyler styleLabelB2:view.messageLabel]; - [view setMessage:@""]; - return view; -} - - (MFDigitTextBox *)digitField { - MFDigitTextBox *textField = [[MFDigitTextBox alloc] init]; textField.delegate = self; textField.mfTextBoxDelegate = self; @@ -128,8 +119,9 @@ } - (void)updateView:(CGFloat)size { + [super updateView:size]; [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [MFStyler styleLabelB2:self.messageLabel]; + [self.formLabel updateView:size]; // Remove all current UI. if (self.textFields.count > 0) { @@ -146,6 +138,29 @@ }]; } +- (void)setupView { + [super setupView]; + [self.formLabel styleB2:YES]; + [self setFormText:@""]; + [self alignCenterHorizontal]; +} + +#pragma mark - Molecule + +- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { + NSNumber *digitsNumber = [json optionalNumberForKey:@"digits"]; + NSUInteger digits = digitsNumber ? digitsNumber.integerValue : 4; + if (digits != self.numberOfDigits) { + self.numberOfDigits = digits; + [self buildTextFieldsViewForSize:[MVMCoreUIUtility getWidth]]; + } + [super setWithJSON:json delegateObject:delegateObject additionalData:additionalData]; +} + ++ (CGFloat)estimatedHeightForRow:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject { + return 44; +} + #pragma mark - Getters - (NSString *)placeholder { @@ -172,15 +187,13 @@ #pragma mark - Setters -- (void)setMessage:(nullable NSString *)message { - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - if (message.length > 0) { - self.messageToTextFieldPin.constant = 10; - } else { - self.messageToTextFieldPin.constant = 0; - } - self.messageLabel.text = message; - }]; +- (void)setFormText:(NSString *)formText { + if (formText.length > 0) { + self.messageToTextFieldPin.constant = 10; + } else { + self.messageToTextFieldPin.constant = 0; + } + [super setFormText:formText]; } - (void)setAsSecureTextEntry:(BOOL)secureTextEntry { @@ -284,6 +297,11 @@ - (void)enable:(BOOL)enable { [super enable:enable]; + if (enable) { + [self.formLabel styleB2:YES]; + } else { + self.formLabel.textColor = [UIColor mfBattleshipGrey]; + } for (UITextField *textField in self.textFields) { textField.userInteractionEnabled = enable; textField.enabled = enable; diff --git a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.xib b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.xib index 1792b9f8..37e6609b 100644 --- a/MVMCoreUI/Atoms/TextFields/MFDigitTextField.xib +++ b/MVMCoreUI/Atoms/TextFields/MFDigitTextField.xib @@ -1,24 +1,19 @@ - + - + - - - NHaasGroteskDSStd-65Md - - + - @@ -28,7 +23,7 @@ -