Created
October 30, 2019 02:35
-
-
Save rashidthedeveloper/0732426c589c0130597a10c1719356c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import liraries | |
import React, { Component } from 'react'; | |
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native'; | |
import SwipeableRow from './SwipeableRow'; | |
// create a component | |
class App extends Component { | |
render() { | |
return ( | |
<View style={styles.container}> | |
<SwipeableRow></SwipeableRow> | |
</View> | |
); | |
} | |
} | |
// define your styles | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
}, | |
}); | |
//make this component available to the app | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Animated, StyleSheet} from 'react-native'; | |
import { RectButton } from 'react-native-gesture-handler'; | |
import Swipeable from 'react-native-gesture-handler/Swipeable'; | |
export default class SwipeableRow extends Component { | |
renderLeftActions = (progress, dragX) => { | |
const trans = dragX.interpolate({ | |
inputRange: [0, 50, 100, 101], | |
outputRange: [-20, 0, 0, 1], | |
}); | |
return ( | |
<RectButton style={styles.leftAction} onPress={console.log('Pressed')}> | |
<Animated.Text | |
style={[ | |
styles.actionText, | |
{ | |
transform: [{ translateX: trans }], | |
}, | |
]}> | |
Swiped!! | |
</Animated.Text> | |
</RectButton> | |
); | |
}; | |
render() { | |
return ( | |
<Swipeable | |
renderLeftActions={this.renderLeftActions}> | |
<RectButton style={styles.rectButton}> | |
</RectButton> | |
</Swipeable> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
leftAction: { | |
flex: 1, | |
backgroundColor: 'cyan', | |
justifyContent: 'center', | |
}, | |
actionText: { | |
color: 'black', | |
fontSize: 16, | |
}, | |
rectButton: { | |
width:'100%', | |
height: 80, | |
backgroundColor: 'blue', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment