/ / Zatvorenie SwipeRow vnútri FlatList pomocou Native-Base - reaktívne natívne, natívne-base

Uzavretie nástroja SwipeRow vo vnútri FlatList pomocou natívnej základne - reakcia s natívnou, natívnou základňou

Ako môžem zatvoriť SwipeRow vnútri FlatList?

Toto je jednoduchá vec, ktorá sa dá robiť s ListView, ale pretože ďalšie vydanie bude používať FlatList, malo by to byť možné.

Z čítania ich zdrojového kódu sa zdá, že ešte nie je implementovaný.

odpovede:

2 pre odpoveď č. 1

môžete to vyskúšať

import React, { Component } from "react";
import { FlatList } from "react-native";
import { Container, Header, Content, SwipeRow, View, Text, Icon, Button } from "native-base";

export default class App extends Component {
constructor(props) {
super(props)
this.state = { data: [{ key: "a" }, { key: "b" }] }
this.component = [];
this.selectedRow;
}
render() {
return (
<Container>
<Header />
<Content>
<FlatList
data={[{ key: "a", value: "Row one" }, { key: "b", value: "Row two" }, { key: "c", value: "Row three" }, { key: "d", value: "Row four" }, { key: "e", value: "Row five" }]}
keyExtractor={(item) => item.key}
renderItem={({ item }) => <SwipeRow
ref={(c) => { this.component[item.key] = c }}
leftOpenValue={75}
rightOpenValue={-75}
onRowOpen={() => {
if (this.selectedRow && this.selectedRow !== this.component[item.key]) { this.selectedRow._root.closeRow(); }
this.selectedRow = this.component[item.key]
}}
left={
<Button success onPress={() => alert("Add")}>
<Icon active name="add" />
</Button>
}
body={
<View style={{ paddingLeft: 20 }}>
<Text>{item.value}</Text>
</View>
}
right={
<Button danger onPress={() => alert("Delete")}>
<Icon active name="trash" />
</Button>
}
/>}
/>
<Button style={{ margin: 20 }} onPress={() => this.selectedRow._root.closeRow()}><Text>Close row</Text></Button>
</Content>
</Container>
);
}
}

tu zadajte popis obrázku