moving_radio_button
This commit is contained in:
parent
62fe21a9d3
commit
5d46f8c0d4
@ -11,6 +11,8 @@
|
||||
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 */; };
|
||||
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; };
|
||||
0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; };
|
||||
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; };
|
||||
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; };
|
||||
01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -167,6 +169,8 @@
|
||||
0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = "<group>"; };
|
||||
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = "<group>"; };
|
||||
0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = "<group>"; };
|
||||
0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = "<group>"; };
|
||||
0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = "<group>"; };
|
||||
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = "<group>"; };
|
||||
01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = "<group>"; };
|
||||
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
|
||||
@ -587,6 +591,8 @@
|
||||
D22D1F19220341F50077CEC0 /* MVMCoreUICheckBox.m */,
|
||||
D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */,
|
||||
D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */,
|
||||
0198F7A02256A80A0066C936 /* MFRadioButton.h */,
|
||||
0198F7A22256A80A0066C936 /* MFRadioButton.m */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -715,6 +721,7 @@
|
||||
D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */,
|
||||
D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */,
|
||||
D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */,
|
||||
0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */,
|
||||
D29DF25221E6A177003B2FB9 /* MFMdnTextField.h in Headers */,
|
||||
D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */,
|
||||
D29DF29921E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h in Headers */,
|
||||
@ -920,6 +927,7 @@
|
||||
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
|
||||
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
|
||||
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
|
||||
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
|
||||
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
|
||||
D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */,
|
||||
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,
|
||||
|
||||
89
MVMCoreUI/Atoms/Views/MFRadioButton.h
Normal file
89
MVMCoreUI/Atoms/Views/MFRadioButton.h
Normal file
@ -0,0 +1,89 @@
|
||||
//
|
||||
// MFRadioButton.h
|
||||
// MobileFirstFramework
|
||||
//
|
||||
// Created by Seshamani, Shreyas on 12/14/17.
|
||||
// Copyright © 2017 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCore/MVMCoreViewProtocol.h>
|
||||
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
ButtonSizeSmall,//24
|
||||
ButtonSizeSmall1,//30
|
||||
ButtonSizeSmall2,//36
|
||||
ButtonSizeMedium,//48
|
||||
ButtonSizeLarge,//60
|
||||
ButtonSizeExtraLarge,//96
|
||||
} ButtonSize;
|
||||
|
||||
@interface MFRadioButton : UIView <MVMCoreViewProtocol>
|
||||
|
||||
|
||||
// THESE ARE JUST DUMMY APIS. They will be deleted later!!!!
|
||||
|
||||
typedef void (^PerformActionForRadioButton)(void);
|
||||
|
||||
/* perform action for accessibility action*/
|
||||
@property (nullable, copy, nonatomic) PerformActionForRadioButton performActionForCheck;
|
||||
typedef void (^CircleSelectedClosure)(_Nonnull id sender);
|
||||
|
||||
|
||||
@property (nonatomic, strong, nullable) UIColor* fillColor;
|
||||
@property (nonatomic, strong, nullable) UIColor* borderColor;
|
||||
@property (nonatomic) CGFloat circleBorderWidth;
|
||||
@property (nonatomic, copy, nullable) CircleSelectedClosure circleSelectedBlock;
|
||||
@property (nonatomic, copy, nullable) CircleSelectedClosure handleSelectionBlock;
|
||||
@property (nonatomic) CGFloat circleDiameter;
|
||||
@property (nonatomic, nullable, strong, readonly) CAShapeLayer * myCircle;
|
||||
|
||||
@property (nonatomic, strong, nullable) NSLayoutConstraint *heightConstraint;
|
||||
@property (nonatomic, strong, nullable) NSLayoutConstraint *widthConstraint;
|
||||
@property (nonatomic) BOOL respondsToTapGesture;
|
||||
@property (nonatomic, getter = isSelected) BOOL selected;
|
||||
|
||||
// Set line width manually
|
||||
- (void)setCheckMarkLineWidth:(CGFloat)lineWidth;
|
||||
|
||||
// Determine and set line width based on circle diameter
|
||||
- (void)calculateAndSetCheckMarkLineWidth;
|
||||
|
||||
- (void)setCheckMarkColor:(nullable UIColor *)color;
|
||||
|
||||
-(void)animateCheckMark;
|
||||
|
||||
-(void)drawCheckMarkWithoutAnimation;
|
||||
|
||||
-(void)animateSelect:(nullable UIColor *)fillColor BorderColor:(nullable UIColor *)borderColor;
|
||||
|
||||
- (void)addAccessibilityInformationIndex:(NSUInteger)index Total:(NSUInteger)totalCount;
|
||||
|
||||
#pragma mark - Convenience
|
||||
|
||||
/* Adds the border with the set border color and SelectableCircleBorderWidth */
|
||||
- (void)addBorder;
|
||||
|
||||
/* Removes the border */
|
||||
- (void)removeBorder;
|
||||
|
||||
/* Checks if the fill color is white*/
|
||||
- (BOOL)isFillColorWhite;
|
||||
|
||||
/* Resize the circle for animations */
|
||||
-(void)resize:(ButtonSize)newSize;
|
||||
|
||||
/* Deselect circle without calling blocks */
|
||||
- (void)cancelSelection;
|
||||
|
||||
/* Disable the outer view */
|
||||
- (void)disableState;
|
||||
|
||||
/* Enable outer view */
|
||||
- (void)enableState;
|
||||
|
||||
#pragma mark - Animation
|
||||
-(void)animateOutline:(nonnull UIColor *)strokeColor IsSelected:(BOOL)selected;
|
||||
|
||||
@end
|
||||
178
MVMCoreUI/Atoms/Views/MFRadioButton.m
Normal file
178
MVMCoreUI/Atoms/Views/MFRadioButton.m
Normal file
@ -0,0 +1,178 @@
|
||||
//
|
||||
// MFRadioButton.m
|
||||
// MobileFirstFramework
|
||||
//
|
||||
// Created by Seshamani, Shreyas on 12/14/17.
|
||||
// Copyright © 2017 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MFRadioButton.h"
|
||||
#import <MVMCoreUI/UIColor+MFConvenience.h>
|
||||
|
||||
static CGFloat const DefaultOuterCircleSize = 31;
|
||||
static CGFloat const DefaultInnerCircleSize = 19;
|
||||
|
||||
@interface MFRadioButton ()
|
||||
@property (nullable, weak, nonatomic) UIView *outerCircleView;
|
||||
@property (nullable, weak, nonatomic) UIView *innerCircleView;
|
||||
@end
|
||||
|
||||
|
||||
@implementation MFRadioButton
|
||||
|
||||
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
|
||||
if (self = [super initWithCoder:aDecoder]) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
|
||||
if (self = [super init]) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)updateView:(CGFloat)size {
|
||||
|
||||
}
|
||||
|
||||
- (void)setupView {
|
||||
|
||||
if (!self.outerCircleView && !self.innerCircleView) {
|
||||
|
||||
UIView *outerCircleView = [[UIView alloc] init];
|
||||
[self addSubview:outerCircleView];
|
||||
outerCircleView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
outerCircleView.layer.borderColor = [UIColor grayColor].CGColor;
|
||||
outerCircleView.layer.borderWidth = 2.0;
|
||||
|
||||
[outerCircleView.topAnchor constraintEqualToAnchor:self.topAnchor].active = YES;
|
||||
[outerCircleView.leftAnchor constraintEqualToAnchor:self.leftAnchor].active = YES;
|
||||
[outerCircleView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor].active = YES;
|
||||
[outerCircleView.rightAnchor constraintEqualToAnchor:self.rightAnchor].active = YES;
|
||||
|
||||
[outerCircleView.widthAnchor constraintEqualToConstant:DefaultOuterCircleSize].active = YES;
|
||||
[outerCircleView.heightAnchor constraintEqualToConstant:DefaultOuterCircleSize].active = YES;
|
||||
|
||||
UIView *innerCircleView = [[UIView alloc] init];
|
||||
[outerCircleView addSubview:innerCircleView];
|
||||
innerCircleView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
innerCircleView.backgroundColor = [UIColor blackColor];
|
||||
innerCircleView.hidden = YES;
|
||||
|
||||
[innerCircleView.centerXAnchor constraintEqualToAnchor:outerCircleView.centerXAnchor].active = YES;
|
||||
[innerCircleView.centerYAnchor constraintEqualToAnchor:outerCircleView.centerYAnchor].active = YES;
|
||||
[innerCircleView.widthAnchor constraintEqualToConstant:DefaultInnerCircleSize].active = YES;
|
||||
[innerCircleView.heightAnchor constraintEqualToConstant:DefaultInnerCircleSize].active = YES;
|
||||
|
||||
outerCircleView.userInteractionEnabled = NO;
|
||||
innerCircleView.userInteractionEnabled = NO;
|
||||
|
||||
outerCircleView.layer.cornerRadius = DefaultOuterCircleSize/2;
|
||||
innerCircleView.layer.cornerRadius = DefaultInnerCircleSize/2;
|
||||
|
||||
self.outerCircleView = outerCircleView;
|
||||
self.innerCircleView = innerCircleView;
|
||||
|
||||
self.isAccessibilityElement = YES;
|
||||
}
|
||||
}
|
||||
|
||||
//- (BOOL)isSelected {
|
||||
// return self.selected;
|
||||
//}
|
||||
|
||||
- (void)setSelected:(BOOL)selected {
|
||||
self.innerCircleView.hidden = !selected;
|
||||
_selected = selected;
|
||||
}
|
||||
|
||||
/* Disable outer view */
|
||||
- (void)disableState {
|
||||
self.outerCircleView.layer.borderColor = [UIColor mfLightSilver].CGColor;
|
||||
}
|
||||
|
||||
/* Enable the outer view */
|
||||
- (void)enableState {
|
||||
self.outerCircleView.layer.borderColor = [UIColor grayColor].CGColor;
|
||||
}
|
||||
|
||||
#pragma mark - DUMMMIES
|
||||
|
||||
// Set line width manually
|
||||
- (void)setCheckMarkLineWidth:(CGFloat)lineWidth {}
|
||||
|
||||
// Determine and set line width based on circle diameter
|
||||
- (void)calculateAndSetCheckMarkLineWidth {}
|
||||
|
||||
- (void)setCheckMarkColor:(nullable UIColor *)color {}
|
||||
|
||||
-(void)animateCheckMark {}
|
||||
|
||||
-(void)drawCheckMarkWithoutAnimation {}
|
||||
|
||||
-(void)animateSelect:(nullable UIColor *)fillColor BorderColor:(nullable UIColor *)borderColor {}
|
||||
|
||||
//- (void)addAccessibilityInformationIndex:(NSUInteger)index Total:(NSUInteger)totalCount {}
|
||||
|
||||
/* Adds the border with the set border color and SelectableCircleBorderWidth */
|
||||
- (void)addBorder {}
|
||||
|
||||
/* Removes the border */
|
||||
- (void)removeBorder {}
|
||||
|
||||
/* Checks if the fill color is white*/
|
||||
- (BOOL)isFillColorWhite { return NO; }
|
||||
|
||||
/* Resize the circle for animations */
|
||||
-(void)resize:(ButtonSize)newSize {}
|
||||
|
||||
/* Deselect circle without calling blocks */
|
||||
- (void)cancelSelection {}
|
||||
|
||||
#pragma mark - Animation
|
||||
-(void)animateOutline:(nonnull UIColor *)strokeColor IsSelected:(BOOL)selected {}
|
||||
|
||||
#pragma mark - Accessibility fucntion
|
||||
|
||||
- (UIAccessibilityTraits)accessibilityTraits {
|
||||
return ([super accessibilityTraits] | UIAccessibilityTraitButton);
|
||||
}
|
||||
|
||||
- (void)addAccessibilityInformationIndex:(NSUInteger)index Total:(NSUInteger)totalCount {
|
||||
if(self.selected == YES){
|
||||
self.accessibilityTraits = (self.accessibilityTraits | UIAccessibilityTraitSelected);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[super touchesEnded:touches withEvent:event];
|
||||
if (self.performActionForCheck) {
|
||||
self.performActionForCheck();
|
||||
}
|
||||
}
|
||||
|
||||
//- (BOOL)accessibilityActivate {
|
||||
// if (self.performActionForCheck) {
|
||||
// self.performActionForCheck();
|
||||
// return YES;
|
||||
// } else {
|
||||
// return NO;
|
||||
// }
|
||||
//}
|
||||
|
||||
@end
|
||||
@ -85,6 +85,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
|
||||
#import <MVMCoreUI/MVMCoreUICheckMarkView.h>
|
||||
#import <MVMCoreUI/MVMCoreUICheckBox.h>
|
||||
#import <MVMCoreUI/MVMCoreUISwitch.h>
|
||||
#import <MVMCoreUI/MFRadioButton.h>
|
||||
|
||||
#pragma mark Buttons
|
||||
#import <MVMCoreUI/MFButtonProtocol.h>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user