Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Changed slide deck to use react-native-page-swiper
Browse files Browse the repository at this point in the history
  • Loading branch information
whs committed Mar 28, 2016
1 parent 259741e commit 2cfd1ae
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "components/react-native-page-swiper"]
path = components/react-native-page-swiper
url = [email protected]:fixt/react-native-page-swiper.git
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

This project from mobile software development class.

## Note on react-native-page-swiper
Remove .babelrc before building. The npm version is too old and does not offer `pager` property.

## Goals
### Project proposal stage
- [x] Slide layout
Expand Down
6 changes: 1 addition & 5 deletions components/Editor/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import NavBar, { NavButton, NavTitle, NavGroup } from 'react-native-nav'
import NavBarStyle from '../navbarstyle';

var styles = StyleSheet.create({
root: {
flex: 1,
alignItems: 'stretch'
},
});

export default class Editor extends Component {
Expand Down Expand Up @@ -60,7 +56,7 @@ export default class Editor extends Component {
toolbar = null;
}
return (
<View style={styles.root}>
<View style={{flex: 1}}>
{toolbar}
<StatusBar hidden={this.state.preview} animated={false} />
<SlideDeck slides={[
Expand Down
1 change: 0 additions & 1 deletion components/ImagePicker/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var styles = StyleSheet.create({
padding: 5,
},
search: {
elevation: 5,
height: 30,
width: 300,
backgroundColor: 'white',
Expand Down
30 changes: 17 additions & 13 deletions components/SlideDeck/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import React, {
StyleSheet,
Text,
View,
ViewPagerAndroid,
LayoutAnimation
LayoutAnimation,
Dimensions
} from 'react-native';
import Slide from '../Slide';
import Swiper from '../react-native-page-swiper/src';

var styles = StyleSheet.create({
deck: {
Expand All @@ -26,7 +27,7 @@ export default class SlideDeck extends Component {

componentWillReceiveProps(props){
if(this.pager && props.presenting != this.props.presenting){
this.pager.setPageWithoutAnimation(0);
this.pager.goToPage(0);
}
}

Expand All @@ -42,11 +43,9 @@ export default class SlideDeck extends Component {
);
});

let eop = null;

if(this.props.presenting){
eop = (
<View>
slides.push((
<View key="eop">
<Slide
width={this.state.width} height={this.state.height}
editable={false} presenting={this.props.presenting}
Expand All @@ -56,19 +55,24 @@ export default class SlideDeck extends Component {
text2Color: 'white'
}} />
</View>
);
));
}

let {width, height} = Dimensions.get('window');
if(height > width){
width = height;
}

return (
<View style={styles.deck} onLayout={this._onLayout}>
<ViewPagerAndroid
initialPage={0}
<Swiper
index={0}
pager={false}
style={styles.slider}
keyboardDismissMode="on-drag"
springFriction={10}
ref={(pager) => this.pager = pager}>
{slides}
{eop}
</ViewPagerAndroid>
</Swiper>
</View>
);
}
Expand Down
5 changes: 2 additions & 3 deletions components/navbarstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ export default StyleSheet.create({
color: '#ffffff',
},
navIcon: {
width: Platform.OS == 'ios' ? 32 : 48,
height: Platform.OS == 'ios' ? 32 : 48,
width: 32,
height: 32,
},
navButton: {
paddingLeft: 5,
paddingRight: 5,
},
navBar: {
backgroundColor: '#00aa00',
elevation: 4,
},
});
1 change: 1 addition & 0 deletions components/react-native-page-swiper

0 comments on commit 2cfd1ae

Please sign in to comment.