The Starter App, Part 2: Login screen UI

Matteo Mazzarolo
2 min readOct 2, 2018

--

Welcome to The Starter App, an in-depth tutorial about building mobile apps using React-Native.

This tutorial is also available on GitHub (where you can find the source code) and on my personal website.

Please notice that on Medium the code will be posted as an image (created using carbon.now) because the code block and the gist embedding doesn’t work correctly on mobile.

If you’d like to copy & paste the code I’d suggest reading the article on GitHub or on my personal website instead.

See the The Starter App introduction for further info.

In the previous chapter we completed the setup of the development environment so we can finally focus on coding our app.

In this chapter we’ll create the UI of the login screen, starting from the following mockup:

App mockup

The Button component

The button component is quite often the first component built in a new React-Native project.

We’re not aiming at doing anything fancy here, so let’s start with a simple button that accepts just a label and an onPress prop.

src/components/Button.tsx

The FormTextInput component

Instead of using the raw React Native TextInput we’ll wrap it in our own component.

Creating your own custom version of the components offered by React Native is more often than not a good practice because it leads to an improved UI consistency and simplifies future refactorings.

src/components/FormTextInput.tsx

The login form UI

Now that all our presentational components are ready we can use them to compose our login screen.

src/containers/LoginScreen.tsx

Neat!

That’s it

That’s all for this chapter. In the next one we’ll improve the keyboard support of our login form ⌨️!

--

--