deprecating
This commit is contained in:
parent
f1d80adf57
commit
aa4da8f74f
@ -106,14 +106,14 @@ open class CaretButton: MFCustomButton {
|
|||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
// Default values for view.
|
// Default values for view.
|
||||||
@objc open override func setAsMolecule() {
|
@objc open func setAsMolecule() {
|
||||||
|
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
setTitleColor(enabledColor, for: .normal)
|
setTitleColor(enabledColor, for: .normal)
|
||||||
setTitleColor(disabledColor, for: .disabled)
|
setTitleColor(disabledColor, for: .disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
@objc open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData)
|
setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData)
|
||||||
|
|
||||||
guard let dictionary = json else { return }
|
guard let dictionary = json else { return }
|
||||||
|
|||||||
@ -11,14 +11,14 @@
|
|||||||
#import <MVMCoreUI/ButtonDelegateProtocol.h>
|
#import <MVMCoreUI/ButtonDelegateProtocol.h>
|
||||||
#import <MVMCoreUI/MFButtonProtocol.h>
|
#import <MVMCoreUI/MFButtonProtocol.h>
|
||||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||||
@import MVMCore.MVMCoreViewProtocol;
|
@class MVMCoreUIDelegateObject;
|
||||||
|
|
||||||
typedef void (^ButtonTapBlock)(id _Nonnull sender);
|
typedef void (^ButtonTapBlock)(id _Nonnull sender);
|
||||||
|
|
||||||
extern CGFloat const CloseButtonHeight;
|
extern CGFloat const CloseButtonHeight;
|
||||||
extern CGFloat const CloseButtonWidth;
|
extern CGFloat const CloseButtonWidth;
|
||||||
|
|
||||||
@interface MFCustomButton : UIButton <MFButtonProtocol, MVMCoreUIMoleculeViewProtocol>
|
@interface MFCustomButton : UIButton <MFButtonProtocol>
|
||||||
|
|
||||||
@property (nullable, nonatomic, strong) NSDictionary *actionMap;
|
@property (nullable, nonatomic, strong) NSDictionary *actionMap;
|
||||||
@property (nullable, nonatomic, weak) id <ButtonDelegateProtocol> buttonDelegate;
|
@property (nullable, nonatomic, weak) id <ButtonDelegateProtocol> buttonDelegate;
|
||||||
@ -28,14 +28,19 @@ extern CGFloat const CloseButtonWidth;
|
|||||||
- (void)addBlock:(nonnull ButtonTapBlock)buttonTapBlock forControlEvents:(UIControlEvents)event;
|
- (void)addBlock:(nonnull ButtonTapBlock)buttonTapBlock forControlEvents:(UIControlEvents)event;
|
||||||
|
|
||||||
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler.
|
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler.
|
||||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)delegate additionalData:(nullable NSDictionary *)additionalData;
|
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData;
|
||||||
|
|
||||||
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate
|
|
||||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate;
|
|
||||||
|
|
||||||
//accessibility
|
//accessibility
|
||||||
- (void)addAccessibilityForCameraControl;
|
- (void)addAccessibilityForCameraControl;
|
||||||
|
|
||||||
- (nonnull UIAccessibilityCustomAction *)accessibilityCustomAction;
|
- (nonnull UIAccessibilityCustomAction *)accessibilityCustomAction;
|
||||||
|
|
||||||
|
#pragma mark - Deprecated
|
||||||
|
|
||||||
|
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler.
|
||||||
|
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)delegate additionalData:(nullable NSDictionary *)additionalData __deprecated;
|
||||||
|
|
||||||
|
// Sets up the button with the passed in action map. Will set the title and set the action to use the action handler. Also pass in the button delegate
|
||||||
|
- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate __deprecated;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
@import MVMCore.NSDictionary_MFConvenience;
|
@import MVMCore.NSDictionary_MFConvenience;
|
||||||
#import "MVMCoreUIUtility.h"
|
#import "MVMCoreUIUtility.h"
|
||||||
#import "MVMCoreUIConstants.h"
|
#import "MVMCoreUIConstants.h"
|
||||||
|
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||||
|
|
||||||
CGFloat const CloseButtonHeight = 40.0f;
|
CGFloat const CloseButtonHeight = 40.0f;
|
||||||
CGFloat const CloseButtonWidth = 40.0f;
|
CGFloat const CloseButtonWidth = 40.0f;
|
||||||
@ -37,6 +38,52 @@ CGFloat const CloseButtonWidth = 40.0f;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData {
|
||||||
|
|
||||||
|
self.actionMap = actionMap;
|
||||||
|
self.titleLabel.numberOfLines = 0;
|
||||||
|
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||||
|
[self setTitle:[actionMap stringForKey:KeyTitle] forState:UIControlStateNormal];
|
||||||
|
|
||||||
|
[self setEnabled:![actionMap[KeyDisableButton]boolValue]];
|
||||||
|
|
||||||
|
self.buttonDelegate = delegateObject.buttonDelegate;
|
||||||
|
__weak MFCustomButton *weakSelf = self;
|
||||||
|
[self addBlock:^(id _Nonnull sender) {
|
||||||
|
|
||||||
|
BOOL performAction = YES;
|
||||||
|
if (weakSelf.buttonDelegate && [weakSelf.buttonDelegate respondsToSelector:@selector(button:shouldPerformActionWithMap:additionalData:)]) {
|
||||||
|
performAction = [weakSelf.buttonDelegate button:weakSelf shouldPerformActionWithMap:actionMap additionalData:additionalData];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (performAction) {
|
||||||
|
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject];
|
||||||
|
}
|
||||||
|
} forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
}
|
||||||
|
|
||||||
|
//accessibility
|
||||||
|
-(void)addAccessibilityForCameraControl{
|
||||||
|
self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"];
|
||||||
|
self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"];
|
||||||
|
self.accessibilityTraits = UIAccessibilityTraitNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (UIAccessibilityCustomAction *)accessibilityCustomAction {
|
||||||
|
NSString *name = self.accessibilityLabel ?: self.titleLabel.text;
|
||||||
|
return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action {
|
||||||
|
if (self.buttonTapBlock) {
|
||||||
|
self.buttonTapBlock(self);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Deprecated
|
||||||
|
|
||||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)delegate additionalData:(nullable NSDictionary *)additionalData {
|
- (void)setWithActionMap:(nullable NSDictionary *)actionMap delegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||||
|
|
||||||
self.actionMap = actionMap;
|
self.actionMap = actionMap;
|
||||||
@ -53,11 +100,11 @@ CGFloat const CloseButtonWidth = 40.0f;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
|
- (void)setWithActionMap:(nullable NSDictionary *)actionMap actionDelegate:(nullable NSObject <MVMCoreActionDelegateProtocol>*)actionDelegate additionalData:(nullable NSDictionary *)additionalData buttonDelegate:(nullable id <ButtonDelegateProtocol>)buttonDelegate {
|
||||||
|
|
||||||
if (!buttonDelegate) {
|
if (!buttonDelegate) {
|
||||||
[self setWithActionMap:actionMap delegate:actionDelegate additionalData:additionalData];
|
[self setWithActionMap:actionMap delegate:actionDelegate additionalData:additionalData];
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
self.actionMap = actionMap;
|
self.actionMap = actionMap;
|
||||||
self.titleLabel.numberOfLines = 0;
|
self.titleLabel.numberOfLines = 0;
|
||||||
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||||
@ -86,24 +133,4 @@ CGFloat const CloseButtonWidth = 40.0f;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//accessibility
|
|
||||||
-(void)addAccessibilityForCameraControl{
|
|
||||||
self.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraButton"];
|
|
||||||
self.accessibilityHint = [MVMCoreUIUtility hardcodedStringWithKey:@"AccCameraHint"];
|
|
||||||
self.accessibilityTraits = UIAccessibilityTraitNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (UIAccessibilityCustomAction *)accessibilityCustomAction {
|
|
||||||
NSString *name = self.accessibilityLabel ?: self.titleLabel.text;
|
|
||||||
return [[UIAccessibilityCustomAction alloc] initWithName:name target:self selector:@selector(performAccessibilityAction:)];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)performAccessibilityAction:(UIAccessibilityCustomAction *)action {
|
|
||||||
if (self.buttonTapBlock) {
|
|
||||||
self.buttonTapBlock(self);
|
|
||||||
}
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -11,8 +11,10 @@ import UIKit
|
|||||||
@objc(MVMCoreUIDelegateObject)
|
@objc(MVMCoreUIDelegateObject)
|
||||||
open class DelegateObject: MVMCore.DelegateObject {
|
open class DelegateObject: MVMCore.DelegateObject {
|
||||||
public weak var formValidationProtocol: FormValidationProtocol?
|
public weak var formValidationProtocol: FormValidationProtocol?
|
||||||
|
public weak var buttonDelegate: ButtonDelegateProtocol?
|
||||||
|
|
||||||
open override func setAll(withDelegate delegate: Any) {
|
open override func setAll(withDelegate delegate: Any) {
|
||||||
formValidationProtocol = delegate as? FormValidationProtocol
|
formValidationProtocol = delegate as? FormValidationProtocol
|
||||||
|
buttonDelegate = delegate as? ButtonDelegateProtocol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user