Sfoglia il codice sorgente

refactored navigation options (#2474)

* refactored navigation options

* test fix

* better namings
yogevbd 7 anni fa
parent
commit
b0da9e2470
42 ha cambiato i file con 548 aggiunte e 577 eliminazioni
  1. 0
    12
      lib/android/app/src/main/java/com/reactnativenavigation/parse/NavigationOptions.java
  2. 14
    0
      lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarOptions.java
  3. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java
  4. 2
    8
      lib/ios/RNNBottomTabOptions.h
  5. 51
    0
      lib/ios/RNNBottomTabOptions.m
  6. 2
    9
      lib/ios/RNNBottomTabsOptions.h
  7. 45
    0
      lib/ios/RNNBottomTabsOptions.m
  8. 0
    1
      lib/ios/RNNCommandsHandler.m
  9. 0
    1
      lib/ios/RNNNavigationButtons.h
  10. 14
    15
      lib/ios/RNNNavigationButtons.m
  11. 1
    1
      lib/ios/RNNNavigationController.m
  12. 11
    20
      lib/ios/RNNNavigationOptions.h
  13. 11
    254
      lib/ios/RNNNavigationOptions.m
  14. 1
    1
      lib/ios/RNNNavigationStackManager.m
  15. 17
    0
      lib/ios/RNNOptions.h
  16. 18
    0
      lib/ios/RNNOptions.m
  17. 1
    2
      lib/ios/RNNRootViewController.h
  18. 4
    11
      lib/ios/RNNRootViewController.m
  19. 2
    1
      lib/ios/RNNRootViewProtocol.h
  20. 1
    1
      lib/ios/RNNSideMenuChildVC.m
  21. 1
    1
      lib/ios/RNNSideMenuController.m
  22. 2
    8
      lib/ios/RNNSideMenuOptions.h
  23. 22
    10
      lib/ios/RNNSideMenuOptions.m
  24. 1
    1
      lib/ios/RNNTabBarController.m
  25. 0
    32
      lib/ios/RNNTabBarOptions.m
  26. 0
    32
      lib/ios/RNNTabItemOptions.m
  27. 4
    8
      lib/ios/RNNTopBarOptions.h
  28. 164
    28
      lib/ios/RNNTopBarOptions.m
  29. 3
    8
      lib/ios/RNNTopTabOptions.h
  30. 5
    10
      lib/ios/RNNTopTabOptions.m
  31. 7
    0
      lib/ios/RNNTopTabsOptions.h
  32. 10
    0
      lib/ios/RNNTopTabsOptions.m
  33. 2
    2
      lib/ios/RNNTopTabsViewController.m
  34. 48
    22
      lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj
  35. 3
    3
      lib/ios/ReactNativeNavigationTests/RNNNavigationOptionsTest.m
  36. 5
    5
      lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m
  37. 0
    5
      lib/src/params/options/NavigationOptions.js
  38. 0
    20
      lib/src/params/options/NavigationOptions.test.js
  39. 6
    0
      lib/src/params/options/TopBar.js
  40. 22
    1
      lib/src/params/options/TopBar.test.js
  41. 46
    42
      playground/src/containers/OptionsScreen.js
  42. 1
    1
      playground/src/containers/WelcomeScreen.js

+ 0
- 12
lib/android/app/src/main/java/com/reactnativenavigation/parse/NavigationOptions.java Vedi File

@@ -37,8 +37,6 @@ public class NavigationOptions implements DEFAULT_VALUES {
37 37
 		result.topTabsOptions = TopTabsOptions.parse(json.optJSONObject("topTabs"));
38 38
         result.topTabOptions = TopTabOptions.parse(typefaceManager, json.optJSONObject("topTab"));
39 39
 		result.bottomTabsOptions = BottomTabsOptions.parse(json.optJSONObject("bottomTabs"));
40
-		result.rightButtons = Button.parseJsonArray(json.optJSONArray("rightButtons"));
41
-        result.leftButtons = Button.parseJsonArray(json.optJSONArray("leftButtons"));
42 40
 
43 41
 		return result.withDefaultOptions(defaultOptions);
44 42
 	}
@@ -47,21 +45,11 @@ public class NavigationOptions implements DEFAULT_VALUES {
47 45
     @NonNull public TopTabsOptions topTabsOptions = new TopTabsOptions();
48 46
     @NonNull public TopTabOptions topTabOptions = new TopTabOptions();
49 47
     @NonNull public BottomTabsOptions bottomTabsOptions = new BottomTabsOptions();
50
-    public ArrayList<Button> leftButtons;
51
-    public ArrayList<Button> rightButtons;
52 48
 
53 49
 	public void mergeWith(final NavigationOptions other) {
54 50
         topBarOptions.mergeWith(other.topBarOptions);
55 51
         topTabsOptions.mergeWith(other.topTabsOptions);
56 52
         bottomTabsOptions.mergeWith(other.bottomTabsOptions);
57
-
58
-        if(other.leftButtons != null) {
59
-            leftButtons = other.leftButtons;
60
-        }
61
-
62
-        if(other.rightButtons != null) {
63
-            rightButtons = other.rightButtons;
64
-        }
65 53
     }
66 54
 
67 55
     NavigationOptions withDefaultOptions(final NavigationOptions other) {

+ 14
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarOptions.java Vedi File

@@ -9,6 +9,8 @@ import com.reactnativenavigation.utils.TypefaceLoader;
9 9
 
10 10
 import org.json.JSONObject;
11 11
 
12
+import java.util.ArrayList;
13
+
12 14
 public class TopBarOptions implements DEFAULT_VALUES {
13 15
 
14 16
 	public static TopBarOptions parse(TypefaceLoader typefaceManager, JSONObject json) {
@@ -22,6 +24,8 @@ public class TopBarOptions implements DEFAULT_VALUES {
22 24
 		options.textFontFamily = typefaceManager.getTypeFace(json.optString("textFontFamily", NO_VALUE));
23 25
 		options.hidden = NavigationOptions.BooleanOptions.parse(json.optString("hidden"));
24 26
 		options.animateHide = NavigationOptions.BooleanOptions.parse(json.optString("animateHide"));
27
+		options.rightButtons = Button.parseJsonArray(json.optJSONArray("rightButtons"));
28
+		options.leftButtons = Button.parseJsonArray(json.optJSONArray("leftButtons"));
25 29
 
26 30
 		return options;
27 31
 	}
@@ -33,6 +37,8 @@ public class TopBarOptions implements DEFAULT_VALUES {
33 37
 	@Nullable public Typeface textFontFamily;
34 38
 	public NavigationOptions.BooleanOptions hidden = NavigationOptions.BooleanOptions.False;
35 39
 	public NavigationOptions.BooleanOptions animateHide = NavigationOptions.BooleanOptions.False;
40
+	public ArrayList<Button> leftButtons;
41
+	public ArrayList<Button> rightButtons;
36 42
 
37 43
 	void mergeWith(final TopBarOptions other) {
38 44
 		if (!NO_VALUE.equals(other.title)) title = other.title;
@@ -48,6 +54,10 @@ public class TopBarOptions implements DEFAULT_VALUES {
48 54
 			hidden = other.hidden;
49 55
 		if (other.animateHide != NavigationOptions.BooleanOptions.NoValue)
50 56
 			animateHide = other.animateHide;
57
+		if(other.leftButtons != null)
58
+			leftButtons = other.leftButtons;
59
+		if(other.rightButtons != null)
60
+			rightButtons = other.rightButtons;
51 61
 	}
52 62
 
53 63
     void mergeWithDefault(TopBarOptions defaultOptions) {
@@ -65,5 +75,9 @@ public class TopBarOptions implements DEFAULT_VALUES {
65 75
             hidden = defaultOptions.hidden;
66 76
         if (animateHide == NavigationOptions.BooleanOptions.NoValue)
67 77
             animateHide = defaultOptions.animateHide;
78
+		if(leftButtons == null)
79
+			leftButtons = defaultOptions.leftButtons;
80
+		if(rightButtons == null)
81
+			rightButtons = defaultOptions.rightButtons;
68 82
     }
69 83
 }

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java Vedi File

@@ -26,7 +26,7 @@ public class OptionsPresenter {
26 26
 
27 27
     public void applyOptions(NavigationOptions options) {
28 28
         applyTopBarOptions(options.topBarOptions);
29
-        applyButtons(options.leftButtons, options.rightButtons);
29
+        applyButtons(options.topBarOptions.leftButtons, options.topBarOptions.rightButtons);
30 30
         applyTopTabsOptions(options.topTabsOptions);
31 31
         applyTopTabOptions(options.topTabOptions);
32 32
     }

lib/ios/RNNTabItemOptions.h → lib/ios/RNNBottomTabOptions.h Vedi File

@@ -1,6 +1,6 @@
1
-#import <Foundation/Foundation.h>
1
+#import "RNNOptions.h"
2 2
 
3
-@interface RNNTabItemOptions : NSObject
3
+@interface RNNBottomTabOptions : RNNOptions
4 4
 
5 5
 @property (nonatomic) NSUInteger tag;
6 6
 @property (nonatomic, strong) NSString* title;
@@ -9,10 +9,4 @@
9 9
 @property (nonatomic, strong) NSNumber* visible;
10 10
 @property (nonatomic, strong) NSDictionary* icon;
11 11
 
12
--(instancetype)initWithDict:(NSDictionary*)tabItemDict;
13
-
14
--(void)mergeWith:(NSDictionary *)otherOptions;
15
-
16
--(void)resetOptions;
17
-
18 12
 @end

+ 51
- 0
lib/ios/RNNBottomTabOptions.m Vedi File

@@ -0,0 +1,51 @@
1
+#import "RNNBottomTabOptions.h"
2
+
3
+@implementation RNNBottomTabOptions
4
+
5
+-(instancetype)initWithDict:(NSDictionary *)tabItemDict {
6
+	self = [super init];
7
+	
8
+	[self mergeWith:tabItemDict];
9
+	self.tag = [tabItemDict[@"tag"] integerValue];
10
+	
11
+	return self;
12
+}
13
+
14
+- (void)applyOn:(UIViewController *)viewController {
15
+	if (self.title || self.icon) {
16
+		UITabBarItem* tabItem = [[UITabBarItem alloc] initWithTitle:self.title image:[RCTConvert UIImage:self.icon] tag:self.tag];
17
+		tabItem.accessibilityIdentifier = self.testID;
18
+		[viewController.navigationController setTabBarItem:tabItem];
19
+	}
20
+	
21
+	if (self.badge) {
22
+		NSString *badge = [RCTConvert NSString:self.badge];
23
+		if (viewController.navigationController) {
24
+			viewController.navigationController.tabBarItem.badgeValue = badge;
25
+		} else {
26
+			viewController.tabBarItem.badgeValue = badge;
27
+		}
28
+	}
29
+	
30
+	if (self.visible) {
31
+		[viewController.tabBarController setSelectedIndex:[viewController.tabBarController.viewControllers indexOfObject:viewController]];
32
+	}
33
+	
34
+	[self resetOptions];
35
+}
36
+
37
+-(void)mergeWith:(NSDictionary *)otherOptions {
38
+	for (id key in otherOptions) {
39
+		[self setValue:[otherOptions objectForKey:key] forKey:key];
40
+	}
41
+}
42
+
43
+-(void)resetOptions {
44
+	self.title = nil;
45
+	self.badge = nil;
46
+	self.visible = nil;
47
+	self.icon = nil;
48
+	self.testID = nil;
49
+}
50
+
51
+@end

lib/ios/RNNTabBarOptions.h → lib/ios/RNNBottomTabsOptions.h Vedi File

@@ -1,8 +1,6 @@
1
-#import <Foundation/Foundation.h>
1
+#import "RNNOptions.h"
2 2
 
3
-extern const NSInteger BLUR_TOPBAR_TAG;
4
-
5
-@interface RNNTabBarOptions : NSObject
3
+@interface RNNBottomTabsOptions : RNNOptions
6 4
 
7 5
 @property (nonatomic, strong) NSNumber* hidden;
8 6
 @property (nonatomic, strong) NSNumber* animateHide;
@@ -11,9 +9,4 @@ extern const NSInteger BLUR_TOPBAR_TAG;
11 9
 @property (nonatomic, strong) NSNumber* drawUnder;
12 10
 @property (nonatomic, strong) NSString* currentTabId;
13 11
 
14
--(instancetype)init;
15
--(instancetype)initWithDict:(NSDictionary *)topBarOptions;
16
--(void)mergeWith:(NSDictionary*)otherOptions;
17
-- (void)resetOptions;
18
-
19 12
 @end

+ 45
- 0
lib/ios/RNNBottomTabsOptions.m Vedi File

@@ -0,0 +1,45 @@
1
+#import "RNNBottomTabsOptions.h"
2
+#import "RNNTabBarController.h"
3
+extern const NSInteger BLUR_TOPBAR_TAG;
4
+
5
+@implementation RNNBottomTabsOptions
6
+
7
+- (void)applyOn:(UIViewController *)viewController {
8
+	if (self.currentTabIndex) {
9
+		[viewController.tabBarController setSelectedIndex:[self.currentTabIndex unsignedIntegerValue]];
10
+	}
11
+	
12
+	if (self.currentTabId) {
13
+		[(RNNTabBarController*)viewController.tabBarController setSelectedIndexByContainerID:self.currentTabId];
14
+	}
15
+	
16
+	if (self.hidden) {
17
+		[((RNNTabBarController *)viewController.tabBarController) setTabBarHidden:[self.hidden boolValue] animated:[self.animateHide boolValue]];
18
+	}
19
+	
20
+	if (self.testID) {
21
+		viewController.tabBarController.tabBar.accessibilityIdentifier = self.testID;
22
+	}
23
+	
24
+	if (self.drawUnder) {
25
+		if ([self.drawUnder boolValue]) {
26
+			viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
27
+		} else {
28
+			viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;
29
+		}
30
+	}
31
+	
32
+	[self resetOptions];
33
+}
34
+
35
+- (void)resetOptions {
36
+	self.currentTabId = nil;
37
+	self.currentTabIndex = nil;
38
+}
39
+
40
+-(void)mergeWith:(NSDictionary *)otherOptions {
41
+	for (id key in otherOptions) {
42
+		[self setValue:[otherOptions objectForKey:key] forKey:key];
43
+	}
44
+}
45
+@end

+ 0
- 1
lib/ios/RNNCommandsHandler.m Vedi File

@@ -46,7 +46,6 @@
46 46
 		[CATransaction setCompletionBlock:completion];
47 47
 		
48 48
 		[rootVc.navigationOptions applyOn:vc];
49
-		[rootVc applyNavigationButtons];
50 49
 		
51 50
 		[CATransaction commit];
52 51
 	}

+ 0
- 1
lib/ios/RNNNavigationButtons.h Vedi File

@@ -4,7 +4,6 @@
4 4
 
5 5
 @interface RNNNavigationButtons : NSObject
6 6
 
7
--(instancetype)init;
8 7
 -(instancetype)initWithViewController:(RNNRootViewController*)viewController;
9 8
 
10 9
 -(void)applyLeftButtons:(NSArray*)leftButtons rightButtons:(NSArray*)rightButtons;

+ 14
- 15
lib/ios/RNNNavigationButtons.m Vedi File

@@ -4,16 +4,15 @@
4 4
 #import "RCTHelpers.h"
5 5
 
6 6
 @interface RNNNavigationButtons()
7
+
7 8
 @property (weak, nonatomic) RNNRootViewController* viewController;
9
+@property (strong, nonatomic) NSArray* rightButtons;
10
+@property (strong, nonatomic) NSArray* leftButtons;
8 11
 
9 12
 @end
10 13
 
11 14
 @implementation RNNNavigationButtons
12 15
 
13
--(instancetype)init {
14
-	return [super init];
15
-}
16
-
17 16
 -(instancetype)initWithViewController:(RNNRootViewController*)viewController {
18 17
 	self = [super init];
19 18
 	
@@ -23,11 +22,11 @@
23 22
 }
24 23
 
25 24
 -(void)applyLeftButtons:(NSArray*)leftButtons rightButtons:(NSArray*)rightButtons {
26
-	if(leftButtons) {
25
+	if (leftButtons) {
27 26
 		[self setButtons:leftButtons side:@"left" animated:NO];
28 27
 	}
29 28
 	
30
-	if(rightButtons) {
29
+	if (rightButtons) {
31 30
 		[self setButtons:rightButtons side:@"right" animated:NO];
32 31
 	}
33 32
 }
@@ -41,14 +40,14 @@
41 40
 		}
42 41
 	}
43 42
 	
44
-	if ([side isEqualToString:@"left"])
45
-	{
46
-		[self.viewController.navigationItem setLeftBarButtonItems:barButtonItems animated:animated];
43
+	if ([side isEqualToString:@"left"]) {
44
+		self.leftButtons = barButtonItems;
45
+		[self.viewController.navigationItem setLeftBarButtonItems:self.leftButtons animated:animated];
47 46
 	}
48 47
 	
49
-	if ([side isEqualToString:@"right"])
50
-	{
51
-		[self.viewController.navigationItem setRightBarButtonItems:barButtonItems animated:animated];
48
+	if ([side isEqualToString:@"right"]) {
49
+		self.rightButtons = barButtonItems;
50
+		[self.viewController.navigationItem setRightBarButtonItems:self.rightButtons animated:animated];
52 51
 	}
53 52
 }
54 53
 
@@ -56,7 +55,7 @@
56 55
 	NSString* buttonId = dictionary[@"id"];
57 56
 	NSString* title = dictionary[@"title"];
58 57
 	
59
-	if(!buttonId){
58
+	if (!buttonId) {
60 59
 		@throw [NSException exceptionWithName:@"NSInvalidArgumentException" reason:[@"button id is not specified " stringByAppendingString:title] userInfo:nil];
61 60
 	}
62 61
 	
@@ -104,8 +103,8 @@
104 103
 	return barButtonItem;
105 104
 }
106 105
 
107
--(void)onButtonPress:(RNNUIBarButtonItem*)barButtonItem
108
-{
106
+-(void)onButtonPress:(RNNUIBarButtonItem*)barButtonItem {
109 107
 	[self.viewController.eventEmitter sendOnNavigationButtonPressed:self.viewController.containerId buttonId:barButtonItem.buttonId];
110 108
 }
109
+
111 110
 @end

+ 1
- 1
lib/ios/RNNNavigationController.m Vedi File

@@ -7,7 +7,7 @@
7 7
 	return self.viewControllers.lastObject.supportedInterfaceOrientations;
8 8
 }
9 9
 
10
-- (BOOL)isAnimated {
10
+- (BOOL)isCustomTransitioned {
11 11
 	return NO;
12 12
 }
13 13
 

+ 11
- 20
lib/ios/RNNNavigationOptions.h Vedi File

@@ -1,46 +1,37 @@
1 1
 #import <Foundation/Foundation.h>
2
-#import <UIKit/UIKit.h>
3 2
 #import "RNNTopBarOptions.h"
4
-#import "RNNTabBarOptions.h"
3
+#import "RNNBottomTabsOptions.h"
4
+#import "RNNBottomTabOptions.h"
5 5
 #import "RNNSideMenuOptions.h"
6
-#import "RNNTabItemOptions.h"
7 6
 #import "RNNTopTabOptions.h"
7
+#import "RNNTopTabsOptions.h"
8 8
 
9 9
 extern const NSInteger BLUR_STATUS_TAG;
10 10
 extern const NSInteger BLUR_TOPBAR_TAG;
11 11
 extern const NSInteger TOP_BAR_TRANSPARENT_TAG;
12 12
 
13
-@interface RNNNavigationOptions : NSObject
13
+@interface RNNNavigationOptions : RNNOptions
14
+
15
+@property (nonatomic, strong) RNNTopBarOptions* topBar;
16
+@property (nonatomic, strong) RNNBottomTabsOptions* bottomTabs;
17
+@property (nonatomic, strong) RNNBottomTabOptions* bottomTab;
18
+@property (nonatomic, strong) RNNTopTabsOptions* topTabs;
19
+@property (nonatomic, strong) RNNTopTabOptions* topTab;
20
+@property (nonatomic, strong) RNNSideMenuOptions* sideMenu;
14 21
 
15 22
 @property (nonatomic, strong) NSNumber* statusBarHidden;
16 23
 @property (nonatomic, strong) NSNumber* screenBackgroundColor;
17 24
 @property (nonatomic, strong) NSMutableDictionary* originalTopBarImages;
18 25
 @property (nonatomic, strong) NSString* backButtonTransition;
19 26
 @property (nonatomic, strong) id orientation;
20
-@property (nonatomic, strong) NSArray* leftButtons;
21
-@property (nonatomic, strong) NSArray* rightButtons;
22 27
 @property (nonatomic, strong) NSNumber* statusBarBlur;
23 28
 @property (nonatomic, strong) NSNumber* statusBarHideWithTopBar;
24 29
 @property (nonatomic, strong) NSNumber* popGesture;
25
-@property (nonatomic, strong) RNNTopBarOptions* topBar;
26
-@property (nonatomic, strong) RNNTabBarOptions* bottomTabs;
27
-@property (nonatomic, strong) RNNTopTabOptions* topTab;
28
-@property (nonatomic, strong) RNNSideMenuOptions* sideMenu;
29 30
 @property (nonatomic, strong) UIImage* backgroundImage;
30 31
 @property (nonatomic, strong) UIImage* rootBackgroundImage;
31
-@property (nonatomic, strong) RNNTabItemOptions* tabItem;
32 32
 
33 33
 
34 34
 - (UIInterfaceOrientationMask)supportedOrientations;
35 35
 
36
--(instancetype)init;
37
--(instancetype)initWithDict:(NSDictionary *)navigationOptions;
38
-
39
--(void)applyOn:(UIViewController*)viewController;
40
--(void)mergeWith:(NSDictionary*)otherOptions;
41
--(void)storeOriginalTopBarImages:(UIViewController*)viewController;
42
-
43
-- (void)applyTabBarItemOptions:(UIViewController*)viewController;
44
-- (void)applyTopTab:(UIViewController*)viewController;
45 36
 
46 37
 @end

+ 11
- 254
lib/ios/RNNNavigationOptions.m Vedi File

@@ -5,6 +5,7 @@
5 5
 #import "RNNTopBarOptions.h"
6 6
 #import "RNNSideMenuController.h"
7 7
 #import "RNNRootViewController.h"
8
+#import "RNNNavigationButtons.h"
8 9
 
9 10
 const NSInteger BLUR_STATUS_TAG = 78264801;
10 11
 const NSInteger BLUR_TOPBAR_TAG = 78264802;
@@ -12,8 +13,6 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
12 13
 
13 14
 @implementation RNNNavigationOptions
14 15
 
15
-
16
-
17 16
 -(instancetype)init {
18 17
 	return [self initWithDict:@{}];
19 18
 }
@@ -24,31 +23,22 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
24 23
 	self.screenBackgroundColor = [navigationOptions objectForKey:@"screenBackgroundColor"];
25 24
 	self.backButtonTransition = [navigationOptions objectForKey:@"backButtonTransition"];
26 25
 	self.orientation = [navigationOptions objectForKey:@"orientation"];
27
-	self.leftButtons = [navigationOptions objectForKey:@"leftButtons"];
28
-	self.rightButtons = [navigationOptions objectForKey:@"rightButtons"];
29 26
 	self.topBar = [[RNNTopBarOptions alloc] initWithDict:[navigationOptions objectForKey:@"topBar"]];
30 27
 	self.topTab = [[RNNTopTabOptions alloc] initWithDict:[navigationOptions objectForKey:@"topTab"]];
31
-	self.bottomTabs = [[RNNTabBarOptions alloc] initWithDict:[navigationOptions objectForKey:@"bottomTabs"]];
28
+	self.bottomTabs = [[RNNBottomTabsOptions alloc] initWithDict:[navigationOptions objectForKey:@"bottomTabs"]];
32 29
 	self.sideMenu = [[RNNSideMenuOptions alloc] initWithDict:[navigationOptions objectForKey:@"sideMenu"]];
33 30
 	self.backgroundImage = [RCTConvert UIImage:[navigationOptions objectForKey:@"backgroundImage"]];
34 31
 	self.rootBackgroundImage = [RCTConvert UIImage:[navigationOptions objectForKey:@"rootBackgroundImage"]];
35
-	self.tabItem = [[RNNTabItemOptions alloc] initWithDict:[navigationOptions objectForKey:@"bottomTab"]];
32
+	self.bottomTab = [[RNNBottomTabOptions alloc] initWithDict:[navigationOptions objectForKey:@"bottomTab"]];
36 33
     
37 34
 	return self;
38 35
 }
39 36
 
40 37
 -(void)mergeWith:(NSDictionary *)otherOptions {
41 38
 	for (id key in otherOptions) {
42
-		if ([key isEqualToString:@"topBar"]) {
43
-			[self.topBar mergeWith:[otherOptions objectForKey:key]];
44
-		} else if ([key isEqualToString:@"bottomTabs"]) {
45
-			[self.bottomTabs mergeWith:[otherOptions objectForKey:key]];
46
-		} else if ([key isEqualToString:@"topTab"]) {
47
-			[self.topTab mergeWith:[otherOptions objectForKey:key]];
48
-		} else if ([key isEqualToString:@"sideMenu"]) {
49
-			[self.sideMenu mergeWith:[otherOptions objectForKey:@"sideMenu"]];
50
-		} else if ([key isEqualToString:@"bottomTab"]) {
51
-			[self.tabItem mergeWith:[otherOptions objectForKey:key]];
39
+		if ([[self valueForKey:key] isKindOfClass:[RNNOptions class]]) {
40
+			RNNOptions* options = [self valueForKey:key];
41
+			[options mergeWith:[otherOptions objectForKey:key]];
52 42
 		} else {
53 43
 			[self setValue:[otherOptions objectForKey:key] forKey:key];
54 44
 		}
@@ -56,145 +46,11 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
56 46
 }
57 47
 
58 48
 -(void)applyOn:(UIViewController*)viewController {
59
-	if (self.topBar) {
60
-		if (self.topBar.backgroundColor) {
61
-			UIColor* backgroundColor = [RCTConvert UIColor:self.topBar.backgroundColor];
62
-			viewController.navigationController.navigationBar.barTintColor = backgroundColor;
63
-		} else {
64
-			viewController.navigationController.navigationBar.barTintColor = nil;
65
-		}
66
-		
67
-		if (self.topBar.title) {
68
-			viewController.navigationItem.title = self.topBar.title;
69
-		}
70
-		
71
-		if (@available(iOS 11.0, *)) {
72
-			if (self.topBar.largeTitle){
73
-				if ([self.topBar.largeTitle boolValue]) {
74
-					viewController.navigationController.navigationBar.prefersLargeTitles = YES;
75
-					viewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;
76
-				} else {
77
-					viewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
78
-				}
79
-			} else {
80
-				viewController.navigationController.navigationBar.prefersLargeTitles = NO;
81
-				viewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
82
-			}
83
-		}
84
-		
85
-		
86
-		if (self.topBar.textFontFamily || self.topBar.textFontSize || self.topBar.textColor) {
87
-			NSMutableDictionary* navigationBarTitleTextAttributes = [NSMutableDictionary new];
88
-			if (self.topBar.textColor) {
89
-				navigationBarTitleTextAttributes[NSForegroundColorAttributeName] = [RCTConvert UIColor:[self.topBar valueForKey:@"textColor"]];
90
-			}
91
-			if (self.topBar.textFontFamily){
92
-				if(self.topBar.textFontSize) {
93
-					navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.topBar.textFontFamily size:[self.topBar.textFontSize floatValue]];
94
-				} else {
95
-					navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.topBar.textFontFamily size:20];
96
-				}
97
-			} else if (self.topBar.textFontSize) {
98
-				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:[self.topBar.textFontSize floatValue]];
99
-			}
100
-			viewController.navigationController.navigationBar.titleTextAttributes = navigationBarTitleTextAttributes;
101
-			if (@available(iOS 11.0, *)){
102
-				viewController.navigationController.navigationBar.largeTitleTextAttributes = navigationBarTitleTextAttributes;
103
-			}
104
-			
105
-		}
106
-		
107
-		
108
-		if (self.topBar.hidden){
109
-			[viewController.navigationController setNavigationBarHidden:[self.topBar.hidden boolValue] animated:[self.topBar.animateHide boolValue]];
110
-		}
111
-		
112
-		if (self.topBar.hideOnScroll) {
113
-			viewController.navigationController.hidesBarsOnSwipe = [self.topBar.hideOnScroll boolValue];
114
-		}
115
-		
116
-		if (self.topBar.buttonColor) {
117
-			UIColor* buttonColor = [RCTConvert UIColor:self.topBar.buttonColor];
118
-			viewController.navigationController.navigationBar.tintColor = buttonColor;
119
-		} else {
120
-			viewController.navigationController.navigationBar.tintColor = nil;
121
-		}
122
-		
123
-		if ([self.topBar.blur boolValue]) {
124
-			if (![viewController.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]) {
125
-				
126
-				[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
127
-				viewController.navigationController.navigationBar.shadowImage = [UIImage new];
128
-				UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
129
-				CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
130
-				blur.frame = CGRectMake(0, -1 * statusBarFrame.size.height, viewController.navigationController.navigationBar.frame.size.width, viewController.navigationController.navigationBar.frame.size.height + statusBarFrame.size.height);
131
-				blur.userInteractionEnabled = NO;
132
-				blur.tag = BLUR_TOPBAR_TAG;
133
-				[viewController.navigationController.navigationBar insertSubview:blur atIndex:0];
134
-				[viewController.navigationController.navigationBar sendSubviewToBack:blur];
135
-			}
136
-		} else {
137
-			UIView *blur = [viewController.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG];
138
-			if (blur) {
139
-				[viewController.navigationController.navigationBar setBackgroundImage: nil forBarMetrics:UIBarMetricsDefault];
140
-				viewController.navigationController.navigationBar.shadowImage = nil;
141
-				[blur removeFromSuperview];
142
-			}
143
-		}
144
-		
145
-		void (^disableTopBarTransparent)() = ^void(){
146
-			UIView *transparentView = [viewController.navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG];
147
-			if (transparentView){
148
-				[transparentView removeFromSuperview];
149
-				[viewController.navigationController.navigationBar setBackgroundImage:self.originalTopBarImages[@"backgroundImage"] forBarMetrics:UIBarMetricsDefault];
150
-				viewController.navigationController.navigationBar.shadowImage = self.originalTopBarImages[@"shadowImage"];
151
-				self.originalTopBarImages = nil;
152
-			}
153
-		};
154
-	
155
-		if (self.topBar.transparent) {
156
-			if ([self.topBar.transparent boolValue]) {
157
-				if (![viewController.navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG]){
158
-					[self storeOriginalTopBarImages:viewController];
159
-					[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
160
-					viewController.navigationController.navigationBar.shadowImage = [UIImage new];
161
-					UIView *transparentView = [[UIView alloc] initWithFrame:CGRectZero];
162
-					transparentView.tag = TOP_BAR_TRANSPARENT_TAG;
163
-					[viewController.navigationController.navigationBar insertSubview:transparentView atIndex:0];
164
-				}
165
-			} else {
166
-				disableTopBarTransparent();
167
-			}
168
-		} else {
169
-			disableTopBarTransparent();
170
-		}
171
-
172
-		if (self.topBar.translucent) {
173
-			viewController.navigationController.navigationBar.translucent = [self.topBar.translucent boolValue];
174
-		}
175
-
176
-		if (self.topBar.drawUnder) {
177
-			if ([self.topBar.drawUnder boolValue]) {
178
-				viewController.edgesForExtendedLayout |= UIRectEdgeTop;
179
-			} else {
180
-				viewController.edgesForExtendedLayout &= ~UIRectEdgeTop;
181
-			}
182
-		}
183
-		
184
-		if (self.topBar.noBorder) {
185
-			if ([self.topBar.noBorder boolValue]) {
186
-				viewController.navigationController.navigationBar
187
-				.shadowImage = [[UIImage alloc] init];
188
-			} else {
189
-				viewController.navigationController.navigationBar
190
-				.shadowImage = nil;
191
-			}
192
-		}
193
-		
194
-		if (self.topBar.testID) {
195
-			viewController.navigationController.navigationBar.accessibilityIdentifier = self.topBar.testID;
196
-		}
197
-	}
49
+	[self.topBar applyOn:viewController];
50
+	[self.bottomTabs applyOn:viewController];
51
+	[self.topTab applyOn:viewController];
52
+	[self.bottomTab applyOn:viewController];
53
+	[self.sideMenu applyOn:viewController];
198 54
 	
199 55
 	if (self.popGesture) {
200 56
 		viewController.navigationController.interactivePopGestureRecognizer.enabled = [self.popGesture boolValue];
@@ -205,34 +61,6 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
205 61
 		viewController.view.backgroundColor = screenColor;
206 62
 	}
207 63
 	
208
-	if (self.bottomTabs) {
209
-		if (self.bottomTabs.currentTabIndex) {
210
-			[viewController.tabBarController setSelectedIndex:[self.bottomTabs.currentTabIndex unsignedIntegerValue]];
211
-		}
212
-		
213
-		if (self.bottomTabs.currentTabId) {
214
-			[(RNNTabBarController*)viewController.tabBarController setSelectedIndexByContainerID:self.bottomTabs.currentTabId];
215
-		}
216
-		
217
-		if (self.bottomTabs.hidden) {
218
-			[((RNNTabBarController *)viewController.tabBarController) setTabBarHidden:[self.bottomTabs.hidden boolValue] animated:[self.bottomTabs.animateHide boolValue]];
219
-		}
220
-		
221
-		if (self.bottomTabs.testID) {
222
-			viewController.tabBarController.tabBar.accessibilityIdentifier = self.bottomTabs.testID;
223
-		}
224
-		
225
-		if (self.bottomTabs.drawUnder) {
226
-			if ([self.bottomTabs.drawUnder boolValue]) {
227
-				viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
228
-			} else {
229
-				viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;
230
-			}
231
-		}
232
-		
233
-		[self.bottomTabs resetOptions];
234
-	}
235
-	
236 64
 	if (self.statusBarBlur) {
237 65
 		UIView* curBlurView = [viewController.view viewWithTag:BLUR_STATUS_TAG];
238 66
 		if ([self.statusBarBlur boolValue]) {
@@ -249,27 +77,6 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
249 77
 		}
250 78
 	}
251 79
 	
252
-	RNNSideMenuController* sideMenuController = (RNNSideMenuController*)UIApplication.sharedApplication.delegate.window.rootViewController;
253
-	if ([sideMenuController isKindOfClass:[RNNSideMenuController class]]) {
254
-		if (self.sideMenu.leftSideVisible) {
255
-			if (self.sideMenu.leftSideVisible.boolValue) {
256
-				[sideMenuController showSideMenu:MMDrawerSideLeft animated:YES];
257
-			} else {
258
-				[sideMenuController hideSideMenu:MMDrawerSideLeft animated:YES];
259
-			}
260
-		}
261
-		
262
-		if (self.sideMenu.rightSideVisible) {
263
-			if (self.sideMenu.rightSideVisible.boolValue) {
264
-				[sideMenuController showSideMenu:MMDrawerSideRight animated:YES];
265
-			} else {
266
-				[sideMenuController hideSideMenu:MMDrawerSideRight animated:YES];
267
-			}
268
-		}
269
-		
270
-		[self.sideMenu resetOptions];
271
-	}
272
-	
273 80
 	if (self.backgroundImage) {
274 81
 		UIImageView* backgroundImageView = (viewController.view.subviews.count > 0) ? viewController.view.subviews[0] : nil;
275 82
 		if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
@@ -293,42 +100,6 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
293 100
 		backgroundImageView.image = self.rootBackgroundImage;
294 101
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
295 102
 	}
296
-	
297
-	[self applyTabBarItemOptions:viewController];
298
-	[self applyTopTab:viewController];
299
-}
300
-
301
-- (void)applyTopTab:(RNNRootViewController*)viewController {
302
-	if (self.topTab) {
303
-		if (self.topTab.title) {
304
-			[viewController.topTabsViewController viewController:viewController changedTitle:self.topTab.title];
305
-		}
306
-	}
307
-}
308
-
309
-- (void)applyTabBarItemOptions:(UIViewController*)viewController {
310
-	if (self.tabItem) {
311
-		if (self.tabItem.title || self.tabItem.icon) {
312
-			UITabBarItem* tabItem = [[UITabBarItem alloc] initWithTitle:self.tabItem.title image:[RCTConvert UIImage:self.tabItem.icon] tag:self.tabItem.tag];
313
-			tabItem.accessibilityIdentifier = self.tabItem.testID;
314
-			[viewController.navigationController setTabBarItem:tabItem];
315
-		}
316
-		
317
-		if (self.tabItem.badge) {
318
-			NSString *badge = [RCTConvert NSString:self.tabItem.badge];
319
-			if (viewController.navigationController) {
320
-				viewController.navigationController.tabBarItem.badgeValue = badge;
321
-			} else {
322
-				viewController.tabBarItem.badgeValue = badge;
323
-			}
324
-		}
325
-		
326
-		if (self.tabItem.visible) {
327
-			[viewController.tabBarController setSelectedIndex:[viewController.tabBarController.viewControllers indexOfObject:viewController]];
328
-		}
329
-		
330
-		[self.tabItem resetOptions];
331
-	}
332 103
 }
333 104
 
334 105
 - (UIInterfaceOrientationMask)supportedOrientations {
@@ -357,18 +128,4 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
357 128
 	return supportedOrientationsMask;
358 129
 }
359 130
 
360
--(void)storeOriginalTopBarImages:(UIViewController*)viewController {
361
-	NSMutableDictionary *originalTopBarImages = [@{} mutableCopy];
362
-	UIImage *bgImage = [viewController.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault];
363
-	if (bgImage != nil) {
364
-		originalTopBarImages[@"backgroundImage"] = bgImage;
365
-	}
366
-	UIImage *shadowImage = viewController.navigationController.navigationBar.shadowImage;
367
-	if (shadowImage != nil) {
368
-		originalTopBarImages[@"shadowImage"] = shadowImage;
369
-	}
370
-	self.originalTopBarImages = originalTopBarImages;
371
-}
372
-
373
-
374 131
 @end

+ 1
- 1
lib/ios/RNNNavigationStackManager.m Vedi File

@@ -25,7 +25,7 @@ dispatch_queue_t RCTGetUIManagerQueue(void);
25 25
 	self.toVC = newTop;
26 26
 	self.fromVC = vc;
27 27
 	
28
-	if (self.toVC.isAnimated) {
28
+	if (self.toVC.isCustomTransitioned) {
29 29
 		vc.navigationController.delegate = newTop;
30 30
 	} else {
31 31
 		vc.navigationController.delegate = nil;

+ 17
- 0
lib/ios/RNNOptions.h Vedi File

@@ -0,0 +1,17 @@
1
+#import <Foundation/Foundation.h>
2
+#import <UIKit/UIKit.h>
3
+#import <React/RCTConvert.h>
4
+@protocol RNNOptionsProtocol <NSObject>
5
+
6
+@optional
7
+-(void)resetOptions;
8
+-(void)applyOn:(UIViewController*)viewController;
9
+
10
+@end
11
+
12
+@interface RNNOptions : NSObject <RNNOptionsProtocol>
13
+
14
+-(instancetype)initWithDict:(NSDictionary*)dict;
15
+-(void)mergeWith:(NSDictionary*)otherOptions;
16
+
17
+@end

+ 18
- 0
lib/ios/RNNOptions.m Vedi File

@@ -0,0 +1,18 @@
1
+
2
+#import "RNNOptions.h"
3
+
4
+@implementation RNNOptions
5
+
6
+-(instancetype)initWithDict:(NSDictionary *)dict {
7
+	self = [super init];
8
+	[self mergeWith:dict];
9
+	return self;
10
+}
11
+
12
+-(void)mergeWith:(NSDictionary *)otherOptions {
13
+	for (id key in otherOptions) {
14
+		[self setValue:[otherOptions objectForKey:key] forKey:key];
15
+	}
16
+}
17
+
18
+@end

+ 1
- 2
lib/ios/RNNRootViewController.h Vedi File

@@ -25,10 +25,9 @@
25 25
 		   animator:(RNNAnimator*)animator;
26 26
 
27 27
 
28
--(void)applyNavigationButtons;
29 28
 -(void)applyTabBarItem;
30 29
 -(void)applyTopTabsOptions;
31 30
 
32
--(BOOL)isAnimated;
31
+-(BOOL)isCustomTransitioned;
33 32
 
34 33
 @end

+ 4
- 11
lib/ios/RNNRootViewController.m Vedi File

@@ -2,12 +2,10 @@
2 2
 #import "RNNRootViewController.h"
3 3
 #import <React/RCTConvert.h>
4 4
 #import "RNNAnimator.h"
5
-#import "RNNNavigationButtons.h"
6 5
 
7 6
 @interface RNNRootViewController()
8 7
 @property (nonatomic, strong) NSString* containerName;
9 8
 @property (nonatomic) BOOL _statusBarHidden;
10
-@property (nonatomic, strong) RNNNavigationButtons* navigationButtons;
11 9
 
12 10
 @end
13 11
 
@@ -33,21 +31,20 @@
33 31
 											   object:nil];
34 32
 	self.navigationController.modalPresentationStyle = UIModalPresentationCustom;
35 33
 	self.navigationController.delegate = self;
36
-	self.navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:self];
34
+
37 35
 	return self;
38 36
 }
39 37
 	
40 38
 -(void)viewWillAppear:(BOOL)animated{
41 39
 	[super viewWillAppear:animated];
42 40
 	[self.navigationOptions applyOn:self];
43
-	[self applyNavigationButtons];
44 41
 }
45 42
 
46 43
 - (void)viewDidLoad {
47 44
 	[super viewDidLoad];
48 45
 }
49 46
 
50
--(BOOL)isAnimated {
47
+-(BOOL)isCustomTransitioned {
51 48
 	return self.animator;
52 49
 }
53 50
 
@@ -106,16 +103,12 @@
106 103
 
107 104
 }
108 105
 
109
--(void)applyNavigationButtons{
110
-	[self.navigationButtons applyLeftButtons:self.navigationOptions.leftButtons rightButtons:self.navigationOptions.rightButtons];
111
-}
112
-
113 106
 -(void)applyTabBarItem {
114
-	[self.navigationOptions applyTabBarItemOptions:self];
107
+	[self.navigationOptions.bottomTab applyOn:self];
115 108
 }
116 109
 
117 110
 -(void)applyTopTabsOptions {
118
-	[self.navigationOptions applyTopTab:self];
111
+	[self.navigationOptions.topTab applyOn:self];
119 112
 }
120 113
 
121 114
 /**

+ 2
- 1
lib/ios/RNNRootViewProtocol.h Vedi File

@@ -1,9 +1,10 @@
1
+#import "RNNNavigationOptions.h"
1 2
 
2 3
 @protocol RNNRootViewProtocol <NSObject, UINavigationControllerDelegate>
3 4
 
4 5
 @required
5 6
 
6
-- (BOOL)isAnimated;
7
+- (BOOL)isCustomTransitioned;
7 8
 
8 9
 @end
9 10
 

+ 1
- 1
lib/ios/RNNSideMenuChildVC.m Vedi File

@@ -33,7 +33,7 @@
33 33
 	return self;
34 34
 }
35 35
 
36
-- (BOOL)isAnimated {
36
+- (BOOL)isCustomTransitioned {
37 37
 	return NO;
38 38
 }
39 39
 

+ 1
- 1
lib/ios/RNNSideMenuController.m Vedi File

@@ -72,7 +72,7 @@
72 72
 	}
73 73
 }
74 74
 
75
-- (BOOL)isAnimated {
75
+- (BOOL)isCustomTransitioned {
76 76
 	return NO;
77 77
 }
78 78
 

+ 2
- 8
lib/ios/RNNSideMenuOptions.h Vedi File

@@ -1,14 +1,8 @@
1
-#import <Foundation/Foundation.h>
1
+#import "RNNOptions.h"
2 2
 
3
-@interface RNNSideMenuOptions : NSObject
3
+@interface RNNSideMenuOptions : RNNOptions
4 4
 
5 5
 @property (nonatomic, strong) NSNumber* leftSideVisible;
6 6
 @property (nonatomic, strong) NSNumber* rightSideVisible;
7 7
 
8
--(instancetype)init;
9
--(instancetype)initWithDict:(NSDictionary *)sideMenuOptions;
10
--(void)mergeWith:(NSDictionary*)otherOptions;
11
-
12
--(void)resetOptions;
13
-
14 8
 @end

+ 22
- 10
lib/ios/RNNSideMenuOptions.m Vedi File

@@ -1,17 +1,29 @@
1 1
 #import "RNNSideMenuOptions.h"
2
+#import "RNNSideMenuController.h"
2 3
 
3 4
 @implementation RNNSideMenuOptions
4 5
 
5
--(instancetype)init {
6
-	return [self initWithDict:@{}];
7
-}
8
-
9
--(instancetype)initWithDict:(NSDictionary *)sideMenuOptions {
10
-	self = [super init];
11
-	
12
-	[self mergeWith:sideMenuOptions];
13
-	
14
-	return self;
6
+- (void)applyOn:(UIViewController *)viewController {
7
+	RNNSideMenuController* sideMenuController = (RNNSideMenuController*)UIApplication.sharedApplication.delegate.window.rootViewController;
8
+	if ([sideMenuController isKindOfClass:[RNNSideMenuController class]]) {
9
+		if (self.leftSideVisible) {
10
+			if (self.leftSideVisible.boolValue) {
11
+				[sideMenuController showSideMenu:MMDrawerSideLeft animated:YES];
12
+			} else {
13
+				[sideMenuController hideSideMenu:MMDrawerSideLeft animated:YES];
14
+			}
15
+		}
16
+		
17
+		if (self.rightSideVisible) {
18
+			if (self.rightSideVisible.boolValue) {
19
+				[sideMenuController showSideMenu:MMDrawerSideRight animated:YES];
20
+			} else {
21
+				[sideMenuController hideSideMenu:MMDrawerSideRight animated:YES];
22
+			}
23
+		}
24
+		
25
+		[self resetOptions];
26
+	}
15 27
 }
16 28
 
17 29
 -(void)mergeWith:(NSDictionary *)otherOptions {

+ 1
- 1
lib/ios/RNNTabBarController.m Vedi File

@@ -33,7 +33,7 @@
33 33
 	}
34 34
 }
35 35
 
36
-- (BOOL)isAnimated {
36
+- (BOOL)isCustomTransitioned {
37 37
 	return NO;
38 38
 }
39 39
 

+ 0
- 32
lib/ios/RNNTabBarOptions.m Vedi File

@@ -1,32 +0,0 @@
1
-#import "RNNTabBarOptions.h"
2
-
3
-@implementation RNNTabBarOptions
4
-
5
--(instancetype)init {
6
-	return [self initWithDict:@{}];
7
-}
8
-
9
--(instancetype)initWithDict:(NSDictionary *)tabBarOptions {
10
-	self = [super init];
11
-	
12
-	self.hidden = [tabBarOptions valueForKey:@"hidden"];
13
-	self.animateHide = [tabBarOptions valueForKey:@"animateHide"];
14
-	self.currentTabIndex = [tabBarOptions valueForKey:@"currentTabIndex"];
15
-	self.testID = [tabBarOptions valueForKey:@"testID"];
16
-	self.currentTabId = [tabBarOptions valueForKey:@"currentTabId"];
17
-	self.drawUnder = [tabBarOptions valueForKey:@"drawUnder"];
18
-	
19
-	return self;
20
-}
21
-
22
-- (void)resetOptions {
23
-	self.currentTabId = nil;
24
-	self.currentTabIndex = nil;
25
-}
26
-
27
--(void)mergeWith:(NSDictionary *)otherOptions {
28
-	for (id key in otherOptions) {
29
-		[self setValue:[otherOptions objectForKey:key] forKey:key];
30
-	}
31
-}
32
-@end

+ 0
- 32
lib/ios/RNNTabItemOptions.m Vedi File

@@ -1,32 +0,0 @@
1
-#import "RNNTabItemOptions.h"
2
-
3
-@implementation RNNTabItemOptions
4
-
5
--(instancetype)initWithDict:(NSDictionary *)tabItemDict {
6
-	self = [super init];
7
-	
8
-	self.title = tabItemDict[@"title"];
9
-	self.tag = [tabItemDict[@"tag"] integerValue];
10
-	self.badge = tabItemDict[@"badge"];
11
-	self.testID = tabItemDict[@"testID"];
12
-	self.visible = tabItemDict[@"visible"];
13
-	self.icon = tabItemDict[@"icon"];
14
-	
15
-	return self;
16
-}
17
-
18
--(void)mergeWith:(NSDictionary *)otherOptions {
19
-	for (id key in otherOptions) {
20
-		[self setValue:[otherOptions objectForKey:key] forKey:key];
21
-	}
22
-}
23
-
24
--(void)resetOptions {
25
-	self.title = nil;
26
-	self.badge = nil;
27
-	self.visible = nil;
28
-	self.icon = nil;
29
-	self.testID = nil;
30
-}
31
-
32
-@end

+ 4
- 8
lib/ios/RNNTopBarOptions.h Vedi File

@@ -1,9 +1,9 @@
1
-#import <Foundation/Foundation.h>
1
+#import "RNNOptions.h"
2 2
 
3
-extern const NSInteger BLUR_TOPBAR_TAG;
4
-
5
-@interface RNNTopBarOptions : NSObject
3
+@interface RNNTopBarOptions : RNNOptions
6 4
 
5
+@property (nonatomic, strong) NSArray* leftButtons;
6
+@property (nonatomic, strong) NSArray* rightButtons;
7 7
 @property (nonatomic, strong) NSNumber* backgroundColor;
8 8
 @property (nonatomic, strong) NSNumber* textColor;
9 9
 @property (nonatomic, strong) NSString* title;
@@ -21,8 +21,4 @@ extern const NSInteger BLUR_TOPBAR_TAG;
21 21
 @property (nonatomic, strong) NSNumber* largeTitle;
22 22
 @property (nonatomic, strong) NSString* testID;
23 23
 
24
--(instancetype)init;
25
--(instancetype)initWithDict:(NSDictionary *)topBarOptions;
26
--(void)mergeWith:(NSDictionary*)otherOptions;
27
-
28 24
 @end

+ 164
- 28
lib/ios/RNNTopBarOptions.m Vedi File

@@ -1,39 +1,175 @@
1 1
 #import "RNNTopBarOptions.h"
2
+#import "RNNNavigationButtons.h"
2 3
 
3
-@implementation RNNTopBarOptions
4
+extern const NSInteger BLUR_TOPBAR_TAG;
4 5
 
5
--(instancetype)init {
6
-	return [self initWithDict:@{}];
7
-}
6
+@interface RNNTopBarOptions ()
7
+
8
+@property (nonatomic, strong) NSMutableDictionary* originalTopBarImages;
9
+@property (nonatomic, strong) RNNNavigationButtons* navigationButtons;
10
+
11
+@end
8 12
 
9
--(instancetype)initWithDict:(NSDictionary *)topBarOptions {
10
-	self = [super init];
11
-	
12
-	self.title = [topBarOptions valueForKey:@"title"];
13
-	self.backgroundColor = [topBarOptions valueForKey:@"backgroundColor"];
14
-	self.textColor = [topBarOptions valueForKey:@"textColor"];
15
-	self.textFontFamily = [topBarOptions valueForKey:@"textFontFamily"];
16
-	self.textFontSize = [topBarOptions valueForKey:@"textFontSize"];
17
-	self.hidden = [topBarOptions valueForKey:@"hidden"];
18
-	self.hideOnScroll = [topBarOptions valueForKey:@"hideOnScroll"];
19
-	self.buttonColor = [topBarOptions valueForKey:@"buttonColor"];
20
-	self.blur = [topBarOptions valueForKey:@"blur"];
21
-	self.translucent = [topBarOptions valueForKey:@"translucent"];
22
-	self.transparent = [topBarOptions valueForKey:@"transparent"];
23
-	self.noBorder = [topBarOptions valueForKey:@"noBorder"];
24
-	self.animateHide = [topBarOptions valueForKey:@"animateHide"];
25
-	self.largeTitle = [topBarOptions valueForKey:@"largeTitle"];
26
-	self.testID = [topBarOptions valueForKey:@"testID"];
27
-	self.drawUnder = [topBarOptions valueForKey:@"drawUnder"];
28
-	
29
-	return self;
13
+@implementation RNNTopBarOptions
14
+
15
+- (void)applyOn:(UIViewController*)viewController {
16
+	if (self.backgroundColor) {
17
+		UIColor* backgroundColor = [RCTConvert UIColor:self.backgroundColor];
18
+		viewController.navigationController.navigationBar.barTintColor = backgroundColor;
19
+	} else {
20
+		viewController.navigationController.navigationBar.barTintColor = nil;
21
+	}
22
+	
23
+	if (self.title) {
24
+		viewController.navigationItem.title = self.title;
25
+	}
26
+	
27
+	if (@available(iOS 11.0, *)) {
28
+		if (self.largeTitle){
29
+			if ([self.largeTitle boolValue]) {
30
+				viewController.navigationController.navigationBar.prefersLargeTitles = YES;
31
+				viewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;
32
+			} else {
33
+				viewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
34
+			}
35
+		} else {
36
+			viewController.navigationController.navigationBar.prefersLargeTitles = NO;
37
+			viewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
38
+		}
39
+	}
40
+	
41
+	
42
+	if (self.textFontFamily || self.textFontSize || self.textColor) {
43
+		NSMutableDictionary* navigationBarTitleTextAttributes = [NSMutableDictionary new];
44
+		if (self.textColor) {
45
+			navigationBarTitleTextAttributes[NSForegroundColorAttributeName] = [RCTConvert UIColor:[self valueForKey:@"textColor"]];
46
+		}
47
+		if (self.textFontFamily){
48
+			if(self.textFontSize) {
49
+				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.textFontFamily size:[self.textFontSize floatValue]];
50
+			} else {
51
+				navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont fontWithName:self.textFontFamily size:20];
52
+			}
53
+		} else if (self.textFontSize) {
54
+			navigationBarTitleTextAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:[self.textFontSize floatValue]];
55
+		}
56
+		viewController.navigationController.navigationBar.titleTextAttributes = navigationBarTitleTextAttributes;
57
+		if (@available(iOS 11.0, *)){
58
+			viewController.navigationController.navigationBar.largeTitleTextAttributes = navigationBarTitleTextAttributes;
59
+		}
60
+		
61
+	}
62
+	
63
+	
64
+	if (self.hidden){
65
+		[viewController.navigationController setNavigationBarHidden:[self.hidden boolValue] animated:[self.animateHide boolValue]];
66
+	}
67
+	
68
+	if (self.hideOnScroll) {
69
+		viewController.navigationController.hidesBarsOnSwipe = [self.hideOnScroll boolValue];
70
+	}
71
+	
72
+	if (self.buttonColor) {
73
+		UIColor* buttonColor = [RCTConvert UIColor:self.buttonColor];
74
+		viewController.navigationController.navigationBar.tintColor = buttonColor;
75
+	} else {
76
+		viewController.navigationController.navigationBar.tintColor = nil;
77
+	}
78
+	
79
+	if ([self.blur boolValue]) {
80
+		if (![viewController.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]) {
81
+			
82
+			[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
83
+			viewController.navigationController.navigationBar.shadowImage = [UIImage new];
84
+			UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
85
+			CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
86
+			blur.frame = CGRectMake(0, -1 * statusBarFrame.size.height, viewController.navigationController.navigationBar.frame.size.width, viewController.navigationController.navigationBar.frame.size.height + statusBarFrame.size.height);
87
+			blur.userInteractionEnabled = NO;
88
+			blur.tag = BLUR_TOPBAR_TAG;
89
+			[viewController.navigationController.navigationBar insertSubview:blur atIndex:0];
90
+			[viewController.navigationController.navigationBar sendSubviewToBack:blur];
91
+		}
92
+	} else {
93
+		UIView *blur = [viewController.navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG];
94
+		if (blur) {
95
+			[viewController.navigationController.navigationBar setBackgroundImage: nil forBarMetrics:UIBarMetricsDefault];
96
+			viewController.navigationController.navigationBar.shadowImage = nil;
97
+			[blur removeFromSuperview];
98
+		}
99
+	}
100
+	
101
+	void (^disableTopBarTransparent)() = ^void(){
102
+		UIView *transparentView = [viewController.navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG];
103
+		if (transparentView){
104
+			[transparentView removeFromSuperview];
105
+			[viewController.navigationController.navigationBar setBackgroundImage:self.originalTopBarImages[@"backgroundImage"] forBarMetrics:UIBarMetricsDefault];
106
+			viewController.navigationController.navigationBar.shadowImage = self.originalTopBarImages[@"shadowImage"];
107
+			self.originalTopBarImages = nil;
108
+		}
109
+	};
110
+	
111
+	if (self.transparent) {
112
+		if ([self.transparent boolValue]) {
113
+			if (![viewController.navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG]){
114
+				[self storeOriginalTopBarImages:viewController];
115
+				[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
116
+				viewController.navigationController.navigationBar.shadowImage = [UIImage new];
117
+				UIView *transparentView = [[UIView alloc] initWithFrame:CGRectZero];
118
+				transparentView.tag = TOP_BAR_TRANSPARENT_TAG;
119
+				[viewController.navigationController.navigationBar insertSubview:transparentView atIndex:0];
120
+			}
121
+		} else {
122
+			disableTopBarTransparent();
123
+		}
124
+	} else {
125
+		disableTopBarTransparent();
126
+	}
127
+	
128
+	if (self.translucent) {
129
+		viewController.navigationController.navigationBar.translucent = [self.translucent boolValue];
130
+	}
131
+	
132
+	if (self.drawUnder) {
133
+		if ([self.drawUnder boolValue]) {
134
+			viewController.edgesForExtendedLayout |= UIRectEdgeTop;
135
+		} else {
136
+			viewController.edgesForExtendedLayout &= ~UIRectEdgeTop;
137
+		}
138
+	}
139
+	
140
+	if (self.noBorder) {
141
+		if ([self.noBorder boolValue]) {
142
+			viewController.navigationController.navigationBar
143
+			.shadowImage = [[UIImage alloc] init];
144
+		} else {
145
+			viewController.navigationController.navigationBar
146
+			.shadowImage = nil;
147
+		}
148
+	}
149
+	
150
+	if (self.testID) {
151
+		viewController.navigationController.navigationBar.accessibilityIdentifier = self.testID;
152
+	}
153
+	
154
+	if (self.rightButtons || self.leftButtons) {
155
+		_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:(RNNRootViewController*)viewController];
156
+		[_navigationButtons applyLeftButtons:self.leftButtons rightButtons:self.rightButtons];
157
+	}
30 158
 }
31 159
 
32
--(void)mergeWith:(NSDictionary *)otherOptions {
33
-	for (id key in otherOptions) {
34
-		[self setValue:[otherOptions objectForKey:key] forKey:key];
160
+-(void)storeOriginalTopBarImages:(UIViewController*)viewController {
161
+	NSMutableDictionary *originalTopBarImages = [@{} mutableCopy];
162
+	UIImage *bgImage = [viewController.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault];
163
+	if (bgImage != nil) {
164
+		originalTopBarImages[@"backgroundImage"] = bgImage;
35 165
 	}
166
+	UIImage *shadowImage = viewController.navigationController.navigationBar.shadowImage;
167
+	if (shadowImage != nil) {
168
+		originalTopBarImages[@"shadowImage"] = shadowImage;
169
+	}
170
+	self.originalTopBarImages = originalTopBarImages;
36 171
 }
172
+
37 173
 @end
38 174
 
39 175
 

+ 3
- 8
lib/ios/RNNTopTabOptions.h Vedi File

@@ -1,14 +1,9 @@
1
-#import <Foundation/Foundation.h>
1
+#import "RNNOptions.h"
2 2
 
3
-extern const NSInteger BLUR_TOPBAR_TAG;
4
-
5
-@interface RNNTopTabOptions : NSObject
3
+@interface RNNTopTabOptions : RNNOptions
6 4
 
7 5
 @property (nonatomic, strong) NSString* title;
8
-
9
--(instancetype)init;
10
--(instancetype)initWithDict:(NSDictionary *)topBarOptions;
11
--(void)mergeWith:(NSDictionary*)otherOptions;
6
+@property (nonatomic, strong) NSString* titleFontFamily;
12 7
 
13 8
 @end
14 9
 

+ 5
- 10
lib/ios/RNNTopTabOptions.m Vedi File

@@ -1,17 +1,12 @@
1 1
 #import "RNNTopTabOptions.h"
2
+#import "RNNRootViewController.h"
2 3
 
3 4
 @implementation RNNTopTabOptions
4 5
 
5
--(instancetype)init {
6
-	return [self initWithDict:@{}];
7
-}
8
-
9
--(instancetype)initWithDict:(NSDictionary *)tabBarOptions {
10
-	self = [super init];
11
-	
12
-	self.title = [tabBarOptions valueForKey:@"title"];
13
-	
14
-	return self;
6
+- (void)applyOn:(RNNRootViewController*)viewController {
7
+	if (self.title) {
8
+		[viewController.topTabsViewController viewController:viewController changedTitle:self.title];
9
+	}
15 10
 }
16 11
 
17 12
 -(void)mergeWith:(NSDictionary *)otherOptions {

+ 7
- 0
lib/ios/RNNTopTabsOptions.h Vedi File

@@ -0,0 +1,7 @@
1
+#import "RNNOptions.h"
2
+
3
+@interface RNNTopTabsOptions : RNNOptions
4
+
5
+@property (nonatomic, strong) NSNumber* backgroundColor;
6
+
7
+@end

+ 10
- 0
lib/ios/RNNTopTabsOptions.m Vedi File

@@ -0,0 +1,10 @@
1
+#import "RNNTopTabsOptions.h"
2
+#import "RNNTopTabsViewController.h"
3
+
4
+@implementation RNNTopTabsOptions
5
+
6
+- (void)applyOn:(RNNTopTabsViewController *)viewController {
7
+
8
+}
9
+
10
+@end

+ 2
- 2
lib/ios/RNNTopTabsViewController.m Vedi File

@@ -15,7 +15,7 @@
15 15
 
16 16
 - (instancetype)init {
17 17
 	self = [super init];
18
-		
18
+	
19 19
 	[self.view setBackgroundColor:[UIColor whiteColor]];
20 20
 	self.edgesForExtendedLayout = UIRectEdgeNone;
21 21
 	
@@ -72,7 +72,7 @@
72 72
     [super viewDidLoad];
73 73
 }
74 74
 
75
-- (BOOL)isAnimated {
75
+- (BOOL)isCustomTransitioned {
76 76
 	return NO;
77 77
 }
78 78
 

+ 48
- 22
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj Vedi File

@@ -57,6 +57,12 @@
57 57
 		268692831E5054F800E2C612 /* RNNStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 268692811E5054F800E2C612 /* RNNStore.m */; };
58 58
 		26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */; };
59 59
 		26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */; };
60
+		504AFE641FFE53070076E904 /* RNNOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 504AFE621FFE53070076E904 /* RNNOptions.h */; };
61
+		504AFE651FFE53070076E904 /* RNNOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 504AFE631FFE53070076E904 /* RNNOptions.m */; };
62
+		504AFE741FFFF0540076E904 /* RNNTopTabsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 504AFE721FFFF0540076E904 /* RNNTopTabsOptions.h */; };
63
+		504AFE751FFFF0540076E904 /* RNNTopTabsOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 504AFE731FFFF0540076E904 /* RNNTopTabsOptions.m */; };
64
+		504AFE761FFFF1E00076E904 /* RNNNavigationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E83BAD691F27362500A9F3DD /* RNNNavigationOptions.h */; };
65
+		504AFE771FFFF1E20076E904 /* RNNTopBarOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = A7626BFE1FC2FB6700492FB8 /* RNNTopBarOptions.h */; };
60 66
 		507F43C51FF4F17C00D9425B /* RNNTopTabsViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 507F43C31FF4F17C00D9425B /* RNNTopTabsViewController.h */; };
61 67
 		507F43C61FF4F17C00D9425B /* RNNTopTabsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 507F43C41FF4F17C00D9425B /* RNNTopTabsViewController.m */; };
62 68
 		507F43C91FF4F9CC00D9425B /* RNNTopTabOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 507F43C71FF4F9CC00D9425B /* RNNTopTabOptions.h */; };
@@ -68,8 +74,7 @@
68 74
 		507F44201FFA8A8800D9425B /* RNNRootViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 507F441F1FFA8A8800D9425B /* RNNRootViewProtocol.h */; };
69 75
 		50CB3B691FDE911400AA153B /* RNNSideMenuOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50CB3B671FDE911400AA153B /* RNNSideMenuOptions.h */; };
70 76
 		50CB3B6A1FDE911400AA153B /* RNNSideMenuOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50CB3B681FDE911400AA153B /* RNNSideMenuOptions.m */; };
71
-		50EB93411FE14A3E00BD8EEE /* RNNTabItemOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50EB933F1FE14A3E00BD8EEE /* RNNTabItemOptions.h */; };
72
-		50EB93421FE14A3E00BD8EEE /* RNNTabItemOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50EB93401FE14A3E00BD8EEE /* RNNTabItemOptions.m */; };
77
+		50EB93421FE14A3E00BD8EEE /* RNNBottomTabOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50EB93401FE14A3E00BD8EEE /* RNNBottomTabOptions.m */; };
73 78
 		50F5DFC11F407A8C001A00BC /* RNNTabBarController.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F5DFBF1F407A8C001A00BC /* RNNTabBarController.h */; };
74 79
 		50F5DFC21F407A8C001A00BC /* RNNTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F5DFC01F407A8C001A00BC /* RNNTabBarController.m */; };
75 80
 		50F5DFC51F407AA0001A00BC /* RNNNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F5DFC31F407AA0001A00BC /* RNNNavigationController.h */; };
@@ -111,7 +116,7 @@
111 116
 		7BEF0D1C1E43771B003E96B0 /* RNNLayoutNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BEF0D1A1E43771B003E96B0 /* RNNLayoutNode.h */; };
112 117
 		7BEF0D1D1E43771B003E96B0 /* RNNLayoutNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BEF0D1B1E43771B003E96B0 /* RNNLayoutNode.m */; };
113 118
 		A7626BFD1FC2FB2C00492FB8 /* RNNTopBarOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = A7626BFC1FC2FB2C00492FB8 /* RNNTopBarOptions.m */; };
114
-		A7626C011FC5796200492FB8 /* RNNTabBarOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = A7626C001FC5796200492FB8 /* RNNTabBarOptions.m */; };
119
+		A7626C011FC5796200492FB8 /* RNNBottomTabsOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = A7626C001FC5796200492FB8 /* RNNBottomTabsOptions.m */; };
115 120
 		E8367B801F7A8A4700675C05 /* VICMAImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = E8367B7E1F7A8A4700675C05 /* VICMAImageView.h */; };
116 121
 		E8367B811F7A8A4700675C05 /* VICMAImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8367B7F1F7A8A4700675C05 /* VICMAImageView.m */; };
117 122
 		E83BAD681F2734B500A9F3DD /* RNNNavigationOptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E83BAD671F2734B500A9F3DD /* RNNNavigationOptionsTest.m */; };
@@ -216,6 +221,10 @@
216 221
 		26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNRootViewCreator.h; sourceTree = "<group>"; };
217 222
 		26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNReactRootViewCreator.h; sourceTree = "<group>"; };
218 223
 		26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNReactRootViewCreator.m; sourceTree = "<group>"; };
224
+		504AFE621FFE53070076E904 /* RNNOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNOptions.h; sourceTree = "<group>"; };
225
+		504AFE631FFE53070076E904 /* RNNOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNOptions.m; sourceTree = "<group>"; };
226
+		504AFE721FFFF0540076E904 /* RNNTopTabsOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTopTabsOptions.h; sourceTree = "<group>"; };
227
+		504AFE731FFFF0540076E904 /* RNNTopTabsOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTopTabsOptions.m; sourceTree = "<group>"; };
219 228
 		507F43C31FF4F17C00D9425B /* RNNTopTabsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTopTabsViewController.h; sourceTree = "<group>"; };
220 229
 		507F43C41FF4F17C00D9425B /* RNNTopTabsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTopTabsViewController.m; sourceTree = "<group>"; };
221 230
 		507F43C71FF4F9CC00D9425B /* RNNTopTabOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTopTabOptions.h; sourceTree = "<group>"; };
@@ -227,8 +236,8 @@
227 236
 		507F441F1FFA8A8800D9425B /* RNNRootViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNRootViewProtocol.h; sourceTree = "<group>"; };
228 237
 		50CB3B671FDE911400AA153B /* RNNSideMenuOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuOptions.h; sourceTree = "<group>"; };
229 238
 		50CB3B681FDE911400AA153B /* RNNSideMenuOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuOptions.m; sourceTree = "<group>"; };
230
-		50EB933F1FE14A3E00BD8EEE /* RNNTabItemOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTabItemOptions.h; sourceTree = "<group>"; };
231
-		50EB93401FE14A3E00BD8EEE /* RNNTabItemOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTabItemOptions.m; sourceTree = "<group>"; };
239
+		50EB933F1FE14A3E00BD8EEE /* RNNBottomTabOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNBottomTabOptions.h; sourceTree = "<group>"; };
240
+		50EB93401FE14A3E00BD8EEE /* RNNBottomTabOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNBottomTabOptions.m; sourceTree = "<group>"; };
232 241
 		50F5DFBF1F407A8C001A00BC /* RNNTabBarController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTabBarController.h; sourceTree = "<group>"; };
233 242
 		50F5DFC01F407A8C001A00BC /* RNNTabBarController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTabBarController.m; sourceTree = "<group>"; };
234 243
 		50F5DFC31F407AA0001A00BC /* RNNNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNNavigationController.h; sourceTree = "<group>"; };
@@ -272,8 +281,8 @@
272 281
 		7BEF0D1B1E43771B003E96B0 /* RNNLayoutNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNLayoutNode.m; sourceTree = "<group>"; };
273 282
 		A7626BFC1FC2FB2C00492FB8 /* RNNTopBarOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTopBarOptions.m; sourceTree = "<group>"; };
274 283
 		A7626BFE1FC2FB6700492FB8 /* RNNTopBarOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTopBarOptions.h; sourceTree = "<group>"; };
275
-		A7626BFF1FC578AB00492FB8 /* RNNTabBarOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTabBarOptions.h; sourceTree = "<group>"; };
276
-		A7626C001FC5796200492FB8 /* RNNTabBarOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTabBarOptions.m; sourceTree = "<group>"; };
284
+		A7626BFF1FC578AB00492FB8 /* RNNBottomTabsOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNBottomTabsOptions.h; sourceTree = "<group>"; };
285
+		A7626C001FC5796200492FB8 /* RNNBottomTabsOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNBottomTabsOptions.m; sourceTree = "<group>"; };
277 286
 		D8AFADBD1BEE6F3F00A4592D /* libReactNativeNavigation.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReactNativeNavigation.a; sourceTree = BUILT_PRODUCTS_DIR; };
278 287
 		E8367B7E1F7A8A4700675C05 /* VICMAImageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VICMAImageView.h; sourceTree = "<group>"; };
279 288
 		E8367B7F1F7A8A4700675C05 /* VICMAImageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VICMAImageView.m; sourceTree = "<group>"; };
@@ -414,6 +423,29 @@
414 423
 			path = Animations;
415 424
 			sourceTree = "<group>";
416 425
 		};
426
+		504AFE611FFE52EF0076E904 /* Options */ = {
427
+			isa = PBXGroup;
428
+			children = (
429
+				504AFE621FFE53070076E904 /* RNNOptions.h */,
430
+				504AFE631FFE53070076E904 /* RNNOptions.m */,
431
+				E83BAD691F27362500A9F3DD /* RNNNavigationOptions.h */,
432
+				E83BAD6A1F27363A00A9F3DD /* RNNNavigationOptions.m */,
433
+				A7626BFE1FC2FB6700492FB8 /* RNNTopBarOptions.h */,
434
+				A7626BFC1FC2FB2C00492FB8 /* RNNTopBarOptions.m */,
435
+				A7626BFF1FC578AB00492FB8 /* RNNBottomTabsOptions.h */,
436
+				A7626C001FC5796200492FB8 /* RNNBottomTabsOptions.m */,
437
+				50EB933F1FE14A3E00BD8EEE /* RNNBottomTabOptions.h */,
438
+				50EB93401FE14A3E00BD8EEE /* RNNBottomTabOptions.m */,
439
+				507F43C71FF4F9CC00D9425B /* RNNTopTabOptions.h */,
440
+				507F43C81FF4F9CC00D9425B /* RNNTopTabOptions.m */,
441
+				504AFE721FFFF0540076E904 /* RNNTopTabsOptions.h */,
442
+				504AFE731FFFF0540076E904 /* RNNTopTabsOptions.m */,
443
+				50CB3B671FDE911400AA153B /* RNNSideMenuOptions.h */,
444
+				50CB3B681FDE911400AA153B /* RNNSideMenuOptions.m */,
445
+			);
446
+			name = Options;
447
+			sourceTree = "<group>";
448
+		};
417 449
 		507F43F11FF4FCD800D9425B /* HMSegmentControl */ = {
418 450
 			isa = PBXGroup;
419 451
 			children = (
@@ -428,6 +460,7 @@
428 460
 			children = (
429 461
 				E8AEDB471F584175000F5A6A /* Components */,
430 462
 				E8AEDB461F58414D000F5A6A /* Animations */,
463
+				504AFE611FFE52EF0076E904 /* Options */,
431 464
 				261F0E621E6EC94900989DE2 /* RNNModalManager.h */,
432 465
 				261F0E631E6EC94900989DE2 /* RNNModalManager.m */,
433 466
 				261F0E681E6F028A00989DE2 /* RNNNavigationStackManager.h */,
@@ -451,22 +484,10 @@
451 484
 				7BC9346D1E26886E00EFA125 /* RNNControllerFactory.m */,
452 485
 				263905E41E4CAC950023D7D3 /* RNNSideMenuChildVC.h */,
453 486
 				263905E51E4CAC950023D7D3 /* RNNSideMenuChildVC.m */,
454
-				E83BAD691F27362500A9F3DD /* RNNNavigationOptions.h */,
455
-				E83BAD6A1F27363A00A9F3DD /* RNNNavigationOptions.m */,
456 487
 				21B85E5E1F44482A00B314B5 /* RNNNavigationButtons.h */,
457 488
 				21B85E5C1F44480200B314B5 /* RNNNavigationButtons.m */,
458 489
 				214545261F4DC164006E8DA1 /* RNNUIBarButtonItem.h */,
459 490
 				214545241F4DC125006E8DA1 /* RNNUIBarButtonItem.m */,
460
-				50EB933F1FE14A3E00BD8EEE /* RNNTabItemOptions.h */,
461
-				50EB93401FE14A3E00BD8EEE /* RNNTabItemOptions.m */,
462
-				A7626BFE1FC2FB6700492FB8 /* RNNTopBarOptions.h */,
463
-				A7626BFC1FC2FB2C00492FB8 /* RNNTopBarOptions.m */,
464
-				A7626BFF1FC578AB00492FB8 /* RNNTabBarOptions.h */,
465
-				A7626C001FC5796200492FB8 /* RNNTabBarOptions.m */,
466
-				507F43C71FF4F9CC00D9425B /* RNNTopTabOptions.h */,
467
-				507F43C81FF4F9CC00D9425B /* RNNTopTabOptions.m */,
468
-				50CB3B671FDE911400AA153B /* RNNSideMenuOptions.h */,
469
-				50CB3B681FDE911400AA153B /* RNNSideMenuOptions.m */,
470 491
 				507F43C31FF4F17C00D9425B /* RNNTopTabsViewController.h */,
471 492
 				507F43C41FF4F17C00D9425B /* RNNTopTabsViewController.m */,
472 493
 				507F43F61FF525B500D9425B /* RNNSegmentedControl.h */,
@@ -607,6 +628,8 @@
607 628
 			buildActionMask = 2147483647;
608 629
 			files = (
609 630
 				261F0E6A1E6F028A00989DE2 /* RNNNavigationStackManager.h in Headers */,
631
+				504AFE761FFFF1E00076E904 /* RNNNavigationOptions.h in Headers */,
632
+				504AFE771FFFF1E20076E904 /* RNNTopBarOptions.h in Headers */,
610 633
 				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
611 634
 				263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */,
612 635
 				E8AEDB4A1F5C0BAF000F5A6A /* RNNInteractivePopAnimator.h in Headers */,
@@ -647,10 +670,11 @@
647 670
 				507F44201FFA8A8800D9425B /* RNNRootViewProtocol.h in Headers */,
648 671
 				263905CA1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.h in Headers */,
649 672
 				263905B11E4C6F440023D7D3 /* MMDrawerController.h in Headers */,
650
-				50EB93411FE14A3E00BD8EEE /* RNNTabItemOptions.h in Headers */,
673
+				504AFE641FFE53070076E904 /* RNNOptions.h in Headers */,
651 674
 				263905B91E4C6F440023D7D3 /* RCCDrawerController.h in Headers */,
652 675
 				263905B31E4C6F440023D7D3 /* MMDrawerVisualState.h in Headers */,
653 676
 				E8A5CD621F49114F00E89D0D /* RNNElement.h in Headers */,
677
+				504AFE741FFFF0540076E904 /* RNNTopTabsOptions.h in Headers */,
654 678
 				E8E5182E1F83A48B000467AC /* RNNTransitionStateHolder.h in Headers */,
655 679
 				7B1126A91E2D2B6C00F9B03B /* RNNControllerFactory.h in Headers */,
656 680
 				263905D61E4C94970023D7D3 /* RNNSideMenuController.h in Headers */,
@@ -790,8 +814,10 @@
790 814
 				7BBFE5441E25330E002A6182 /* RNNBridgeModule.m in Sources */,
791 815
 				261F0E651E6EC94900989DE2 /* RNNModalManager.m in Sources */,
792 816
 				E8A5CD631F49114F00E89D0D /* RNNElement.m in Sources */,
817
+				504AFE751FFFF0540076E904 /* RNNTopTabsOptions.m in Sources */,
793 818
 				7BEF0D1D1E43771B003E96B0 /* RNNLayoutNode.m in Sources */,
794 819
 				7BA500781E254908001B9E1B /* RNNSplashScreen.m in Sources */,
820
+				504AFE651FFE53070076E904 /* RNNOptions.m in Sources */,
795 821
 				263905BA1E4C6F440023D7D3 /* RCCDrawerController.m in Sources */,
796 822
 				50F5DFC21F407A8C001A00BC /* RNNTabBarController.m in Sources */,
797 823
 				263905BC1E4C6F440023D7D3 /* RCCDrawerHelper.m in Sources */,
@@ -807,9 +833,9 @@
807 833
 				E8A430121F9CB87B00B61A20 /* RNNAnimatedView.m in Sources */,
808 834
 				507F43F51FF4FCFE00D9425B /* HMSegmentedControl.m in Sources */,
809 835
 				507F43C61FF4F17C00D9425B /* RNNTopTabsViewController.m in Sources */,
810
-				50EB93421FE14A3E00BD8EEE /* RNNTabItemOptions.m in Sources */,
836
+				50EB93421FE14A3E00BD8EEE /* RNNBottomTabOptions.m in Sources */,
811 837
 				E8367B811F7A8A4700675C05 /* VICMAImageView.m in Sources */,
812
-				A7626C011FC5796200492FB8 /* RNNTabBarOptions.m in Sources */,
838
+				A7626C011FC5796200492FB8 /* RNNBottomTabsOptions.m in Sources */,
813 839
 				263905AF1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m in Sources */,
814 840
 				E8AEDB4B1F5C0BAF000F5A6A /* RNNInteractivePopAnimator.m in Sources */,
815 841
 				7B4928091E70415400555040 /* RNNCommandsHandler.m in Sources */,

+ 3
- 3
lib/ios/ReactNativeNavigationTests/RNNNavigationOptionsTest.m Vedi File

@@ -19,9 +19,8 @@
19 19
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"backgroundColor" : @(0xff0000ff)}}];
20 20
 	XCTAssertTrue(options.topBar.backgroundColor);
21 21
 }
22
--(void)testReturnsNilWhenStyleDoesNotExist{
23
-	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"someColor" : @(0xff0000ff)}}];
24
-	XCTAssertNil(options.topBar.backgroundColor);
22
+-(void)testThrowsWhenStyleDoesNotExist{
23
+	XCTAssertThrows([[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"someColor" : @(0xff0000ff)}}]);
25 24
 }
26 25
 
27 26
 -(void)testChangeRNNNavigationOptionsDynamically{
@@ -36,4 +35,5 @@
36 35
 	NSDictionary* dynamicOptions = @{@"topBar": @{@"titleeeee" : @"hello"}};
37 36
 	XCTAssertThrows([options mergeWith:dynamicOptions]);
38 37
 }
38
+
39 39
 @end

+ 5
- 5
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m Vedi File

@@ -174,7 +174,7 @@
174 174
 
175 175
 -(void)testTabBadge {
176 176
 	NSString* tabBadgeInput = @"5";
177
-	self.options.tabItem.badge = tabBadgeInput;
177
+	self.options.bottomTab.badge = tabBadgeInput;
178 178
 	__unused RNNTabBarController* vc = [[RNNTabBarController alloc] init];
179 179
 	NSMutableArray* controllers = [NSMutableArray new];
180 180
 	UITabBarItem* item = [[UITabBarItem alloc] initWithTitle:@"A Tab" image:nil tag:1];
@@ -355,7 +355,7 @@
355 355
 }
356 356
 
357 357
 -(void)testRightButtonsWithTitle_withoutStyle {
358
-	self.options.rightButtons = @[@{@"id": @"testId", @"title": @"test"}];
358
+	self.options.topBar.rightButtons = @[@{@"id": @"testId", @"title": @"test"}];
359 359
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
360 360
 	[self.uut viewWillAppear:false];
361 361
 	
@@ -370,7 +370,7 @@
370 370
 -(void)testRightButtonsWithTitle_withStyle {
371 371
 	NSNumber* inputColor = @(0xFFFF0000);
372 372
 	
373
-	self.options.rightButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
373
+	self.options.topBar.rightButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
374 374
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
375 375
 	[self.uut viewWillAppear:false];
376 376
 	
@@ -386,7 +386,7 @@
386 386
 
387 387
 
388 388
 -(void)testLeftButtonsWithTitle_withoutStyle {
389
-	self.options.leftButtons = @[@{@"id": @"testId", @"title": @"test"}];
389
+	self.options.topBar.leftButtons = @[@{@"id": @"testId", @"title": @"test"}];
390 390
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
391 391
 	[self.uut viewWillAppear:false];
392 392
 	
@@ -401,7 +401,7 @@
401 401
 -(void)testLeftButtonsWithTitle_withStyle {
402 402
 	NSNumber* inputColor = @(0xFFFF0000);
403 403
 	
404
-	self.options.leftButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
404
+	self.options.topBar.leftButtons = @[@{@"id": @"testId", @"title": @"test", @"disabled": @true, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
405 405
 	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
406 406
 	[self.uut viewWillAppear:false];
407 407
 	

+ 0
- 5
lib/src/params/options/NavigationOptions.js Vedi File

@@ -1,6 +1,5 @@
1 1
 const TopBar = require('./TopBar');
2 2
 const BottomTabs = require('./BottomTabs');
3
-const Button = require('./Button');
4 3
 const BottomTab = require('./BottomTab');
5 4
 const TopTabs = require('./TopTabs');
6 5
 
@@ -11,16 +10,12 @@ class NavigationOptions {
11 10
    * @property {options:BottomTab} [bottomTab]
12 11
    * @property {string} [orientation]
13 12
    * @property {options:TopTabs} [topTabs]
14
-   * @property {options:Button[]} [rightButtons]
15
-   * @property {options:Button[]} [leftButtons]
16 13
    */
17 14
   constructor(options) {
18 15
     this.topBar = options.topBar && new TopBar(options.topBar);
19 16
     this.bottomTabs = options.bottomTabs && new BottomTabs(options.bottomTabs);
20 17
     this.bottomTab = options.bottomTab && new BottomTab(options.bottomTab);
21 18
     this.orientation = options.orientation;
22
-    this.rightButtons = options.rightButtons && options.rightButtons.map((button) => new Button(button));
23
-    this.leftButtons = options.leftButtons && options.leftButtons.map((button) => new Button(button));
24 19
     this.sideMenu = options.sideMenu;
25 20
     this.backgroundImage = options.backgroundImage;
26 21
     this.rootBackgroundImage = options.rootBackgroundImage;

+ 0
- 20
lib/src/params/options/NavigationOptions.test.js Vedi File

@@ -7,22 +7,6 @@ const TopTabs = require('./TopTabs');
7 7
 const TAB_BAR = {};
8 8
 const TOP_BAR = {};
9 9
 const TAB_ITEM = {};
10
-const RIGHT_BUTTONS = [
11
-  {
12
-    id: 'myBtn',
13
-    testID: 'BTN',
14
-    title: 'My Button',
15
-    buttonColor: 'red'
16
-  }
17
-];
18
-const LEFT_BUTTONS = [
19
-  {
20
-    id: 'myBtn',
21
-    testID: 'BTN',
22
-    title: 'My Button',
23
-    buttonColor: 'red'
24
-  }
25
-];
26 10
 const TOP_TABS = {
27 11
   selectedTabColor: 'blue',
28 12
   unselectedTabColor: 'red'
@@ -32,8 +16,6 @@ const NAVIGATION_OPTIONS = {
32 16
   bottomTabs: TAB_BAR,
33 17
   bottomTab: TAB_ITEM,
34 18
   orientation: 'portrait',
35
-  rightButtons: RIGHT_BUTTONS,
36
-  leftButtons: LEFT_BUTTONS,
37 19
   topTabs: TOP_TABS
38 20
 };
39 21
 
@@ -44,8 +26,6 @@ describe('NavigationOptions', () => {
44 26
     expect(uut.topBar).toBeInstanceOf(TopBar);
45 27
     expect(uut.bottomTab).toBeInstanceOf(BottomTab);
46 28
     expect(uut.orientation).toEqual('portrait');
47
-    expect(uut.rightButtons).toEqual(RIGHT_BUTTONS);
48
-    expect(uut.leftButtons).toEqual(LEFT_BUTTONS);
49 29
     expect(uut.topTabs).toBeInstanceOf(TopTabs);
50 30
   });
51 31
 });

+ 6
- 0
lib/src/params/options/TopBar.js Vedi File

@@ -1,3 +1,5 @@
1
+const Button = require('./Button');
2
+
1 3
 class TopBar {
2 4
   /**
3 5
    * @property {string} [title]
@@ -16,6 +18,8 @@ class TopBar {
16 18
    * @property {boolean} [noBorder]
17 19
    * @property {boolean} [largeTitle]
18 20
    * @property {boolean} [drawUnder]
21
+   * @property {options:Button[]} [rightButtons]
22
+   * @property {options:Button[]} [leftButtons]
19 23
    */
20 24
   constructor(options) {
21 25
     this.title = options.title;
@@ -34,6 +38,8 @@ class TopBar {
34 38
     this.largeTitle = options.largeTitle;
35 39
     this.testID = options.testID;
36 40
     this.drawUnder = options.drawUnder;
41
+    this.rightButtons = options.rightButtons && options.rightButtons.map((button) => new Button(button));
42
+    this.leftButtons = options.leftButtons && options.leftButtons.map((button) => new Button(button));
37 43
   }
38 44
 }
39 45
 

+ 22
- 1
lib/src/params/options/TopBar.test.js Vedi File

@@ -1,4 +1,22 @@
1 1
 const TopBar = require('./TopBar');
2
+const Button = require('./Button');
3
+
4
+const RIGHT_BUTTONS = [
5
+  {
6
+    id: 'myBtn',
7
+    testID: 'BTN',
8
+    title: 'My Button',
9
+    buttonColor: 'red'
10
+  }
11
+];
12
+const LEFT_BUTTONS = [
13
+  {
14
+    id: 'myBtn',
15
+    testID: 'BTN',
16
+    title: 'My Button',
17
+    buttonColor: 'red'
18
+  }
19
+];
2 20
 
3 21
 const TOP_BAR = {
4 22
   title: 'something',
@@ -9,7 +27,9 @@ const TOP_BAR = {
9 27
   hidden: true,
10 28
   animateHide: true,
11 29
   hideOnScroll: true,
12
-  transparent: true
30
+  transparent: true,
31
+  rightButtons: RIGHT_BUTTONS,
32
+  leftButtons: LEFT_BUTTONS
13 33
 };
14 34
 
15 35
 describe('TopBar', () => {
@@ -24,5 +44,6 @@ describe('TopBar', () => {
24 44
     expect(uut.animateHide).toEqual(true);
25 45
     expect(uut.hideOnScroll).toEqual(true);
26 46
     expect(uut.transparent).toEqual(true);
47
+    expect(uut.leftButtons[0]).toBeInstanceOf(Button);
27 48
   });
28 49
 });

+ 46
- 42
playground/src/containers/OptionsScreen.js Vedi File

@@ -20,22 +20,22 @@ class OptionsScreen extends Component {
20 20
         hidden: false,
21 21
         textFontSize: 16,
22 22
         textFontFamily: 'HelveticaNeue-Italic',
23
-        testID: testIDs.TOP_BAR_ELEMENT
24
-      },
25
-      rightButtons: [{
26
-        id: BUTTON_ONE,
27
-        testID: BUTTON_ONE,
28
-        title: 'One',
29
-        buttonFontSize: 28,
30
-        buttonColor: 'red'
31
-      }],
32
-      leftButtons: [{
33
-        id: BUTTON_LEFT,
34
-        testID: BUTTON_LEFT,
35
-        icon: require('../../img/navicon_add.png'),
36
-        title: 'Left',
37
-        buttonColor: 'purple'
38
-      }]
23
+        testID: testIDs.TOP_BAR_ELEMENT,
24
+        rightButtons: [{
25
+          id: BUTTON_ONE,
26
+          testID: BUTTON_ONE,
27
+          title: 'One',
28
+          buttonFontSize: 28,
29
+          buttonColor: 'red'
30
+        }],
31
+        leftButtons: [{
32
+          id: BUTTON_LEFT,
33
+          testID: BUTTON_LEFT,
34
+          icon: require('../../img/navicon_add.png'),
35
+          title: 'Left',
36
+          buttonColor: 'purple'
37
+        }]
38
+      }
39 39
     };
40 40
   }
41 41
 
@@ -71,35 +71,39 @@ class OptionsScreen extends Component {
71 71
   onNavigationButtonPressed(id) {
72 72
     if (id === BUTTON_ONE) {
73 73
       Navigation.setOptions(this.props.containerId, {
74
-        rightButtons: [{
75
-          id: BUTTON_TWO,
76
-          testID: BUTTON_TWO,
77
-          title: 'Two',
78
-          icon: require('../../img/navicon_add.png'),
79
-          disableIconTint: true,
80
-          // disabled: true,
81
-          showAsAction: 'ifRoom',
82
-          buttonColor: 'green',
83
-          buttonFontSize: 28,
84
-          buttonFontWeight: '800'
85
-        }],
86
-        leftButtons: []
74
+        topBar: {
75
+          rightButtons: [{
76
+            id: BUTTON_TWO,
77
+            testID: BUTTON_TWO,
78
+            title: 'Two',
79
+            icon: require('../../img/navicon_add.png'),
80
+            disableIconTint: true,
81
+            // disabled: true,
82
+            showAsAction: 'ifRoom',
83
+            buttonColor: 'green',
84
+            buttonFontSize: 28,
85
+            buttonFontWeight: '800'
86
+          }],
87
+          leftButtons: []
88
+        }
87 89
       });
88 90
     } else if (id === BUTTON_TWO) {
89 91
       Navigation.setOptions(this.props.containerId, {
90
-        rightButtons: [{
91
-          id: BUTTON_ONE,
92
-          testID: BUTTON_ONE,
93
-          title: 'One',
94
-          buttonColor: 'red'
95
-        }],
96
-        leftButtons: [{
97
-          id: BUTTON_LEFT,
98
-          testID: BUTTON_LEFT,
99
-          icon: require('../../img/navicon_add.png'),
100
-          title: 'Left',
101
-          buttonColor: 'purple'
102
-        }]
92
+        topBar: {
93
+          rightButtons: [{
94
+            id: BUTTON_ONE,
95
+            testID: BUTTON_ONE,
96
+            title: 'One',
97
+            buttonColor: 'red'
98
+          }],
99
+          leftButtons: [{
100
+            id: BUTTON_LEFT,
101
+            testID: BUTTON_LEFT,
102
+            icon: require('../../img/navicon_add.png'),
103
+            title: 'Left',
104
+            buttonColor: 'purple'
105
+          }]
106
+        }
103 107
       });
104 108
     } else if (id === BUTTON_LEFT) {
105 109
       Navigation.pop(this.props.containerId);

+ 1
- 1
playground/src/containers/WelcomeScreen.js Vedi File

@@ -183,7 +183,7 @@ class WelcomeScreen extends Component {
183 183
           navigationOptions: {
184 184
             topTab: {
185 185
               title: 'Tab 2',
186
-              titleFontFamily: 'Dosis-Regular'
186
+              titleFontFamily: 'HelveticaNeue-Italic'
187 187
             }
188 188
           }
189 189
         },