Browse Source

Add Icon insets support for buttons (#4699)

* Add button.iconInsets

* Define iconInsets in Options.ts

* Apply color on button iconImage
Yogev Ben David 5 years ago
parent
commit
545e5fef5f
No account linked to committer's email address

+ 2
- 0
lib/ios/RNNButtonOptions.h View File

1
 #import "RNNOptions.h"
1
 #import "RNNOptions.h"
2
+#import "RNNInsetsOptions.h"
2
 
3
 
3
 @interface RNNButtonOptions : RNNOptions
4
 @interface RNNButtonOptions : RNNOptions
4
 
5
 
9
 @property (nonatomic, strong) Color* disabledColor;
10
 @property (nonatomic, strong) Color* disabledColor;
10
 @property (nonatomic, strong) Image* icon;
11
 @property (nonatomic, strong) Image* icon;
11
 @property (nonatomic, strong) Bool* enabled;
12
 @property (nonatomic, strong) Bool* enabled;
13
+@property (nonatomic, strong) RNNInsetsOptions* iconInsets;
12
 
14
 
13
 @end
15
 @end

+ 1
- 0
lib/ios/RNNButtonOptions.m View File

11
 	self.color = [ColorParser parse:dict key:@"color"];
11
 	self.color = [ColorParser parse:dict key:@"color"];
12
 	self.disabledColor = [ColorParser parse:dict key:@"disabledColor"];
12
 	self.disabledColor = [ColorParser parse:dict key:@"disabledColor"];
13
 	self.icon = [ImageParser parse:dict key:@"icon"];
13
 	self.icon = [ImageParser parse:dict key:@"icon"];
14
+	self.iconInsets = [[RNNInsetsOptions alloc] initWithDict:dict];
14
 	self.enabled = [BoolParser parse:dict key:@"enabled"];
15
 	self.enabled = [BoolParser parse:dict key:@"enabled"];
15
 	
16
 	
16
 
17
 

+ 10
- 0
lib/ios/RNNInsetsOptions.h View File

1
+#import "RNNOptions.h"
2
+
3
+@interface RNNInsetsOptions : RNNOptions
4
+
5
+@property (nonatomic, strong) Double* top;
6
+@property (nonatomic, strong) Double* left;
7
+@property (nonatomic, strong) Double* right;
8
+@property (nonatomic, strong) Double* bottom;
9
+
10
+@end

+ 16
- 0
lib/ios/RNNInsetsOptions.m View File

1
+#import "RNNInsetsOptions.h"
2
+
3
+@implementation RNNInsetsOptions
4
+
5
+- (instancetype)initWithDict:(NSDictionary *)dict {
6
+	self = [super init];
7
+	
8
+	self.top = [DoubleParser parse:dict key:@"top"];
9
+	self.left = [DoubleParser parse:dict key:@"left"];
10
+	self.bottom = [DoubleParser parse:dict key:@"bottom"];
11
+	self.right = [DoubleParser parse:dict key:@"right"];
12
+	
13
+	return self;
14
+}
15
+
16
+@end

+ 31
- 7
lib/ios/RNNNavigationButtons.m View File

4
 #import "RCTHelpers.h"
4
 #import "RCTHelpers.h"
5
 #import "UIImage+tint.h"
5
 #import "UIImage+tint.h"
6
 #import "RNNRootViewController.h"
6
 #import "RNNRootViewController.h"
7
+#import "UIImage+insets.h"
7
 
8
 
8
 @interface RNNNavigationButtons()
9
 @interface RNNNavigationButtons()
9
 
10
 
28
 	_defaultLeftButtonStyle = defaultLeftButtonStyle;
29
 	_defaultLeftButtonStyle = defaultLeftButtonStyle;
29
 	_defaultRightButtonStyle = defaultRightButtonStyle;
30
 	_defaultRightButtonStyle = defaultRightButtonStyle;
30
 	if (leftButtons) {
31
 	if (leftButtons) {
31
-		[self setButtons:leftButtons side:@"left" animated:NO defaultStyle:_defaultLeftButtonStyle];
32
+		[self setButtons:leftButtons side:@"left" animated:NO defaultStyle:_defaultLeftButtonStyle insets:[self leftButtonInsets:_defaultLeftButtonStyle.iconInsets]];
32
 	}
33
 	}
33
 	
34
 	
34
 	if (rightButtons) {
35
 	if (rightButtons) {
35
-		[self setButtons:rightButtons side:@"right" animated:NO defaultStyle:_defaultRightButtonStyle];
36
+		[self setButtons:rightButtons side:@"right" animated:NO defaultStyle:_defaultRightButtonStyle insets:[self rightButtonInsets:_defaultRightButtonStyle.iconInsets]];
36
 	}
37
 	}
37
 }
38
 }
38
 
39
 
39
--(void)setButtons:(NSArray*)buttons side:(NSString*)side animated:(BOOL)animated defaultStyle:(RNNButtonOptions *)defaultStyle {
40
+-(void)setButtons:(NSArray*)buttons side:(NSString*)side animated:(BOOL)animated defaultStyle:(RNNButtonOptions *)defaultStyle insets:(UIEdgeInsets)insets {
40
 	NSMutableArray *barButtonItems = [NSMutableArray new];
41
 	NSMutableArray *barButtonItems = [NSMutableArray new];
41
 	NSArray* resolvedButtons = [self resolveButtons:buttons];
42
 	NSArray* resolvedButtons = [self resolveButtons:buttons];
42
 	for (NSDictionary *button in resolvedButtons) {
43
 	for (NSDictionary *button in resolvedButtons) {
43
-		RNNUIBarButtonItem* barButtonItem = [self buildButton:button defaultStyle:defaultStyle];
44
+		RNNUIBarButtonItem* barButtonItem = [self buildButton:button defaultStyle:defaultStyle insets:insets];
44
 		if(barButtonItem) {
45
 		if(barButtonItem) {
45
 			[barButtonItems addObject:barButtonItem];
46
 			[barButtonItems addObject:barButtonItem];
46
 		}
47
 		}
67
 	}
68
 	}
68
 }
69
 }
69
 
70
 
70
--(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary defaultStyle:(RNNButtonOptions *)defaultStyle {
71
+-(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary defaultStyle:(RNNButtonOptions *)defaultStyle insets:(UIEdgeInsets)insets {
71
 	NSString* buttonId = dictionary[@"id"];
72
 	NSString* buttonId = dictionary[@"id"];
72
 	NSString* title = [self getValue:dictionary[@"text"] withDefault:[defaultStyle.text getWithDefaultValue:nil]];
73
 	NSString* title = [self getValue:dictionary[@"text"] withDefault:[defaultStyle.text getWithDefaultValue:nil]];
73
 	NSDictionary* component = dictionary[@"component"];
74
 	NSDictionary* component = dictionary[@"component"];
74
 	NSString* systemItemName = dictionary[@"systemItem"];
75
 	NSString* systemItemName = dictionary[@"systemItem"];
75
 	
76
 	
77
+	UIColor* color = [self color:[RCTConvert UIColor:dictionary[@"color"]] defaultColor:[defaultStyle.color getWithDefaultValue:nil]];
78
+	UIColor* disabledColor = [self color:[RCTConvert UIColor:dictionary[@"disabledColor"]] defaultColor:[defaultStyle.disabledColor getWithDefaultValue:nil]];
79
+	
76
 	if (!buttonId) {
80
 	if (!buttonId) {
77
 		@throw [NSException exceptionWithName:@"NSInvalidArgumentException" reason:[@"button id is not specified " stringByAppendingString:title] userInfo:nil];
81
 		@throw [NSException exceptionWithName:@"NSInvalidArgumentException" reason:[@"button id is not specified " stringByAppendingString:title] userInfo:nil];
78
 	}
82
 	}
83
 		iconImage = [RCTConvert UIImage:iconImage];
87
 		iconImage = [RCTConvert UIImage:iconImage];
84
 	}
88
 	}
85
 	
89
 	
90
+	if (iconImage) {
91
+		iconImage = [iconImage imageWithInsets:insets];
92
+		if (color) {
93
+			iconImage = [iconImage withTintColor:color];
94
+		}
95
+	}
96
+	
97
+	
86
 	RNNUIBarButtonItem *barButtonItem;
98
 	RNNUIBarButtonItem *barButtonItem;
87
 	if (component) {
99
 	if (component) {
88
 		RNNComponentOptions* componentOptions = [RNNComponentOptions new];
100
 		RNNComponentOptions* componentOptions = [RNNComponentOptions new];
116
 	NSMutableDictionary* textAttributes = [[NSMutableDictionary alloc] init];
128
 	NSMutableDictionary* textAttributes = [[NSMutableDictionary alloc] init];
117
 	NSMutableDictionary* disabledTextAttributes = [[NSMutableDictionary alloc] init];
129
 	NSMutableDictionary* disabledTextAttributes = [[NSMutableDictionary alloc] init];
118
 	
130
 	
119
-	UIColor* color = [self color:[RCTConvert UIColor:dictionary[@"color"]] defaultColor:[defaultStyle.color getWithDefaultValue:nil]];
120
-	UIColor* disabledColor = [self color:[RCTConvert UIColor:dictionary[@"disabledColor"]] defaultColor:[defaultStyle.disabledColor getWithDefaultValue:nil]];
121
 	if (!enabledBool && disabledColor) {
131
 	if (!enabledBool && disabledColor) {
122
 		color = disabledColor;
132
 		color = disabledColor;
123
 		[disabledTextAttributes setObject:disabledColor forKey:NSForegroundColorAttributeName];
133
 		[disabledTextAttributes setObject:disabledColor forKey:NSForegroundColorAttributeName];
185
 	return value ? value : defaultValue;
195
 	return value ? value : defaultValue;
186
 }
196
 }
187
 
197
 
198
+- (UIEdgeInsets)leftButtonInsets:(RNNInsetsOptions *)defaultInsets {
199
+	return UIEdgeInsetsMake([defaultInsets.top getWithDefaultValue:0],
200
+					 [defaultInsets.left getWithDefaultValue:0],
201
+					 [defaultInsets.bottom getWithDefaultValue:0],
202
+					 [defaultInsets.right getWithDefaultValue:15]);
203
+}
204
+
205
+- (UIEdgeInsets)rightButtonInsets:(RNNInsetsOptions *)defaultInsets {
206
+	return UIEdgeInsetsMake([defaultInsets.top getWithDefaultValue:0],
207
+					 [defaultInsets.left getWithDefaultValue:15],
208
+					 [defaultInsets.bottom getWithDefaultValue:0],
209
+					 [defaultInsets.right getWithDefaultValue:0]);
210
+}
211
+
188
 @end
212
 @end

+ 11
- 2
lib/ios/RNNUIBarButtonItem.m View File

6
 @implementation RNNUIBarButtonItem
6
 @implementation RNNUIBarButtonItem
7
 
7
 
8
 -(instancetype)init:(NSString*)buttonId withIcon:(UIImage*)iconImage {
8
 -(instancetype)init:(NSString*)buttonId withIcon:(UIImage*)iconImage {
9
-	self = [super initWithImage:iconImage style:UIBarButtonItemStylePlain target:nil action:nil];
9
+	UIButton* button = [[UIButton alloc] init];
10
+	[button addTarget:self action:@selector(onButtonPressed) forControlEvents:UIControlEventTouchUpInside];
11
+	[button setImage:iconImage forState:UIControlStateNormal];
12
+	self = [super initWithCustomView:button];
10
 	self.buttonId = buttonId;
13
 	self.buttonId = buttonId;
11
 	return self;
14
 	return self;
12
 }
15
 }
26
 	self.buttonId = buttonId;
29
 	self.buttonId = buttonId;
27
 	return self;
30
 	return self;
28
 }
31
 }
29
-	
32
+
30
 -(instancetype)init:(NSString*)buttonId withSystemItem:(NSString *)systemItemName {
33
 -(instancetype)init:(NSString*)buttonId withSystemItem:(NSString *)systemItemName {
31
 	UIBarButtonSystemItem systemItem = [RCTConvert UIBarButtonSystemItem:systemItemName];
34
 	UIBarButtonSystemItem systemItem = [RCTConvert UIBarButtonSystemItem:systemItemName];
32
 	self = [super initWithBarButtonSystemItem:systemItem target:nil action:nil];
35
 	self = [super initWithBarButtonSystemItem:systemItem target:nil action:nil];
40
 	self.width = size.width;
43
 	self.width = size.width;
41
 }
44
 }
42
 
45
 
46
+- (void)onButtonPressed {
47
+	[self.target performSelector:self.action
48
+					  withObject:self
49
+					  afterDelay:0];
50
+}
51
+
43
 @end
52
 @end

+ 16
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

181
 		505EDD4A214FDA800071C7DE /* RCTConvert+Modal.h in Headers */ = {isa = PBXBuildFile; fileRef = 505EDD48214FDA800071C7DE /* RCTConvert+Modal.h */; };
181
 		505EDD4A214FDA800071C7DE /* RCTConvert+Modal.h in Headers */ = {isa = PBXBuildFile; fileRef = 505EDD48214FDA800071C7DE /* RCTConvert+Modal.h */; };
182
 		5060DE73219DAD7E00D0C052 /* ReactNativeNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BA500731E2544B9001B9E1B /* ReactNativeNavigation.h */; };
182
 		5060DE73219DAD7E00D0C052 /* ReactNativeNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BA500731E2544B9001B9E1B /* ReactNativeNavigation.h */; };
183
 		5060DE74219DAD8300D0C052 /* RNNBridgeManagerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 502CB43920CBCA140019B2FE /* RNNBridgeManagerDelegate.h */; };
183
 		5060DE74219DAD8300D0C052 /* RNNBridgeManagerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 502CB43920CBCA140019B2FE /* RNNBridgeManagerDelegate.h */; };
184
+		506317AA220B547400B26FC3 /* UIImage+insets.h in Headers */ = {isa = PBXBuildFile; fileRef = 506317A8220B547400B26FC3 /* UIImage+insets.h */; };
185
+		506317AB220B547400B26FC3 /* UIImage+insets.m in Sources */ = {isa = PBXBuildFile; fileRef = 506317A9220B547400B26FC3 /* UIImage+insets.m */; };
186
+		506317AE220B550600B26FC3 /* RNNInsetsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 506317AC220B550600B26FC3 /* RNNInsetsOptions.h */; };
187
+		506317AF220B550600B26FC3 /* RNNInsetsOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 506317AD220B550600B26FC3 /* RNNInsetsOptions.m */; };
184
 		5064495D20DC62B90026709C /* RNNSideMenuSideOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5064495B20DC62B90026709C /* RNNSideMenuSideOptions.h */; };
188
 		5064495D20DC62B90026709C /* RNNSideMenuSideOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5064495B20DC62B90026709C /* RNNSideMenuSideOptions.h */; };
185
 		5064495E20DC62B90026709C /* RNNSideMenuSideOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5064495C20DC62B90026709C /* RNNSideMenuSideOptions.m */; };
189
 		5064495E20DC62B90026709C /* RNNSideMenuSideOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5064495C20DC62B90026709C /* RNNSideMenuSideOptions.m */; };
186
 		50644A2020E11A720026709C /* Constants.h in Headers */ = {isa = PBXBuildFile; fileRef = 50644A1E20E11A720026709C /* Constants.h */; };
190
 		50644A2020E11A720026709C /* Constants.h in Headers */ = {isa = PBXBuildFile; fileRef = 50644A1E20E11A720026709C /* Constants.h */; };
508
 		505EDD3B214FA8000071C7DE /* RNNViewControllerPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNViewControllerPresenter.m; sourceTree = "<group>"; };
512
 		505EDD3B214FA8000071C7DE /* RNNViewControllerPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNViewControllerPresenter.m; sourceTree = "<group>"; };
509
 		505EDD47214FC4A60071C7DE /* RNNLayoutProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNLayoutProtocol.h; sourceTree = "<group>"; };
513
 		505EDD47214FC4A60071C7DE /* RNNLayoutProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNLayoutProtocol.h; sourceTree = "<group>"; };
510
 		505EDD48214FDA800071C7DE /* RCTConvert+Modal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTConvert+Modal.h"; sourceTree = "<group>"; };
514
 		505EDD48214FDA800071C7DE /* RCTConvert+Modal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTConvert+Modal.h"; sourceTree = "<group>"; };
515
+		506317A8220B547400B26FC3 /* UIImage+insets.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+insets.h"; sourceTree = "<group>"; };
516
+		506317A9220B547400B26FC3 /* UIImage+insets.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+insets.m"; sourceTree = "<group>"; };
517
+		506317AC220B550600B26FC3 /* RNNInsetsOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNInsetsOptions.h; sourceTree = "<group>"; };
518
+		506317AD220B550600B26FC3 /* RNNInsetsOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNInsetsOptions.m; sourceTree = "<group>"; };
511
 		5064495B20DC62B90026709C /* RNNSideMenuSideOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuSideOptions.h; sourceTree = "<group>"; };
519
 		5064495B20DC62B90026709C /* RNNSideMenuSideOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuSideOptions.h; sourceTree = "<group>"; };
512
 		5064495C20DC62B90026709C /* RNNSideMenuSideOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuSideOptions.m; sourceTree = "<group>"; };
520
 		5064495C20DC62B90026709C /* RNNSideMenuSideOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuSideOptions.m; sourceTree = "<group>"; };
513
 		50644A1E20E11A720026709C /* Constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
521
 		50644A1E20E11A720026709C /* Constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
697
 				50644A1F20E11A720026709C /* Constants.m */,
705
 				50644A1F20E11A720026709C /* Constants.m */,
698
 				50706E6B20CE7CA5003345C3 /* UIImage+tint.h */,
706
 				50706E6B20CE7CA5003345C3 /* UIImage+tint.h */,
699
 				50706E6C20CE7CA5003345C3 /* UIImage+tint.m */,
707
 				50706E6C20CE7CA5003345C3 /* UIImage+tint.m */,
708
+				506317A8220B547400B26FC3 /* UIImage+insets.h */,
709
+				506317A9220B547400B26FC3 /* UIImage+insets.m */,
700
 				5038A372216CDDB6009280BC /* UIViewController+SideMenuController.h */,
710
 				5038A372216CDDB6009280BC /* UIViewController+SideMenuController.h */,
701
 				5038A373216CDDB6009280BC /* UIViewController+SideMenuController.m */,
711
 				5038A373216CDDB6009280BC /* UIViewController+SideMenuController.m */,
702
 				5038A3BF216E1E66009280BC /* RNNFontAttributesCreator.h */,
712
 				5038A3BF216E1E66009280BC /* RNNFontAttributesCreator.h */,
931
 				E33AC20720B5C4F90090DB8A /* RNNSplitViewOptions.m */,
941
 				E33AC20720B5C4F90090DB8A /* RNNSplitViewOptions.m */,
932
 				E3458D3C20BD9CA10023149B /* RNNPreviewOptions.h */,
942
 				E3458D3C20BD9CA10023149B /* RNNPreviewOptions.h */,
933
 				E3458D3D20BD9CE40023149B /* RNNPreviewOptions.m */,
943
 				E3458D3D20BD9CE40023149B /* RNNPreviewOptions.m */,
944
+				506317AC220B550600B26FC3 /* RNNInsetsOptions.h */,
945
+				506317AD220B550600B26FC3 /* RNNInsetsOptions.m */,
934
 			);
946
 			);
935
 			name = Options;
947
 			name = Options;
936
 			sourceTree = "<group>";
948
 			sourceTree = "<group>";
1250
 				50D031342005149000386B3D /* RNNOverlayManager.h in Headers */,
1262
 				50D031342005149000386B3D /* RNNOverlayManager.h in Headers */,
1251
 				7B1126A71E2D2B6C00F9B03B /* RNNEventEmitter.h in Headers */,
1263
 				7B1126A71E2D2B6C00F9B03B /* RNNEventEmitter.h in Headers */,
1252
 				E8A430111F9CB87B00B61A20 /* RNNAnimatedView.h in Headers */,
1264
 				E8A430111F9CB87B00B61A20 /* RNNAnimatedView.h in Headers */,
1265
+				506317AA220B547400B26FC3 /* UIImage+insets.h in Headers */,
1253
 				5038A3C6216E2D93009280BC /* Number.h in Headers */,
1266
 				5038A3C6216E2D93009280BC /* Number.h in Headers */,
1254
 				50887C1520ECC5C200D06111 /* RNNButtonOptions.h in Headers */,
1267
 				50887C1520ECC5C200D06111 /* RNNButtonOptions.h in Headers */,
1255
 				5049593E216F5D73006D2B81 /* BoolParser.h in Headers */,
1268
 				5049593E216F5D73006D2B81 /* BoolParser.h in Headers */,
1299
 				507F43C91FF4F9CC00D9425B /* RNNTopTabOptions.h in Headers */,
1312
 				507F43C91FF4F9CC00D9425B /* RNNTopTabOptions.h in Headers */,
1300
 				E8A5CD521F464F0400E89D0D /* RNNAnimator.h in Headers */,
1313
 				E8A5CD521F464F0400E89D0D /* RNNAnimator.h in Headers */,
1301
 				50451D0D2042F70900695F00 /* RNNTransition.h in Headers */,
1314
 				50451D0D2042F70900695F00 /* RNNTransition.h in Headers */,
1315
+				506317AE220B550600B26FC3 /* RNNInsetsOptions.h in Headers */,
1302
 				507F43F81FF525B500D9425B /* RNNSegmentedControl.h in Headers */,
1316
 				507F43F81FF525B500D9425B /* RNNSegmentedControl.h in Headers */,
1303
 				50175CD1207A2AA1004FE91B /* RNNComponentOptions.h in Headers */,
1317
 				50175CD1207A2AA1004FE91B /* RNNComponentOptions.h in Headers */,
1304
 				5038A3B1216DF41B009280BC /* UIViewController+RNNOptions.h in Headers */,
1318
 				5038A3B1216DF41B009280BC /* UIViewController+RNNOptions.h in Headers */,
1481
 				506A2B1520973DFD00F43A95 /* RNNErrorHandler.m in Sources */,
1495
 				506A2B1520973DFD00F43A95 /* RNNErrorHandler.m in Sources */,
1482
 				50395588217480C900B0A663 /* IntNumber.m in Sources */,
1496
 				50395588217480C900B0A663 /* IntNumber.m in Sources */,
1483
 				7BBFE5441E25330E002A6182 /* RNNBridgeModule.m in Sources */,
1497
 				7BBFE5441E25330E002A6182 /* RNNBridgeModule.m in Sources */,
1498
+				506317AF220B550600B26FC3 /* RNNInsetsOptions.m in Sources */,
1484
 				261F0E651E6EC94900989DE2 /* RNNModalManager.m in Sources */,
1499
 				261F0E651E6EC94900989DE2 /* RNNModalManager.m in Sources */,
1485
 				50395590217482FE00B0A663 /* NullIntNumber.m in Sources */,
1500
 				50395590217482FE00B0A663 /* NullIntNumber.m in Sources */,
1486
 				E8A5CD631F49114F00E89D0D /* RNNElement.m in Sources */,
1501
 				E8A5CD631F49114F00E89D0D /* RNNElement.m in Sources */,
1519
 				E33AC20020B5BA0B0090DB8A /* RNNSplitViewController.m in Sources */,
1534
 				E33AC20020B5BA0B0090DB8A /* RNNSplitViewController.m in Sources */,
1520
 				263905CF1E4C6F440023D7D3 /* TheSidebarController.m in Sources */,
1535
 				263905CF1E4C6F440023D7D3 /* TheSidebarController.m in Sources */,
1521
 				5038A3C2216E1E66009280BC /* RNNFontAttributesCreator.m in Sources */,
1536
 				5038A3C2216E1E66009280BC /* RNNFontAttributesCreator.m in Sources */,
1537
+				506317AB220B547400B26FC3 /* UIImage+insets.m in Sources */,
1522
 				E8A430121F9CB87B00B61A20 /* RNNAnimatedView.m in Sources */,
1538
 				E8A430121F9CB87B00B61A20 /* RNNAnimatedView.m in Sources */,
1523
 				507F43F51FF4FCFE00D9425B /* HMSegmentedControl.m in Sources */,
1539
 				507F43F51FF4FCFE00D9425B /* HMSegmentedControl.m in Sources */,
1524
 				5012242321736883000F5F98 /* NullColor.m in Sources */,
1540
 				5012242321736883000F5F98 /* NullColor.m in Sources */,

+ 7
- 0
lib/ios/UIImage+insets.h View File

1
+#import <UIKit/UIKit.h>
2
+
3
+@interface UIImage (insets)
4
+
5
+- (UIImage *)imageWithInsets:(UIEdgeInsets)insets;
6
+
7
+@end

+ 20
- 0
lib/ios/UIImage+insets.m View File

1
+#import "UIImage+insets.h"
2
+
3
+@implementation UIImage (insets)
4
+
5
+- (UIImage *)imageWithInsets:(UIEdgeInsets)insets {
6
+	UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.size.width + insets.left + insets.right,
7
+													  self.size.height + insets.top + insets.bottom), false, self.scale);
8
+	CGContextRef context = UIGraphicsGetCurrentContext();
9
+	UIGraphicsPushContext(context);
10
+	
11
+	CGPoint origin = CGPointMake(insets.left, insets.top);
12
+	[self drawAtPoint:origin];
13
+	
14
+	UIGraphicsPopContext();
15
+	UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
16
+	UIGraphicsEndImageContext();
17
+	return newImage;
18
+}
19
+
20
+@end

+ 23
- 0
lib/src/interfaces/Options.ts View File

247
    * Set the button icon
247
    * Set the button icon
248
    */
248
    */
249
   icon?: ImageRequireSource;
249
   icon?: ImageRequireSource;
250
+   /**
251
+   * Set the button icon insets
252
+   */
253
+  iconInsets?: IconInsets;
250
   /**
254
   /**
251
    * Set the button as a custom component
255
    * Set the button as a custom component
252
    */
256
    */
692
   rotation?: OptionsAnimationPropertyConfig;
696
   rotation?: OptionsAnimationPropertyConfig;
693
 }
697
 }
694
 
698
 
699
+export interface IconInsets {
700
+  /**
701
+   * Configure top inset
702
+   */
703
+  top?: number;
704
+  /**
705
+   * Configure left inset
706
+   */
707
+  left?: number;
708
+  /**
709
+   * Configure bottom inset
710
+   */
711
+  bottom?: number;
712
+  /**
713
+   * Configure right inset
714
+   */
715
+  right?: number;
716
+}
717
+
695
 export interface OptionsAnimationPropertiesId extends OptionsAnimationProperties {
718
 export interface OptionsAnimationPropertiesId extends OptionsAnimationProperties {
696
   /**
719
   /**
697
    * ID of the Top Bar we want to animate
720
    * ID of the Top Bar we want to animate