Converted and atomized CaretButton. Removed old objc files of MFCaretButton. Reflected import changes where necessary.
This commit is contained in:
parent
9e3e8cc0e5
commit
c7bcd6e03d
@ -53,12 +53,10 @@
|
||||
D29DF15421E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF15321E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF15F21E69996003B2FB9 /* MFViewController.m */; };
|
||||
D29DF16221E69996003B2FB9 /* MFViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16021E69996003B2FB9 /* MFViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF17321E69E1F003B2FB9 /* MFCaretButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16921E69E1F003B2FB9 /* MFCaretButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D29DF17821E69E1F003B2FB9 /* MFCaretButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF16E21E69E1F003B2FB9 /* MFCaretButton.m */; };
|
||||
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */; };
|
||||
D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */; };
|
||||
D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF17221E69E1F003B2FB9 /* MFTextButton.m */; };
|
||||
@ -157,6 +155,7 @@
|
||||
D2C5001D21F8EE67001DA659 /* LabelWithInternalButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001B21F8EE66001DA659 /* LabelWithInternalButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001C21F8EE66001DA659 /* LabelWithInternalButton.m */; };
|
||||
DBC43900224276B7001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC438FF224276B7001AB423 /* CaretView.swift */; };
|
||||
DBC439062243D262001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC439012242CD35001AB423 /* CaretButton.swift */; };
|
||||
DBD1E75522412BDB00C6AFF4 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBD1E75422412BDB00C6AFF4 /* DashLine.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -219,12 +218,10 @@
|
||||
D29DF15A21E697DA003B2FB9 /* SeparatorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SeparatorView.m; sourceTree = "<group>"; };
|
||||
D29DF15F21E69996003B2FB9 /* MFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFViewController.m; sourceTree = "<group>"; };
|
||||
D29DF16021E69996003B2FB9 /* MFViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFViewController.h; sourceTree = "<group>"; };
|
||||
D29DF16921E69E1F003B2FB9 /* MFCaretButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFCaretButton.h; sourceTree = "<group>"; };
|
||||
D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFCustomButton.h; sourceTree = "<group>"; };
|
||||
D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonDelegateProtocol.h; sourceTree = "<group>"; };
|
||||
D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimaryButton.h; sourceTree = "<group>"; };
|
||||
D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = "<group>"; };
|
||||
D29DF16E21E69E1F003B2FB9 /* MFCaretButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFCaretButton.m; sourceTree = "<group>"; };
|
||||
D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFCustomButton.m; sourceTree = "<group>"; };
|
||||
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrimaryButton.m; sourceTree = "<group>"; };
|
||||
D29DF17221E69E1F003B2FB9 /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = "<group>"; };
|
||||
@ -315,6 +312,7 @@
|
||||
D2C5001B21F8EE66001DA659 /* LabelWithInternalButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelWithInternalButton.h; sourceTree = "<group>"; };
|
||||
D2C5001C21F8EE66001DA659 /* LabelWithInternalButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LabelWithInternalButton.m; sourceTree = "<group>"; };
|
||||
DBC438FF224276B7001AB423 /* CaretView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
|
||||
DBC439012242CD35001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = "<group>"; };
|
||||
DBD1E75422412BDB00C6AFF4 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -533,8 +531,7 @@
|
||||
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */,
|
||||
D29DF16D21E69E1F003B2FB9 /* MFTextButton.h */,
|
||||
D29DF17221E69E1F003B2FB9 /* MFTextButton.m */,
|
||||
D29DF16921E69E1F003B2FB9 /* MFCaretButton.h */,
|
||||
D29DF16E21E69E1F003B2FB9 /* MFCaretButton.m */,
|
||||
DBC439012242CD35001AB423 /* CaretButton.swift */,
|
||||
);
|
||||
path = Buttons;
|
||||
sourceTree = "<group>";
|
||||
@ -735,7 +732,6 @@
|
||||
D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */,
|
||||
D29DF18221E69E54003B2FB9 /* SeparatorView.h in Headers */,
|
||||
D29DF26E21E6AA0B003B2FB9 /* FLAnimatedImage.h in Headers */,
|
||||
D29DF17321E69E1F003B2FB9 /* MFCaretButton.h in Headers */,
|
||||
D2C5001D21F8EE67001DA659 /* LabelWithInternalButton.h in Headers */,
|
||||
D29DF11621E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h in Headers */,
|
||||
D29DF17721E69E1F003B2FB9 /* MFTextButton.h in Headers */,
|
||||
@ -903,11 +899,11 @@
|
||||
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
|
||||
D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */,
|
||||
D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */,
|
||||
D29DF17821E69E1F003B2FB9 /* MFCaretButton.m in Sources */,
|
||||
D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */,
|
||||
D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */,
|
||||
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
|
||||
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
|
||||
DBC439062243D262001AB423 /* CaretButton.swift in Sources */,
|
||||
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
|
||||
D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */,
|
||||
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,
|
||||
|
||||
173
MVMCoreUI/Atoms/Buttons/CaretButton.swift
Normal file
173
MVMCoreUI/Atoms/Buttons/CaretButton.swift
Normal file
@ -0,0 +1,173 @@
|
||||
//
|
||||
// CaretButton.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Kolli, Praneeth on 1/5/18.
|
||||
// Created by Christiano, Kevin on 3/18/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
open class CaretButton: MFCustomButton {
|
||||
//------------------------------------------------------
|
||||
// MARK: - Constants
|
||||
//------------------------------------------------------
|
||||
|
||||
private let CaretViewHeight: CGFloat = 10.8
|
||||
private let CaretViewWidth: CGFloat = 6.6
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//------------------------------------------------------
|
||||
|
||||
@objc public var rightView: UIView?
|
||||
@objc public var rightViewHeight: NSNumber?
|
||||
@objc public var rightViewWidth: NSNumber?
|
||||
|
||||
@objc public var enabledColor: UIColor = .black {
|
||||
didSet {
|
||||
setTitleColor(enabledColor, for: .normal)
|
||||
changeCaretColor()
|
||||
}
|
||||
}
|
||||
|
||||
@objc public var disabledColor: UIColor = .mfSilver() {
|
||||
didSet {
|
||||
setTitleColor(disabledColor, for: .disabled)
|
||||
changeCaretColor()
|
||||
}
|
||||
}
|
||||
|
||||
private var caretSpacingConstraint: NSLayoutConstraint?
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Lifecycle
|
||||
//------------------------------------------------------
|
||||
|
||||
override open func layoutSubviews() {
|
||||
|
||||
addCaretImageView()
|
||||
super.layoutSubviews()
|
||||
}
|
||||
|
||||
public func setEnabled(_ enabled: Bool) {
|
||||
super.isEnabled = enabled
|
||||
|
||||
changeCaretColor()
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Functions
|
||||
//------------------------------------------------------
|
||||
|
||||
private func changeCaretColor() {
|
||||
|
||||
if let rightCaretView = rightView as? CaretView {
|
||||
rightCaretView.tintColor = isEnabled ? enabledColor : disabledColor
|
||||
}
|
||||
}
|
||||
|
||||
private func addCaretImageView() {
|
||||
|
||||
rightView?.removeFromSuperview()
|
||||
let edgeInsets: UIEdgeInsets = contentEdgeInsets
|
||||
|
||||
var rightInset: CGFloat = CaretViewWidth
|
||||
|
||||
if let rightFloatValue = rightViewWidth?.floatValue {
|
||||
rightInset = CGFloat(rightFloatValue)
|
||||
}
|
||||
|
||||
contentEdgeInsets = UIEdgeInsets(top: edgeInsets.top, left: edgeInsets.left, bottom: edgeInsets.bottom, right: 4 + rightInset)
|
||||
|
||||
var caretViewIs: UIView? = rightView
|
||||
if rightView == nil {
|
||||
caretViewIs = CaretView()
|
||||
rightView = caretViewIs
|
||||
}
|
||||
|
||||
rightView?.translatesAutoresizingMaskIntoConstraints = false
|
||||
if let right = rightView {
|
||||
addSubview(right)
|
||||
}
|
||||
|
||||
var width: CGFloat = CaretViewWidth
|
||||
if let rightFloatValue = rightViewWidth?.floatValue {
|
||||
width = CGFloat(rightFloatValue)
|
||||
}
|
||||
|
||||
var caretViewWidthConstraint: NSLayoutConstraint?
|
||||
|
||||
if let caretViewIs = caretViewIs {
|
||||
caretViewWidthConstraint = NSLayoutConstraint(item: caretViewIs, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: width)
|
||||
caretViewWidthConstraint?.isActive = true
|
||||
}
|
||||
|
||||
var height: CGFloat = CaretViewHeight
|
||||
|
||||
if let rightHeight = rightViewHeight?.floatValue {
|
||||
height = CGFloat(rightHeight)
|
||||
}
|
||||
|
||||
var caretViewHeightConstraint: NSLayoutConstraint?
|
||||
if let caretViewIs = caretViewIs {
|
||||
caretViewHeightConstraint = NSLayoutConstraint(item: caretViewIs, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: height)
|
||||
caretViewHeightConstraint?.isActive = true
|
||||
}
|
||||
|
||||
var caretLabelSpacing: NSLayoutConstraint?
|
||||
if let caretViewIs = caretViewIs {
|
||||
caretLabelSpacing = NSLayoutConstraint(item: caretViewIs, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 4.0)
|
||||
caretLabelSpacing?.isActive = true
|
||||
}
|
||||
caretSpacingConstraint = caretLabelSpacing
|
||||
|
||||
var caretCenterY: NSLayoutConstraint?
|
||||
if let caretViewIs = caretViewIs {
|
||||
caretCenterY = NSLayoutConstraint(item: caretViewIs, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0)
|
||||
caretCenterY?.isActive = true
|
||||
}
|
||||
|
||||
let caretLabelRightPin = NSLayoutConstraint(item: self, attribute: .right, relatedBy: .greaterThanOrEqual, toItem: caretViewIs, attribute: .right, multiplier: 1.0, constant: 0)
|
||||
caretLabelRightPin.isActive = true
|
||||
contentHorizontalAlignment = .left
|
||||
//set correct color after layout
|
||||
changeCaretColor()
|
||||
}
|
||||
|
||||
public func updateCaretSpacing(_ spacing: CGFloat) {
|
||||
|
||||
caretSpacingConstraint?.constant = spacing
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Atomization
|
||||
//------------------------------------------------------
|
||||
|
||||
// Default values for view.
|
||||
@objc open override func setAsMolecule() {
|
||||
|
||||
backgroundColor = .clear
|
||||
}
|
||||
|
||||
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||
|
||||
// Configure class properties with JSON values
|
||||
guard let jsonDictionary = json else { return }
|
||||
|
||||
if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String {
|
||||
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
|
||||
}
|
||||
|
||||
if let enableColorHex = jsonDictionary["enableColor"] as? String {
|
||||
enabledColor = UIColor.mfGet(forHex: enableColorHex)
|
||||
}
|
||||
|
||||
if let disabledColorHex = jsonDictionary["disabledColor"] as? String {
|
||||
disabledColor = UIColor.mfGet(forHex: disabledColorHex)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
//
|
||||
// MFCaretButton.h
|
||||
// MobileFirstFramework
|
||||
//
|
||||
// Created by Kolli, Praneeth on 1/5/18.
|
||||
// Copyright © 2018 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCoreUI/MFCustomButton.h>
|
||||
@interface MFCaretButton : MFCustomButton
|
||||
|
||||
@property (nullable, nonatomic, strong) UIView *rightView;
|
||||
@property (nullable, nonatomic, strong) NSNumber *rightViewHeight;
|
||||
@property (nullable, nonatomic, strong) NSNumber *rightViewWidth;
|
||||
|
||||
-(void)updateCaretSpacing:(CGFloat)spacing;
|
||||
|
||||
/* The fill color of the Caret and titleLabel. The default is blackColor */
|
||||
-(void)setEnableCaretColor:(nullable UIColor *)enableCaretColor;
|
||||
|
||||
/* The fill color of the Caret and titleLabel. The default is mfSilver */
|
||||
-(void)setDisabledCaretColor:(nullable UIColor *)disabledCaretColor;
|
||||
|
||||
@end
|
||||
@ -1,113 +0,0 @@
|
||||
//
|
||||
// MFCaretButton.m
|
||||
// MobileFirstFramework
|
||||
//
|
||||
// Created by Kolli, Praneeth on 1/5/18.
|
||||
// Copyright © 2018 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MFCaretButton.h"
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
#import "UIColor+MFConvenience.h"
|
||||
|
||||
@interface MFCaretButton ()
|
||||
|
||||
@property (nonatomic, strong) UIColor *enableColor;
|
||||
@property (nonatomic, strong) UIColor *disabledColor;
|
||||
@property (nonatomic, strong) NSLayoutConstraint *caretSpacingConstraint;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MFCaretButton
|
||||
|
||||
CGFloat const CaretViewHeight = 10.8f;
|
||||
CGFloat const CaretViewWidth = 6.6f;
|
||||
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[self addCaretImageView];
|
||||
[super layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)enabled {
|
||||
[super setEnabled:enabled];
|
||||
[self changeCaretColor];
|
||||
}
|
||||
- (void)changeCaretColor {
|
||||
[self setTitleColor:self.enableColor forState:UIControlStateNormal];
|
||||
[self setTitleColor:self.disabledColor forState:UIControlStateDisabled];
|
||||
if ([self.rightView isKindOfClass:[CaretView class]]) {
|
||||
CaretView *caretView = (CaretView *)self.rightView;
|
||||
if (self.enabled) {
|
||||
[caretView setLineColor:self.enableColor];
|
||||
} else {
|
||||
[caretView setLineColor:self.disabledColor];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addCaretImageView {
|
||||
[self.rightView removeFromSuperview];
|
||||
UIEdgeInsets edgeInsets = self.contentEdgeInsets;
|
||||
CGFloat rightInset = self.rightViewWidth?self.rightViewWidth.floatValue:CaretViewWidth;
|
||||
UIEdgeInsets newInsets = UIEdgeInsetsMake(edgeInsets.top, edgeInsets.left, edgeInsets.bottom, 4 + rightInset);
|
||||
self.contentEdgeInsets = newInsets;
|
||||
UIView *caretViewIs = self.rightView;
|
||||
if (!self.rightView) {
|
||||
caretViewIs = [[CaretView alloc]init];
|
||||
self.rightView = caretViewIs;
|
||||
}
|
||||
self.rightView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self addSubview:self.rightView];
|
||||
|
||||
CGFloat width = self.rightViewWidth?self.rightViewWidth.floatValue:CaretViewWidth;
|
||||
NSLayoutConstraint *caretViewWidthConstraint = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width];
|
||||
caretViewWidthConstraint.active = YES;
|
||||
|
||||
CGFloat height = self.rightViewHeight?self.rightViewHeight.floatValue:CaretViewHeight;
|
||||
NSLayoutConstraint *caretViewHeightConstraint = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:height];
|
||||
caretViewHeightConstraint.active = YES;
|
||||
|
||||
NSLayoutConstraint *caretLabelSpacing = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.titleLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:4.0];
|
||||
caretLabelSpacing.active = YES;
|
||||
self.caretSpacingConstraint = caretLabelSpacing;
|
||||
|
||||
NSLayoutConstraint *caretCenterY = [NSLayoutConstraint constraintWithItem:caretViewIs attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0];
|
||||
caretCenterY.active = YES;
|
||||
|
||||
NSLayoutConstraint *caretLabelRightPin = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:caretViewIs attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
|
||||
caretLabelRightPin.active = YES;
|
||||
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
||||
//set correct color after layout
|
||||
[self changeCaretColor];
|
||||
}
|
||||
- (void)updateCaretSpacing:(CGFloat)spacing {
|
||||
if (self.caretSpacingConstraint != nil) {
|
||||
self.caretSpacingConstraint.constant = spacing;
|
||||
}
|
||||
}
|
||||
- (void)setEnableCaretColor:(UIColor *)enableCaretColor {
|
||||
self.enableColor = enableCaretColor;
|
||||
[self changeCaretColor];
|
||||
}
|
||||
- (void)setDisabledCaretColor:(UIColor *)disabledCaretColor {
|
||||
self.disabledColor = disabledCaretColor;
|
||||
[self changeCaretColor];
|
||||
}
|
||||
@synthesize enableColor = _enableColor;
|
||||
- (UIColor *)enableColor {
|
||||
if (!_enableColor) {
|
||||
_enableColor = [UIColor blackColor];
|
||||
}
|
||||
return _enableColor;
|
||||
}
|
||||
|
||||
@synthesize disabledColor = _disabledColor;
|
||||
- (UIColor *)disabledColor {
|
||||
if (!_disabledColor) {
|
||||
_disabledColor = [UIColor mfSilver];
|
||||
}
|
||||
return _disabledColor;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -10,13 +10,15 @@
|
||||
@import MVMCore.MVMCoreActionDelegateProtocol;
|
||||
#import <MVMCoreUI/ButtonDelegateProtocol.h>
|
||||
#import <MVMCoreUI/MFButtonProtocol.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
@import MVMCore.MVMCoreViewProtocol;
|
||||
|
||||
typedef void (^ButtonTapBlock)(id _Nonnull sender);
|
||||
|
||||
extern CGFloat const CloseButtonHeight;
|
||||
extern CGFloat const CloseButtonWidth;
|
||||
|
||||
@interface MFCustomButton : UIButton <MFButtonProtocol>
|
||||
@interface MFCustomButton : UIButton <MFButtonProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary *actionMap;
|
||||
@property (nullable, nonatomic, weak) id <ButtonDelegateProtocol> buttonDelegate;
|
||||
@ -35,4 +37,5 @@ extern CGFloat const CloseButtonWidth;
|
||||
- (void)addAccessibilityForCameraControl;
|
||||
|
||||
- (nonnull UIAccessibilityCustomAction *)accessibilityCustomAction;
|
||||
|
||||
@end
|
||||
|
||||
@ -22,34 +22,36 @@ open class CaretView: MFView {
|
||||
|
||||
@objc public init() {
|
||||
super.init(frame: CGRect.zero)
|
||||
|
||||
isOpaque = false
|
||||
backgroundColor = .clear
|
||||
strokeColor = .black
|
||||
}
|
||||
|
||||
@objc public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
isOpaque = false
|
||||
backgroundColor = .clear
|
||||
strokeColor = .black
|
||||
}
|
||||
|
||||
@objc required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
||||
isOpaque = false
|
||||
backgroundColor = .clear
|
||||
strokeColor = .black
|
||||
}
|
||||
|
||||
@objc public init(lineWidth: CGFloat) {
|
||||
super.init(frame: CGRect())
|
||||
|
||||
isOpaque = false
|
||||
backgroundColor = .clear
|
||||
self.lineWidth = lineWidth
|
||||
}
|
||||
|
||||
@objc override open func setupView() {
|
||||
|
||||
defaultState()
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Functions
|
||||
//------------------------------------------------------
|
||||
|
||||
private func defaultState() {
|
||||
|
||||
isOpaque = false
|
||||
isHidden = false
|
||||
backgroundColor = .clear
|
||||
strokeColor = .black
|
||||
}
|
||||
|
||||
@ -81,7 +83,6 @@ open class CaretView: MFView {
|
||||
strokeColor?.setFill()
|
||||
path.fill()
|
||||
path.close()
|
||||
backgroundColor = .clear
|
||||
}
|
||||
|
||||
@objc public func setLineColor(_ color: UIColor?) {
|
||||
@ -97,10 +98,7 @@ open class CaretView: MFView {
|
||||
// Default values for view.
|
||||
@objc open override func setAsMolecule() {
|
||||
|
||||
backgroundColor = .clear
|
||||
strokeColor = .black
|
||||
isHidden = false
|
||||
isOpaque = false
|
||||
defaultState()
|
||||
}
|
||||
|
||||
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
@ -94,7 +94,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
|
||||
#import <MVMCoreUI/MFCustomButton.h>
|
||||
#import <MVMCoreUI/PrimaryButton.h>
|
||||
#import <MVMCoreUI/MFTextButton.h>
|
||||
#import <MVMCoreUI/MFCaretButton.h>
|
||||
|
||||
#pragma mark TextFields
|
||||
#import <MVMCoreUI/MFTextField.h>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user