Skip to content

Commit

Permalink
Added example
Browse files Browse the repository at this point in the history
  • Loading branch information
Marton Bodonyi committed Mar 6, 2017
1 parent bbecfb1 commit 7d91c66
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions example/ReactNativeTouchThroughViewExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Example implementation of react-native-touch-through-view component.
* https://github.com/rome2rio/react-native-touch-through-view
* @flow
*/

import React, { Component } from 'react';
import {
StyleSheet,
Text,
Image,
Dimensions,
ScrollView,
ListView,
Button,
View
} from 'react-native';
import { TouchThroughView, TouchThroughWrapper } from 'react-native-touch-through-view';

const ReactNativeTouchThroughViewExample = () => (
<View style={styles.container}>
<View style={styles.artistInfo}>
<View style={styles.albumImageWrapper}>
<Image source={require("./album.jpg")} style={styles.albumImage} />
</View>
<Button style={styles.button} title="Play" onPress={() => { }} />
</View>
<TouchThroughWrapper style={styles.scrollWrapper}>
<ListView
style={styles.scroller}
dataSource={dataSource}
renderHeader={() => <TouchThroughView style={styles.touchThroughView} />}
renderRow={(rowData) => {
return (
<Text style={styles.itemRow}>{rowData}</Text>
)
}}>
</ListView>
</TouchThroughWrapper>
</View>
);

export default ReactNativeTouchThroughViewExample

const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
const rows = [];

let i = 0;
while (i < 1000) {
rows.push(`Item ${i}`);
i++;
}

const dataSource = ds.cloneWithRows(rows);

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#eee',
paddingTop: 20,
},
button: {
marginTop: 20,
},
albumImage: {
width: 300,
height: 300,
},
albumImageWrapper: {
marginTop: 20,
marginBottom: 10,
padding: 10,
width: 320,
height: 320,
alignSelf: 'center',
backgroundColor: 'white',
shadowColor: '#ccc',
shadowOpacity: 1,
shadowRadius: 5,
shadowOffset: { width: 0, height: 0 },
},
artistInfo: {
position: 'absolute',
top: 20,
left: 0,
right: 0,
height: 400,
zIndex: 0,
},
scroller: {
zIndex: 1,
},
scrollWrapper: {
flex: 1,
},
touchThroughView: {
height: 400,
flex: 1,
},
itemRow: {
backgroundColor: '#ddd',
padding: 20,
borderBottomWidth: 5,
borderBottomColor: '#000',
}
});
Binary file added example/album.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 7d91c66

Please sign in to comment.