import React, { Component } from 'react';
import { Animated, StyleSheet, I18nManager, View } from 'react-native';
import { RectButton } from 'react-native-gesture-handler';
import Swipeable from 'react-native-gesture-handler/Swipeable';
const AnimatedView = Animated.createAnimatedComponent(View);
export default class GmailStyleSwipeableRow extends Component {
private renderLeftActions = (
_progress: Animated.AnimatedInterpolation,
dragX: Animated.AnimatedInterpolation
) => {
const scale = dragX.interpolate({
inputRange: [0, 80],
outputRange: [0, 1],
extrapolate: 'clamp',
});
return (
{/* Change it to some icons */}
);
};
private renderRightActions = (
_progress: Animated.AnimatedInterpolation,
dragX: Animated.AnimatedInterpolation
) => {
const scale = dragX.interpolate({
inputRange: [-80, 0],
outputRange: [1, 0],
extrapolate: 'clamp',
});
return (
{/* Change it to some icons */}
);
};
private swipeableRow?: Swipeable;
private updateRef = (ref: Swipeable) => {
this.swipeableRow = ref;
};
private close = () => {
this.swipeableRow?.close();
};
render() {
const { children } = this.props;
return (
{children}
);
}
}
const styles = StyleSheet.create({
leftAction: {
flex: 1,
backgroundColor: '#388e3c',
justifyContent: 'flex-end',
alignItems: 'center',
flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',
},
actionIcon: {
width: 30,
marginHorizontal: 10,
backgroundColor: 'plum',
height: 20,
},
rightAction: {
alignItems: 'center',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
backgroundColor: '#dd2c00',
flex: 1,
justifyContent: 'flex-end',
},
});