diff --git a/Examples/FlatList.js b/Examples/FlatList.js index 027142e..84edce1 100644 --- a/Examples/FlatList.js +++ b/Examples/FlatList.js @@ -6,7 +6,7 @@ import { Image, TouchableOpacity, FlatList, - Dimensions, + Dimensions } from 'react-native'; import { Transition, FluidNavigator } from '../lib'; @@ -15,23 +15,26 @@ class ListScreen extends React.Component { constructor(props) { super(props); this.state = { - items: [], + items: [] }; } - componentWillMount() { + componentDidMount() { const items = []; const imageSize = 80; const numberOfImages = 40; const randMax = 100; for (let i = 0; i < numberOfImages; i++) { - let randomNumber = Math.floor((Math.random() * randMax) + 1); - const idExists = (e) => e.id === randomNumber; + let randomNumber = Math.floor(Math.random() * randMax + 1); + const idExists = e => e.id === randomNumber; while (items.findIndex(idExists) > -1) { - randomNumber = Math.floor((Math.random() * randMax) + 1); + randomNumber = Math.floor(Math.random() * randMax + 1); } - items.push({ url: `https://picsum.photos/${imageSize}/${imageSize}?image=${randomNumber}`, id: randomNumber }); + items.push({ + url: `https://picsum.photos/${imageSize}/${imageSize}?image=${randomNumber}`, + id: randomNumber + }); } this.setState({ ...this.state, items }); } @@ -51,7 +54,9 @@ class ListScreen extends React.Component { renderItem = ({ item, index }) => ( { this.props.navigation.navigate('details', { item, index }); }} + onPress={() => { + this.props.navigation.navigate('details', { item, index }); + }} > @@ -61,8 +66,7 @@ class ListScreen extends React.Component { {item.url} - - ) + ); } class DetailsScreen extends React.Component { @@ -81,7 +85,10 @@ class DetailsScreen extends React.Component { Image URI: {this.props.navigation.state.params.item.url} - this.props.navigation.goBack()}> + this.props.navigation.goBack()} + > Back @@ -93,7 +100,7 @@ class DetailsScreen extends React.Component { const styles = StyleSheet.create({ container: { - flex: 1, + flex: 1 }, row: { margin: 10, @@ -106,57 +113,58 @@ const styles = StyleSheet.create({ shadowOffset: { width: 0, height: 5 }, shadowOpacity: 0.4, flexDirection: 'row', - elevation: 3, + elevation: 3 }, textContainer: { flexDirection: 'column', marginLeft: 18, flex: 1, - justifyContent: 'center', + justifyContent: 'center' }, image: { width: 80, height: 80, - borderRadius: 40, + borderRadius: 40 }, caption: { fontWeight: 'bold', - fontSize: 14, + fontSize: 14 }, largeImage: { width: Dimensions.get('window').width, - height: Dimensions.get('window').width, + height: Dimensions.get('window').width }, bottomContainer: { backgroundColor: '#ECECEC', flex: 1, - padding: 20, + padding: 20 }, button: { padding: 12, backgroundColor: '#CECECE', justifyContent: 'center', - alignItems: 'center', - }, + alignItems: 'center' + } }); -const Navigator = FluidNavigator({ - list: { screen: ListScreen }, - details: { screen: DetailsScreen }, -}, { - defaultNavigationOptions: { - gesturesEnabled: true, +const Navigator = FluidNavigator( + { + list: { screen: ListScreen }, + details: { screen: DetailsScreen } }, -}); + { + defaultNavigationOptions: { + gesturesEnabled: true + } + } +); class FlatListScreen extends React.Component { static router = Navigator.router; render() { const { navigation } = this.props; - return ( - - ); + return ; } } diff --git a/Examples/ImageTransition.js b/Examples/ImageTransition.js index 1a52866..f245dd1 100644 --- a/Examples/ImageTransition.js +++ b/Examples/ImageTransition.js @@ -1,71 +1,83 @@ import React, { Component } from 'react'; -import { View, Text, Dimensions, Button, TouchableOpacity, FlatList, Image, StyleSheet } from 'react-native'; +import { + View, + Text, + Dimensions, + Button, + TouchableOpacity, + FlatList, + Image, + StyleSheet +} from 'react-native'; import chunk from 'lodash.chunk'; import { FluidNavigator, Transition } from '../lib'; const styles = StyleSheet.create({ container: { - flex: 1, + flex: 1 }, detailsImage: { width: Dimensions.get('window').width, - height: Dimensions.get('window').width * 0.5, + height: Dimensions.get('window').width * 0.5 }, detailsView: { padding: 10, backgroundColor: '#ECECEC', - flex: 1, + flex: 1 }, buttonContainer: { flex: 1, - justifyContent: 'flex-end', + justifyContent: 'flex-end' }, text: { - paddingBottom: 40, + paddingBottom: 40 }, row: { - flexDirection: 'row', + flexDirection: 'row' }, cell: { - margin: 2, + margin: 2 }, header: { height: 65, justifyContent: 'center', alignItems: 'center', - backgroundColor: '#0000FA', + backgroundColor: '#0000FA' }, headerText: { fontWeight: 'bold', fontSize: 18, - color: '#FFF', + color: '#FFF' }, imageContainer: { - flexDirection: 'row', - }, + flexDirection: 'row' + } }); class ImageListScreen extends React.Component { constructor(props) { super(props); this.state = { - items: [], + items: [] }; } - componentWillMount() { + componentDidMount() { const items = []; const size = Dimensions.get('window').width; const max = 39; const randMax = 100; for (let i = 0; i < max; i++) { - let randomNumber = Math.floor((Math.random() * randMax) + 1); - const idExists = (e) => e.id === randomNumber; + let randomNumber = Math.floor(Math.random() * randMax + 1); + const idExists = e => e.id === randomNumber; while (items.findIndex(idExists) > -1) { - randomNumber = Math.floor((Math.random() * randMax) + 1); + randomNumber = Math.floor(Math.random() * randMax + 1); } - items.push({ url: `https://picsum.photos/${size}/${size}?image=${randomNumber}`, id: randomNumber }); + items.push({ + url: `https://picsum.photos/${size}/${size}?image=${randomNumber}`, + id: randomNumber + }); } this.setState({ ...this.state, items }); } @@ -75,9 +87,12 @@ class ImageListScreen extends React.Component { this.props.navigation.navigate('imageDetails', { url: image.url })} + imageSelected={image => + this.props.navigation.navigate('imageDetails', { url: image.url }) + } /> - ); + + ); } } @@ -101,7 +116,7 @@ class ImageDetailsScreen extends React.Component { {uri} -