Browse Source

BottomTab iconsInsets support

yogevbd 6 years ago
parent
commit
56c1564060
2 changed files with 18 additions and 1 deletions
  1. 1
    0
      lib/ios/RNNBottomTabOptions.h
  2. 17
    1
      lib/ios/RNNBottomTabOptions.m

+ 1
- 0
lib/ios/RNNBottomTabOptions.h View File

8
 @property (nonatomic, strong) NSString* testID;
8
 @property (nonatomic, strong) NSString* testID;
9
 @property (nonatomic, strong) NSNumber* visible;
9
 @property (nonatomic, strong) NSNumber* visible;
10
 @property (nonatomic, strong) NSDictionary* icon;
10
 @property (nonatomic, strong) NSDictionary* icon;
11
+@property (nonatomic, strong) NSDictionary* iconInsets;
11
 
12
 
12
 @end
13
 @end

+ 17
- 1
lib/ios/RNNBottomTabOptions.m View File

13
 
13
 
14
 - (void)applyOn:(UIViewController *)viewController {
14
 - (void)applyOn:(UIViewController *)viewController {
15
 	if (self.title || self.icon) {
15
 	if (self.title || self.icon) {
16
-		UITabBarItem* tabItem = [[UITabBarItem alloc] initWithTitle:self.title image:[RCTConvert UIImage:self.icon] tag:self.tag];
16
+		UITabBarItem* tabItem = [[UITabBarItem alloc] initWithTitle:nil image:[RCTConvert UIImage:self.icon] tag:self.tag];
17
 		tabItem.accessibilityIdentifier = self.testID;
17
 		tabItem.accessibilityIdentifier = self.testID;
18
+		
19
+		if (self.iconInsets && ![self.iconInsets isKindOfClass:[NSNull class]]) {
20
+			id topInset = self.iconInsets[@"top"];
21
+			id leftInset = self.iconInsets[@"left"];
22
+			id bottomInset = self.iconInsets[@"bottom"];
23
+			id rightInset = self.iconInsets[@"right"];
24
+			
25
+			CGFloat top = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:topInset] : 0;
26
+			CGFloat left = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:leftInset] : 0;
27
+			CGFloat bottom = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:bottomInset] : 0;
28
+			CGFloat right = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:rightInset] : 0;
29
+			
30
+			tabItem.imageInsets = UIEdgeInsetsMake(top, left, bottom, right);
31
+		}
32
+		
18
 		[viewController.navigationController setTabBarItem:tabItem];
33
 		[viewController.navigationController setTabBarItem:tabItem];
19
 	}
34
 	}
20
 	
35
 	
43
 	self.visible = nil;
58
 	self.visible = nil;
44
 	self.icon = nil;
59
 	self.icon = nil;
45
 	self.testID = nil;
60
 	self.testID = nil;
61
+	self.iconInsets = nil;
46
 }
62
 }
47
 
63
 
48
 @end
64
 @end