2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ReactNative > createMaterialBottomTabNavigatorの使い方

Posted at

createMaterialBottomTabNavigatorの使い方

公式ページを読んでもさっぱりわからなかったのでメモ

createMaterialBottomTabNavigator · React Navigation

↓のようなマテリアルなボトム・バー
Kobito.QxbyFT.png

以下に使い方サンプルあり
Snack

使い方
createMaterialBottomTabNavigatorを作って、
App.jsで使うだけ。

なんてステキ仕様

createBottomTabNavigator · React Navigation の方はRedux-Offlineでバグがありましたが、createMaterialBottomTabNavigatorはちゃんと動きました。

App.js

App.js
import React, { Component } from 'react';
import MyTabs from 'Navigation';

export default class App extends Component {
  render() {
    return (
      <MyTabs />
    );
  }
}

Navigation.js

Navigation.js
import React, { Component } from 'react';
import { Platform } from 'react-native';
import { createMaterialBottomTabNavigator } from 'react-navigation-material-bottom-tabs';
import Icon from 'react-native-vector-icons/Ionicons';

import HomeScreen from 'HomeScreen';
import ProfileScreen from 'ProfileScreen';
import SettingsScreen from 'SettingsScreen';

export default createMaterialBottomTabNavigator(
  {
    Home: {
      screen: HomeScreen,
      navigationOptions: {
        tabBarLabel: 'Home',
        tabBarColor: '#842655',
        tabBarIcon: ({ tintColor, focused }) => (
          <Icon size={25} name={ Platform.OS === 'ios' ? (focused ? 'ios-home' : 'ios-home-outline') : 'md-home' } style={{ color: tintColor }} />
        )
      }
    },
    Profile: {
      screen: ProfileScreen,
      navigationOptions: {
        tabBarLabel: 'Profile',
        tabBarColor: '#1e1e1d',
        tabBarIcon: ({ tintColor, focused }) => (
          <Icon size={25} name={ Platform.OS === 'ios' ? (focused ? 'ios-contact' : 'ios-contact-outline') : 'md-contact' } style={{ color: tintColor }} />
        )
      }
    },
    Settings: {
      screen: SettingsScreen,
      navigationOptions: {
        tabBarLabel: 'Settings',
        tabBarColor: '#ff3838',
        tabBarIcon: ({ tintColor, focused }) => (
          <Icon size={25} name={ Platform.OS === 'ios' ? (focused ? 'ios-settings' : 'ios-settings-outline') : 'md-settings' } style={{ color: tintColor }} />
        )
      }
    }
  },
  {
    shifting: true,
    activeTintColor: 'white',
    inactiveTintColor: '#ddd',
  }
);
2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?