Skip to content

Instantly share code, notes, and snippets.

@wallabyway
Last active October 25, 2017 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallabyway/6203e754c41de268dadd41684f65bb30 to your computer and use it in GitHub Desktop.
Save wallabyway/6203e754c41de268dadd41684f65bb30 to your computer and use it in GitHub Desktop.
import React from 'react';
import { StackNavigator, NavigationActions } from 'react-navigation';
import { FlatList, View, Text, TouchableOpacity } from 'react-native';
import {styles} from "./styles";
let mTabNav;
class FileListNav extends React.Component {
constructor(props) {
super(props);
this.state = {
list: [{id:0, name:"Project A"}
,{id:1, name:"Folder A"}
,{id:2, name:"Project B"}
,{id:3, name:"My 3D File", type:"versions"}
],
}
}
static navigationOptions = ({ navigation }) => ({
title: `${navigation.state.params.headerTitle}`,
});
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<FlatList
data={this.state.list}
keyExtractor={item => item.id}
onRefresh={this.handleRefresh}
refreshing={this.state.refreshing}
renderItem={ ({item}) =>
<TouchableOpacity style={styles.listitem}
onPress={ () => {
if (item.type == 'versions')
mTabNav.navigate('ViewerTab', {urn: item.id, refreshing:true})
else {
navigate('Links', {headerTitle:item.name, selectedItem:item, refreshing:true} );
}
}}>
<Text>{item.name}</Text>
</TouchableOpacity>
}
/>
</View>
);
}
}
const StackNav = StackNavigator({
Links: {
screen: FileListNav,
navigationOptions: {
headerBackTitle: null
},
}
}, {
initialRouteParams: {
headerTitle: 'Hubs',
type: 'hubs',
refreshing: false
}
});
export default class FileList extends React.Component {
render() {
mTabNav = this.props.navigation;
return <StackNav / >
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment