|
@@ -54,15 +54,12 @@ export const MASCOT_STYLE = {
|
54
|
54
|
LOVE: 6,
|
55
|
55
|
COOL: 7,
|
56
|
56
|
ANGRY: 8,
|
|
57
|
+ RANDOM: 999,
|
57
|
58
|
};
|
58
|
59
|
|
59
|
60
|
|
60
|
61
|
class Mascot extends React.Component<Props, State> {
|
61
|
62
|
|
62
|
|
- state = {
|
63
|
|
- currentEmotion: this.props.emotion
|
64
|
|
- }
|
65
|
|
-
|
66
|
63
|
static defaultProps = {
|
67
|
64
|
animated: false,
|
68
|
65
|
entryAnimation: {
|
|
@@ -91,6 +88,8 @@ class Mascot extends React.Component<Props, State> {
|
91
|
88
|
onPress: (viewRef: AnimatableViewRef) => null;
|
92
|
89
|
onLongPress: (viewRef: AnimatableViewRef) => null;
|
93
|
90
|
|
|
91
|
+ initialEmotion: number;
|
|
92
|
+
|
94
|
93
|
constructor(props: Props) {
|
95
|
94
|
super(props);
|
96
|
95
|
this.viewRef = React.createRef();
|
|
@@ -106,12 +105,21 @@ class Mascot extends React.Component<Props, State> {
|
106
|
105
|
this.glassesList[GLASSES_STYLE.NORMAL] = MASCOT_GLASSES;
|
107
|
106
|
this.glassesList[GLASSES_STYLE.COOl] = MASCOT_SUNGLASSES;
|
108
|
107
|
|
|
108
|
+ this.initialEmotion = this.props.emotion;
|
|
109
|
+
|
|
110
|
+ if (this.initialEmotion === MASCOT_STYLE.RANDOM)
|
|
111
|
+ this.initialEmotion = Math.floor(Math.random() * MASCOT_STYLE.ANGRY) + 1;
|
|
112
|
+
|
|
113
|
+ this.state = {
|
|
114
|
+ currentEmotion: this.initialEmotion
|
|
115
|
+ }
|
|
116
|
+
|
109
|
117
|
if (this.props.onPress == null) {
|
110
|
118
|
this.onPress = (viewRef: AnimatableViewRef) => {
|
111
|
119
|
if (viewRef.current != null) {
|
112
|
120
|
this.setState({currentEmotion: MASCOT_STYLE.LOVE});
|
113
|
121
|
viewRef.current.rubberBand(1500).then(() => {
|
114
|
|
- this.setState({currentEmotion: this.props.emotion});
|
|
122
|
+ this.setState({currentEmotion: this.initialEmotion});
|
115
|
123
|
});
|
116
|
124
|
|
117
|
125
|
}
|
|
@@ -125,7 +133,7 @@ class Mascot extends React.Component<Props, State> {
|
125
|
133
|
if (viewRef.current != null) {
|
126
|
134
|
this.setState({currentEmotion: MASCOT_STYLE.ANGRY});
|
127
|
135
|
viewRef.current.tada(1000).then(() => {
|
128
|
|
- this.setState({currentEmotion: this.props.emotion});
|
|
136
|
+ this.setState({currentEmotion: this.initialEmotion});
|
129
|
137
|
});
|
130
|
138
|
|
131
|
139
|
}
|