mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-12 17:31:06 +08:00
Update depenencies, update Prettier
This commit is contained in:
@@ -47,40 +47,40 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"clamp": "^1.0.1",
|
||||
"hoist-non-react-statics": "^1.2.0",
|
||||
"hoist-non-react-statics": "^2.0.0",
|
||||
"path-to-regexp": "^1.7.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react-native-drawer-layout-polyfill": "^1.3.1",
|
||||
"react-native-drawer-layout-polyfill": "^1.3.2",
|
||||
"react-native-tab-view": "^0.0.66"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-core": "^6.24.1",
|
||||
"babel-core": "^6.25.0",
|
||||
"babel-eslint": "^7.2.3",
|
||||
"babel-jest": "^20.0.1",
|
||||
"babel-plugin-flow-react-proptypes": "^2.2.1",
|
||||
"babel-jest": "^20.0.3",
|
||||
"babel-plugin-flow-react-proptypes": "^3.4.1",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"babel-preset-react-native": "^1.9.2",
|
||||
"babel-preset-react-native": "^2.0.0",
|
||||
"babel-preset-react-native-stage-0": "^1.0.1",
|
||||
"babel-preset-react-native-syntax": "^1.0.0",
|
||||
"babel-preset-stage-1": "^6.24.1",
|
||||
"codecov": "^2.2.0",
|
||||
"eslint": "^3.19.0",
|
||||
"eslint-config-prettier": "^2.1.0",
|
||||
"eslint-plugin-flowtype": "^2.33.0",
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"eslint-plugin-jsx-a11y": "^5.0.1",
|
||||
"eslint-plugin-prettier": "^2.0.1",
|
||||
"eslint-plugin-react": "^7.0.1",
|
||||
"eslint": "^4.1.1",
|
||||
"eslint-config-prettier": "^2.3.0",
|
||||
"eslint-plugin-flowtype": "^2.34.1",
|
||||
"eslint-plugin-import": "^2.6.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.0.2",
|
||||
"eslint-plugin-prettier": "^2.1.2",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"flow-bin": "^0.49.1",
|
||||
"jest": "^20.0.1",
|
||||
"prettier": "^1.3.1",
|
||||
"prettier-eslint": "^6.2.2",
|
||||
"jest": "^20.0.4",
|
||||
"prettier": "^1.5.2",
|
||||
"prettier-eslint": "^6.4.1",
|
||||
"react": "16.0.0-alpha.12",
|
||||
"react-native": "^0.45.1",
|
||||
"react-native-vector-icons": "^4.1.1",
|
||||
"react-test-renderer": "^15.4.2"
|
||||
"react-native-vector-icons": "^4.2.0",
|
||||
"react-test-renderer": "^15.6.1"
|
||||
},
|
||||
"jest": {
|
||||
"notify": true,
|
||||
|
||||
34
packages/react-navigation/src/TypeDefinition.js
vendored
34
packages/react-navigation/src/TypeDefinition.js
vendored
@@ -135,9 +135,9 @@ export type NavigationRouter<State, Action, Options> = {
|
||||
export type NavigationScreenOption<T> =
|
||||
| T
|
||||
| ((
|
||||
navigation: NavigationScreenProp<NavigationRoute, NavigationAction>,
|
||||
config: T
|
||||
) => T);
|
||||
navigation: NavigationScreenProp<NavigationRoute, NavigationAction>,
|
||||
config: T
|
||||
) => T);
|
||||
|
||||
export type NavigationScreenDetails<T> = {
|
||||
options: T,
|
||||
@@ -157,12 +157,12 @@ export type NavigationScreenConfigProps = {
|
||||
export type NavigationScreenConfig<Options> =
|
||||
| Options
|
||||
| (NavigationScreenConfigProps &
|
||||
(({
|
||||
navigationOptions: NavigationScreenProp<
|
||||
NavigationRoute,
|
||||
NavigationAction
|
||||
>,
|
||||
}) => Options));
|
||||
(({
|
||||
navigationOptions: NavigationScreenProp<
|
||||
NavigationRoute,
|
||||
NavigationAction
|
||||
>,
|
||||
}) => Options));
|
||||
|
||||
export type NavigationComponent =
|
||||
| NavigationScreenComponent<*, *>
|
||||
@@ -302,14 +302,14 @@ export type NavigationTabScreenOptions = NavigationScreenOptions & {
|
||||
tabBarIcon?:
|
||||
| React.Element<*>
|
||||
| ((options: { tintColor: ?string, focused: boolean }) => ?React.Element<
|
||||
*
|
||||
>),
|
||||
*
|
||||
>),
|
||||
tabBarLabel?:
|
||||
| string
|
||||
| React.Element<*>
|
||||
| ((options: { tintColor: ?string, focused: boolean }) => ?React.Element<
|
||||
*
|
||||
>),
|
||||
*
|
||||
>),
|
||||
tabBarVisible?: boolean,
|
||||
};
|
||||
|
||||
@@ -317,13 +317,13 @@ export type NavigationDrawerScreenOptions = NavigationScreenOptions & {
|
||||
drawerIcon?:
|
||||
| React.Element<*>
|
||||
| ((options: { tintColor: ?string, focused: boolean }) => ?React.Element<
|
||||
*
|
||||
>),
|
||||
*
|
||||
>),
|
||||
drawerLabel?:
|
||||
| React.Element<*>
|
||||
| ((options: { tintColor: ?string, focused: boolean }) => ?React.Element<
|
||||
*
|
||||
>),
|
||||
*
|
||||
>),
|
||||
};
|
||||
|
||||
export type NavigationRouteConfigMap = {
|
||||
|
||||
@@ -82,7 +82,9 @@ export default function createNavigationContainer<T: *>(
|
||||
invariant(
|
||||
keys.length === 0,
|
||||
'This navigator has both navigation and container props, so it is ' +
|
||||
`unclear if it should own its own state. Remove props: "${keys.join(', ')}" ` +
|
||||
`unclear if it should own its own state. Remove props: "${keys.join(
|
||||
', '
|
||||
)}" ` +
|
||||
'if the navigator should get its state from the navigation prop. If the ' +
|
||||
'navigator should maintain its own state, do not pass a navigation prop.'
|
||||
);
|
||||
|
||||
@@ -28,8 +28,8 @@ const DefaultDrawerConfig = {
|
||||
* Default drawer width is screen width - header width
|
||||
* https://material.io/guidelines/patterns/navigation-drawer.html
|
||||
*/
|
||||
drawerWidth: Dimensions.get('window').width -
|
||||
(Platform.OS === 'android' ? 56 : 64),
|
||||
drawerWidth:
|
||||
Dimensions.get('window').width - (Platform.OS === 'android' ? 56 : 64),
|
||||
contentComponent: DrawerItems,
|
||||
drawerPosition: 'left',
|
||||
};
|
||||
@@ -74,7 +74,7 @@ const DrawerNavigator = (
|
||||
routeConfigs,
|
||||
config,
|
||||
NavigatorTypes.DRAWER
|
||||
)((props: *) => (
|
||||
)((props: *) =>
|
||||
<DrawerView
|
||||
{...props}
|
||||
drawerWidth={drawerWidth}
|
||||
@@ -82,7 +82,7 @@ const DrawerNavigator = (
|
||||
contentOptions={contentOptions}
|
||||
drawerPosition={drawerPosition}
|
||||
/>
|
||||
));
|
||||
);
|
||||
|
||||
return createNavigationContainer(navigator, containerConfig);
|
||||
};
|
||||
|
||||
@@ -34,6 +34,7 @@ export default (
|
||||
onTransitionEnd,
|
||||
navigationOptions,
|
||||
} = stackConfig;
|
||||
|
||||
const stackRouterConfig = {
|
||||
initialRouteName,
|
||||
initialRouteParams,
|
||||
@@ -48,7 +49,7 @@ export default (
|
||||
routeConfigMap,
|
||||
stackConfig,
|
||||
NavigatorTypes.STACK
|
||||
)((props: *) => (
|
||||
)((props: *) =>
|
||||
<CardStackTransitioner
|
||||
{...props}
|
||||
headerMode={headerMode}
|
||||
@@ -58,7 +59,7 @@ export default (
|
||||
onTransitionStart={onTransitionStart}
|
||||
onTransitionEnd={onTransitionEnd}
|
||||
/>
|
||||
));
|
||||
);
|
||||
|
||||
return createNavigationContainer(navigator, stackConfig.containerOptions);
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ const TabNavigator = (
|
||||
routeConfigs,
|
||||
config,
|
||||
NavigatorTypes.TABS
|
||||
)((props: *) => (
|
||||
)((props: *) =>
|
||||
<TabView
|
||||
{...props}
|
||||
tabBarComponent={tabBarComponent}
|
||||
@@ -57,7 +57,7 @@ const TabNavigator = (
|
||||
animationEnabled={animationEnabled}
|
||||
lazy={lazy}
|
||||
/>
|
||||
));
|
||||
);
|
||||
|
||||
return createNavigationContainer(navigator, tabsConfig.containerOptions);
|
||||
};
|
||||
@@ -100,9 +100,8 @@ const Presets = {
|
||||
TabNavigator.Presets = {
|
||||
iOSBottomTabs: Presets.iOSBottomTabs,
|
||||
AndroidTopTabs: Presets.AndroidTopTabs,
|
||||
Default: Platform.OS === 'ios'
|
||||
? Presets.iOSBottomTabs
|
||||
: Presets.AndroidTopTabs,
|
||||
Default:
|
||||
Platform.OS === 'ios' ? Presets.iOSBottomTabs : Presets.AndroidTopTabs,
|
||||
};
|
||||
|
||||
export default TabNavigator;
|
||||
|
||||
@@ -19,7 +19,7 @@ const createNavigator = (
|
||||
routeConfigs: NavigationRouteConfigMap,
|
||||
navigatorConfig: any,
|
||||
navigatorType: NavigatorType
|
||||
) => (View: NavigationNavigator<*, *, *, *>) => {
|
||||
) => (NavigationView: NavigationNavigator<*, *, *, *>) => {
|
||||
class Navigator extends React.Component {
|
||||
props: NavigationNavigatorProps<*>;
|
||||
|
||||
@@ -30,7 +30,7 @@ const createNavigator = (
|
||||
static navigatorType = navigatorType;
|
||||
|
||||
render() {
|
||||
return <View {...this.props} router={router} />;
|
||||
return <NavigationView {...this.props} router={router} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,8 @@ export default (
|
||||
const tabRouters = {};
|
||||
order.forEach((routeName: string) => {
|
||||
const routeConfig = routeConfigs[routeName];
|
||||
paths[routeName] = typeof routeConfig.path === 'string'
|
||||
? routeConfig.path
|
||||
: routeName;
|
||||
paths[routeName] =
|
||||
typeof routeConfig.path === 'string' ? routeConfig.path : routeName;
|
||||
tabRouters[routeName] = null;
|
||||
if (routeConfig.screen && routeConfig.screen.router) {
|
||||
tabRouters[routeName] = routeConfig.screen.router;
|
||||
|
||||
@@ -13,7 +13,9 @@ test('should get config for screen', () => {
|
||||
|
||||
class HomeScreen extends Component {
|
||||
static navigationOptions = ({ navigation }: *) => ({
|
||||
title: `Welcome ${navigation.state.params ? navigation.state.params.user : 'anonymous'}`,
|
||||
title: `Welcome ${navigation.state.params
|
||||
? navigation.state.params.user
|
||||
: 'anonymous'}`,
|
||||
gesturesEnabled: true,
|
||||
});
|
||||
|
||||
|
||||
24
packages/react-navigation/src/views/CardStack.js
vendored
24
packages/react-navigation/src/views/CardStack.js
vendored
@@ -258,9 +258,8 @@ class CardStack extends Component {
|
||||
if (index !== scene.index) {
|
||||
return false;
|
||||
}
|
||||
const immediateIndex = this._immediateIndex == null
|
||||
? index
|
||||
: this._immediateIndex;
|
||||
const immediateIndex =
|
||||
this._immediateIndex == null ? index : this._immediateIndex;
|
||||
const currentDragDistance = gesture[isVertical ? 'dy' : 'dx'];
|
||||
const currentDragPosition =
|
||||
event.nativeEvent[isVertical ? 'pageY' : 'pageX'];
|
||||
@@ -296,9 +295,10 @@ class CardStack extends Component {
|
||||
const axisDistance = isVertical
|
||||
? layout.height.__getValue()
|
||||
: layout.width.__getValue();
|
||||
const currentValue = I18nManager.isRTL && axis === 'dx'
|
||||
? startValue + gesture[axis] / axisDistance
|
||||
: startValue - gesture[axis] / axisDistance;
|
||||
const currentValue =
|
||||
I18nManager.isRTL && axis === 'dx'
|
||||
? startValue + gesture[axis] / axisDistance
|
||||
: startValue - gesture[axis] / axisDistance;
|
||||
const value = clamp(index - 1, currentValue, index);
|
||||
position.setValue(value);
|
||||
},
|
||||
@@ -312,9 +312,8 @@ class CardStack extends Component {
|
||||
}
|
||||
this._isResponding = false;
|
||||
|
||||
const immediateIndex = this._immediateIndex == null
|
||||
? index
|
||||
: this._immediateIndex;
|
||||
const immediateIndex =
|
||||
this._immediateIndex == null ? index : this._immediateIndex;
|
||||
|
||||
// Calculate animate duration according to gesture speed and moved distance
|
||||
const axisDistance = isVertical
|
||||
@@ -352,9 +351,10 @@ class CardStack extends Component {
|
||||
});
|
||||
|
||||
const { options } = this._getScreenDetails(scene);
|
||||
const gesturesEnabled = typeof options.gesturesEnabled === 'boolean'
|
||||
? options.gesturesEnabled
|
||||
: Platform.OS === 'ios';
|
||||
const gesturesEnabled =
|
||||
typeof options.gesturesEnabled === 'boolean'
|
||||
? options.gesturesEnabled
|
||||
: Platform.OS === 'ios';
|
||||
|
||||
const handlers = gesturesEnabled ? responder.panHandlers : {};
|
||||
const containerStyle = [
|
||||
|
||||
@@ -46,7 +46,7 @@ const DrawerNavigatorItems = ({
|
||||
onItemPress,
|
||||
style,
|
||||
labelStyle,
|
||||
}: Props) => (
|
||||
}: Props) =>
|
||||
<View style={[styles.container, style]}>
|
||||
{items.map((route: NavigationRoute, index: number) => {
|
||||
const focused = activeItemKey === route.key;
|
||||
@@ -82,8 +82,7 @@ const DrawerNavigatorItems = ({
|
||||
</TouchableItem>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
</View>;
|
||||
|
||||
/* Material design specs - https://material.io/guidelines/patterns/navigation-drawer.html#navigation-drawer-specs */
|
||||
DrawerNavigatorItems.defaultProps = {
|
||||
|
||||
@@ -115,7 +115,7 @@ export default class DrawerView<T: *> extends PureComponent<void, Props, void> {
|
||||
return navigationState;
|
||||
};
|
||||
|
||||
_renderNavigationView = () => (
|
||||
_renderNavigationView = () =>
|
||||
<DrawerSidebar
|
||||
screenProps={this.props.screenProps}
|
||||
navigation={this._screenNavigationProp}
|
||||
@@ -123,8 +123,7 @@ export default class DrawerView<T: *> extends PureComponent<void, Props, void> {
|
||||
contentComponent={this.props.contentComponent}
|
||||
contentOptions={this.props.contentOptions}
|
||||
style={this.props.style}
|
||||
/>
|
||||
);
|
||||
/>;
|
||||
|
||||
_drawer: any;
|
||||
|
||||
|
||||
@@ -94,16 +94,17 @@ class Header extends React.PureComponent<void, HeaderProps, HeaderState> {
|
||||
|
||||
// On iOS, width of left/right components depends on the calculated
|
||||
// size of the title.
|
||||
const onLayoutIOS = Platform.OS === 'ios'
|
||||
? (e: LayoutEvent) => {
|
||||
this.setState({
|
||||
widths: {
|
||||
...this.state.widths,
|
||||
[props.scene.key]: e.nativeEvent.layout.width,
|
||||
},
|
||||
});
|
||||
}
|
||||
: undefined;
|
||||
const onLayoutIOS =
|
||||
Platform.OS === 'ios'
|
||||
? (e: LayoutEvent) => {
|
||||
this.setState({
|
||||
widths: {
|
||||
...this.state.widths,
|
||||
[props.scene.key]: e.nativeEvent.layout.width,
|
||||
},
|
||||
});
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<HeaderTitle
|
||||
|
||||
@@ -65,9 +65,10 @@ class HeaderBackButton extends React.PureComponent<DefaultProps, Props, State> {
|
||||
truncatedTitle,
|
||||
} = this.props;
|
||||
|
||||
const renderTruncated = this.state.initialTextWidth && width
|
||||
? this.state.initialTextWidth > width
|
||||
: false;
|
||||
const renderTruncated =
|
||||
this.state.initialTextWidth && width
|
||||
? this.state.initialTextWidth > width
|
||||
: false;
|
||||
|
||||
const backButtonTitle = renderTruncated ? truncatedTitle : title;
|
||||
|
||||
@@ -124,28 +125,30 @@ const styles = StyleSheet.create({
|
||||
fontSize: 17,
|
||||
paddingRight: 10,
|
||||
},
|
||||
icon: Platform.OS === 'ios'
|
||||
? {
|
||||
height: 21,
|
||||
width: 13,
|
||||
marginLeft: 10,
|
||||
marginRight: 22,
|
||||
marginVertical: 12,
|
||||
resizeMode: 'contain',
|
||||
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
||||
}
|
||||
: {
|
||||
height: 24,
|
||||
width: 24,
|
||||
margin: 16,
|
||||
resizeMode: 'contain',
|
||||
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
||||
},
|
||||
iconWithTitle: Platform.OS === 'ios'
|
||||
? {
|
||||
marginRight: 5,
|
||||
}
|
||||
: {},
|
||||
icon:
|
||||
Platform.OS === 'ios'
|
||||
? {
|
||||
height: 21,
|
||||
width: 13,
|
||||
marginLeft: 10,
|
||||
marginRight: 22,
|
||||
marginVertical: 12,
|
||||
resizeMode: 'contain',
|
||||
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
||||
}
|
||||
: {
|
||||
height: 24,
|
||||
width: 24,
|
||||
margin: 16,
|
||||
resizeMode: 'contain',
|
||||
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
||||
},
|
||||
iconWithTitle:
|
||||
Platform.OS === 'ios'
|
||||
? {
|
||||
marginRight: 5,
|
||||
}
|
||||
: {},
|
||||
});
|
||||
|
||||
export default HeaderBackButton;
|
||||
|
||||
@@ -17,14 +17,13 @@ type Props = {
|
||||
|
||||
const AnimatedText = Animated.Text;
|
||||
|
||||
const HeaderTitle = ({ style, ...rest }: Props) => (
|
||||
const HeaderTitle = ({ style, ...rest }: Props) =>
|
||||
<AnimatedText
|
||||
numberOfLines={1}
|
||||
{...rest}
|
||||
style={[styles.title, style]}
|
||||
accessibilityTraits="header"
|
||||
/>
|
||||
);
|
||||
/>;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
title: {
|
||||
|
||||
@@ -40,8 +40,11 @@ type Props = {
|
||||
showIcon: boolean,
|
||||
};
|
||||
|
||||
export default class TabBarBottom
|
||||
extends PureComponent<DefaultProps, Props, void> {
|
||||
export default class TabBarBottom extends PureComponent<
|
||||
DefaultProps,
|
||||
Props,
|
||||
void
|
||||
> {
|
||||
// See https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/UIKitUICatalog/UITabBar.html
|
||||
static defaultProps = {
|
||||
activeTintColor: '#3478f6', // Default active tint color in iOS 10
|
||||
|
||||
@@ -37,8 +37,11 @@ type Props = {
|
||||
iconStyle?: ViewStyleProp,
|
||||
};
|
||||
|
||||
export default class TabBarTop
|
||||
extends PureComponent<DefaultProps, Props, void> {
|
||||
export default class TabBarTop extends PureComponent<
|
||||
DefaultProps,
|
||||
Props,
|
||||
void
|
||||
> {
|
||||
static defaultProps = {
|
||||
activeTintColor: '#fff',
|
||||
inactiveTintColor: '#fff',
|
||||
|
||||
@@ -153,9 +153,8 @@ class TabView extends PureComponent<void, Props, void> {
|
||||
screenProps || {}
|
||||
);
|
||||
|
||||
const tabBarVisible = options.tabBarVisible == null
|
||||
? true
|
||||
: options.tabBarVisible;
|
||||
const tabBarVisible =
|
||||
options.tabBarVisible == null ? true : options.tabBarVisible;
|
||||
|
||||
if (tabBarComponent !== undefined && tabBarVisible) {
|
||||
if (tabBarPosition === 'bottom') {
|
||||
|
||||
@@ -34,8 +34,11 @@ type DefaultProps = {
|
||||
pressColor: string,
|
||||
};
|
||||
|
||||
export default class TouchableItem
|
||||
extends Component<DefaultProps, Props, void> {
|
||||
export default class TouchableItem extends Component<
|
||||
DefaultProps,
|
||||
Props,
|
||||
void
|
||||
> {
|
||||
static defaultProps = {
|
||||
borderless: false,
|
||||
pressColor: 'rgba(0, 0, 0, .32)',
|
||||
|
||||
@@ -157,18 +157,19 @@ class Transitioner extends React.Component<*, Props, State> {
|
||||
const positionHasChanged = position.__getValue() !== toValue;
|
||||
|
||||
// if swiped back, indexHasChanged == true && positionHasChanged == false
|
||||
const animations = indexHasChanged && positionHasChanged
|
||||
? [
|
||||
timing(progress, {
|
||||
...transitionSpec,
|
||||
toValue: 1,
|
||||
}),
|
||||
timing(position, {
|
||||
...transitionSpec,
|
||||
toValue: nextProps.navigation.state.index,
|
||||
}),
|
||||
]
|
||||
: [];
|
||||
const animations =
|
||||
indexHasChanged && positionHasChanged
|
||||
? [
|
||||
timing(progress, {
|
||||
...transitionSpec,
|
||||
toValue: 1,
|
||||
}),
|
||||
timing(position, {
|
||||
...transitionSpec,
|
||||
toValue: nextProps.navigation.state.index,
|
||||
}),
|
||||
]
|
||||
: [];
|
||||
|
||||
// update scenes and play the transition
|
||||
this._isTransitionRunning = true;
|
||||
|
||||
@@ -17,11 +17,11 @@ type InjectedProps = {
|
||||
export default function withNavigation<T: *>(
|
||||
Component: ReactClass<T & InjectedProps>
|
||||
) {
|
||||
const componentWithNavigation = (props: T, { navigation }: Context) => (
|
||||
<Component {...props} navigation={navigation} />
|
||||
);
|
||||
const componentWithNavigation = (props: T, { navigation }: Context) =>
|
||||
<Component {...props} navigation={navigation} />;
|
||||
|
||||
componentWithNavigation.displayName = `withNavigation(${Component.displayName || Component.name})`;
|
||||
componentWithNavigation.displayName = `withNavigation(${Component.displayName ||
|
||||
Component.name})`;
|
||||
|
||||
componentWithNavigation.contextTypes = {
|
||||
navigation: propTypes.object.isRequired,
|
||||
|
||||
@@ -19,7 +19,8 @@ export default function withCachedChildNavigation<T: *, N: *>(
|
||||
Comp: ReactClass<T & InjectedProps<N>>
|
||||
): ReactClass<T> {
|
||||
return class extends PureComponent {
|
||||
static displayName = `withCachedChildNavigation(${Comp.displayName || Comp.name})`;
|
||||
static displayName = `withCachedChildNavigation(${Comp.displayName ||
|
||||
Comp.name})`;
|
||||
|
||||
props: T;
|
||||
|
||||
|
||||
@@ -165,7 +165,9 @@ function printFileSizes(stats, previousSizeMap) {
|
||||
sizeLabel += rightPadding;
|
||||
}
|
||||
console.log(
|
||||
` ${sizeLabel} ${chalk.dim(asset.folder + path.sep)}${chalk.cyan(asset.name)}`
|
||||
` ${sizeLabel} ${chalk.dim(asset.folder + path.sep)}${chalk.cyan(
|
||||
asset.name
|
||||
)}`
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -211,10 +213,14 @@ function build(previousSizeMap) {
|
||||
if (homepagePath && homepagePath.indexOf('.github.io/') !== -1) {
|
||||
// "homepage": "http://user.github.io/project"
|
||||
console.log(
|
||||
`The project was built assuming it is hosted at ${chalk.green(publicPath)}.`
|
||||
`The project was built assuming it is hosted at ${chalk.green(
|
||||
publicPath
|
||||
)}.`
|
||||
);
|
||||
console.log(
|
||||
`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.`
|
||||
`You can control this with the ${chalk.green(
|
||||
'homepage'
|
||||
)} field in your ${chalk.cyan('package.json')}.`
|
||||
);
|
||||
console.log();
|
||||
console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
|
||||
@@ -230,7 +236,9 @@ function build(previousSizeMap) {
|
||||
console.log(` ${chalk.yellow('"scripts"')}: {`);
|
||||
console.log(` ${chalk.dim('// ...')}`);
|
||||
console.log(
|
||||
` ${chalk.yellow('"deploy"')}: ${chalk.yellow('"gh-pages -d build"')}`
|
||||
` ${chalk.yellow('"deploy"')}: ${chalk.yellow(
|
||||
'"gh-pages -d build"'
|
||||
)}`
|
||||
);
|
||||
console.log(' }');
|
||||
console.log();
|
||||
@@ -241,10 +249,14 @@ function build(previousSizeMap) {
|
||||
} else if (publicPath !== '/') {
|
||||
// "homepage": "http://mywebsite.com/project"
|
||||
console.log(
|
||||
`The project was built assuming it is hosted at ${chalk.green(publicPath)}.`
|
||||
`The project was built assuming it is hosted at ${chalk.green(
|
||||
publicPath
|
||||
)}.`
|
||||
);
|
||||
console.log(
|
||||
`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.`
|
||||
`You can control this with the ${chalk.green(
|
||||
'homepage'
|
||||
)} field in your ${chalk.cyan('package.json')}.`
|
||||
);
|
||||
console.log();
|
||||
console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
|
||||
@@ -257,18 +269,24 @@ function build(previousSizeMap) {
|
||||
if (homepagePath) {
|
||||
// "homepage": "http://mywebsite.com"
|
||||
console.log(
|
||||
`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.`
|
||||
`You can control this with the ${chalk.green(
|
||||
'homepage'
|
||||
)} field in your ${chalk.cyan('package.json')}.`
|
||||
);
|
||||
console.log();
|
||||
} else {
|
||||
// no homepage
|
||||
console.log(
|
||||
`To override this, specify the ${chalk.green('homepage')} in your ${chalk.cyan('package.json')}.`
|
||||
`To override this, specify the ${chalk.green(
|
||||
'homepage'
|
||||
)} in your ${chalk.cyan('package.json')}.`
|
||||
);
|
||||
console.log('For example, add this to build it for GitHub Pages:');
|
||||
console.log();
|
||||
console.log(
|
||||
` ${chalk.green('"homepage"')}${chalk.cyan(': ')}${chalk.green('"http://myname.github.io/myapp"')}${chalk.cyan(',')}`
|
||||
` ${chalk.green('"homepage"')}${chalk.cyan(': ')}${chalk.green(
|
||||
'"http://myname.github.io/myapp"'
|
||||
)}${chalk.cyan(',')}`
|
||||
);
|
||||
console.log();
|
||||
}
|
||||
|
||||
5
packages/react-navigation/website/src/App.js
vendored
5
packages/react-navigation/website/src/App.js
vendored
@@ -363,11 +363,10 @@ const BlogPage = createNavigator(
|
||||
})
|
||||
)(PageWithSidebar);
|
||||
|
||||
const NotFoundError = () => (
|
||||
const NotFoundError = () =>
|
||||
<div className="errorScreen">
|
||||
<h1>Page not found</h1>
|
||||
</div>
|
||||
);
|
||||
</div>;
|
||||
|
||||
const App = createNavigator(
|
||||
TabRouter({
|
||||
|
||||
@@ -66,10 +66,8 @@ class AppFrame extends React.Component {
|
||||
const hasChildNavigation = !!route.routes;
|
||||
return (
|
||||
<div className={`main-app ${isMobileMenuOpen ? 'mobileMenuActive' : ''}`}>
|
||||
|
||||
<nav className="pt-navbar" id="navbar">
|
||||
<div className="inner-navbar">
|
||||
|
||||
<Link
|
||||
className="pt-navbar-group pt-align-left project-title"
|
||||
to="Home"
|
||||
@@ -79,16 +77,16 @@ class AppFrame extends React.Component {
|
||||
role="presentation"
|
||||
className="logo"
|
||||
/>
|
||||
<h1 className="pt-navbar-heading">
|
||||
React Navigation
|
||||
</h1>
|
||||
<h1 className="pt-navbar-heading">React Navigation</h1>
|
||||
</Link>
|
||||
|
||||
<NavigationLinks navigation={navigation} className="navbuttons" />
|
||||
|
||||
{hasChildNavigation &&
|
||||
<span
|
||||
className={`pt-icon-properties openMenuButton ${isMobileMenuOpen ? 'active' : ''}`}
|
||||
className={`pt-icon-properties openMenuButton ${isMobileMenuOpen
|
||||
? 'active'
|
||||
: ''}`}
|
||||
onClick={() => {
|
||||
this.setState(s => ({
|
||||
isMobileMenuOpen: !s.isMobileMenuOpen,
|
||||
@@ -96,7 +94,6 @@ class AppFrame extends React.Component {
|
||||
window.scrollTo(0, 0);
|
||||
}}
|
||||
/>}
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@ import React from 'react';
|
||||
import Prism from 'prismjs';
|
||||
import 'prismjs/components/prism-jsx';
|
||||
|
||||
const CodeBlock = ({ code }) => (
|
||||
const CodeBlock = ({ code }) =>
|
||||
<pre>
|
||||
<code
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: Prism.highlight(code, Prism.languages.jsx),
|
||||
}}
|
||||
/>
|
||||
</pre>
|
||||
);
|
||||
</pre>;
|
||||
|
||||
export default CodeBlock;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import React from 'react';
|
||||
|
||||
const Footer = () => (
|
||||
const Footer = () =>
|
||||
<div className="footer">
|
||||
<div className="inner-footer">
|
||||
|
||||
<section className="copyright">
|
||||
<a href="https://github.com/react-community/react-navigation">
|
||||
React Navigation
|
||||
@@ -13,9 +12,7 @@ const Footer = () => (
|
||||
Distributed under BSD License
|
||||
</a>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
</div>;
|
||||
|
||||
export default Footer;
|
||||
|
||||
@@ -6,14 +6,13 @@ import CodeBlock from './CodeBlock';
|
||||
|
||||
import Link from './Link';
|
||||
|
||||
const GettingStartedButton = () => (
|
||||
const GettingStartedButton = () =>
|
||||
<div className="cta-row">
|
||||
<Link className="cta" to="GettingStarted">
|
||||
<span className="label">Get Started</span>
|
||||
<span className="icon pt-icon-arrow-right" />
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
</div>;
|
||||
|
||||
const ExampleCodeBrowser = (config, ExampleFiles) => {
|
||||
const fileNames = Object.keys(ExampleFiles);
|
||||
@@ -164,7 +163,6 @@ class HomePage extends Component {
|
||||
<div className="home-container">
|
||||
<div className="hero-bg" />
|
||||
<div className="home-body">
|
||||
|
||||
<div className="hero">
|
||||
<h1>Navigation for React Native</h1>
|
||||
<div className="video">
|
||||
@@ -183,7 +181,8 @@ class HomePage extends Component {
|
||||
<div className="section-inner">
|
||||
<h1>Easy-to-Use Navigators</h1>
|
||||
<h3>
|
||||
Start quickly with built-in navigators that deliver a seamless out-of-the box experience.
|
||||
Start quickly with built-in navigators that deliver a seamless
|
||||
out-of-the box experience.
|
||||
</h3>
|
||||
|
||||
<StackExampleBrowser />
|
||||
@@ -194,7 +193,8 @@ class HomePage extends Component {
|
||||
<div className="section-inner">
|
||||
<h1>Components built for iOS and Android</h1>
|
||||
<h3>
|
||||
Navigation views that deliver 60fps animations, and utilize native components to deliver a great look and feel.
|
||||
Navigation views that deliver 60fps animations, and utilize
|
||||
native components to deliver a great look and feel.
|
||||
</h3>
|
||||
|
||||
<TabExampleBrowser alt />
|
||||
@@ -205,14 +205,15 @@ class HomePage extends Component {
|
||||
<div className="section-inner">
|
||||
<h1>Routers built for the future</h1>
|
||||
<h3>
|
||||
Routers define the relationship between URIs, actions, and navigation state. Share navigation logic between mobile apps, web apps, and server rendering.
|
||||
Routers define the relationship between URIs, actions, and
|
||||
navigation state. Share navigation logic between mobile apps,
|
||||
web apps, and server rendering.
|
||||
</h3>
|
||||
<GettingStartedButton />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
|
||||
</div>
|
||||
<div className="hero-screen" />
|
||||
</div>
|
||||
|
||||
16
packages/react-navigation/website/src/MDPage.js
vendored
16
packages/react-navigation/website/src/MDPage.js
vendored
@@ -33,7 +33,7 @@ const getHeadingForLevel = level => {
|
||||
}
|
||||
};
|
||||
|
||||
const MDPage = ({ navigation, docPath }) => (
|
||||
const MDPage = ({ navigation, docPath }) =>
|
||||
<Markdown
|
||||
source={DocsMD[docPath]}
|
||||
className="md-section"
|
||||
@@ -68,7 +68,10 @@ const MDPage = ({ navigation, docPath }) => (
|
||||
const className = `md-header ${linkHeader}`;
|
||||
return (
|
||||
<Header id={id} className={className}>
|
||||
{children} <a href={`#${id}`} title={children}>#</a>
|
||||
{children}{' '}
|
||||
<a href={`#${id}`} title={children}>
|
||||
#
|
||||
</a>
|
||||
</Header>
|
||||
);
|
||||
},
|
||||
@@ -76,10 +79,13 @@ const MDPage = ({ navigation, docPath }) => (
|
||||
if (href.indexOf('PhoneGraphic:') === 0) {
|
||||
const graphicName = href.split('PhoneGraphic:')[1];
|
||||
}
|
||||
return <Link href={href}>{children}</Link>;
|
||||
return (
|
||||
<Link href={href}>
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
/>;
|
||||
|
||||
export default MDPage;
|
||||
|
||||
@@ -31,9 +31,9 @@ class PageWithSidebar extends Component {
|
||||
prevAction = NavigationActions.navigate({
|
||||
routeName: state.routes[prev].routeName,
|
||||
action: NavigationActions.navigate({
|
||||
routeName: state.routes[prev].routes[
|
||||
state.routes[prev].routes.length - 1
|
||||
].routeName,
|
||||
routeName:
|
||||
state.routes[prev].routes[state.routes[prev].routes.length - 1]
|
||||
.routeName,
|
||||
}),
|
||||
});
|
||||
}
|
||||
@@ -61,7 +61,6 @@ class PageWithSidebar extends Component {
|
||||
return (
|
||||
<div className="page-body">
|
||||
<div className="inner-page-body">
|
||||
|
||||
<div className="left-sidebar">
|
||||
<ul className="pt-menu pt-elevation-1 navmenu">
|
||||
{state.routes &&
|
||||
@@ -81,12 +80,14 @@ class PageWithSidebar extends Component {
|
||||
to={route.routeName}
|
||||
className={
|
||||
'pt-menu-header ' +
|
||||
options.icon +
|
||||
' ' +
|
||||
(isActive ? 'active' : '')
|
||||
options.icon +
|
||||
' ' +
|
||||
(isActive ? 'active' : '')
|
||||
}
|
||||
>
|
||||
<h6>{options.linkName}</h6>
|
||||
<h6>
|
||||
{options.linkName}
|
||||
</h6>
|
||||
</LinkableLi>
|
||||
<div>
|
||||
{route.routes &&
|
||||
@@ -110,7 +111,9 @@ class PageWithSidebar extends Component {
|
||||
return (
|
||||
<Link
|
||||
to={childRoute.routeName}
|
||||
className={`pt-menu-item page ${isChildActive ? 'active' : ''}`}
|
||||
className={`pt-menu-item page ${isChildActive
|
||||
? 'active'
|
||||
: ''}`}
|
||||
key={childI}
|
||||
>
|
||||
{linkName}
|
||||
@@ -134,13 +137,15 @@ class PageWithSidebar extends Component {
|
||||
>
|
||||
{' '}Edit on GitHub
|
||||
</Link>}
|
||||
{prevAction && <Link to={prevAction}>Previous: {prevName}</Link>}
|
||||
{prevAction &&
|
||||
<Link to={prevAction}>
|
||||
Previous: {prevName}
|
||||
</Link>}
|
||||
{nextAction &&
|
||||
<Link to={nextAction} className="nextLink">
|
||||
Next: {nextName}
|
||||
</Link>}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user