Instructions:
- Checkout the commit (the last one if there's more than one), you can use
git checkout -f
- Follow the steps
- Compare with the next commit to see how well you did
7780834 π¨ App bootstrapping
- Add a TextInput component
- Save the value to the state
- Show how to easily show the state with JSON.stringify
09a5bad π¨ Create some basic components
- Add user and password to the state
- Create two inputs for them
- Add icons from Expo icons
- Use colors from This palette
2b51f50 π Add username and password fields, with icons
- Add a Button that logs the user and password onPress
- Group the header as a view
- Group the inputs as a view
- Create a row for each input
- Create a column with appropriate flex values
1d48086 π
π» Layout of the Login screen
- Add a KeyboardAvoidingView with behavior 'padding'
- Fix the bottom margin for the Button
c4513ab πΉ Avoid Keyboard on the View
- Move the screen to js/screens/Login
ccefa77 π Move screen to a separate component
-
yarn add react-navigation
-
Create a StackNavigator and render it in App
-
Create js/screens/Tweets
-
Add the screen to the Navigator
-
Navigate when pressing the button using navigate
Estimated elapsed time: 1 hour
ae571fc β΄ Add react-navigation
155e40e β΄ Create the base stack navigator, with just one screen
afb123d πΆ Add empty tweets screen
5c2cd66 β΄ Navigate to the Tweets screen
yarn add firebase
- Create js/connectors/Firebase
- Copy code from the expo docs
- Copy the credentials from the Firebase Console
e2bd996 π₯ Add Firebase
48c8dd0 π₯ Create Firebase connector
- Add Firebase web sign in
- Navigate only if it worked
7296302 π₯ Basic Firebase login
- Set default user/password on the state
d34df66 β‘οΈ Set default user/password for faster development during demo
- In componentWillMount add listeners to /tweets and /users
- Firebase web read/write
firebase
.database()
.ref("users")
.on("value", snapshot => {
this.setState({ users: snapshot.val() });
});
firebase
.database()
.ref("tweets")
.on("value", snapshot => {
this.setState({ tweets: snapshot.val() });
});
432f34c π Watch users and tweets from Firebase
d37404f β¨ Add Tweet component
{
Object.keys(this.state.tweets).map(tweetKey => (
<Tweet
key={tweetKey}
tweet={this.state.tweets[tweetKey].text}
user={this.state.users[this.state.tweets[tweetKey].uid]}
/>
));
}
407e464 β¨ Show tweet list
a420910 β¨ Add Header component
e70a138 β¨ Render Header component
e62ce76 β¬οΈ Add margin for the status bar
- Switch the map for a proper FlatList
<FlatList
data={Object.keys(this.state.tweets)
.map(key => ({
...this.state.tweets[key],
key
}))
.reverse()}
renderItem={({ item }) => (
<Tweet tweet={item.text} user={this.state.users[item.uid]} />
)}
/>
f1acd42 π Switch to a FlatList
1ca302a β¨ Create Footer component
d1d172b β¨ Use the Footer component
- Call update on firebase when pressing the icon
- Firebase web read/write
sendTweet() {
if (this.state.tweet.length < 1) return;
// Get a key for a new Tweet.
var newTweetKey = firebase
.database()
.ref()
.child('tweets')
.push().key;
return firebase
.database()
.ref(`/tweets/${newTweetKey}`)
.update({
text: this.state.tweet,
uid: this.props.navigation.state.params.user.uid
});
}
84abff9 βοΈ Add send tweet functionality
5f7b0f6 πΉ Avoid Keyboard on the Tweets View
6cded0e πͺ Clean the footer after sending
Estimated duration: 2 hours