Merge branch 'develop' into feature/kevin
# Conflicts: # MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift
This commit is contained in:
commit
2ec2c2b0b8
@ -324,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;
|
||||
}
|
||||
|
||||
@ -20,7 +20,8 @@
|
||||
|
||||
static const CGFloat FaultTolerance = 20.f;
|
||||
static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
@interface MVMCoreUICheckBox ()
|
||||
|
||||
@interface MVMCoreUICheckBox () <FormValidationProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
@property (nonatomic, readwrite) BOOL isSelected;
|
||||
@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 *checkboxHeight;
|
||||
|
||||
@property (nonatomic) BOOL isRequired;
|
||||
@property (nullable, strong, nonatomic) NSString *fieldKey;
|
||||
@property (nullable, strong, nonatomic) DelegateObject *delegate;
|
||||
|
||||
@end
|
||||
|
||||
@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
|
||||
|
||||
+ (instancetype)mfCheckBox {
|
||||
@ -69,8 +105,33 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
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
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCheckedColor:(UIColor *)checkedColor unCheckColor:(UIColor *)unCheckedColor text:(NSString *)text {
|
||||
if (self = [super init]) {
|
||||
[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 {
|
||||
[self setupView];
|
||||
if (checkedColor) {
|
||||
self.checkedColor = checkedColor;
|
||||
}
|
||||
if (unCheckedColor) {
|
||||
self.unCheckedColor = unCheckedColor;
|
||||
}
|
||||
[self setupWithCheckedColor:checkedColor unCheckColor:unCheckedColor];
|
||||
[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 {
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
[self.descriptionLabel updateView:size];
|
||||
@ -254,7 +323,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
[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.isSelected = selected;
|
||||
@ -272,6 +341,9 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
||||
} completion:nil];
|
||||
[self.checkMark updateCheckSelected:NO animated:animated];
|
||||
}
|
||||
|
||||
FormValidator *formValidator = ((MVMCoreUIDelegateObject *)self.delegate).formValidationProtocol.formValidatorModel;
|
||||
[formValidator enableByValidation];
|
||||
}
|
||||
|
||||
- (void)setColor:(nullable UIColor *)color forState:(UIControlState)state {
|
||||
|
||||
@ -44,13 +44,13 @@
|
||||
// Pins all edges to its super. 0 constant
|
||||
- (void)pinToSuperView;
|
||||
|
||||
// Add a view to be constrained in this view.
|
||||
- (void)addConstrainedView:(nonnull UIView *)view;
|
||||
|
||||
// Resets all the constraints to default.
|
||||
- (void)resetConstraints;
|
||||
|
||||
// For setting up the view.
|
||||
- (void)setupView;
|
||||
|
||||
// Add a view to be constrained in this view.
|
||||
- (void)addConstrainedView:(nonnull UIView *)view;
|
||||
|
||||
@end
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
+ (nonnull ViewConstrainingView *)viewConstrainingView:(UIView *)view {
|
||||
ViewConstrainingView *constrainingView = [[ViewConstrainingView alloc] initWithFrame:CGRectZero];
|
||||
constrainingView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
@ -52,7 +52,7 @@
|
||||
self.bottomPin = dictionary[ConstraintBot];
|
||||
self.rightPin = dictionary[ConstraintTrailing];
|
||||
}
|
||||
|
||||
|
||||
- (void)setPinConstantsWithInsets:(UIEdgeInsets)insets {
|
||||
[self setTopPinConstant:insets.top left:insets.left bottom:insets.bottom right:insets.right];
|
||||
}
|
||||
|
||||
@ -25,6 +25,9 @@
|
||||
// true while 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 ..
|
||||
@property (nonatomic) BOOL interactive;
|
||||
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
|
||||
#import "MFTabBarInteractor.h"
|
||||
|
||||
static CGFloat pannablePercentage = 0.15;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MFTabBarPanningDirection) {
|
||||
MFTabBarPanningDirectionLeft,
|
||||
MFTabBarPanningDirectionRight
|
||||
@ -33,6 +31,7 @@ typedef NS_ENUM(NSUInteger, MFTabBarPanningDirection) {
|
||||
|
||||
- (nullable instancetype)initWithViewController:(nullable UIViewController *)viewController delegate:(nullable id<MFSwipeNavigationProtocol>)delegate {
|
||||
if (self = [super init]) {
|
||||
self.pannablePercentage = 0.15;
|
||||
self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
|
||||
[viewController.view addGestureRecognizer:self.panGesture];
|
||||
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.
|
||||
CGRect frame = pan.view.frame;
|
||||
CGRect pannableFrameLeft = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width*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 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-self.pannablePercentage), frame.origin.y, frame.size.width*self.pannablePercentage, frame.size.height);
|
||||
|
||||
switch (pan.state) {
|
||||
case UIGestureRecognizerStateBegan:
|
||||
|
||||
@ -22,6 +22,6 @@ import Foundation
|
||||
// The Field name key value pair for sending to server
|
||||
@objc optional func formFieldName() -> String?
|
||||
|
||||
// The Feild value key value paid for sending to server
|
||||
@objc optional func formFieldValue() -> String?
|
||||
// The Field value key value pair for sending to server
|
||||
@objc optional func formFieldValue() -> Any?
|
||||
}
|
||||
|
||||
@ -32,7 +32,8 @@
|
||||
@"standardFooter": StandardFooterView.class,
|
||||
@"caretView": CaretView.class,
|
||||
@"caretButton": CaretButton.class,
|
||||
@"textField" : MFTextField.class
|
||||
@"textField" : MFTextField.class,
|
||||
@"checkbox" : MVMCoreUICheckBox.class
|
||||
} mutableCopy];
|
||||
});
|
||||
return mapping;
|
||||
|
||||
@ -38,6 +38,9 @@ extern NSString * const KeyTextColor;
|
||||
extern NSString * const KeyIsHidden;
|
||||
extern NSString * const KeyIsOpaque;
|
||||
|
||||
extern NSString * const KeyFieldKey;
|
||||
extern NSString * const KeyRequired;
|
||||
|
||||
#pragma mark - Values
|
||||
|
||||
extern NSString * const StringY;
|
||||
|
||||
@ -21,6 +21,8 @@ NSString * const KeyValue = @"value";
|
||||
NSString * const KeyLabel = @"label";
|
||||
NSString * const KeyDisable = @"disable";
|
||||
NSString * const KeyFieldName = @"fieldName";
|
||||
NSString * const KeyFieldKey = @"fieldKey";
|
||||
NSString * const KeyRequired = @"required";
|
||||
|
||||
NSString * const KeyHideMainMenu = @"hideMainMenu";
|
||||
NSString * const KeyProgressPercent = @"progressPercent";
|
||||
@ -37,6 +39,7 @@ NSString * const KeyTextColor = @"textColor";
|
||||
NSString * const KeyIsHidden = @"isHidden";
|
||||
NSString * const KeyIsOpaque = @"isOpaque";
|
||||
|
||||
|
||||
#pragma mark - Values
|
||||
|
||||
NSString * const StringY = @"Y";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user