Skip to content

Instantly share code, notes, and snippets.

@imamjnn
Last active February 12, 2018 04:05
Show Gist options
  • Save imamjnn/1aefd587c0092b97e6370f86751250e3 to your computer and use it in GitHub Desktop.
Save imamjnn/1aefd587c0092b97e6370f86751250e3 to your computer and use it in GitHub Desktop.
import { AppRegistry } from 'react-native';
import App from './src/app';

AppRegistry.registerComponent('testingApp', () => App);
  • Create file app.js in src
import { Navigation } from 'react-native-navigation';

import { registerScreens } from './screens';

registerScreens(); // this is where you register all of your app's screens

// start the app
Navigation.startTabBasedApp({
  tabs: [
    {
      label: 'One',
      screen: 'testingApp.FirstTabScreen', // this is a registered name for a screen
      icon: require('./img/one.png'),
      selectedIcon: require('./img/one_selected.png'), // iOS only
      title: 'Screen One'
    },
    {
      label: 'Two',
      screen: 'testingApp.SecondTabScreen',
      icon: require('./img/two.png'),
      selectedIcon: require('./img/two_selected.png'), // iOS only
      title: 'Screen Two'
    }
  ],
  animationType: 'fade'
});
  • Create screens FirstTabScreen.js SecondTabScreen.js in screens
  • Then create index.js in same directory
import { Navigation } from 'react-native-navigation';

import { registerScreens } from './screens';

registerScreens(); // this is where you register all of your app's screens

// start the app
Navigation.startTabBasedApp({
  tabs: [
    {
      label: 'One',
      screen: 'testingApp.FirstTabScreen', // this is a registered name for a screen
      icon: require('./img/one.png'),
      selectedIcon: require('./img/one_selected.png'), // iOS only
      title: 'Screen One'
    },
    {
      label: 'Two',
      screen: 'testingApp.SecondTabScreen',
      icon: require('./img/two.png'),
      selectedIcon: require('./img/two_selected.png'), // iOS only
      title: 'Screen Two'
    }
  ],
  animationType: 'fade'
});

Additional, how to get a splash screen

  • Modify MainActivity.java
package com.testingapp;

import android.widget.LinearLayout;
import android.graphics.Color;
import android.widget.TextView;
import android.view.Gravity;
import android.util.TypedValue;
import com.reactnativenavigation.controllers.SplashActivity;

public class MainActivity extends SplashActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    public LinearLayout createSplashLayout() {
        LinearLayout view = new LinearLayout(this);
        TextView textView = new TextView(this);

        view.setBackgroundColor(Color.parseColor("#ffffff"));
        view.setGravity(Gravity.CENTER);

        textView.setTextColor(Color.parseColor("#000000"));
        textView.setText("Testing App");
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 40);

        view.addView(textView);
        return view;
    }
    
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment