-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
135 lines (126 loc) · 2.97 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import {
Keyboard,
StyleSheet,
View,
Text,
TextInput,
Image,
Button,
} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
// Install react-native-linear-gradient: "https://www.npmjs.com/package/react-native-linear-gradient"
const App: () => React$Node = () => {
// function constructor() {
// this.state = {
// username,
// };
// this.handleChangeUsername = this.handleChangeUsername.bind(this);
// }
// function handleChangeUsername(username) {
// this.setState({
// value: username,
// });
// }
function onPressButton(username) {
const githubURL = 'https://api.github.com/users';
return fetch(githubURL)
.then(response => response.json())
.then(json => {
return json.users;
})
.catch(error => {
console.error(error);
});
}
function handleKeyPress(e) {
if (e.nativeEvent.key === 'Enter') {
Keyboard.dismiss();
onPressButton();
}
}
return (
<View style={styles.body}>
<View style={styles.container}>
<Image
style={styles.image}
source={require('./assets/github-logo.png')}
/>
<Text style={styles.title}>GitHub User Grabber</Text>
<Text style={styles.description}>
Enter a GitHub username to lookup:
</Text>
<TextInput
style={styles.textInput}
placeholder="e.g. RayanAlkhelaiwi"
placeholderTextColor="#eff3f6"
onKeyPresss={handleKeyPress}
// defaultValue={this.state.username}
// onChangeText={this.handleChangeUsername}
/>
<LinearGradient
colors = {
['#34d058', '#28a745'] //Original Gradient colors: #34d058 & #28a745 (From Github's New/Clone-or-download button)
}
style={styles.linearGradient}>
<Text style={styles.button}>Lookup</Text>
</LinearGradient>
</View>
</View>
);
};
const styles = StyleSheet.create({
body: {
flex: 1,
backgroundColor: Colors.black,
flexDirection: 'column',
justifyContent: 'center',
},
container: {
justifyContent: 'center',
margin: 24,
},
image: {
width: 150,
height: 150,
alignSelf: 'center',
marginBottom: 48,
},
title: {
color: Colors.white,
fontSize: 24,
fontWeight: '600',
paddingBottom: 32,
},
description: {
color: Colors.white,
marginTop: 8,
fontWeight: '400',
},
textInput: {
color: Colors.white,
},
linearGradient: {
// flex: 1,
paddingLeft: 15,
paddingRight: 15,
borderRadius: 5
},
button: {
fontSize: 18,
fontFamily: 'Gill Sans',
textAlign: 'center',
margin: 10,
color: '#fff',
backgroundColor: 'transparent',
},
});
export default App;