Commit aed87281 by Tonk

update open only one swipeable

parent f31bc19c
...@@ -63,23 +63,6 @@ const Row = ({ data }) => ( ...@@ -63,23 +63,6 @@ const Row = ({ data }) => (
); );
class SwipeableRow extends Component { 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; selectedRow = null;
state = { state = {
isVisible: false, isVisible: false,
...@@ -123,8 +106,9 @@ class SwipeableRow extends Component { ...@@ -123,8 +106,9 @@ class SwipeableRow extends Component {
</> </>
); );
}; };
updateRef = ref => { updateRef = instance => {
this._swipeableRow = ref; this._swipeableRow = instance;
this.swipeInstance = instance;
}; };
cfDelete = () => { cfDelete = () => {
this._swipeableRow.close(); this._swipeableRow.close();
...@@ -137,17 +121,19 @@ class SwipeableRow extends Component { ...@@ -137,17 +121,19 @@ class SwipeableRow extends Component {
this.setState({ isVisible: false }); this.setState({ isVisible: false });
}; };
_onSwipeOpen = () => {
this.props.onSwipeOpen(this.swipeInstance);
};
render() { render() {
return ( return (
<Swipeable <Swipeable
ref={this.updateRef} ref={this.updateRef}
friction={2} friction={2}
// leftThreshold={80}
rightThreshold={40} rightThreshold={40}
// renderLeftActions={this.renderLeftActions}
renderRightActions={this.renderRightActions} renderRightActions={this.renderRightActions}
containerStyle={{ backgroundColor: color.primary }} containerStyle={{ backgroundColor: color.primary }}
onSwipeableWillOpen={this._onSwipeOpen}
> >
<Row data={this.props.item} /> <Row data={this.props.item} />
</Swipeable> </Swipeable>
......
...@@ -363,7 +363,13 @@ export default class TimerScreen extends Component { ...@@ -363,7 +363,13 @@ export default class TimerScreen extends Component {
</Fab> </Fab>
); );
}; };
_onSwipeOpen = swipeInstance => {
if (this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) {
this.currentlyOpenSwipe.close();
}
this.currentlyOpenSwipe = swipeInstance;
};
render() { render() {
return ( return (
<> <>
...@@ -396,7 +402,9 @@ export default class TimerScreen extends Component { ...@@ -396,7 +402,9 @@ export default class TimerScreen extends Component {
)} )}
ItemSeparatorComponent={() => <View style={styles.separator} />} ItemSeparatorComponent={() => <View style={styles.separator} />}
ListFooterComponent={() => item.timer.length > 0 && <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}`} keyExtractor={(item, index) => `timer ${index}`}
/> />
</Tab> </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