-
Notifications
You must be signed in to change notification settings - Fork 0
/
FavoriteButton.js
64 lines (49 loc) · 1.1 KB
/
FavoriteButton.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
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TextInput,
ListView,
TouchableNativeFeedback,
Alert
} from 'react-native';
import { Router, Scene, Actions } from 'react-native-router-flux';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
import { Result } from './Result.js'
class FavoriteButton extends Component {
constructor(props) {
super(props);
this.state = {
favorite: false
};
}
handleClick() {
this.setState({favorite: !this.state.favorite})
}
render() {
if (!this.state.favorite) {
return (
<MaterialIcons
onPress={this.handleClick.bind(this)}
style={{marginRight: 20, marginLeft: 20}}
name="favorite-border"
size={30}
color="#e76248"
/>
)
}
return (
<MaterialIcons
onPress={this.handleClick.bind(this)}
style={{marginRight: 20, marginLeft: 20}}
name="favorite"
size={30}
color="#e76248"
/>
)
}
}
export default FavoriteButton;