GithubHelp home page GithubHelp logo

alex-melnyk / react-native-multibar Goto Github PK

View Code? Open in Web Editor NEW
314.0 9.0 56.0 4.14 MB

React Native MultiBar

License: BSD 3-Clause "New" or "Revised" License

JavaScript 8.90% TypeScript 91.10%
react-native tabbar

react-native-multibar's Introduction

React Native MultiBar

This module provides the functionality to implement extended actions by adding a custom tab bar with an advanced button.

[![NPM Version][npm-image]][npm-url] [npm-image]: https://img.shields.io/npm/v/react-native-multibar.svg [npm-url]: https://www.npmjs.com/package/react-native-multibar

Preview

Example

There is an example how to use the react-native-multibar Tabber Expo or Tabber RN

Install

yarn add react-native-multibar

or

npm i react-native-multibar

Usage

export default function App() {
  const Tab = React.useRef<ReturnType<typeof createBottomTabNavigator>>(createBottomTabNavigator()).current;

  return (
    <NavigationContainer>
      <MultiBarProvider
        overlayProps={{
          expandingMode: 'staging'
        }}
        data={[
          ({ params }) => (
            <TouchIcon
              name="chevron-left"
              color="#E24E1B"
              size={20}
              onPress={() => {
                if (params.canGoBack()) {
                  params.goBack();
                }
              }}
            />
          ),
          ({ params }) => (
            <TouchIcon
              name="flag"
              color="#E24E1B"
              size={20}
              onPress={() => {
              }}
            />
          ),
          ({ params }) => (
            <TouchIcon
              name="headphones"
              color="#E24E1B"
              size={20}
              onPress={() => {
              }}
            />
          ),
          ({ params }) => (
            <TouchIcon
              name="heart"
              color="#E24E1B"
              size={20}
              onPress={() => {
              }}
            />
          ),
          ({ params }) => (
            <TouchIcon
              name="star"
              color="#E24E1B"
              size={20}
              onPress={() => {
              }}
            />
          ),
          ({ params }) => (
            <TouchIcon
              name="music"
              color="#E24E1B"
              size={20}
              onPress={() => {
              }}
            />
          ),
        ]}
        initialExtrasVisible={false}
      >
        <Tab.Navigator
          tabBar={(props) => (
            <BottomTabBarWrapper params={props.navigation}>
              <BottomTabBar {...props} />
            </BottomTabBarWrapper>
          )}
        >
          <Tab.Screen
            name="Home"
            component={DemoScreen}
            options={{
              tabBarIcon: ({ color, size }) => (
                <MaterialIcons
                  name="home"
                  style={{
                    fontSize: size,
                    color: color
                  }}
                />
              )
            }}
          />
          <Tab.Screen
            name="Likes"
            component={DemoScreen}
            options={{
              tabBarIcon: ({ color, size }) => (
                <MaterialIcons
                  name="star"
                  style={{
                    fontSize: size,
                    color: color
                  }}
                />
              )
            }}
          />
          <Tab.Screen
            name="Center"
            component={DemoScreen}
            options={{
              tabBarLabel: '',
              tabBarButton: () => (
                <MultiBarButton
                  style={{
                    backgroundColor: '#E24E1B'
                  }}
                >
                  <MaterialIcons
                    name="add"
                    style={{
                      fontSize: 32,
                      color: '#EDF2F4'
                    }}
                  />
                </MultiBarButton>
              )
            }}
          />
          <Tab.Screen
            name="Posts"
            component={DemoScreen}
            options={{
              tabBarIcon: ({ color, size }) => (
                <MaterialIcons
                  name="message"
                  style={{
                    fontSize: size,
                    color: color
                  }}
                />
              )
            }}
          />
          <Tab.Screen
            name="Settings"
            component={DemoScreen}
            options={{
              tabBarIcon: ({ color, size }) => (
                <MaterialIcons
                  name="settings"
                  style={{
                    fontSize: size,
                    color: color
                  }}
                />
              )
            }}
          />
        </Tab.Navigator>
      </MultiBarProvider>
    </NavigationContainer>
  );
}

License (MIT)

Copyright 2021 Melnyk Aleksandr Viktorovych

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

react-native-multibar's People

Contributors

alex-melnyk avatar dependabot[bot] avatar mhretab avatar oihso avatar rafaelpadovani avatar yajanarao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-multibar's Issues

Animated: `useNativeDriver` was not specified.

I'm getting " Animated: useNativeDriver was not specified. This is a required option and must be explicitly set to true or false" as a warning. How to remove that?

Is there any prop to set it explicitly?

View beneath Navigation Bar

I'm using react-native-multibar in my React Native project and I had noticed that if I have a ScrollView in a component being displayed, it goes underneath the Navigation Bar. I thought it was an issue with react-navigation but as I was reproducing it, I had determined it's probably caused by react-native-multibar.

Here's the issue I created in react-navigation react-navigation/react-navigation#8327
Here's the snack of it being reproduced https://snack.expo.io/@destinybonavita/disrespectful-french-fries

Routes.TabsScreenName

I am getting: TypeError: undefined is not an object (evaluating 'routeConfigs[initialRouteName].params').

How am I setting up 'Routes' to define them?

Here is my code:

import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { createSwitchNavigator, createStackNavigator, createAppContainer, createBottomTabNavigator } from 'react-navigation';
import { Icon } from 'react-native-material-ui';
import {FluidNavigator, Transition} from 'react-navigation-fluid-transitions';

import Home from './pages/Home';
import Profile from './pages/Profile';
import Offers from './pages/Offers';
import Login from './pages/Login';
import Register from './pages/Register';
import AuthLoading from './pages/AuthLoading';
import MobileReg from "./pages/MobileReg";
import MobileSignIn from "./pages/MobileSignIn";
import AccountPage from "./pages/AccountPage";
import Locations from "./pages/Locations";
import {MultiBar, MultiBarToggle} from "react-native-multibar";

const AuthStack = FluidNavigator({
  Login: { screen: Login },
  Register: { screen: Register },
});

const BottomTab = createBottomTabNavigator({
  [Routes.TabsHome]: {
    screen: Home,
    navigationOptions: () => ({
      tabBarIcon: ({tintColor}) => (
          <Icon
              name="home"
              color={tintColor}
              size={24}
          />
      )
    })
  },
  [Routes.TabsLocations]: {
    screen: Locations,
    navigationOptions: () => ({
      tabBarIcon: ({tintColor}) => (
          <Icon
              name="heart"
              color={tintColor}
              size={24}
          />
      )
    })
  },
  MultiBar: {
    screen: () => null,
    navigationOptions: ({navigation}) => ({
      tabBarIcon: () => (
          <MultiBarToggle
              navigation={navigation}
              actionSize={30}
              routes={[
                {
                  routeName: 'Home',
                  color: '#FF8360',
                  icon: (
                      <Icon
                          name="rocket"
                          color="#333333"
                          size={15}
                      />
                  )
                },
                {
                  routeName: 'SignIn',
                  color: '#E8E288',
                  icon: (
                      <Icon
                          name="dashboard"
                          color="#333333"
                          size={15}
                      />
                  )
                },
                {
                  routeName: 'MobileStart',
                  color: '#7DCE82',
                  icon: (
                      <Icon
                          name="gears"
                          color="#333333"
                          size={15}
                      />
                  )
                },
              ]}
              icon={(
                  <Icon
                      name="plus"
                      color="#FFFFFF"
                      size={24}
                  />
              )}
          />
      )
    }),
    params: {
      navigationDisabled: true
    }
  },
  [Routes.TabsProfile]: {
    screen: Profile,
    navigationOptions: () => ({
      tabBarIcon: ({tintColor}) => (
          <Icon
              name="lock"
              color={tintColor}
              size={24}
          />
      )
    })
  },
  [Routes.TabsProfile]: {
    screen: Profile,
    navigationOptions: () => ({
      tabBarIcon: ({tintColor}) => (
          <Icon
              name="user"
              color={tintColor}
              size={24}
          />
      )
    })
  }
}, {
  tabBarComponent: MultiBar,
  tabBarOptions: {
    showLabel: false,
    activeTintColor: '#F8F8F8',
    inactiveTintColor: '#586589',
    style: {
      backgroundColor: '#171F33'
    },
    tabStyle: {}
  }
});
// const BottomTab = createBottomTabNavigator({
//     Home: { screen: Home },
//     Profile: { screen: Profile },
//     Offers: { screen: Offers },
//   },
//   {
//     defaultNavigationOptions: ({ navigation }) => ({
//       tabBarIcon: ({ focused, horizontal, tintColor }) => {
//         const { routeName } = navigation.state;
//         let IconName;
//         if (routeName === 'Home') {
//           IconName = 'home'
//         } else if (routeName === 'Profile') {
//           IconName = 'person'
//         } else {
//           IconName = 'settings'
//         }
//         return (
//           <Icon name={IconName} />
//         );
//       }
//     }),
//     tabBarOptions: {
//       activeTintColor: 'tomato',
//       inactiveTintColor: 'gray',
//     },
//   }
// );

const Nav = createAppContainer(FluidNavigator(
  {
    AuthLoading: AuthLoading,
    App: BottomTab,
    Auth: AuthStack,

      MobileStart: MobileReg,
      SignIn: MobileSignIn,
      Profile: AccountPage,


  },
  {
      initialRouteName: 'Home'
  }
));

class Navigation extends Component {
  render() {
    return (
      <Nav />
    );
  }
}

export default Navigation;

Make Another element untouchable except the showed button

i'm following your tutorial from itnext.io its work very well, but i want another element except 3 showed button(rocket, home, archive) is untouchable so there's no option to click another place except thats 3 button or outside it to hide them again.

Show Modal on Tab Item Press

I'm using useState() to show and hide a modal with a multi bar icon, but when the modal is showing, the "wheel" of icons is not going away.

React Navigation 3.11.1

Hi I just start to use your version because my own implementation doesn't work on android only.
I cannot click on the small icon nothing happen.

So I just try your library but same thing happen. I think it's a rect navigation version issue.

One other question: Is it possible with your library to make a navigation on the toggle click ?

thanks

Is it possible to use the tab bar without renderScene?

I’m using next.js and don’t want to take over Navigation. I like how next does it, but with the default react-native tab bars, it requires a tense scene and handles navigation. Can I somehow use just three tab bar and manually maintain / set routing?

typescript

All imports in import declaration are unused.ts(6192)
Could not find a declaration file for module 'react-native-multibar'. 'c:/Users/nashf/github/RestaurantApp/node_modules/react-native-multibar/index.js' implicitly has an 'any' type.
Try npm install @types/react-native-multibar if it exists or add a new declaration (.d.ts) file containing declare module 'react-native-multibar';ts(7016)

This doesn't seem to work nice with typescript. Please correct / advise.

MultiTab background color and keep bottom bar when click in hidden buttons

Hi there,

I sucessufly implemented the real-native-multibar with the examples provided.

I would like to know if is possible to change the color of the round add button?

Like these:

PREVIEW_COLLAPSED copy

Another question is if is possible to keep the bar when I click the other hidden buttons. I see that if I click I go to a page without return. I know that I can create a "back"button, but I would like to keep that tab to be able to click and go to others views without clicking the back button.

Thanks in advance!

setExtrasVisible can't change via context

When we try to update context setExtrasVisible as true or false its not trigger the multibar open icon

its response as extrasVisible: {"data": [[Function anonymous], [Function anonymous], [Function anonymous], [Function anonymous]], "extrasVisible": false, "overlayProps": {"expandingMode": "staging", "iconSize": 50, "overlayRadius": 100}, "setExtrasVisible": [Function bound dispatchAction]}

class Home extends PureComponent {
static contextType = HeaderHeightContext;
static contextType = MultiBarContext;
closeBarBtn=()=>{
this.context.setExtrasVisible(false);
}

}

Bottom Navigator Enclosed with

<MultiBarProvider
overlayProps={{
expandingMode: 'staging',
iconSize: 50,
overlayRadius: 100,
}}
data={[
({params}) => (
<TouchIcon
name="create"
color="royalblue"
size={40}
onPress={() => {
return RootNavigation.navigate('Homes', {
screen: 'screen1',
});
}}
/>
), ({params}) => (
<TouchIcon
name="create"
color="royalblue"
size={40}
onPress={() => {
return RootNavigation.navigate('Homes', {
screen: 'screen2',
});
}}
/>
),
]}
iconSize={40}
overlayRadius={100}
initialExtrasVisible={false}>

<Tab.Navigator>
.....
</Tab.Navigator>

Android doesn't fire actions

Hi Alex,

Firstly, thank you for that brilliant job. I am using Expo with last version of navigation and my android test phone is not firing actions. It seems that navigation bar bottom has no overflow enabled. iOS works perfectly!

this package itself specifies a `main` module field that could not be resolved

While trying to resolve module react-native-multibar from file, the package /node_modules/react-native-multibar/package.jsonwas successfully found. However, this package itself specifies amain module field that could not be resolved (/node_modules/react-native-multibar/dist/index.js`. Indeed, none of these files exist.

using latest version i.e. 1.1.5
Expo SDK version: 42

Check the render method of `MultiBar`.

Hello Alex,

first thanks for open sourcing your plugin.

I unfortunately have trouble using it.

Here is my configuration:

import React from 'react';
import { Platform } from 'react-native';
import { createBottomTabNavigator, createStackNavigator } from 'react-navigation';

import TabBarIcon from '../components/TabBarIcon';
import HomeScreen from '../screens/HomeScreen';
import LinksScreen from '../screens/LinksScreen';
import SettingsScreen from '../screens/SettingsScreen';
import { MultiBar, MultiBarToggle } from 'react-native-multibar';
import { Icon } from "expo";

const HomeStack = createStackNavigator({
    Home: HomeScreen,
});

HomeStack.navigationOptions = {
    tabBarLabel: 'Home',
    tabBarIcon: ({focused}) => (
        <TabBarIcon
            focused={focused}
            name={
                Platform.OS === 'ios'
                    ? `ios-information-circle${focused ? '' : '-outline'}`
                    : 'md-information-circle'
            }
        />
    ),
};

const TheorysStack = createStackNavigator({
    Links: LinksScreen,
});

TheorysStack.navigationOptions = {
    tabBarLabel: 'Links',
    tabBarIcon: ({focused}) => (
        <TabBarIcon
            focused={focused}
            name={Platform.OS === 'ios' ? 'ios-link' : 'md-link'}
        />
    ),
};

const LinksStack = createStackNavigator({
    Links: LinksScreen,
});

LinksStack.navigationOptions = {
    tabBarLabel: 'Links',
    tabBarIcon: ({focused}) => (
        <TabBarIcon
            focused={focused}
            name={Platform.OS === 'ios' ? 'ios-link' : 'md-link'}
        />
    ),
};

const HelpStack = createStackNavigator({
    Settings: SettingsScreen,
});

HelpStack.navigationOptions = {
    tabBarLabel: 'Settings',
    tabBarIcon: ({focused}) => (
        <TabBarIcon
            focused={focused}
            name={Platform.OS === 'ios' ? 'ios-options' : 'md-options'}
        />
    ),
};

const SettingsStack = createStackNavigator({
    Settings: SettingsScreen,
});

SettingsStack.navigationOptions = {
    tabBarLabel: 'Settings',
    tabBarIcon: ({focused}) => (
        <TabBarIcon
            focused={focused}
            name={Platform.OS === 'ios' ? 'ios-options' : 'md-options'}
        />
    ),
};

const MultiBarStack = {
    screen: () => null,
    navigationOptions: ({navigation}) => ({
        tabBarIcon: () => (
            <MultiBarToggle
                navigation={navigation}
                actionSize={30}
                routes={[
                    {
                        routeName: 'OTHER_SCREEN',
                        color: '#FF8360',
                        icon: (
                            <Icon
                                name="rocket"
                                color="#333333"
                                size={15}
                            />
                        )
                    },
                    {
                        routeName: 'OTHER_SCREEN',
                        color: '#E8E288',
                        icon: (
                            <Icon
                                name="dashboard"
                                color="#333333"
                                size={15}
                            />
                        )
                    },
                    {
                        routeName: 'OTHER_SCREEN',
                        color: '#7DCE82',
                        icon: (
                            <Icon
                                name="gears"
                                color="#333333"
                                size={15}
                            />
                        )
                    },
                ]}
                icon={(
                    <Icon
                        name="plus"
                        color="#FFFFFF"
                        size={24}
                    />
                )}
            />
        )
    }),
    params: {
        navigationDisabled: true
    }
};

export default createBottomTabNavigator({
    HomeStack,
    TheorysStack,
    MultiBarStack,
    HelpStack,
    SettingsStack
}, {
    tabBarComponent: MultiBar,
    tabBarOptions: {
        showLabel: false,
        activeTintColor: '#F8F8F8',
        inactiveTintColor: '#586589',
        style: {
            backgroundColor: '#171F33'
        },
        tabStyle: {}
    }
});

It says:

Invariant Violation: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of MultiBar.

Do you have any idea, what is wrong?

Thanks beforehand and regards,

Aldous

Cannot read property 'index' of undefined

<Tabs.Navigator
  // tabBar={MultiBar}
  tabBarOptions={{
    showLabel: false,
    activeTintColor: '#F8F8F8',
    inactiveTintColor: '#586589',
    style: {
      backgroundColor: '#171F33'
    },
    tabStyle: {}
  }}
>

I get this error whenever i uncomment the line with tabBar={MultiBar}

Cannot read property 'index' of undefined

  • node_modules/react-native-multibar/src/components/MultiBar.js:11:100 in MultiBar
  • node_modules/@react-navigation/bottom-tabs/src/views/BottomTabView.tsx:83:5 in renderTabBar
  • ... 9 more stack frames from framework internals

Warning: %s: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI., RootErrorBoundary

  • node_modules/expo/build/logs/LogSerialization.js:166:14 in _captureConsoleStackTrace
  • node_modules/expo/build/logs/LogSerialization.js:41:24 in serializeLogDataAsync
  • ... 9 more stack frames from framework internals

No rotation of the center icon

Would it be possible to add a switch to the rotation of the main button if you will add a different icon, it looks very bad.
Screenshot_20190604-141348_Expo 1

Android version 7 not working

Hello,
this is good library but in android version 7.0 its not working. the toggle button is clipped inside the parent bottom bar

issue

icon on not acction (routeName screen not showing)

App Content covered by the multibar

Hi,
I am using react-native-multibar in on of my projects and I am facing an issue that the multibar is covering up my app content which is a flatlist and the end data is not showing completely.
2
1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.