Added toast on copy

This commit is contained in:
Romain CLEMENT 2023-04-03 11:51:01 +02:00
parent 05c4a573f8
commit 4e34f2ce37
2 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import React from 'react';
import { View, Text, Clipboard } from 'react-native';
import IconVector from 'react-native-vector-icons/FontAwesome5';
import Toast from 'react-native-simple-toast';
export default class ClipElement extends React.Component<any, any> {
@ -8,10 +9,15 @@ export default class ClipElement extends React.Component<any, any> {
super(props);
}
onCopy() {
Clipboard.setString(this.props.title);
Toast.show('Put "' + this.props.title + '" in clipboard', Toast.SHORT);
}
render(): JSX.Element {
return <View style={{flex:1,margin:10,flexDirection:'row',justifyContent:'space-between',alignItems:'center'}}>
<Text style={{fontSize:20,}}>{this.props.title}</Text>
<IconVector name="clipboard" size={40} onPress={() => Clipboard.setString(this.props.title)} />
<IconVector name="clipboard" size={40} onPress={() => this.onCopy()} />
</View>;
}
}

View File

@ -15,6 +15,7 @@
"expo-cli": "^6.3.2",
"react": "18.2.0",
"react-native": "0.71.4",
"react-native-simple-toast": "^2.0.0",
"react-native-vector-icons": "^9.2.0"
},
"devDependencies": {