Food Delivery App UI Clone in React Native #1 : Splash Screen Integration

This is the first part of our implementation of the React Native Food Delivery app UI Clone tutorial series. This tutorial series was inspired by the  React native Food Delivery App template which provides an amazing Food Delivery app starter template written in React Native with many delicious features. Hence, anyone can make their own food delivery app for any restaurant with this beautiful food delivery restaurant app template. In any Food Delivery app, there must be the features for menu, food orders, reservations, etc. In this tutorial series, we will try to replicate the UI from the Food Delivery App template. In this part, we are going to implement the splash screen in the React Native app using the latest version of React Native and required plugins.

Overview

In this part, we are going to implement the Splash Screen using the latest version of React Native and plugins. Major steps in this tutorial are going to take place in Xcode as we need to configure the iOS part of the app for displaying the Splash Screen. The idea is to add the required splash screen icons and configure the native iOS app directory in the Xcode. We are going to make use of the react-native-splash-screen package in the React Native part as well as the iOS part to display the splash screen transition. Most of the work takes place in Xcode for configuring the splash screen and only some minor part is for the react-native side.

If we realize, there is already a default splash screen from react native project. But we are going to implement our own splash screen with our own logo icon for our React Native Food Delivery App App UI clone project. For now, we have just put some text on the splash screen which is displayed in the emulator simulation below:

Animated GIF

 

Downloading Required Logo

For this tutorial series, we have the Scooter logo icon which we are going to integrate into the splash screen. The download link for the logo is provided below:

Scooter free vector icons designed by Freepik

Download this free icon in SVG, PSD, PNG, EPS format or as webfonts. Flaticon, the largest database of free vector icons.

 

Installing Splash Screen package

Here, we are going to install the react-native-splash-screen package into our project. The react-native-splash-screen package provides us with a splash screen API for react-native which can programmatically hide and show the splash screen. This package works for both iOS as well as Android platforms. All the configuration for the React Native part as well as the native part is provided in the documentation. Now, to install the package, we need to use the following command:

>>>yarn add react-native-splash-screen

Now, we need to link this package if it is not linked automatically. If the installation does not work, we can check the documentation for manual configuration.

Now, we need to update the pod. For that, we need to go to the iOS folder and run the following commands:

>>>cd ios 

>>>pod update

 

Configuring Splash Screen in Xcode

In this step, we are going to configure the app in Xcode in order to integrate the splash screen. First,  we need to open our project on Xcode as shown in the screenshot below:

Next, we need to add our app logo icon to the ‘Images.xcassets’ folder. For that, we need to navigation to ‘Images.xcassets’ folder and create New Image Set as shown in the screenshot below:

Then, we need to rename the new image set as SplashScreen. Next, we need to add our app logo images to the SplashScreen image set as shown in the screenshot below:

 

Now, we need to open ‘LaunchScreen.xib’ file where we can find our default splash screen as shown in the screenshot below:

As we can see, all the default setups are shown in the right configuration panel of Xcode.

Now,  we need to remove the default text and navigate to the ‘View” tab of the panel.  Here, we are going to change the background color to brown as shown in the screenshot below:

Next, we need to add our app logo by clicking on the Image View button in the image as shown in the screenshot below:

Now, we will have the UIImageView as shown in the screenshot below:

Next, we need to add the SplashScreen image set to the Image View tab of the right panel. The SplashScreen image is to be added to the Image field as shown in the screenshot below:

Hence, we will get our app logo into our UIImageView. Now, we can shape the size of the logo from the above screen. Therefore, we have successfully completed the styling of the splash screen.

Next, we need to add the react-native-splash-screen package to the Xcode.

 

Activating splash screen in Xcode

Here, we are going to integrate the react-native-splash-screen into our Xcode ios project. For that, we need to go to:

node_modules ➜ react-native-splash-screen ➜ ios

 Then, we need to add SplashScreen.xcodeprojfile to it as shown in the screenshot below:

Next, we need to go to: Build Settings → Search Paths → Header Search Paths of the Xcode and add the following path:

$(SRCROOT)/../node_modules/react-native-splash-screen/ios

The visual representation of this step is highlighted in the screenshot below:

Lastly, we need to import the react-native-splash-screen package into the Appdelegate.m file and activate the splash screen. Here, the package is imported as RNSplashScreen.h“. Now, to trigger the splash screen, we need to add [RNSplashScreen show] at the position as shown in the code snippet screenshot below:

Now, if we re-run the project in our iOS emulator, we will get the following result:

 

Animated GIF

As we can see, the splash screen appears when we launch the app. But, it stays there and does not hide automatically to display the app screen. So, our next step is to hide the splash screen when the react native app screen is mounted.

 

Hiding the Splash Screen

In this step, we are going to hide the splash screen after the react native app screen successfully mounts. For that, we need to go back to the App.js file of our React Native project and make use of the react-native-splash-screen package. First, we need to import the react-native-splash-screen package as a SplashScreen module in our App.js file as shown in the code snippet below:

import SplashScreen from 'react-native-splash-screen';

Then, we need to call the hide() function provided by SplashScreen module inside the componentDidMount function as shown in the code snippet below:

export default class App extends React.Component {
  componentDidMount() {
    // do stuff while splash screen is shown
    // After having done stuff (such as async tasks) hide the splash screen
    SplashScreen.hide();
  }

This will help to hide the splash screen as soon as the app screen mounts.

Now, if we re-run our project in the emulator, we will get the following result:

Animated GIF

As we can see, the splash screen appears when we launch the app and then successfully hides after the component is mounted.

Finally, we have successfully completed the integration of the Splash Screen in our implementation of the Food Delivery App UI clone in React Native.

 

Conclusion

This tutorial is the first part of the React Native Food Delivery app UI clone tutorial series. Here, we learned how to add the logo icon as an image set to the required folder in the Xcode in order to integrate the splash screen. Then, we got the step by step guide on how to configure the iOS part in the Xcode in order to display the splash screen. Lastly, we also learned how to make use of the react-native-splash-screen package in both the React Native part as well as the native iOS part in XCode for showing and hiding the splash screen.

Note that the tutorial for the configuration of the splash screen in the Android platform is available in a separate tutorial article. We can follow the steps in that tutorial in other to implement the same splash screen for the Android platform.

Moreover, in the upcoming parts, we will build some cool walkthrough screens that introduce our app to the users.