-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTODO.txt
117 lines (100 loc) · 2.98 KB
/
TODO.txt
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
// Live reload
// Show user input in console
console.log("name: " + this.state.userName);
// Attach chrome debuger
// Validate name field
disabled={this.state.userName.length === 0 ? true : false}
// Add scroll view
<ScrollView style={styles.container} contentContainerStyle={{alignItems: 'center'}}>
// Bring back avatar
_onAvatarPick: function(avatar) {
this.setState({avatar: avatar});
},
_renderAvatarPick: function() {
return (
<ScrollView style={styles.container} contentContainerStyle={{alignItems: 'center'}}>
<Text style={styles.textLabel}>Pick your avatar</Text>
{_.map(this.state.avatarsList, (avatar) => {
return (
<TouchableHighlight style={avatar === this.state.avatar ? styles.selected : {}}
underlayColor='#99d9f4'
onPress={() => this._onAvatarPick(avatar) }>
<Image
style={styles.image}
source={{uri: avatar}} />
</TouchableHighlight>
);
})}
<NiceButton
disabled={this.state.avatar.length === 0 ? true : false}
withStyle={{marginLeft: 50, marginRight: 50}}
name="Continue" onPress={this._onContinue} />
</ScrollView>
);
},
avatar: '',
avatarsList: [
'http://icons.iconarchive.com/icons/iconka/buddy/128/officer-man-icon.png',
'http://icons.iconarchive.com/icons/iconka/buddy/128/angel-icon.png',
'http://icons.iconarchive.com/icons/iconka/buddy/128/alien-female-icon.png',
'http://icons.iconarchive.com/icons/aha-soft/free-large-boss/512/Admin-icon.png',
'http://icons.iconarchive.com/icons/iconka/buddy/128/airhostess-woman-icon.png',
'http://icons.iconarchive.com/icons/iconka/buddy/128/nurse-girl-icon.png',
],
}
},
// Finish form
_onContinue: function() {
if (this.state.formNumber === 1) {
this.props.onFormCompleted({
name: this.state.userName,
avatar: this.state.avatar,
});
} else {
this.setState({formNumber: this.state.formNumber + 1});
}
},
// Render both forms
if (this.state.formNumber === 0) {
return this._renderNamePick();
} else {
return this._renderAvatarPick();
}
// Form functionality
_onFormCompleted: function(userData) {
this.firebaseRef = new Firebase("https://softbinator-chat.firebaseio.com/users");
var newUserRef = this.firebaseRef.push(userData);
this.setState({
formCompleted: true,
user: {
name: userData.name,
avatar: userData.avatar,
objectId: newUserRef.key(),
}
});
},
// Bring back chat
_renderChat: function() {
return (
<NavigatorIOS
style={styles.container}
initialRoute={{
component: ChatScreen,
title: "Softbinator group chat",
passProps: { user: this.state.user},
}} />
);
},
if (this.state.formCompleted) {
return this._renderChat();
} else {
return this._renderRegisterForm();
}
// Open profile from chat
this.props.navigator.push({
title: "Profile",
component: Profile,
passProps: {
user: message.user,
}
});