import React, { Component } from 'react';
import {
Animated,
StyleSheet,
Text,
View,
I18nManager,
Alert,
} from 'react-native';
import { RectButton } from 'react-native-gesture-handler';
import Swipeable from 'react-native-gesture-handler/Swipeable';
export default class AppleStyleSwipeableRow extends Component {
private renderLeftActions = (
_progress: Animated.AnimatedInterpolation,
dragX: Animated.AnimatedInterpolation
) => {
const trans = dragX.interpolate({
inputRange: [0, 50, 100, 101],
outputRange: [-20, 0, 0, 1],
extrapolate: 'clamp',
});
return (
Archive
);
};
private renderRightAction = (
text: string,
color: string,
x: number,
progress: Animated.AnimatedInterpolation
) => {
const trans = progress.interpolate({
inputRange: [0, 1],
outputRange: [x, 0],
});
const pressHandler = () => {
this.close();
Alert.alert(text);
};
return (
{text}
);
};
private renderRightActions = (
progress: Animated.AnimatedInterpolation,
_dragAnimatedValue: Animated.AnimatedInterpolation
) => (
{this.renderRightAction('More', '#C8C7CD', 192, progress)}
{this.renderRightAction('Flag', '#ffab00', 128, progress)}
{this.renderRightAction('More', '#dd2c00', 64, progress)}
);
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: '#497AFC',
justifyContent: 'center',
},
actionText: {
color: 'white',
fontSize: 16,
backgroundColor: 'transparent',
padding: 10,
},
rightAction: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
});