Skip to content

Commit

Permalink
add swipable card
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnylazuardi committed Dec 31, 2016
1 parent 9bf22bd commit ca4bc89
Show file tree
Hide file tree
Showing 15 changed files with 822 additions and 175 deletions.
19 changes: 18 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,23 @@ import HistoryScreen from './src/components/HistoryScreen';
import BeginRunScreen from './src/components/BeginRunScreen';
import RunningScreen from './src/components/RunningScreen';

import {
createRouter,
NavigationProvider,
StackNavigation,
NavigationStyles
} from '@exponent/ex-navigation';

const Router = createRouter(() => ({
splash: () => SplashScreen,
home: () => HomeScreen,
begin: () => BeginRunScreen,
running: () => RunningScreen,
history: () => HistoryScreen
}));

class App extends React.Component {

constructor(props) {
super(props);
this.state = {
Expand All @@ -37,7 +52,9 @@ class App extends React.Component {
}

return (
<RunningScreen />
<NavigationProvider router={Router}>
<StackNavigation initialRoute="splash" />
</NavigationProvider>
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"private": true,
"main": "main.js",
"dependencies": {
"exponent": "~12.0.3",
"@exponent/ex-navigation": "^2.7.0",
"@exponent/vector-icons": "~2.0.3",
"exponent": "~12.0.3",
"react": "~15.3.2",
"react-native": "git+https://github.com/exponentjs/react-native#sdk-12.0.0"
}
}
}
30 changes: 26 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,34 @@ Inspiration: https://dribbble.com/shots/2764470-Rethinking-Nike-Running

## Features

- FadedZoom Transition
This will add FadedZoom transition to ex-navigator (you can use it on another project)

```
import FadedZoom from '../animations/FadedZoom';
static route = {
styles: {
...FadedZoom,
},
};
```

- Swipeable Card
- Shared Content Transition
- Native View Graphs
The card can be swiped up-down to toggle hide and left-right to change current card view.

- Geolocation & Animated Marker
The homescreen will show your current location with animated marker

- Box Shadow & Gradient
(iOS only) There will be shadow around the button and cards.

## MIT Licensed

© 2016 Sonny Lazuardi

## License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

MIT Licensed (c) 2016 @sonnylazuardi
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 changes: 43 additions & 0 deletions src/animations/FadedZoom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
Animated,
Easing
} from 'react-native';

const configureTimingTransition = (transitionProps, previousTransitionProps) => ({
timing: Animated.timing,
easing: Easing.inOut(Easing.linear),
duration: 150,
});

export default FadedZoom = {
configureTransition: configureTimingTransition,
sceneAnimations: (props) => {
const {
position,
scene,
} = props;

const index = scene.index;
const inputRange = [index - 1, index, index + 1];

const opacity = position.interpolate({
inputRange,
outputRange: [0, 1, 0],
});

const scale = position.interpolate({
inputRange,
outputRange: [1.2, 1, 1.2],
});

return {
opacity,
transform: [
{ translateX: 0 },
{ translateY: 0 },
{ scale: scale },
],
};
},
gestures: null,
};
35 changes: 27 additions & 8 deletions src/components/BeginRunScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ import {
TouchableOpacity
} from 'react-native';
import { Components } from 'exponent';
import FadedZoom from '../animations/FadedZoom';

class BeginRunScreen extends React.Component {
static route = {
styles: {
...FadedZoom,
},
}

onBack = () => {
this.props.navigator.pop();
};

onRun = () => {
this.props.navigator.push('running');
};

componentDidMount() {
this.refs.scrollView.scrollTo({y: 0, x: 85, animated: true});
}


render() {
return (
<View style={styles.container}>
Expand All @@ -23,7 +40,9 @@ class BeginRunScreen extends React.Component {
/>
<View style={styles.toolbar}>
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Image source={require('../images/back-icon.png')} style={styles.logoicon} />
<TouchableOpacity onPress={this.onBack}>
<Image source={require('../images/back-icon.png')} style={styles.logoicon} />
</TouchableOpacity>
</View>
<View style={{flex: 3, justifyContent: 'center', alignItems: 'center'}}>
<Image source={require('../images/logonike-white.png')} style={styles.logosmall} />
Expand Down Expand Up @@ -134,14 +153,14 @@ class BeginRunScreen extends React.Component {
</ScrollView>
</View>
</View>
<View style={{paddingVertical: 10, paddingHorizontal: 50}}>
<TouchableOpacity style={styles.buttonRedWrapper}>
<View style={styles.buttonRed} shadowColor={'#000'} shadowOffset={{width: 10, height: 10}} shadowOpacity={0.6} shadowRadius={30}>
<Text style={styles.buttonRedText}>START</Text>
</View>
</TouchableOpacity>
</View>
</ScrollView>
<View style={{paddingVertical: 10, paddingHorizontal: 50, position: 'absolute', bottom: 15, left: 0, right: 0}}>
<TouchableOpacity style={styles.buttonRedWrapper} onPress={this.onRun}>
<View style={styles.buttonRed} shadowColor={'#000'} shadowOffset={{width: 10, height: 10}} shadowOpacity={0.6} shadowRadius={30}>
<Text style={styles.buttonRedText}>START</Text>
</View>
</TouchableOpacity>
</View>
</View>
);
}
Expand Down
34 changes: 34 additions & 0 deletions src/components/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import {
View,
Text,
StyleSheet,
Image,
Dimensions
} from 'react-native';

const windowWidth = Dimensions.get('window').width;

class Card extends React.Component {
render() {
return (
<View style={styles.card} shadowColor={'#000'} shadowOffset={{width: 0, height: 10}} shadowOpacity={0.4} shadowRadius={20}>
{this.props.children}
</View>
);
}
}

const styles = StyleSheet.create({
card: {
backgroundColor: '#fff',
borderRadius: 10,
height: 400,
flex: 1,
marginHorizontal: 40,
marginVertical: 30,
minWidth: windowWidth - 80,
},
});

export default Card;
143 changes: 143 additions & 0 deletions src/components/CardCoach.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import React from 'react';
import {
View,
Text,
StyleSheet,
Image
} from 'react-native';
import Card from './Card';

class CardCoach extends React.Component {
render() {
return (
<Card>
<View style={styles.cardHeader}>
<View style={{flex: 1, alignItems: 'flex-start'}}>
<View style={{flexDirection: 'row', alignItems: 'center'}}>
<Image source={require('../images/coach-icon.png')} style={styles.profileicon} />
<Text style={{fontFamily: 'bebas-neue', fontSize: 18, color: '#282a2c'}}>NIKE+ COACH</Text>
</View>
</View>
<View style={{flex: 1, alignItems: 'flex-end'}}>
<View style={{flexDirection: 'row', alignItems: 'center', marginTop: 3}}>
<Text style={{fontFamily: 'bebas-neue', fontSize: 18, color: '#adadad'}}>THIS WEEK</Text>
</View>
</View>
</View>
<View style={{height: 30}}>

</View>
<View style={styles.cardContent}>
<View style={{flex: 2}}>
<Text style={styles.textSmall}>MON 16</Text>
</View>
<View style={{flex: 5}}>
<Text style={styles.text}>WALK 1.6KM</Text>
</View>
<View style={{flex: 1}}>
<Text>🙌</Text>
</View>
</View>
<View style={styles.cardContent}>
<View style={{flex: 2}}>
<Text style={styles.textSmall}>TUE 17</Text>
</View>
<View style={{flex: 5}}>
<Text style={styles.text}>RUN 4.8KM</Text>
</View>
<View style={{flex: 1}}>
<Text>💪</Text>
</View>
</View>
<View style={styles.cardContent}>
<View style={{flex: 2}}>
<Text style={[styles.textSmall, {color: '#f02733'}]}>WED 18</Text>
</View>
<View style={{flex: 5}}>
<Text style={[styles.text, {color: '#f02733'}]}>CROSS TRAIN</Text>
</View>
<View style={{flex: 1}}>
<Text>🤔</Text>
</View>
</View>
<View style={styles.cardContent}>
<View style={{flex: 2}}>
<Text style={[styles.textSmall, {color: '#eee'}]}>THU 19</Text>
</View>
<View style={{flex: 6}}>
<Text style={[styles.text, {color: '#eee'}]}>REST</Text>
</View>
</View>
<View style={styles.cardContent}>
<View style={{flex: 2}}>
<Text style={[styles.textSmall, {color: '#eee'}]}>FRI 20</Text>
</View>
<View style={{flex: 6}}>
<Text style={[styles.text, {color: '#eee'}]}>WALK 1.6KM</Text>
</View>
</View>
</Card>
);
}
}

const styles = StyleSheet.create({
cardHeader: {
flexDirection: 'row',
paddingVertical: 20,
paddingHorizontal: 25,
paddingBottom: 0,
},
profileicon: {
height: 30,
width: 30
},
profileiconred: {
height: 30,
width: 30,
marginTop: 8
},
cardContent: {
flexDirection: 'row',
paddingHorizontal: 25,
marginVertical: 8,
justifyContent: 'flex-start',
alignItems: 'center'
},
profilepicture: {
height: 60,
width: 60,
borderRadius: 30,
marginHorizontal: 10,
marginTop: 5
},
cardLabel: {
fontFamily: 'bebas-neue',
fontSize: 18,
color: '#adadad'
},
cardText: {
fontFamily: 'bebas-neue',
fontSize: 30
},
cardTextSmall: {
fontFamily: 'bebas-neue',
fontSize: 13
},
graphText: {
textAlign: 'center',
fontFamily: 'bebas-neue',
fontSize: 13,
color: '#adadad'
},
text: {
fontFamily: 'bebas-neue',
fontSize: 20
},
textSmall: {
fontFamily: 'bebas-neue',
fontSize: 14
}
});

export default CardCoach;
Loading

0 comments on commit ca4bc89

Please sign in to comment.