Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ interface OnModalDismissedListener {
setAnimation(screenParams);
setStatusBarStyle(screenParams.styleParams);
setNavigationBarStyle(screenParams.styleParams);
setDrawUnderStatusBar(screenParams.styleParams);
}

private void setStatusBarStyle(StyleParams styleParams) {
Expand All @@ -128,6 +129,12 @@ private void setStatusBarStyle(StyleParams styleParams) {
StatusBar.setTextColorScheme(window.getDecorView(), styleParams.statusBarTextColorScheme);
}

private void setDrawUnderStatusBar(StyleParams styleParams) {
Window window = getWindow();
if (window == null) return;
StatusBar.displayOverScreen(window.getDecorView(), styleParams.drawUnderStatusBar);
}

private void setNavigationBarStyle(StyleParams styleParams) {
NavigationBar.setColor(getWindow(), styleParams.navigationBarColor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!NavigationApplication.instance.getReactGateway().hasStartedCreatingContext()) {
if (!NavigationApplication.instance.getReactGateway().hasStartedCreatingContext() ||
getIntent() == null ||
getIntent().getBundleExtra("ACTIVITY_PARAMS_BUNDLE") == null) {
SplashActivity.start(this);
finish();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public String getHexColor() {
public int getColor(int defaultColor) {
return hasColor() ? getColor() : defaultColor;
}

@Override
public String toString() {
return this.getHexColor();
}
}

public static class Font {
Expand Down Expand Up @@ -84,6 +89,7 @@ public String toString() {
public StatusBarTextColorScheme statusBarTextColorScheme;
public Color statusBarColor;
public boolean statusBarHidden;
public boolean drawUnderStatusBar;
public Color contextualMenuStatusBarColor;
public Color contextualMenuButtonsColor;
public Color contextualMenuBackgroundColor;
Expand Down Expand Up @@ -119,6 +125,7 @@ public String toString() {
public Font titleBarButtonFontFamily;

public Color topTabTextColor;
public Font topTabTextFontFamily;
public Color topTabIconColor;
public Color selectedTopTabTextColor;
public Color selectedTopTabIconColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public StyleParams parse() {
result.statusBarColor = getColor("statusBarColor", getDefaultStatusBarColor());
result.statusBarHidden = getBoolean("statusBarHidden", getDefaultStatusHidden());
result.statusBarTextColorScheme = StatusBarTextColorScheme.fromString(params.getString("statusBarTextColorScheme"), getDefaultStatusBarTextColorScheme());
result.drawUnderStatusBar = params.getBoolean("drawUnderStatusBar", getDefaultDrawUnderStatusBar());
result.contextualMenuStatusBarColor = getColor("contextualMenuStatusBarColor", getDefaultContextualMenuStatusBarColor());
result.contextualMenuButtonsColor = getColor("contextualMenuButtonsColor", getDefaultContextualMenuButtonsColor());
result.contextualMenuBackgroundColor = getColor("contextualMenuBackgroundColor", getDefaultContextualMenuBackgroundColor());
Expand Down Expand Up @@ -70,6 +71,7 @@ public StyleParams parse() {
result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());

result.topTabTextColor = getColor("topTabTextColor", getDefaultTopTabTextColor());
result.topTabTextFontFamily = getFont("topTabTextFontFamily", getDefaultTopTabTextFontFamily());
result.topTabIconColor = getColor("topTabIconColor", getDefaultTopTabIconColor());
result.selectedTopTabIconColor = getColor("selectedTopTabIconColor", getDefaultSelectedTopTabIconColor());
result.selectedTopTabTextColor = getColor("selectedTopTabTextColor", getDefaultSelectedTopTabTextColor());
Expand Down Expand Up @@ -124,6 +126,7 @@ private StyleParams createDefaultStyleParams() {
result.titleBarTitleFont = new StyleParams.Font();
result.titleBarSubtitleFontFamily = new StyleParams.Font();
result.titleBarButtonFontFamily = new StyleParams.Font();
result.topTabTextFontFamily = new StyleParams.Font();
result.titleBarHeight = -1;
result.screenAnimationType = "slide-up";
return result;
Expand Down Expand Up @@ -281,6 +284,10 @@ private boolean getDefaultStatusHidden() {
return AppStyle.appStyle != null && AppStyle.appStyle.statusBarHidden;
}

private boolean getDefaultDrawUnderStatusBar() {
return AppStyle.appStyle != null && AppStyle.appStyle.drawUnderStatusBar;
}

private StyleParams.Font getDefaultBottomTabsFontFamily() {
return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.bottomTabFontFamily;
}
Expand All @@ -301,6 +308,10 @@ private StyleParams.Font getDefaultSubtitleFontFamily() {
return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.titleBarSubtitleFontFamily;
}

private StyleParams.Font getDefaultTopTabTextFontFamily() {
return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.topTabTextFontFamily;
}

private StyleParams.Font getDefaultTitleBarButtonFont() {
return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.titleBarButtonFontFamily;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public Screen(AppCompatActivity activity, ScreenParams screenParams, LeftButtonO
createViews();
EventBus.instance.register(this);
sharedElements = new SharedElements();
setDrawUnderStatusBar(styleParams.drawUnderStatusBar);
}

public void registerSharedElement(SharedElementTransition toView, String key) {
Expand Down Expand Up @@ -106,6 +107,7 @@ public void setStyle() {
setStatusBarHidden(styleParams.statusBarHidden);
setStatusBarTextColorScheme(styleParams.statusBarTextColorScheme);
setNavigationBarColor(styleParams.navigationBarColor);
setDrawUnderStatusBar(styleParams.drawUnderStatusBar);
topBar.setStyle(styleParams);
if (styleParams.screenBackgroundColor.hasColor()) {
setBackgroundColor(styleParams.screenBackgroundColor.getColor());
Expand Down Expand Up @@ -174,6 +176,10 @@ private void setStatusBarHidden(boolean statusBarHidden) {
StatusBar.setHidden(((NavigationActivity) activity).getScreenWindow(), statusBarHidden);
}

private void setDrawUnderStatusBar(boolean drawUnderStatusBar) {
StatusBar.displayOverScreen(this, drawUnderStatusBar);
}

private void setStatusBarTextColorScheme(StatusBarTextColorScheme textColorScheme) {
StatusBar.setTextColorScheme(this, textColorScheme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ public static void setColor(Window window, StyleParams.Color statusBarColor) {
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void displayOverScreen(View view, boolean shouldDisplay) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;

if(shouldDisplay) {
int flags = view.getSystemUiVisibility();
flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
flags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
view.setSystemUiVisibility(flags);
} else {
int flags = view.getSystemUiVisibility();
flags &= ~View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
flags &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
view.setSystemUiVisibility(flags);
}
}

@TargetApi(Build.VERSION_CODES.M)
public static void setTextColorScheme(View view, StatusBarTextColorScheme textColorScheme) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ public void unmountReactView() {

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int measuredHeight = viewMeasurer.getMeasuredHeight(heightMeasureSpec);
setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthMeasureSpec), measuredHeight);
int widthSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST);
int heightSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.AT_MOST);

super.onMeasure(widthSpec, heightSpec);

int measuredHeight = viewMeasurer.getMeasuredHeight(heightSpec);
setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthSpec), measuredHeight);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void setFont() {
@NonNull
private ArrayList<View> findActualTextViewInMenuByLabel() {
ArrayList<View> outViews = new ArrayList<>();
parent.findViewsWithText(outViews, buttonParams.label, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
parent.findViewsWithText(outViews, buttonParams.label, View.FIND_VIEWS_WITH_TEXT);
return outViews;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private void setTopTabsStyle(StyleParams style) {
topTabs.setTopTabsTextColor(style);
topTabs.setSelectedTabIndicatorStyle(style);
topTabs.setScrollable(style);
topTabs.setTopTabsTextFontFamily(style);
}

public void showContextualMenu(final ContextualMenuParams params, StyleParams styleParams, Callback onButtonClicked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.support.design.widget.TabLayout;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.reactnativenavigation.params.StyleParams;
import com.reactnativenavigation.views.utils.TopTabsIconColorHelper;
Expand Down Expand Up @@ -39,6 +43,24 @@ void setTopTabsTextColor(StyleParams style) {
setTabTextColors(tabTextColor, selectedTabColor);
}

void setTopTabsTextFontFamily(StyleParams style) {
if (style.topTabTextFontFamily.hasFont()) {
ViewGroup viewGroup = (ViewGroup) this.getChildAt(0);

for (int tab = 0; tab < viewGroup.getChildCount(); tab++) {
ViewGroup tabViewGroup = (ViewGroup) viewGroup.getChildAt(tab);

for (int i = 0; i < tabViewGroup.getChildCount(); i++) {
View tabViewChild = tabViewGroup.getChildAt(i);
if (tabViewChild instanceof TextView) {
((TextView) tabViewChild).setTypeface(
style.topTabTextFontFamily.get(), Typeface.NORMAL);
}
}
}
}
}

void setScrollable(StyleParams style) {
if (style.topTabsScrollable) {
setTabMode(TabLayout.MODE_SCROLLABLE);
Expand Down
1 change: 1 addition & 0 deletions docs/styling-the-navigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ this.props.navigator.setStyle({
navBarButtonFontFamily: 'sans-serif-thin', // Change the font family of textual buttons
topBarElevationShadowEnabled: false, // default: true. Disables TopBar elevation shadow on Lolipop and above
statusBarColor: '#000000', // change the color of the status bar.
drawUnderStatusBar: false, // default: false, will draw the screen underneath the statusbar. Useful togheter with statusBarColor: transparent
collapsingToolBarImage: "http://lorempixel.com/400/200/", // Collapsing Toolbar image.
collapsingToolBarImage: require('../../img/topbar.jpg'), // Collapsing Toolbar image. Either use a url or require a local image.
collapsingToolBarCollapsedColor: '#0f2362', // Collapsing Toolbar scrim color.
Expand Down
2 changes: 1 addition & 1 deletion docs/top-level-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Navigation.startTabBasedApp({
     drawerShadow: true, // optional, add this if you want a side menu drawer shadow
     contentOverlayColor: 'rgba(0,0,0,0.25)', // optional, add this if you want a overlay color when drawer is open
leftDrawerWidth: 50, // optional, add this if you want a define left drawer width (50=percent)
rightDrawerWidth: 50 // optional, add this if you want a define right drawer width (50=percent)
rightDrawerWidth: 50, // optional, add this if you want a define right drawer width (50=percent)
shouldStretchDrawer: true // optional, iOS only with 'MMDrawer' type, whether or not the panning gesture will “hard-stop” at the maximum width for a given drawer side, default : true
},
type: 'MMDrawer', // optional, iOS only, types: 'TheSideBar', 'MMDrawer' default: 'MMDrawer'
Expand Down
1 change: 1 addition & 0 deletions example/src/screens/types/TopTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {PixelRatio} from 'react-native';
class TopTabs extends React.Component {
static navigatorStyle = {
topTabTextColor: '#ffffff',
topTabTextFontFamily: 'BioRhyme-Bold',
selectedTopTabTextColor: '#ff505c',

// Icons
Expand Down
6 changes: 4 additions & 2 deletions ios/RCCNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actio
if ([self.topViewController isKindOfClass:[RCCViewController class]])
{
RCCViewController *topViewController = ((RCCViewController*)self.topViewController);
topViewController.previewController = nil;
[topViewController.navigationController unregisterForPreviewingWithContext:topViewController.previewContext];
viewController.previewActions = previewActions;
viewController.previewCommit = actionParams[@"previewCommit"] ? [actionParams[@"previewCommit"] boolValue] : YES;
NSNumber *previewHeight = actionParams[@"previewHeight"];
Expand All @@ -184,7 +186,7 @@ - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actio
[bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
UIView *view = viewRegistry[previewViewID];
topViewController.previewView = view;
[topViewController registerForPreviewingWithDelegate:(id)topViewController sourceView:view];
topViewController.previewContext = [topViewController registerForPreviewingWithDelegate:(id)topViewController sourceView:view];
}];
});
topViewController.previewController = viewController;
Expand Down Expand Up @@ -257,7 +259,7 @@ - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actio
if (!component) return;

NSMutableDictionary *passProps = [actionParams[@"passProps"] mutableCopy];
passProps[@"commantType"] = @"resetTo";
passProps[@"commandType"] = @"resetTo";
NSDictionary *navigatorStyle = actionParams[@"style"];

RCCViewController *viewController = [[RCCViewController alloc] initWithComponent:component passProps:passProps navigatorStyle:navigatorStyle globalProps:nil bridge:bridge];
Expand Down
1 change: 1 addition & 0 deletions ios/RCCViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern NSString* const RCCViewControllerCancelReactTouchesNotification;
@property (nonatomic) UIView *previewView;
@property (nonatomic) NSArray *previewActions;
@property (nonatomic) BOOL previewCommit;
@property (nonatomic) id previewContext;

+ (UIViewController*)controllerWithLayout:(NSDictionary *)layout globalProps:(NSDictionary *)globalProps bridge:(RCTBridge *)bridge;

Expand Down
14 changes: 14 additions & 0 deletions src/deprecated/platformSpecificDeprecated.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ function navigatorPush(navigator, params) {
adapted = adaptNavigationParams(adapted);
adapted.overrideBackPress = params.overrideBackPress;
adapted.timestamp = Date.now();
if (!adapted.passProps) {
adapted.passProps = {};
}
if (!adapted.passProps.commandType) {
adapted.passProps.commandType = 'Push';
}

return newPlatformSpecific.push(adapted);
}
Expand Down Expand Up @@ -143,6 +149,7 @@ function convertStyleParams(originalStyleObject) {
statusBarColor: processColor(originalStyleObject.statusBarColor),
statusBarHidden: originalStyleObject.statusBarHidden,
statusBarTextColorScheme: originalStyleObject.statusBarTextColorScheme,
drawUnderStatusBar: originalStyleObject.drawUnderStatusBar || false,
topBarReactView: originalStyleObject.navBarCustomView,
topBarReactViewAlignment: originalStyleObject.navBarComponentAlignment,
topBarReactViewInitialProps: originalStyleObject.navBarCustomViewInitialProps,
Expand Down Expand Up @@ -183,6 +190,7 @@ function convertStyleParams(originalStyleObject) {
drawBelowTopBar: !originalStyleObject.drawUnderNavBar,

topTabTextColor: processColor(originalStyleObject.topTabTextColor),
topTabTextFontFamily: originalStyleObject.topTabTextFontFamily,
topTabIconColor: processColor(originalStyleObject.topTabIconColor),
selectedTopTabIconColor: processColor(originalStyleObject.selectedTopTabIconColor),
selectedTopTabTextColor: processColor(originalStyleObject.selectedTopTabTextColor),
Expand Down Expand Up @@ -472,6 +480,12 @@ function showModal(params) {
adapted = adaptNavigationParams(adapted);
adapted.overrideBackPress = params.overrideBackPress;
adapted.timestamp = Date.now();
if (!adapted.passProps) {
adapted.passProps = {};
}
if (!adapted.passProps.commandType) {
adapted.passProps.commandType = 'ShowModal';
}

newPlatformSpecific.showModal(adapted);
}
Expand Down