1.7.9 • Published 7 years ago

react-native-thrux-router v1.7.9

Weekly downloads
2
License
MIT
Repository
github
Last release
7 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

7 years ago

1.7.8

7 years ago

1.7.7

7 years ago

1.7.6

7 years ago

1.7.5

7 years ago

1.7.4

7 years ago

1.7.3

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.6

7 years ago

1.6.5

7 years ago

1.6.4

7 years ago

1.6.3

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.8

7 years ago

1.4.7

7 years ago

1.4.6

7 years ago

1.4.5

7 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago