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,5 +8,6 @@
8 8
 @property (nonatomic, strong) NSString* testID;
9 9
 @property (nonatomic, strong) NSNumber* visible;
10 10
 @property (nonatomic, strong) NSDictionary* icon;
11
+@property (nonatomic, strong) NSDictionary* iconInsets;
11 12
 
12 13
 @end

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

@@ -13,8 +13,23 @@
13 13
 
14 14
 - (void)applyOn:(UIViewController *)viewController {
15 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 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 33
 		[viewController.navigationController setTabBarItem:tabItem];
19 34
 	}
20 35
 	
@@ -43,6 +58,7 @@
43 58
 	self.visible = nil;
44 59
 	self.icon = nil;
45 60
 	self.testID = nil;
61
+	self.iconInsets = nil;
46 62
 }
47 63
 
48 64
 @end