Commit aed87281 by Tonk

update open only one swipeable

parent f31bc19c
......@@ -63,23 +63,6 @@ const Row = ({ data }) => (
);
class SwipeableRow extends Component {
// renderLeftActions = (progress, dragX) => {
// const scale = dragX.interpolate({
// inputRange: [0, 80],
// outputRange: [0, 1],
// extrapolate: 'clamp',
// });
// return (
// <RectButton style={styles.leftAction} onPress={this.close}>
// <AnimatedIcon
// name="archive"
// size={30}
// color="#fff"
// style={[styles.actionIcon, { transform: [{ scale }] }]}
// />
// </RectButton>
// );
// };
selectedRow = null;
state = {
isVisible: false,
......@@ -123,8 +106,9 @@ class SwipeableRow extends Component {
</>
);
};
updateRef = ref => {
this._swipeableRow = ref;
updateRef = instance => {
this._swipeableRow = instance;
this.swipeInstance = instance;
};
cfDelete = () => {
this._swipeableRow.close();
......@@ -137,17 +121,19 @@ class SwipeableRow extends Component {
this.setState({ isVisible: false });
};
_onSwipeOpen = () => {
this.props.onSwipeOpen(this.swipeInstance);
};
render() {
return (
<Swipeable
ref={this.updateRef}
friction={2}
// leftThreshold={80}
rightThreshold={40}
// renderLeftActions={this.renderLeftActions}
renderRightActions={this.renderRightActions}
containerStyle={{ backgroundColor: color.primary }}
onSwipeableWillOpen={this._onSwipeOpen}
>
<Row data={this.props.item} />
</Swipeable>
......
......@@ -363,7 +363,13 @@ export default class TimerScreen extends Component {
</Fab>
);
};
_onSwipeOpen = swipeInstance => {
if (this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) {
this.currentlyOpenSwipe.close();
}
this.currentlyOpenSwipe = swipeInstance;
};
render() {
return (
<>
......@@ -396,7 +402,9 @@ export default class TimerScreen extends Component {
)}
ItemSeparatorComponent={() => <View style={styles.separator} />}
ListFooterComponent={() => item.timer.length > 0 && <View style={styles.separator} />}
renderItem={({ item, index }) => <SwipeableRow item={item} index={index} />}
renderItem={({ item, index }) => (
<SwipeableRow item={item} index={index} onSwipeOpen={this._onSwipeOpen} />
)}
keyExtractor={(item, index) => `timer ${index}`}
/>
</Tab>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment