-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
138 lines (137 loc) · 3.19 KB
/
App.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* @Author: your name
* @Date: 2021-01-30 14:39:06
* @LastEditTime: 2021-04-07 15:09:14
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /demo2/App.js
*/
import React, { Component } from 'react';
import {
View,
SafeAreaView,
Text,Alert,
TextInput,
Button,
StyleSheet,
ImageBackground
} from 'react-native';
import { WebView } from 'react-native-webview';
import HttpClient from './utils/server'
const image = { uri: "https://w.wallhaven.cc/full/6k/wallhaven-6kdxex.jpg" };
export default class App extends Component {
constructor(props) {
super(props);
this.state={
title:'',
inputTitle:''
};
}
getAnswer(){
let self = this;
fetch('http://www.tuling123.com/openapi/api', {
method: 'post',
body: JSON.stringify({
key: "d0542def0cb94cc48e4bdd836b25281c",
info: this.state.inputTitle
}),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(e =>{
// Alert.alert(e.text)
self.setState({
title:e.text,
})
})
}
render() {
return (
<SafeAreaView>
<View style={{
height:"100%",
width:"100%",
}}>
<ImageBackground source={require("./assets/images/bk.jpg")} style={styles.image}>
<View style={styles.bubble}>
<Text style={{
color:"#ed556a",
fontSize:20
}} >{this.state.title}
</Text>
</View>
<View style={{
position:"relative",
top:"-1%",
height: "60%",
width: "100%",
overflow:'hidden',
}}>
<WebView style={{
backgroundColor:"transparent",
// backgroundColor:"red"
}} source={{ uri: 'https://kyingstar.com/' }} />
</View>
<View>
<View style={styles.flexRow}>
<TextInput
style={styles.input}
onChangeText={text => {
this.setState({
inputTitle:text
})
}}
/>
<Button
onPress={() => {
this.getAnswer()
}}
title="发送"
/>
</View>
</View>
</ImageBackground>
</View>
</SafeAreaView>
)
}
}
const styles = StyleSheet.create({
bubble: {
position:"relative",
bottom:"-14%",
height:"10%",
margin:20,
backgroundColor: "rgba(255,255,255,0.7)",
borderRadius:3,
padding:5
},
flexRow: {
position:"relative",
top:"-10%",
margin: 20,
flexDirection: 'row',
justifyContent: 'space-between',
backgroundColor: "rgba(255,255,255,0.7)",
borderRadius:3
},
image: {
flex: 1,
resizeMode: "cover",
justifyContent: "center"
},
container: {
flex: 1,
flexDirection: "column"
},
input: {
height: 40,
width: 300,
marginLeft:20,
borderColor: 'gray',
borderWidth: 1,
borderWidth:0
}
})