Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/styling #307

Merged
merged 39 commits into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8c75378
Set to use old bridge for compatibility with 0.30+
explorigin Aug 16, 2016
dea1f29
Fixed crash occurring when tabBarBackgroundColor or tabBarButtonColor…
Aug 25, 2016
047b2ea
Merge branch 'fix/android-tab-color-crash'
Aug 26, 2016
4072678
Merge branch 'master' of github.com:wix/react-native-navigation
Aug 26, 2016
8a3d5c3
Merge branch 'master' of github.com:wix/react-native-navigation
Aug 26, 2016
ba006af
Merge branch 'master' of github.com:wix/react-native-navigation
Aug 30, 2016
cf8e024
Merge branch 'master' of github.com:wix/react-native-navigation
Aug 30, 2016
6d79c5c
Merge branch 'master' of github.com:wix/react-native-navigation
Aug 31, 2016
12699b8
Merge branch 'master' of github.com:wix/react-native-navigation
Sep 13, 2016
bdd8608
Adds setStyle property to index.js
simonmitchell Sep 13, 2016
ab036cd
Adds native code for setting style on RCCViewController
simonmitchell Sep 13, 2016
d836f16
Merge branch 'master' of github.com:wix/react-native-navigation
Sep 13, 2016
0196a85
Fixes setStyle function
simonmitchell Sep 13, 2016
e7bdbb4
Fixes setting style on navigator
simonmitchell Sep 13, 2016
e843ea3
Adds some styling to tab bar controller and fixes some bugs
simonmitchell Sep 13, 2016
97bba03
Adds ability to set modal presentation style
simonmitchell Sep 13, 2016
4996985
Makes sure autoAdjustScrollViewInsets isn't propagated through when p…
simonmitchell Sep 13, 2016
b456653
Changes import to reference controllers rather than react-native-cont…
simonmitchell Sep 13, 2016
69ef47c
Fixed to work with RN 33
Sep 13, 2016
c2c6b52
Merge branch 'master' of github.com:wix/react-native-navigation into …
Sep 13, 2016
d228896
Fixes updating title font styling with new RCCTitleViewHelper logic
simonmitchell Sep 13, 2016
ef018fb
Fixes subtitle being shown
simonmitchell Sep 13, 2016
7d78793
Merge feature/styling into feature/rn33
simonmitchell Sep 13, 2016
4d98695
Merge pull request #1 from wix/master
simonmitchell Sep 26, 2016
9902ba6
Merge master into feature/styling
simonmitchell Sep 26, 2016
c38001b
Merge branch 'feature/rn33'
Sep 26, 2016
f580fc1
Merge origin/master into feature/styling
simonmitchell Oct 13, 2016
5d8b188
Adds extendedLayoutIncludesOpaqueBars to navigation styling
simonmitchell Oct 13, 2016
9966233
Adds ability to add shadows to text in navigation bar / tab bar
simonmitchell Nov 2, 2016
a45d7da
Merge branch 'master' into feature/styling
simonmitchell Dec 20, 2016
8f1c4a6
Merge branch 'master' into feature/styling
simonmitchell Dec 20, 2016
6049d56
Fixed merged ReactGateway.java file
Dec 20, 2016
23753e1
Fixed issue with rightButtons getting ignored in preference for empty…
Dec 22, 2016
7e5c9b4
Merge remote-tracking branch 'wix/master'
simonmitchell Jan 25, 2017
5e03646
Merge master into feature/styling
simonmitchell Jan 25, 2017
4a2f816
Merge remote-tracking branch 'wix/master' into feature/styling
simonmitchell Feb 6, 2017
f10860c
Fixes compiler error
simonmitchell Feb 9, 2017
240ccf3
Merge branch 'master' into feature/styling
guyca Feb 10, 2017
6c5050e
Merge branch 'master' into feature/styling
guyca Feb 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/RCCNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actio
[mergedStyle removeObjectForKey:@"navBarTranslucent"];
[mergedStyle removeObjectForKey:@"statusBarHideWithNavBar"];
[mergedStyle removeObjectForKey:@"autoAdjustScrollViewInsets"];
[mergedStyle removeObjectForKey:@"statusBarTextColorSchemeSingleScreen"];

[mergedStyle addEntriesFromDictionary:navigatorStyle];
navigatorStyle = mergedStyle;
Expand Down
11 changes: 10 additions & 1 deletion ios/RCCTabBarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
#import "RCTConvert.h"
#import "RCCManager.h"
#import "RCTHelpers.h"
#import "RCTUIManager.h"

@interface RCTUIManager ()

- (void)configureNextLayoutAnimation:(NSDictionary *)config
withCallback:(RCTResponseSenderBlock)callback
errorCallback:(__unused RCTResponseSenderBlock)errorCallback;

@end

@implementation RCCTabBarController

Expand Down Expand Up @@ -121,7 +130,7 @@ - (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children

NSMutableDictionary *selectedAttributes = [RCTHelpers textAttributesFromDictionary:tabsStyle withPrefix:@"tabBarSelectedText" baseFont:[UIFont systemFontOfSize:10]];
if (!selectedAttributes[NSForegroundColorAttributeName] && selectedButtonColor) {
selectedAttributes[NSForegroundColorAttributeName] = buttonColor;
selectedAttributes[NSForegroundColorAttributeName] = selectedButtonColor;
}

[viewController.tabBarItem setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected];
Expand Down
157 changes: 83 additions & 74 deletions ios/RCCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,54 +100,54 @@ - (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children
{
NSString *component = props[@"component"];
if (!component) return nil;

NSDictionary *passProps = props[@"passProps"];
NSDictionary *navigatorStyle = props[@"style"];

NSMutableDictionary *mergedProps = [NSMutableDictionary dictionaryWithDictionary:globalProps];
[mergedProps addEntriesFromDictionary:passProps];

RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:component initialProperties:mergedProps];
if (!reactView) return nil;

self = [super init];
if (!self) return nil;

[self commonInit:reactView navigatorStyle:navigatorStyle props:props];

return self;
}

- (instancetype)initWithComponent:(NSString *)component passProps:(NSDictionary *)passProps navigatorStyle:(NSDictionary*)navigatorStyle globalProps:(NSDictionary *)globalProps bridge:(RCTBridge *)bridge
{
NSMutableDictionary *mergedProps = [NSMutableDictionary dictionaryWithDictionary:globalProps];
[mergedProps addEntriesFromDictionary:passProps];

RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:component initialProperties:mergedProps];
if (!reactView) return nil;

self = [super init];
if (!self) return nil;

[self commonInit:reactView navigatorStyle:navigatorStyle props:passProps];

return self;
}

- (void)commonInit:(RCTRootView*)reactView navigatorStyle:(NSDictionary*)navigatorStyle props:(NSDictionary*)props
{
self.view = reactView;

self.edgesForExtendedLayout = UIRectEdgeNone; // default
self.automaticallyAdjustsScrollViewInsets = NO; // default

self.navigatorStyle = [NSMutableDictionary dictionaryWithDictionary:navigatorStyle];

[self setStyleOnInit];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onRNReload) name:RCTReloadNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onCancelReactTouches) name:RCCViewControllerCancelReactTouchesNotification object:nil];

// In order to support 3rd party native ViewControllers, we support passing a class name as a prop mamed `ExternalNativeScreenClass`
// In this case, we create an instance and add it as a child ViewController which preserves the VC lifecycle.
// In case some props are necessary in the native ViewController, the ExternalNativeScreenProps can be used to pass them
Expand Down Expand Up @@ -208,7 +208,7 @@ -(void)setStyleOnAppearForViewController:(UIViewController*)viewController appea
UIColor *color = screenBackgroundColor != (id)[NSNull null] ? [RCTConvert UIColor:screenBackgroundColor] : nil;
viewController.view.backgroundColor = color;
}

NSString *navBarBackgroundColor = self.navigatorStyle[@"navBarBackgroundColor"];
if (navBarBackgroundColor) {

Expand Down Expand Up @@ -257,18 +257,16 @@ -(void)setStyleOnAppearForViewController:(UIViewController*)viewController appea
{
viewController.navigationController.navigationBar.tintColor = nil;
}

BOOL viewControllerBasedStatusBar = false;

NSObject *viewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] infoDictionary][@"UIViewControllerBasedStatusBarAppearance"];
if (viewControllerBasedStatusBarAppearance && [viewControllerBasedStatusBarAppearance isKindOfClass:[NSNumber class]]) {
viewControllerBasedStatusBar = [(NSNumber *)viewControllerBasedStatusBarAppearance boolValue];
}


NSString *statusBarTextColorSchemeSingleScreen = self.navigatorStyle[@"statusBarTextColorSchemeSingleScreen"];
NSString *statusBarTextColorScheme = self.navigatorStyle[@"statusBarTextColorScheme"];
if (statusBarTextColorScheme && [statusBarTextColorScheme isEqualToString:@"light"]) {
NSString *finalColorScheme = statusBarTextColorSchemeSingleScreen ? : statusBarTextColorScheme;

if (finalColorScheme && [finalColorScheme isEqualToString:@"light"]) {

viewController.navigationController.navigationBar.barStyle = UIBarStyleBlack;
if (!statusBarTextColorSchemeSingleScreen) {
viewController.navigationController.navigationBar.barStyle = UIBarStyleBlack;
}
self._statusBarTextColorSchemeLight = true;
if (!viewControllerBasedStatusBarAppearance) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Expand All @@ -277,14 +275,16 @@ -(void)setStyleOnAppearForViewController:(UIViewController*)viewController appea

} else {

viewController.navigationController.navigationBar.barStyle = UIBarStyleDefault;
if (!statusBarTextColorSchemeSingleScreen) {
viewController.navigationController.navigationBar.barStyle = UIBarStyleDefault;
}
self._statusBarTextColorSchemeLight = false;
if (!viewControllerBasedStatusBarAppearance) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
[viewController setNeedsStatusBarAppearanceUpdate];
}

NSNumber *navBarHidden = self.navigatorStyle[@"navBarHidden"];
BOOL navBarHiddenBool = navBarHidden ? [navBarHidden boolValue] : NO;
if (viewController.navigationController.navigationBarHidden != navBarHiddenBool) {
Expand Down Expand Up @@ -340,28 +340,31 @@ -(void)setStyleOnAppearForViewController:(UIViewController*)viewController appea

NSNumber *navBarTransparent = self.navigatorStyle[@"navBarTransparent"];
BOOL navBarTransparentBool = navBarTransparent ? [navBarTransparent boolValue] : NO;
if (navBarTransparentBool) {

if (![viewController.navigationController.navigationBar viewWithTag:TRANSPARENT_NAVBAR_TAG]) {

[self storeOriginalNavBarImages];

[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
viewController.navigationController.navigationBar.shadowImage = [UIImage new];
UIView *transparentView = [[UIView alloc] initWithFrame:CGRectZero];
transparentView.tag = TRANSPARENT_NAVBAR_TAG;
[viewController.navigationController.navigationBar insertSubview:transparentView atIndex:0];

void (^action)() = ^ {
if (navBarTransparentBool)
{
if (![viewController.navigationController.navigationBar viewWithTag:TRANSPARENT_NAVBAR_TAG])
{
[self storeOriginalNavBarImages];

[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
viewController.navigationController.navigationBar.shadowImage = [UIImage new];
UIView *transparentView = [[UIView alloc] initWithFrame:CGRectZero];
transparentView.tag = TRANSPARENT_NAVBAR_TAG;
[viewController.navigationController.navigationBar insertSubview:transparentView atIndex:0];
}
}

} else {

UIView *transparentView = [viewController.navigationController.navigationBar viewWithTag:TRANSPARENT_NAVBAR_TAG];
if (transparentView) {

[transparentView removeFromSuperview];
[viewController.navigationController.navigationBar setBackgroundImage:self.originalNavBarImages[@"bgImage"] forBarMetrics:UIBarMetricsDefault];
viewController.navigationController.navigationBar.shadowImage = self.originalNavBarImages[@"shadowImage"];
self.originalNavBarImages = nil;
else
{
UIView *transparentView = [viewController.navigationController.navigationBar viewWithTag:TRANSPARENT_NAVBAR_TAG];
if (transparentView)
{
[transparentView removeFromSuperview];
[viewController.navigationController.navigationBar setBackgroundImage:self.originalNavBarImages[@"bgImage"] forBarMetrics:UIBarMetricsDefault];
viewController.navigationController.navigationBar.shadowImage = self.originalNavBarImages[@"shadowImage"];
self.originalNavBarImages = nil;
}
}
};

Expand Down Expand Up @@ -416,15 +419,15 @@ -(void)setStyleOnAppearForViewController:(UIViewController*)viewController appea
} else {
self.navBarHairlineImageView.hidden = NO;
}

//Bug fix: in case there is a interactivePopGestureRecognizer, it prevents react-native from getting touch events on the left screen area that the gesture handles
//overriding the delegate of the gesture prevents this from happening while keeping the gesture intact (another option was to disable it completely by demand)
self.originalInteractivePopGestureDelegate = nil;
if (self.navigationController != nil && self.navigationController.interactivePopGestureRecognizer != nil) {
if (self.navigationController != nil && self.navigationController.interactivePopGestureRecognizer != nil)
{
id <UIGestureRecognizerDelegate> interactivePopGestureRecognizer = self.navigationController.interactivePopGestureRecognizer.delegate;
if (interactivePopGestureRecognizer != nil) {
if (interactivePopGestureRecognizer != nil)
{
self.originalInteractivePopGestureDelegate = interactivePopGestureRecognizer;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
Expand All @@ -449,8 +452,9 @@ -(void)storeOriginalNavBarImages {
-(void)setStyleOnDisappear
{
self.navBarHairlineImageView.hidden = NO;

if (self.navigationController != nil && self.navigationController.interactivePopGestureRecognizer != nil && self.originalInteractivePopGestureDelegate != nil) {

if (self.navigationController != nil && self.navigationController.interactivePopGestureRecognizer != nil && self.originalInteractivePopGestureDelegate != nil)
{
self.navigationController.interactivePopGestureRecognizer.delegate = self.originalInteractivePopGestureDelegate;
self.originalInteractivePopGestureDelegate = nil;
}
Expand Down Expand Up @@ -533,27 +537,30 @@ - (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
-(void)addExternalVCIfNecessary:(NSDictionary*)props
{
NSString *externalScreenClass = props[@"externalNativeScreenClass"];
if (externalScreenClass != nil) {
if (externalScreenClass != nil)
{
Class class = NSClassFromString(externalScreenClass);
if (class != NULL) {
if (class != NULL)
{
id obj = [[class alloc] init];
if (obj != nil && [obj isKindOfClass:[UIViewController class]] && [obj conformsToProtocol:@protocol(RCCExternalViewControllerProtocol)]) {
if (obj != nil && [obj isKindOfClass:[UIViewController class]] && [obj conformsToProtocol:@protocol(RCCExternalViewControllerProtocol)])
{
((id <RCCExternalViewControllerProtocol>)obj).controllerDelegate = self;
[obj setProps:props[@"externalNativeScreenProps"]];

UIViewController *viewController = (UIViewController*)obj;
[self addChildViewController:viewController];
viewController.view.frame = self.view.bounds;
viewController.view.frame = self.view.bounds;
[self.view addSubview:viewController.view];
[viewController didMoveToParentViewController:self];

} else {
}
else
{
NSLog(@"addExternalVCIfNecessary: could not create instance. Make sure that your class is a UIViewController whihc confirms to RCCExternalViewControllerProtocol");
}
} else {
}
else
{
NSLog(@"addExternalVCIfNecessary: could not create class from string. Check that the proper class name wass passed in ExternalNativeScreenClass");
}
}
Expand All @@ -564,19 +571,21 @@ -(void)addExternalVCIfNecessary:(NSDictionary*)props
- (NSString*) customNewRelicInteractionName
{
NSString *interactionName = nil;

if (self.view != nil && [self.view isKindOfClass:[RCTRootView class]]) {
if (self.view != nil && [self.view isKindOfClass:[RCTRootView class]])
{
NSString *moduleName = ((RCTRootView*)self.view).moduleName;
if(moduleName != nil) {
if(moduleName != nil)
{
interactionName = [NSString stringWithFormat:@"RCCViewController: %@", moduleName];
}
}

if (interactionName == nil) {

if (interactionName == nil)
{
interactionName = [NSString stringWithFormat:@"RCCViewController with title: %@", self.title];
}

return interactionName;
}

Expand Down
11 changes: 10 additions & 1 deletion src/deprecated/platformSpecificDeprecated.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ function addNavigatorParams(screen, navigator = null, idx = '') {
}

function addNavigatorButtons(screen, sideMenuParams) {

const Screen = Navigation.getRegisteredScreen(screen.screen);
if (screen.navigatorButtons == null) {
screen.navigatorButtons = _.cloneDeep(Screen.navigatorButtons);
Expand Down Expand Up @@ -514,9 +515,17 @@ function getLeftButtonDeprecated(screen) {
function getRightButtons(screen) {
if (screen.navigatorButtons && screen.navigatorButtons.rightButtons) {
return screen.navigatorButtons.rightButtons;
} else if (screen.rightButtons) {
return screen.rightButtons
}

const Screen = Navigation.getRegisteredScreen(screen.screen);

if (Screen.navigatorButtons && !_.isEmpty(Screen.navigatorButtons)) {
return _.cloneDeep(Screen.navigatorButtons);
}

return screen.rightButtons;
return null;
}

function addNavigationStyleParams(screen) {
Expand Down