Setup example app

This commit is contained in:
Satyajit Sahoo
2016-10-24 03:43:56 +05:30
parent 065e6f08ce
commit 9ddb159f7d
16 changed files with 249 additions and 119 deletions

View File

@@ -0,0 +1,52 @@
/* @flow */
import React, { Component } from 'react';
import {
View,
Text,
StyleSheet,
} from 'react-native';
import { Colors, TouchableRipple } from 'react-native-paper';
import RipplesExample from './RipplesExample';
export const examples = {
ripples: RipplesExample,
};
export default class ExampleList extends Component {
static route = {
navigationBar: {
title: 'Examples',
},
};
render() {
return (
<View style={styles.list}>
{Object.keys(examples).map(id => (
<TouchableRipple
key={id}
style={styles.item}
onPress={() => this.props.navigator.push(id)}
>
<Text style={styles.text}>{examples[id].title}</Text>
</TouchableRipple>
))}
</View>
);
}
}
const styles = StyleSheet.create({
item: {
padding: 16,
borderBottomColor: Colors.grey300,
borderBottomWidth: StyleSheet.hairlineWidth,
},
text: {
fontSize: 16,
fontWeight: 'bold',
},
});

View File

@@ -0,0 +1,12 @@
/* @flow */
import { Component } from 'react';
export default class RipplesExample extends Component {
static title = 'Ripples';
render() {
return null;
}
}

32
example/src/Router.js Normal file
View File

@@ -0,0 +1,32 @@
/* @flow */
import React from 'react';
import {
createRouter,
} from '@exponent/ex-navigation';
import ExampleList, { examples } from './ExampleList';
const routes = Object.keys(examples)
.map(id => ({ id, item: examples[id] }))
.reduce((acc, { id, item }) => {
const Comp = item;
const Screen = props => <Comp {...props} />;
Screen.route = {
navigationBar: {
title: Comp.title,
}
};
return {
...acc,
[id]: () => Screen,
};
}, {});
const Router = createRouter(() => ({
home: () => ExampleList,
...routes,
}));
export default Router;