Merge branch 'develop' into feature/kevin

# Conflicts:
#	MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift
This commit is contained in:
Christiano, Kevin 2019-05-01 15:47:46 -04:00
commit 2ec2c2b0b8
10 changed files with 103 additions and 22 deletions

View File

@ -324,7 +324,7 @@
} }
// key used to send text value to server // key used to send text value to server
string = [map string:@"fieldKey"]; string = [map string:KeyFieldKey];
if (string.length > 0) { if (string.length > 0) {
self.fieldKey = string; self.fieldKey = string;
} }

View File

@ -20,7 +20,8 @@
static const CGFloat FaultTolerance = 20.f; static const CGFloat FaultTolerance = 20.f;
static const CGFloat CheckBoxHeightWidth = 18.0; static const CGFloat CheckBoxHeightWidth = 18.0;
@interface MVMCoreUICheckBox ()
@interface MVMCoreUICheckBox () <FormValidationProtocol, MVMCoreUIMoleculeViewProtocol>
@property (nonatomic, readwrite) BOOL isSelected; @property (nonatomic, readwrite) BOOL isSelected;
@property (weak, nonatomic) UIView *checkedSquare; @property (weak, nonatomic) UIView *checkedSquare;
@ -39,10 +40,45 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
@property (nullable, strong, nonatomic) NSLayoutConstraint *checkboxWidth; @property (nullable, strong, nonatomic) NSLayoutConstraint *checkboxWidth;
@property (nullable, strong, nonatomic) NSLayoutConstraint *checkboxHeight; @property (nullable, strong, nonatomic) NSLayoutConstraint *checkboxHeight;
@property (nonatomic) BOOL isRequired;
@property (nullable, strong, nonatomic) NSString *fieldKey;
@property (nullable, strong, nonatomic) DelegateObject *delegate;
@end @end
@implementation MVMCoreUICheckBox @implementation MVMCoreUICheckBox
#pragma mark - MVMCoreUIMoleculeViewProtocol
- (BOOL)needsToBeConstrained {
return YES;
}
- (UIStackViewAlignment)moleculeAlignment {
return UIStackViewAlignmentLeading;
}
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
self.delegate = delegateObject;
self.fieldKey = [json stringForKey:KeyFieldKey];
self.isRequired = [json boolForKey:KeyRequired];
NSString *checkedColorHex = [json string:@"checkedColor"];
NSString *unCheckedColorHex = [json string:@"unCheckedColor"];
UIColor *checkedColor = checkedColorHex ? [UIColor mfGetColorForHex:checkedColorHex]: [UIColor blackColor];
UIColor *unCheckedColor = unCheckedColorHex ? [UIColor mfGetColorForHex:unCheckedColorHex]: [UIColor clearColor];
[self setupWithCheckedColor:checkedColor
unCheckColor:unCheckedColor
label:[json dict:KeyLabel]
delegateObject:delegateObject
additionalData: additionalData];
}
#pragma mark - convenient class methods #pragma mark - convenient class methods
+ (instancetype)mfCheckBox { + (instancetype)mfCheckBox {
@ -69,8 +105,33 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
return checkBox; return checkBox;
} }
#pragma mark - FormValidationProtocol
- (BOOL)isValidField {
if (self.isRequired) {
return self.isSelected;
}
return true;
}
- (nullable NSString *)formFieldName {
return self.fieldKey;
}
- (nullable id)formFieldValue {
return @(self.isSelected);
}
#pragma mark - inits #pragma mark - inits
- (instancetype)init {
self = [super init];
if (self) {
[self setupView];
}
return self;
}
- (instancetype)initWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor text:(NSString *)text { - (instancetype)initWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor text:(NSString *)text {
if (self = [super init]) { if (self = [super init]) {
[self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor text:text]; [self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor text:text];
@ -207,17 +268,25 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
} }
} }
- (void)setupWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor {
if (checkedColor) {
self.checkedColor = checkedColor;
}
if (unCheckedColor) {
self.unCheckedColor = unCheckedColor;
}
}
- (void)setupWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor text:(NSString *)text { - (void)setupWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor text:(NSString *)text {
[self setupView]; [self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor];
if (checkedColor) {
self.checkedColor = checkedColor;
}
if (unCheckedColor) {
self.unCheckedColor = unCheckedColor;
}
[self setDescriptionText:text]; [self setDescriptionText:text];
} }
- (void)setupWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor label:(NSDictionary *)labelJson delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
[self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor];
[self.descriptionLabel setWithJSON:labelJson delegateObject:delegateObject additionalData:additionalData];
}
- (void)updateView:(CGFloat)size { - (void)updateView:(CGFloat)size {
[MVMCoreDispatchUtility performBlockOnMainThread:^{ [MVMCoreDispatchUtility performBlockOnMainThread:^{
[self.descriptionLabel updateView:size]; [self.descriptionLabel updateView:size];
@ -254,7 +323,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
[self setSelected:selected animated:animated runBlock:YES]; [self setSelected:selected animated:animated runBlock:YES];
} }
- (void)setSelected:(BOOL)selected animated:(BOOL)animated runBlock:(BOOL)runBlock{ - (void)setSelected:(BOOL)selected animated:(BOOL)animated runBlock:(BOOL)runBlock {
[self addAccessibilityLabel:selected]; [self addAccessibilityLabel:selected];
self.isSelected = selected; self.isSelected = selected;
@ -272,6 +341,9 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
} completion:nil]; } completion:nil];
[self.checkMark updateCheckSelected:NO animated:animated]; [self.checkMark updateCheckSelected:NO animated:animated];
} }
FormValidator *formValidator = ((MVMCoreUIDelegateObject *)self.delegate).formValidationProtocol.formValidatorModel;
[formValidator enableByValidation];
} }
- (void)setColor:(nullable UIColor *)color forState:(UIControlState)state { - (void)setColor:(nullable UIColor *)color forState:(UIControlState)state {

View File

@ -44,13 +44,13 @@
// Pins all edges to its super. 0 constant // Pins all edges to its super. 0 constant
- (void)pinToSuperView; - (void)pinToSuperView;
// Add a view to be constrained in this view.
- (void)addConstrainedView:(nonnull UIView *)view;
// Resets all the constraints to default. // Resets all the constraints to default.
- (void)resetConstraints; - (void)resetConstraints;
// For setting up the view. // For setting up the view.
- (void)setupView; - (void)setupView;
// Add a view to be constrained in this view.
- (void)addConstrainedView:(nonnull UIView *)view;
@end @end

View File

@ -25,6 +25,9 @@
// true while panning // true while panning
@property (nonatomic) BOOL panning; @property (nonatomic) BOOL panning;
//set pannable percentage 0 to 1
@property (nonatomic) CGFloat pannablePercentage;
// can be used to keep track of if we are .. // can be used to keep track of if we are ..
@property (nonatomic) BOOL interactive; @property (nonatomic) BOOL interactive;

View File

@ -8,8 +8,6 @@
#import "MFTabBarInteractor.h" #import "MFTabBarInteractor.h"
static CGFloat pannablePercentage = 0.15;
typedef NS_ENUM(NSUInteger, MFTabBarPanningDirection) { typedef NS_ENUM(NSUInteger, MFTabBarPanningDirection) {
MFTabBarPanningDirectionLeft, MFTabBarPanningDirectionLeft,
MFTabBarPanningDirectionRight MFTabBarPanningDirectionRight
@ -33,6 +31,7 @@ typedef NS_ENUM(NSUInteger, MFTabBarPanningDirection) {
- (nullable instancetype)initWithViewController:(nullable UIViewController *)viewController delegate:(nullable id<MFSwipeNavigationProtocol>)delegate { - (nullable instancetype)initWithViewController:(nullable UIViewController *)viewController delegate:(nullable id<MFSwipeNavigationProtocol>)delegate {
if (self = [super init]) { if (self = [super init]) {
self.pannablePercentage = 0.15;
self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)]; self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[viewController.view addGestureRecognizer:self.panGesture]; [viewController.view addGestureRecognizer:self.panGesture];
self.delegate = delegate; self.delegate = delegate;
@ -48,8 +47,8 @@ typedef NS_ENUM(NSUInteger, MFTabBarPanningDirection) {
// Simulates an edge gesture by only accepting pans at the edge of the screen. Needed because edge gesture doesn't work nicely with extended menus such as on ipad. // Simulates an edge gesture by only accepting pans at the edge of the screen. Needed because edge gesture doesn't work nicely with extended menus such as on ipad.
CGRect frame = pan.view.frame; CGRect frame = pan.view.frame;
CGRect pannableFrameLeft = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width*pannablePercentage, frame.size.height); CGRect pannableFrameLeft = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width*self.pannablePercentage, frame.size.height);
CGRect pannableFrameRight = CGRectMake(frame.origin.x + frame.size.width*(1-pannablePercentage), frame.origin.y, frame.size.width*pannablePercentage, frame.size.height); CGRect pannableFrameRight = CGRectMake(frame.origin.x + frame.size.width*(1-self.pannablePercentage), frame.origin.y, frame.size.width*self.pannablePercentage, frame.size.height);
switch (pan.state) { switch (pan.state) {
case UIGestureRecognizerStateBegan: case UIGestureRecognizerStateBegan:

View File

@ -22,6 +22,6 @@ import Foundation
// The Field name key value pair for sending to server // The Field name key value pair for sending to server
@objc optional func formFieldName() -> String? @objc optional func formFieldName() -> String?
// The Feild value key value paid for sending to server // The Field value key value pair for sending to server
@objc optional func formFieldValue() -> String? @objc optional func formFieldValue() -> Any?
} }

View File

@ -32,7 +32,8 @@
@"standardFooter": StandardFooterView.class, @"standardFooter": StandardFooterView.class,
@"caretView": CaretView.class, @"caretView": CaretView.class,
@"caretButton": CaretButton.class, @"caretButton": CaretButton.class,
@"textField" : MFTextField.class @"textField" : MFTextField.class,
@"checkbox" : MVMCoreUICheckBox.class
} mutableCopy]; } mutableCopy];
}); });
return mapping; return mapping;

View File

@ -38,6 +38,9 @@ extern NSString * const KeyTextColor;
extern NSString * const KeyIsHidden; extern NSString * const KeyIsHidden;
extern NSString * const KeyIsOpaque; extern NSString * const KeyIsOpaque;
extern NSString * const KeyFieldKey;
extern NSString * const KeyRequired;
#pragma mark - Values #pragma mark - Values
extern NSString * const StringY; extern NSString * const StringY;

View File

@ -21,6 +21,8 @@ NSString * const KeyValue = @"value";
NSString * const KeyLabel = @"label"; NSString * const KeyLabel = @"label";
NSString * const KeyDisable = @"disable"; NSString * const KeyDisable = @"disable";
NSString * const KeyFieldName = @"fieldName"; NSString * const KeyFieldName = @"fieldName";
NSString * const KeyFieldKey = @"fieldKey";
NSString * const KeyRequired = @"required";
NSString * const KeyHideMainMenu = @"hideMainMenu"; NSString * const KeyHideMainMenu = @"hideMainMenu";
NSString * const KeyProgressPercent = @"progressPercent"; NSString * const KeyProgressPercent = @"progressPercent";
@ -37,6 +39,7 @@ NSString * const KeyTextColor = @"textColor";
NSString * const KeyIsHidden = @"isHidden"; NSString * const KeyIsHidden = @"isHidden";
NSString * const KeyIsOpaque = @"isOpaque"; NSString * const KeyIsOpaque = @"isOpaque";
#pragma mark - Values #pragma mark - Values
NSString * const StringY = @"Y"; NSString * const StringY = @"Y";