-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathApp.js
More file actions
82 lines (76 loc) · 2.02 KB
/
App.js
File metadata and controls
82 lines (76 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
import {
SafeAreaView,
StyleSheet,
View,
Text,
TextInput,
} from 'react-native';
import { OpenGraphAwareInput, OpenGraphDisplay, OpenGraphParser } from 'react-native-opengraph-kit';
export default class Example extends Component {
state = {
data: [],
};
handleIconPress = () => {
console.log('Pressed X');
}
handleTextChange = (event) => {
OpenGraphParser.extractMeta(event.nativeEvent.text)
.then((data) => {
console.log(data);
this.setState({ data });
})
.catch((error) => {
console.log(error);
});
}
render() {
return (
<SafeAreaView>
<View style={styles.container}>
<Text style={styles.title}>OpenGraphAwareInput</Text>
<OpenGraphAwareInput
showIcon
containerStyle={styles.textInput}
/>
<Text style={styles.title}>Using OpenGraphParser with normal TextInput</Text>
<TextInput
style={styles.textInput}
onChange={this.handleTextChange}
/>
<Text style={styles.title}>OpenGraphDisplay</Text>
{this.state.data.map((meta, i) =>
<OpenGraphDisplay
key={meta}
data={meta}
/>
)}
</View>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
paddingTop: 50,
padding: 10,
},
textInput: {
borderWidth: 1,
borderColor: '#ccc',
minHeight: 100,
},
title: {
fontSize: 16,
fontWeight: 'bold',
marginBottom: 10,
marginTop: 5,
},
});