-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.ios.js
131 lines (119 loc) · 3.01 KB
/
index.ios.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
import React, { Component } from "react";
import {
AppRegistry,
Image,
StatusBar,
TabBarIOS,
Text,
TextInput,
TouchableHighlight,
View,
WebView,
} from "react-native";
class Header extends Component {
constructor(...args) {
super(...args);
this.state = { text: "" };
}
onChangeText(text) {
this.setState({ text });
}
onHomeButtonClicked() {
this.setState({ text: "" });
this.props.onHomeButtonClicked();
}
onSubmitEditing() {
this.props.onSearchRequested(this.state.text);
}
render() {
return(
<View style={{
backgroundColor: "#262F40",
paddingBottom: 12,
paddingLeft: 12,
paddingRight: 12,
paddingTop: 12 + 20,
}}>
<View style={{ flex: 1, flexDirection: "row" }}>
<View style={{ alignItems: "center", flex: 1, flexDirection: "row" }}>
<TouchableHighlight onPress={this.onHomeButtonClicked.bind(this)}>
<Image source={require("./images/home-white-32x32.png")} onClick/>
</TouchableHighlight>
<TextInput
autoCorrect={false}
editable={true}
onChangeText={this.onChangeText.bind(this)}
onSubmitEditing={this.onSubmitEditing.bind(this)}
placeholder="Search"
style={{
backgroundColor: "#FFF",
borderRadius: 3,
marginLeft: 12,
paddingBottom: 4,
paddingLeft: 8,
paddingRight: 8,
paddingTop: 4,
flex: 1,
}}
value={this.state.text}
/>
</View>
</View>
</View>
);
}
}
class amakani extends Component {
static baseUrl = "http://localhost:3000";
constructor(...args) {
super(...args);
this.state = {
loading: false,
selectedTab: "home",
url: amakani.baseUrl,
};
}
onHomeButtonClicked() {
this.setState({
url: amakani.baseUrl,
});
}
onNavigationStateChange (navigationState) {
this.setState({
loading: navigationState.loading,
url: navigationState.url,
});
}
onSearchRequested(text) {
this.setState({
url: `${amakani.baseUrl}/search?query=${text}`,
});
}
render() {
return (
<View style={{
flex:1
}}>
<StatusBar
barStyle="light-content"
networkActivityIndicatorVisible={this.state.loading}
/>
<Header
onHomeButtonClicked={this.onHomeButtonClicked.bind(this)}
onSearchRequested={this.onSearchRequested.bind(this)}
/>
<WebView
automaticallyAdjustContentInsets={false}
onNavigationStateChange={this.onNavigationStateChange.bind(this)}
source={{ uri: this.state.url }}
startInLoadingState={true}
style={{
backgroundColor: "#262F40",
flex: 1
}}
/>
</View>
);
}
}
AppRegistry.registerComponent("amakani", () => amakani);