Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced React Motion with React Move #126

Merged
merged 31 commits into from
Apr 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9e354a8
Switched from react motion to react move
grahammendick Apr 23, 2017
20ae613
Tweaked format
grahammendick Apr 23, 2017
bbe3699
Prevented re-rendering crumb scenes
grahammendick Apr 23, 2017
358aae8
Cleared out scenes when animation's over
grahammendick Apr 23, 2017
000f4e6
Tweaked format
grahammendick Apr 23, 2017
547a8ba
Renamed variable
grahammendick Apr 23, 2017
77a0f42
Added basic typings for react move
grahammendick Apr 23, 2017
f53f177
Switched Motion for Animate component
grahammendick Apr 25, 2017
0ba1da7
Without spring can return data directly
grahammendick Apr 25, 2017
5a30499
Replaced with official typings from react move
grahammendick Apr 25, 2017
7c98fab
Used color interpolation from react move
grahammendick Apr 26, 2017
5e5baae
Avoided over rendering with url check
grahammendick Apr 26, 2017
c04574c
Removed spring now react motion is gone
grahammendick Apr 26, 2017
d566ae2
Removed react motion typings
grahammendick Apr 26, 2017
159fd10
Removed spring from twitter motion
grahammendick Apr 28, 2017
9129b54
Started without animation
grahammendick Apr 28, 2017
a4f2b09
Prevented double clicks and re-rendering
grahammendick Apr 28, 2017
82ff9e0
Revert "Prevented double clicks and re-rendering"
grahammendick Apr 29, 2017
d576e8a
Prevented double clicks and re-rendering
grahammendick Apr 29, 2017
51cd264
Removed spring from gesture motion
grahammendick Apr 29, 2017
6da3145
Prevented double taps and re-rendering
grahammendick Apr 29, 2017
b06a598
Lowered duration during move
grahammendick Apr 29, 2017
babf04b
Initialised first scene with mounted style
grahammendick Apr 29, 2017
791d539
Moved url out of state onto instance
grahammendick Apr 29, 2017
2e0598d
Returned component
grahammendick Apr 29, 2017
3323cc5
Removed unused parameter
grahammendick Apr 29, 2017
592ed92
Removed unused parameter
grahammendick Apr 29, 2017
4980fd3
Renamed parameters
grahammendick Apr 29, 2017
9302dc2
Changed onBack to match onNavigate syntax
grahammendick Apr 29, 2017
c6742cd
Added duration and easing to props
grahammendick Apr 30, 2017
4336d11
Changed dependency from motion to move
grahammendick Apr 30, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions NavigationReactNative/sample/gesture/Gesture.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import {Dimensions, View} from 'react-native';
import {NavigationMotion, spring} from 'navigation-react-native';
import {NavigationMotion} from 'navigation-react-native';

export default ({stateNavigator}) => (
<NavigationMotion
startStateKey="scene"
unmountedStyle={{translate: spring(1)}}
mountedStyle={(state, {translate = 0}) => ({translate: spring(translate)})}
crumbStyle={{translate: spring(0)}}
unmountedStyle={{translate: 1}}
mountedStyle={(state, {translate = 0}) => ({translate})}
crumbStyle={{translate: 0}}
style={{flex: 1}}
stateNavigator={stateNavigator}>
{({translate}, scene, url) => (
Expand Down
13 changes: 9 additions & 4 deletions NavigationReactNative/sample/gesture/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import {NavigationBackAndroid, spring} from 'navigation-react-native';
export default class Next extends React.Component {
constructor(props) {
super(props);
const {url, crumbs} = props.stateNavigator.stateContext;
this.url = url;
this.crumbs = crumbs;
this.panResponder = PanResponder.create({
onMoveShouldSetPanResponder: this.handleMoveShouldSetPanResponder.bind(this),
onPanResponderMove: this.handlePanResponderMove.bind(this),
onPanResponderRelease: this.handlePanResponderEnd.bind(this),
onPanResponderTerminate: this.handlePanResponderEnd.bind(this),
});
}
shouldComponentUpdate(props) {
return this.url === props.stateNavigator.stateContext.url;
}
handleMoveShouldSetPanResponder(e, gestureState) {
var {stateNavigator} = this.props;
return stateNavigator.canNavigateBack(1);
Expand All @@ -29,11 +35,10 @@ export default class Next extends React.Component {
}
render() {
const {stateNavigator} = this.props;
const {url, crumbs} = stateNavigator.stateContext;
return (
<View
style={[
{backgroundColor: crumbs.length % 2 === 0 ? '#036' : '#f36207'},
{backgroundColor: this.crumbs.length % 2 === 0 ? '#036' : '#f36207'},
styles.scene
]}
{...this.panResponder.panHandlers}
Expand All @@ -42,10 +47,10 @@ export default class Next extends React.Component {
<TouchableHighlight
underlayColor="transparent"
onPress={() => {
if (url === stateNavigator.stateContext.url)
if (this.url === stateNavigator.stateContext.url)
stateNavigator.navigate('scene');
}}>
<Text style={styles.text}>Scene {crumbs.length}</Text>
<Text style={styles.text}>Scene {this.crumbs.length}</Text>
</TouchableHighlight>
</View>
)
Expand Down
2 changes: 1 addition & 1 deletion NavigationReactNative/sample/medley/Medley.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default ({stateNavigator}) => (
crumbStyle={state => state.crumbStyle()}
style={{flex: 1}}
stateNavigator={stateNavigator}>
{({translateX = 0, translateY = 0}, scene, url) => (
{({translateX = 0, translateY = 0}, scene, url) => (
<View
key={url}
style={{
Expand Down
65 changes: 38 additions & 27 deletions NavigationReactNative/sample/medley/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,44 @@ const nextDirection = {
West: 'North',
};

export default ({direction, color, stateNavigator}) => {
const {url, crumbs} = stateNavigator.stateContext;
return (
<View style={[
styles.scene,
{backgroundColor: color}
]}>
<NavigationBackAndroid stateNavigator={stateNavigator} />
<TouchableHighlight
underlayColor={color}
onPress={() => {
if (url === stateNavigator.stateContext.url)
stateNavigator.navigate(`scene${nextDirection[direction]}`);
}}>
<Text style={styles.text}>{direction} {crumbs.length}</Text>
</TouchableHighlight>
{stateNavigator.canNavigateBack(1) && <TouchableHighlight
underlayColor={color}
onPress={() => {
if (url === stateNavigator.stateContext.url)
stateNavigator.navigateBack(1);
}}>
<Text style={styles.text}>Back</Text>
</TouchableHighlight>}
</View>
)
};
export default class Scene extends React.Component {
constructor(props, context) {
super(props, context);
const {url, crumbs} = props.stateNavigator.stateContext;
this.url = url;
this.crumbs = crumbs;
}
shouldComponentUpdate(props) {
return this.url === props.stateNavigator.stateContext.url;
}
render() {
const {direction, color, stateNavigator} = this.props;
return (
<View style={[
styles.scene,
{backgroundColor: color}
]}>
<NavigationBackAndroid stateNavigator={stateNavigator} />
<TouchableHighlight
underlayColor={color}
onPress={() => {
if (this.url === stateNavigator.stateContext.url)
stateNavigator.navigate(`scene${nextDirection[direction]}`);
}}>
<Text style={styles.text}>{direction} {this.crumbs.length}</Text>
</TouchableHighlight>
{stateNavigator.canNavigateBack(1) && <TouchableHighlight
underlayColor={color}
onPress={() => {
if (this.url === stateNavigator.stateContext.url)
stateNavigator.navigateBack(1);
}}>
<Text style={styles.text}>Back</Text>
</TouchableHighlight>}
</View>
)
}
}

const styles = StyleSheet.create({
scene: {
Expand Down
25 changes: 12 additions & 13 deletions NavigationReactNative/sample/medley/createStateNavigator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {StateNavigator} from 'navigation';
import Scene from './Scene';
import {spring} from 'navigation-react-native';

export default () => {
const stateNavigator = new StateNavigator([
Expand All @@ -17,20 +16,20 @@ export default () => {
sceneSouth.renderScene = (data, moveScene) => <Scene direction="South" color="green" stateNavigator={stateNavigator}/>;
sceneWest.renderScene = (data, moveScene) => <Scene direction="West" color="black" stateNavigator={stateNavigator}/>;

sceneNorth.unmountedStyle = () => ({translateY: spring(-1, {stiffness: 90})});
sceneEast.unmountedStyle = () => ({translateX: spring(1, {stiffness: 90})});
sceneSouth.unmountedStyle = () => ({translateY: spring(1, {stiffness: 90})});
sceneWest.unmountedStyle = () => ({translateX: spring(-1, {stiffness: 90})});
sceneNorth.unmountedStyle = () => ({translateY: -1});
sceneEast.unmountedStyle = () => ({translateX: 1});
sceneSouth.unmountedStyle = () => ({translateY: 1});
sceneWest.unmountedStyle = () => ({translateX: -1});

sceneNorth.mountedStyle = () => ({translateY: spring(0, {stiffness: 90})});
sceneEast.mountedStyle = () => ({translateX: spring(0, {stiffness: 90})});
sceneSouth.mountedStyle = () => ({translateY: spring(0, {stiffness: 90})});
sceneWest.mountedStyle = () => ({translateX: spring(0, {stiffness: 90})});
sceneNorth.mountedStyle = () => ({translateY: 0});
sceneEast.mountedStyle = () => ({translateX: 0});
sceneSouth.mountedStyle = () => ({translateY: 0});
sceneWest.mountedStyle = () => ({translateX: 0});

sceneNorth.crumbStyle = () => ({translateY: spring(-.3, {stiffness: 90})});
sceneEast.crumbStyle = () => ({translateX: spring(.3, {stiffness: 90})});
sceneSouth.crumbStyle = () => ({translateY: spring(.3, {stiffness: 90})});
sceneWest.crumbStyle = () => ({translateX: spring(-.3, {stiffness: 90})});
sceneNorth.crumbStyle = () => ({translateY: -.3});
sceneEast.crumbStyle = () => ({translateX: .3});
sceneSouth.crumbStyle = () => ({translateY: .3});
sceneWest.crumbStyle = () => ({translateX: -.3});

return stateNavigator;
}
77 changes: 43 additions & 34 deletions NavigationReactNative/sample/twitter/Follows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,51 @@ import React from 'react';
import {StyleSheet, Text, Image, ListView, View, TouchableHighlight} from 'react-native';
import Svg, {Path} from 'react-native-svg';

export default ({follows, stateNavigator}) => {
const {url} = stateNavigator.stateContext;
const dataSource = new ListView
.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
.cloneWithRows(follows);
return (
<ListView
dataSource={dataSource}
renderRow={({id, name, logo}) => (
<TouchableHighlight
underlayColor="white"
onPress={() => {
if (url === stateNavigator.stateContext.url)
stateNavigator.navigate('timeline', {id});
}}>
<View style={styles.follow}>
<Svg
style={styles.icon}
height="28"
width="28"
viewBox="0 0 46 72">
<Path
d="M29.986 9c-14.888 0-27 12.112-27 27s12.112 27 27 27 27-12.112 27-27-12.112-27-27-27zM42.09 47H17.882c-.757 0-.917-.93-.917-2.325 0-.975.325-2.052 1.393-2.616l.033-.022c.706-.429 4.002-1.314 6.945-2.012 1.645 1.861 3.465 2.325 4.651 2.325s3.006-.464 4.65-2.325c2.942.698 6.239 1.583 6.945 2.012.011.007.023.014.033.022 1.068.564 1.393 1.641 1.393 2.616C43.007 46.07 42.847 47 42.09 47zM29.986 23c6.147 0 6.284 6.715 6.284 6.715s.993.044.772 1.86c-.208 1.716-1.307 3.001-2.028 3.001 0 0-1.924 5.003-5.028 5.003s-5.028-5.003-5.028-5.003c-.721 0-1.82-1.285-2.028-3.001-.221-1.815.772-1.86.772-1.86s.347-5.331 3.244-5.677c1.025-.924 2.256-1.038 3.04-1.038z"
fill="rgb(29, 161, 242)"/>
</Svg>
<View>
<Image style={styles.logo} source={logo} />
<View style={styles.details}>
<Text style={styles.name}>{name}</Text>
<Text>followed you.</Text>
export default class Follows extends React.Component {
constructor(props, context) {
super(props, context);
this.url = props.stateNavigator.stateContext.url;
}
shouldComponentUpdate(props) {
return this.url === props.stateNavigator.stateContext.url;
}
render() {
const {follows, stateNavigator} = this.props;
const dataSource = new ListView
.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
.cloneWithRows(follows);
return (
<ListView
dataSource={dataSource}
renderRow={({id, name, logo}) => (
<TouchableHighlight
underlayColor="white"
onPress={() => {
if (this.url === stateNavigator.stateContext.url)
stateNavigator.navigate('timeline', {id});
}}>
<View style={styles.follow}>
<Svg
style={styles.icon}
height="28"
width="28"
viewBox="0 0 46 72">
<Path
d="M29.986 9c-14.888 0-27 12.112-27 27s12.112 27 27 27 27-12.112 27-27-12.112-27-27-27zM42.09 47H17.882c-.757 0-.917-.93-.917-2.325 0-.975.325-2.052 1.393-2.616l.033-.022c.706-.429 4.002-1.314 6.945-2.012 1.645 1.861 3.465 2.325 4.651 2.325s3.006-.464 4.65-2.325c2.942.698 6.239 1.583 6.945 2.012.011.007.023.014.033.022 1.068.564 1.393 1.641 1.393 2.616C43.007 46.07 42.847 47 42.09 47zM29.986 23c6.147 0 6.284 6.715 6.284 6.715s.993.044.772 1.86c-.208 1.716-1.307 3.001-2.028 3.001 0 0-1.924 5.003-5.028 5.003s-5.028-5.003-5.028-5.003c-.721 0-1.82-1.285-2.028-3.001-.221-1.815.772-1.86.772-1.86s.347-5.331 3.244-5.677c1.025-.924 2.256-1.038 3.04-1.038z"
fill="rgb(29, 161, 242)"/>
</Svg>
<View>
<Image style={styles.logo} source={logo} />
<View style={styles.details}>
<Text style={styles.name}>{name}</Text>
<Text>followed you.</Text>
</View>
</View>
</View>
</View>
</TouchableHighlight>
)} />
);
</TouchableHighlight>
)} />
);
}
};

const styles = StyleSheet.create({
Expand Down
28 changes: 20 additions & 8 deletions NavigationReactNative/sample/twitter/Home.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ import TabBar from './TabBar';
import Tweets from './Tweets';
import Follows from './Follows';

export default ({tweets, follows, stateNavigator}) => (
<ScrollableTabView
prerenderingSiblingsNumber={1}
renderTabBar={() => <TabBar stateNavigator={stateNavigator} />}>
<Tweets tweets={tweets} stateNavigator={stateNavigator} tabLabel="Timeline" />
<Follows follows={follows} stateNavigator={stateNavigator} tabLabel="Notification" />
</ScrollableTabView>
);
export default class Home extends React.Component {
constructor(props, context) {
super(props, context);
this.url = props.stateNavigator.stateContext.url;
}
shouldComponentUpdate(props) {
return this.url === props.stateNavigator.stateContext.url;
}
render() {
const {tweets, follows, stateNavigator} = this.props;
return (
<ScrollableTabView
prerenderingSiblingsNumber={1}
renderTabBar={() => <TabBar stateNavigator={stateNavigator} />}>
<Tweets tweets={tweets} stateNavigator={stateNavigator} tabLabel="Timeline" />
<Follows follows={follows} stateNavigator={stateNavigator} tabLabel="Notification" />
</ScrollableTabView>
);
}
};
32 changes: 22 additions & 10 deletions NavigationReactNative/sample/twitter/Home.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@ import React from 'react';
import {StyleSheet, Text, ScrollView, View} from 'react-native';
import Tweets from './Tweets';

export default ({tweets, stateNavigator}) => (
<View style={{flex: 1}}>
<View style={styles.banner}>
<Text style={styles.title}>Home</Text>
</View>
<ScrollView style={styles.view}>
<Tweets tweets={tweets} stateNavigator={stateNavigator} />
</ScrollView>
</View>
);
export default class Home extends React.Component {
constructor(props, context) {
super(props, context);
this.url = props.stateNavigator.stateContext.url;
}
shouldComponentUpdate(props) {
return this.url === props.stateNavigator.stateContext.url;
}
render() {
const {tweets, stateNavigator} = this.props;
return (
<View style={{flex: 1}}>
<View style={styles.banner}>
<Text style={styles.title}>Home</Text>
</View>
<ScrollView style={styles.view}>
<Tweets tweets={tweets} stateNavigator={stateNavigator} />
</ScrollView>
</View>
);
}
};

const styles = StyleSheet.create({
banner: {
Expand Down
Loading