How to use the @react-navigation/core.createSwitchNavigator function in @react-navigation/core

To help you get started, we’ve selected a few @react-navigation/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keybase / client / shared / router-v2 / router.desktop.tsx View on Github external
)

const LoggedOutStackNavigator = createNavigator(
  AppView,
  StackRouter(
    {...Shim.shim(loggedOutRoutes)},
    {
      // @ts-ignore TODO add custom nav options somewhere
      defaultNavigationOptions: () => ({headerHideBorder: true}),
      initialRouteName: 'login',
    }
  ),
  {}
)

const RootStackNavigator = createSwitchNavigator(
  {
    loggedIn: LoggedInStackNavigator,
    loggedOut: LoggedOutStackNavigator,
  },
  {initialRouteName: 'loggedOut'}
)

type Subscriber = (data: {action: Object | null; lastState: Object | null; state: any; type: string}) => void

const createElectronApp = Component => {
  // Based on https://github.com/react-navigation/react-navigation-native/blob/master/src/createAppContainer.js
  class ElectronApp extends React.PureComponent<any, any> {
    private navState: any = null // always use this value and not whats in state since thats async
    private actionEventSubscribers = new Set<Subscriber>()
    private navigation: any
    private initialAction: any = null
github keybase / client / shared / router-v2 / router.desktop.js View on Github external
{}
)

const LoggedOutStackNavigator = createNavigator(
  AppView,
  StackRouter(
    {...Shim.shim(loggedOutRoutes)},
    {
      defaultNavigationOptions: p => ({headerHideBorder: true}),
      initialRouteName: 'login',
    }
  ),
  {}
)

const RootStackNavigator = createSwitchNavigator(
  {
    loggedIn: LoggedInStackNavigator,
    loggedOut: LoggedOutStackNavigator,
  },
  {initialRouteName: 'loggedOut'}
)

const createElectronApp = Component => {
  // Based on https://github.com/react-navigation/react-navigation-native/blob/master/src/createAppContainer.js
  class ElectronApp extends React.PureComponent<any, any> {
    _navState: any = null // always use this value and not whats in state since thats async
    _actionEventSubscribers = new Set()
    _navigation: any
    _initialAction = null

    constructor(props: any) {
github react-navigation / experimental-transitioner / example / App.js View on Github external
onPress={() => navigation.navigate(exampleName)}
        title={exampleName}
      />
    ))}
  </View>
);

const EXAMPLES = {
  Fade,
  Modal,
  Gesture,
  CardStack,
  SharedEl,
};

const AppNavigator = createSwitchNavigator({
  Examples,
  ...EXAMPLES,
});

const StatefulAppNavigator = createAppContainer(AppNavigator);

// const StatefulAppNavigator = createAppContainer(Fade);
// const StatefulAppNavigator = createAppContainer(Modal);
// const StatefulAppNavigator = createAppContainer(Gesture);
// const StatefulAppNavigator = createAppContainer(CardStack);
// const StatefulAppNavigator = createAppContainer(SharedEl);

const App = () => (
  <LayoutProvider style={{ flex: 1 }}>
    <StatefulAppNavigator />
  </LayoutProvider>
github keybase / client / shared / wallets / routes.tsx View on Github external
navigation={childNav}
            component={descriptor.getComponent()}
            screenProps={this.props.screenProps || noScreenProps}
          />
        </WalletsAndDetails>
      </Kb.Box2>
    )
  }
}

const WalletsSubNavigator = createNavigator(
  WalletsSubNav,
  StackRouter(Shim.shim(walletsSubRoutes), {initialRouteName: 'wallet'}),
  {}
)
const OnboardingOrWalletsNavigator = createSwitchNavigator(
  {
    onboarding: RoutedOnboarding,
    walletsubnav: WalletsSubNavigator,
  },
  {initialRouteName: 'onboarding'}
)

type OnboardingOrWalletsProps = NavigationViewProps<any> & {acceptedDisclaimer: boolean}

class _OnboardingOrWallets extends React.Component<OnboardingOrWalletsProps> {
  static router = OnboardingOrWalletsNavigator.router
  static navigationOptions = ({navigation}) => {
    return {
      header: undefined,
      headerExpandable: true,
      // index 0 means we're on the onboarding page, so hide the header
github keybase / client / shared / router-v2 / router.native.tsx View on Github external
initialRouteParams: undefined,
  }
)

const SimpleLoading = () => (
  <Kb.Box2
    direction="vertical"
    fullHeight={true}
    fullWidth={true}
    style={{backgroundColor: Styles.globalColors.white}}
  >
    <Loading allowFeedback={false} failed="" status="" onRetry={null} onFeedback={null} />
  </Kb.Box2>
)

const RootStackNavigator = createSwitchNavigator(
  {
    loading: {screen: SimpleLoading},
    loggedIn: LoggedInStackNavigator,
    loggedOut: LoggedOutStackNavigator,
  },
  {initialRouteName: 'loading'}
)

const AppContainer = createAppContainer(RootStackNavigator)

class RNApp extends React.PureComponent<Props> {
  private nav: any = null

  // TODO remove this eventually, just so we can handle the old style actions
  dispatchOldAction = (old: any) => {
    const nav = this.nav
github keybase / client / shared / router-v2 / router.native.tsx View on Github external
initialRouteParams: undefined,
  }
)

const SimpleLoading = () => (
  <Kb.Box2
    direction="vertical"
    fullHeight={true}
    fullWidth={true}
    style={{backgroundColor: Styles.globalColors.white}}
  >
    <Loading allowFeedback={false} failed="" status="" onRetry={null} onFeedback={null} />
  </Kb.Box2>
)

const RootStackNavigator = createSwitchNavigator(
  {
    loading: {screen: SimpleLoading},
    loggedIn: LoggedInStackNavigator,
    loggedOut: LoggedOutStackNavigator,
  },
  {initialRouteName: 'loading'}
)

const AppContainer = createAppContainer(RootStackNavigator)

class RNApp extends React.PureComponent<Props> {
  private nav: any = null

  // TODO remove this eventually, just so we can handle the old style actions
  dispatchOldAction = (old: any) => {
    const nav = this.nav
github react-navigation / react-navigation / src / navigators / createContainedSwitchNavigator.js View on Github external
const SwitchNavigator = (routeConfigs, config = {}) => {
  const navigator = createSwitchNavigator(routeConfigs, config);
  return createNavigationContainer(navigator);
};
github pavjacko / renative / src / renative / Navigation / index.web2.js View on Github external
const createNavigator = (screens, menu) => {
    Menu = menu;
    return createSwitchNavigator(screens);
};