1.7.9 • Published 8 years ago

react-native-thrux-router v1.7.9

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

React Native - Thrux Router

Travis build version downloads MIT License

Router using Thrux state manager.

TODO Docs, for now just an Example:

index.js

import Router from "react-native-thrux-router";
import React, {Component} from 'react';
import First from "./First";
import Second from "./Second";

const styleBarWhite = Platform.OS === 'android' ? {barStyle: "light-content", backgroundColor: 'rgba(0,0,0,.3)'} : {barStyle: "dark-content"};
const styleBarDark  = assign({barStyle: "light-content"}, Platform.OS === 'android' ? {backgroundColor: '#414141'} : {});

const routes = [
  {id: 'first', title: 'First Scene', component: First, next: 'second'},
  {id: 'second', title: 'Second Scene', component: Second, replace: true, statusBar: styleBarDark},
  {id: 'third', title: 'Third Scene', component: Second, next: 'forth'},
  {id: 'forth', title: 'Forth Scene', component: First}
];

export default class NavigationExample extends Component {
  render = () => (<Router routes={routes} hideNav statusBar={styleBarWhite}/>)
}

First.js

import React, {Component} from 'react';
import {Text, View, TouchableOpacity} from 'react-native';
import {goNextRoute, goBack} from "react-native-thrux-router";
export default class First extends Component {

  render() {
    return (
        <View style={{flex:1, backgroundColor:'#AAEE00', justifyContent:'center'}}>
          <TouchableOpacity onPress={goNextRoute}>
            <Text>Navigate to second screen</Text>
          </TouchableOpacity>
          <TouchableOpacity onPress={goBack}>
            <Text>Back</Text>
          </TouchableOpacity>
        </View>
    );
  }
}

Second.js

import React, {Component} from 'react';
import {Text, View, TouchableOpacity} from 'react-native';
import {goRoute, goBack, openModal} from "react-native-thrux-router";
import ThirdModal from './ThirdModal';

export default class Second extends Component {
  render() {
    return (
        <View style={{flex:1, backgroundColor:'#EEAA00', justifyContent:'center'}}>
          <TouchableOpacity onPress={()=> goRoute('third')}>
            <Text> Second screen </Text>
          </TouchableOpacity>
          <TouchableOpacity onPress={()=> openModal({component:ThirdModal})}>
            <Text> Open Modal</Text>
          </TouchableOpacity>
          <TouchableOpacity onPress={goBack}>
            <Text> Back</Text>
          </TouchableOpacity>
        </View>
    );
  }
}

ThirdModal.js

import React, {Component} from 'react';
import {Text, View, TouchableOpacity} from 'react-native';
import {closeModal} from "react-native-thrux-router";

export default class ThirdModal extends Component {
  render() {
    return (
        <View style={{flex:1, backgroundColor:'#EEAA00', justifyContent:'center'}}>
          <Text> This is a Modal </Text>
          <TouchableOpacity onPress={closeModal}>
            <Text> Back</Text>
          </TouchableOpacity>
        </View>
    );
  }
}
1.7.9

8 years ago

1.7.8

8 years ago

1.7.7

8 years ago

1.7.6

8 years ago

1.7.5

8 years ago

1.7.4

8 years ago

1.7.3

8 years ago

1.7.2

8 years ago

1.7.1

8 years ago

1.7.0

8 years ago

1.6.6

8 years ago

1.6.5

8 years ago

1.6.4

8 years ago

1.6.3

8 years ago

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.1

8 years ago

1.5.0

8 years ago

1.4.8

8 years ago

1.4.7

8 years ago

1.4.6

8 years ago

1.4.5

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago