Merge pull request #11 from ThomasRubini/view-clip

View clip
This commit is contained in:
Romain CLEMENT 2023-04-03 12:14:49 +02:00 committed by GitHub
commit ae0e61ffc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 1 deletions

23
clip/ClipElement.tsx Normal file
View File

@ -0,0 +1,23 @@
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> {
constructor(props: 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={() => this.onCopy()} />
</View>;
}
}

20
clip/ClipList.tsx Normal file
View File

@ -0,0 +1,20 @@
import React from 'react';
import { ScrollView } from 'react-native';
import ClipElement from './ClipElement';
export default class ClipList extends React.Component<any, any> {
constructor(props: any) {
super(props);
}
createClipElement(title: string): JSX.Element {
return <ClipElement title={title} />;
}
render(): JSX.Element {
return <ScrollView>
{this.props.clips.map((entry: any) => this.createClipElement(entry.title))}
</ScrollView>;
}
}

View File

@ -14,7 +14,9 @@
"expo": "^48.0.9",
"expo-cli": "^6.3.2",
"react": "18.2.0",
"react-native": "0.71.4"
"react-native": "0.71.4",
"react-native-simple-toast": "^2.0.0",
"react-native-vector-icons": "^9.2.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
@ -24,6 +26,7 @@
"@tsconfig/react-native": "^2.0.2",
"@types/jest": "^29.2.1",
"@types/react": "^18.0.24",
"@types/react-native-vector-icons": "^6.4.13",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",