Skip to content

Commit

Permalink
Merge branch 'master' into dc/issues/3236-3218-3206-3197-3188-refresh…
Browse files Browse the repository at this point in the history
…-not-working-as-expected

* master:
  fixes Actions.reset when getParent returns null (#3245)
  reset error prop for all actions
  improve ts typings
  README and ISSUE_TEMPLATE updated to reflect decision about 4.0.0-beta.x version (#3242)
  Add support for deprecated Tabs component (#3214)
  • Loading branch information
daviscabral committed Sep 6, 2018
2 parents 33489e3 + ad236fe commit e57e509
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 144 deletions.
8 changes: 7 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
### Version
Tell us which versions you are using:
<!--
v3 and v4.0.0-beta.x are not supported
- react-native-router-flux v4.?.? (v3 is not supported)
You can use `npm ls [package]` or `yarn info [package]` to be sure about the versions that were installed (in case you are not locked to a specific version).
-->
- react-native-router-flux v4.?.?
- react v16.?.?
- react-native v0.?.?

Expand Down
2 changes: 1 addition & 1 deletion Example/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const Example = () => (
<Overlay key="overlay">
<Modal key="modal" hideNavBar transitionConfig={() => ({ screenInterpolator: CardStackStyleInterpolator.forFadeFromBottomAndroid })}>
<Lightbox key="lightbox">
<Stack hideNavBar key="root" titleStyle={{ alignSelf: 'center' }}>
<Stack key="root" titleStyle={{ alignSelf: 'center' }}>
<Scene key="echo" back clone component={EchoView} getTitle={({ navigation }) => navigation.state.key} />
<Scene key="launch" component={Launch} title="Launch" initial type={ActionConst.RESET} />

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

[Follow author @PAksonov](https://twitter.com/PAksonov)

#### NOTE: v4 based on [React Navigation v2.x](https://reactnavigation.org/). See [this branch](https://github.com/aksonov/react-native-router-flux/tree/v3) and [docs](https://github.com/aksonov/react-native-router-flux/blob/master/README3.md) for v3 based on deprecated React Native Experimental Navigation API. It is not supported and may not work with latest React Native versions.
### IMPORTANT NOTES

#### v4 is based on [React Navigation v2.x](https://reactnavigation.org/). See [this branch](https://github.com/aksonov/react-native-router-flux/tree/v3) and [docs](https://github.com/aksonov/react-native-router-flux/blob/master/README3.md) for v3 based on deprecated React Native Experimental Navigation API. It is not supported and may not work with latest React Native versions.

#### v4.0.0-beta.x is based on [React Navigation v1.5.x](https://reactnavigation.org/). It is also not supported and may not work with the latest React Native versions.

___

Expand Down
23 changes: 23 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ All properties of type `React.Component` will receive the same properties availa
## Tabs (`<Tabs>` or `<Scene tabs>`)
Can use all `props` listed above in `<Scene>` as `<Tabs>` is syntatic sugar for `<Scene tabs={true}>`.

| Property | Type | Default | Description |
|-----------------|----------|----------|--------------------------------------------|
| `wrap`     | `boolean` | `true` | Wrap each scene with own navbar automatically (if it is not another container). |
| `activeBackgroundColor` | `string` | | Specifies the active background color for the tab in focus |
| `activeTintColor`     | `string` | | Specifies the active tint color for tabbar icons |
| `inactiveBackgroundColor` | `string` | | Specifies the inactive background color for the tabs not in focus |
| `inactiveTintColor`     | `string` | | Specifies the inactive tint color for tabbar icons |
| `labelStyle` | `object` | | Overrides the styles for the tab label |
| `lazy`     | `boolean` | `false` | Won't render/mount the tab scene until the tab is active |
| `tabBarComponent` | `React.Component` | | React component to render custom tab bar |
| `tabBarPosition`     | `string` | | Specifies tabbar position. Defaults to `bottom` on iOS and `top` on Android. |
| `tabBarStyle` | `object` | | Override the tabbar styles |
| `tabStyle` | `object` | | Override the style for an individual tab of the tabbar |
| `showLabel`     | `boolean` | `true` | Boolean to show or not the tabbar icons labels |
| `tabBarOnPress`     | `function` | | Custom tab bar icon press. |
| `backToInitial`     | `boolean` | `false` | Back to initial screen on focused tab if tab icon was tapped. |
| `upperCaseLabel`     | `boolean` | `true` | Whether to make label uppercase, default is true. |
| `indicatorStyle`     | `object` | | Override the style for active tab indicator. |


## LegacyTabs (`<LegacyTabs>` or `<Scene tabs={true} legacy={true}>`)
Can use all `props` listed above in `<Scene>` as `<LegacyTabs>` is syntatic sugar for `<Scene tabs={true} legacy={true}>`.

| Property | Type | Default | Description |
|-----------------|----------|----------|--------------------------------------------|
| `wrap`     | `boolean` | `true` | Wrap each scene with own navbar automatically (if it is not another container). |
Expand Down
218 changes: 113 additions & 105 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,162 +1,170 @@
/// <reference types="react"/>
/// <reference types="react-native"/>

import * as React from "react";
import { StyleProp, Image, ViewStyle, TextStyle, ImageStyle } from "react-native";
import * as React from 'react';
import { StyleProp, Image, ViewStyle, TextStyle, ImageStyle } from 'react-native';

export var Router: RouterStatic;
export type Router = RouterStatic;

// Router
interface RouterProps extends React.Props<Router> {
sceneStyle?: StyleProp<ViewStyle>;
backAndroidHandler?: Function;
wrapBy?: Function;
scenes?: any;
sceneStyle?: StyleProp<ViewStyle>;
backAndroidHandler?: Function;
wrapBy?: Function;
scenes?: any;
}
interface RouterStatic extends React.ComponentClass<RouterProps> { }
interface RouterStatic extends React.ComponentClass<RouterProps> {}

// Scene
export var Scene: SceneStatic;
export type Scene = SceneStatic;
interface SceneProps extends React.Props<Scene> {
key?: string;
component?: React.ComponentType<any>
back?: boolean;
init?: boolean;
clone?: boolean;
contentComponent?: React.ComponentType<any>
backButtonImage?: string;
backButtonTintColor?: string;
drawer?: boolean;
failure?: () => void;
headerBackTitle?: string;
headerMode?: HeaderModeType;
hideNavBar?: boolean;
hideTabBar?: boolean;
hideBackImage?: boolean;
initial?: boolean;
leftButtonImage?: Image;
modal?: boolean;
navigationBarTitleImage?: Image;
navigationBarTitleImageStyle?: StyleProp<ImageStyle>;
navTransparent?: boolean;
on?: (props: any) => void;
onEnter?: (props: any) => void;
onExit?: (props: any) => void;
onLeft?: (props: any) => void;
onRight?: (props: any) => void;
renderTitle?: React.ComponentType<any>
renderLeftButton?: React.ComponentType<any>
renderRightButton?: React.ComponentType<any>
renderBackButton?: React.ComponentType<any>
rightButtonImage?: Image;
rightButtonTextStyle?: StyleProp<TextStyle>;
success?: () => void;
tabs?: boolean;
title?: string;
titleStyle?: StyleProp<TextStyle>;
type?: ActionConstShort;
[name: string]: any; // These are passed through to the scenes
key?: string;
component?: React.ComponentType<any>;
back?: boolean;
init?: boolean;
clone?: boolean;
contentComponent?: React.ComponentType<any>;
backButtonImage?: string;
backButtonTintColor?: string;
drawer?: boolean;
failure?: (() => void) | string;
headerBackTitle?: string;
headerMode?: HeaderModeType;
hideNavBar?: boolean;
hideTabBar?: boolean;
hideBackImage?: boolean;
initial?: boolean;
leftButtonImage?: Image;
modal?: boolean;
navigationBarTitleImage?: Image;
navigationBarTitleImageStyle?: StyleProp<ImageStyle>;
navTransparent?: boolean;
on?: (props: any) => void;
onEnter?: (props: any) => void;
onExit?: (props: any) => void;
onLeft?: (props: any) => void;
onRight?: (props: any) => void;
renderTitle?: React.ComponentType<any>;
renderLeftButton?: React.ComponentType<any>;
renderRightButton?: React.ComponentType<any>;
renderBackButton?: React.ComponentType<any>;
rightButtonImage?: Image;
rightButtonTextStyle?: StyleProp<TextStyle>;
success?: (() => void) | string;
tabs?: boolean;
title?: string;
titleStyle?: StyleProp<TextStyle>;
type?: ActionConstShort;
[name: string]: any; // These are passed through to the scenes
}
interface TabSceneProps extends React.Props<Scene> {
icon?: React.ComponentType<any>
tabBarLabel?: string;
icon?: React.ComponentType<any>;
tabBarLabel?: string;
}
interface SceneStatic extends React.ComponentClass<SceneProps & TabsProps & TabSceneProps & DrawerProps & ModalProps> { }
export type HeaderModeType = "float" | "screen" | "none";
interface SceneStatic extends React.ComponentClass<SceneProps & TabsProps & TabSceneProps & DrawerProps & ModalProps> {}
export type HeaderModeType = 'float' | 'screen' | 'none';

// Tabs
export var Tabs: TabsStatic;
export type Tabs = TabsStatic;
interface TabsProps extends React.Props<Tabs> {
wrap?: boolean;
activeBackgroundColor?: string;
activeTintColor?: string;
inactiveBackgroundColor?: string;
inactiveTintColor?: string;
labelStyle?: StyleProp<TextStyle>;
lazy?: boolean;
tabBarComponent?: React.ComponentType<any>
tabBarPosition?: TabBarPositionType;
tabBarStyle?: StyleProp<ViewStyle>;
tabStyle?: StyleProp<ViewStyle>;
showLabel?: boolean;
swipeEnabled?: boolean;
tabBarOnPress?: Function;
backToInitial?: boolean;
wrap?: boolean;
activeBackgroundColor?: string;
activeTintColor?: string;
inactiveBackgroundColor?: string;
inactiveTintColor?: string;
labelStyle?: StyleProp<TextStyle>;
lazy?: boolean;
hideTabBar?: boolean;
tabBarComponent?: React.ComponentType<any>;
tabBarPosition?: TabBarPositionType;
tabBarStyle?: StyleProp<ViewStyle>;
tabStyle?: StyleProp<ViewStyle>;
showLabel?: boolean;
swipeEnabled?: boolean;
tabBarOnPress?: Function;
backToInitial?: boolean;
}
interface TabsStatic extends React.ComponentClass<TabsProps> { }
export type TabBarPositionType = "top" | "bottom";
interface TabsStatic extends React.ComponentClass<TabsProps> {}
export type TabBarPositionType = 'top' | 'bottom';

// Drawer
export var Drawer: DrawerStatic;
export type Drawer = DrawerStatic;
interface DrawerProps extends React.Props<Drawer> {
drawerImage?: Image;
drawerIcon?: React.ComponentType<any>
drawerPosition?: DrawerPositionType;
drawerImage?: Image;
drawerIcon?: React.ComponentType<any>;
drawerPosition?: DrawerPositionType;
}
interface DrawerStatic extends React.ComponentClass<SceneProps & DrawerProps> { }
export type DrawerPositionType = "right" | "left";
interface DrawerStatic extends React.ComponentClass<SceneProps & DrawerProps> {}
export type DrawerPositionType = 'right' | 'left';

// Modal
export var Modal: ModalStatic;
export type Modal = ModalStatic;
interface ModalProps extends React.Props<Modal> { }
interface ModalStatic extends React.ComponentClass<SceneProps & ModalProps> { }
interface ModalProps extends React.Props<Modal> {}
interface ModalStatic extends React.ComponentClass<SceneProps & ModalProps> {}

// Overlay
export var Overlay: OverlayStatic;
export type Overlay = OverlayStatic;
interface OverlayProps extends React.Props<Overlay> { }
interface OverlayStatic extends React.ComponentClass<SceneProps & OverlayProps> { }
interface OverlayProps extends React.Props<Overlay> {}
interface OverlayStatic extends React.ComponentClass<SceneProps & OverlayProps> {}

// Lightbox
export var Lightbox : LightboxStatic;
export type Lightbox = LightboxStatic;
interface LightboxProps extends React.Props<Modal> { }
interface LightboxStatic extends React.ComponentClass<LightboxProps> { }
export var Lightbox: LightboxStatic;
export type Lightbox = LightboxStatic;
interface LightboxProps extends React.Props<Modal> {}
interface LightboxStatic extends React.ComponentClass<LightboxProps> {}

// Stack
export var Stack: StackStatic;
export type Stack = StackStatic;

interface StackProps extends React.Props<Stack> {
navigationBarStyle?: StyleProp<ViewStyle>;
icon?: any;
tintColor?: string;
hideNavBar?: boolean;
title?: string;
titleStyle?: StyleProp<TextStyle>;
}
interface StackStatic extends React.ComponentClass<StackProps> {
navigationBarStyle?: StyleProp<ViewStyle>;
icon?: any;
tintColor?: string;
hideNavBar?: boolean;
title?: string;
titleStyle?: StyleProp<TextStyle>;
}
interface StackStatic extends React.ComponentClass<StackProps> {}

export var Actions: ActionsGenericStatic;
export type Actions = ActionsGenericStatic;
interface ActionsStatic {
currentScene: any;
jump: (sceneKey: string, props?: any) => void;
pop: () => void;
popAndPush: (sceneKey: string, props?: any) => void;
popTo: (sceneKey: string, props?: any) => void;
push: (sceneKey: string, props?: any) => void;
refresh: (props?: any) => void;
replace: (sceneKey: string, props?: any) => void;
reset: (sceneKey: string, props?: any) => void;
drawerOpen?: any;
drawerClose?: any;

currentScene: any;
jump: (sceneKey: string, props?: any) => void;
pop: () => void;
popAndPush: (sceneKey: string, props?: any) => void;
popTo: (sceneKey: string, props?: any) => void;
push: (sceneKey: string, props?: any) => void;
refresh: (props?: any) => void;
replace: (sceneKey: string, props?: any) => void;
reset: (sceneKey: string, props?: any) => void;
drawerOpen?: any;
drawerClose?: any;
}
interface ActionsGenericStatic extends ActionsStatic {
[key: string]: (props?: any) => void;
[key: string]: (props?: any) => void;
}

export type ActionConstShort = "jump" | "push" | "replace" | "pop" | "popTo" | "refresh" | "reset";
export type ActionConstShort = 'jump' | 'push' | 'replace' | 'pop' | 'popTo' | 'refresh' | 'reset';
export declare const ActionConst: ActionConst;
export type ActionConst = {
JUMP: string; PUSH: string; PUSH_OR_POP: string; REPLACE: string;
BACK: string; BACK_ACTION: string; POP_TO: string; REFRESH: string;
RESET: string; FOCUS: string; BLUR: string; ANDROID_BACK: string;
}
JUMP: string;
PUSH: string;
PUSH_OR_POP: string;
REPLACE: string;
BACK: string;
BACK_ACTION: string;
POP_TO: string;
REFRESH: string;
RESET: string;
FOCUS: string;
BLUR: string;
ANDROID_BACK: string;
};
9 changes: 9 additions & 0 deletions src/LegacyTabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) 2015-present, Pavel Aksonov
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*
*/
export default () => null;
Loading

0 comments on commit e57e509

Please sign in to comment.