Git Product home page Git Product logo

therezacuet / motion-tab-bar Goto Github PK

View Code? Open in Web Editor NEW
283.0 5.0 73.0 9.66 MB

A beautiful animated flutter widget package library. The tab bar will attempt to use your current theme out of the box, however you may want to theme it.

License: MIT License

Dart 100.00%
widget flutter-apps flutter flutter-package flutter-widget flutter-plugin flutter-ui flutter-material flutter-demo bottomnavigationview

motion-tab-bar's Introduction

Motion Tab Bar compatible with Flutter 3 and RTL support

pub package likes popularity pub points

A beautiful animated widget for your Flutter apps

MotionTabBar Gif

Without Badge With Badge
MotionTabBar Gif MotionTabBar Gif

Getting Started

Add the plugin:

dependencies:
  motion_tab_bar: ^2.0.4

Basic Usage

Use default TabController or MotionTabBarController:

  // TabController _tabController;
  MotionTabBarController? _motionTabBarController;

  @override
  void initState() {
    super.initState();
    
    //// Use normal tab controller
    // _tabController = TabController(
    //   initialIndex: 1,
    //   length: 4,
    //   vsync: this,
    // );

    //// use "MotionTabBarController" to replace with "TabController", if you need to programmatically change the tab
    _motionTabBarController = MotionTabBarController(
      initialIndex: 1,
      length: 4,
      vsync: this,
    );
  }

  @override
  void dispose() {
    super.dispose();

    // _tabController.dispose();
    _motionTabBarController!.dispose();
  }

Add Motion Tab Bar to Scaffold bottomNavigationBar:

  bottomNavigationBar: MotionTabBar(
    controller: _motionTabBarController, // ADD THIS if you need to change your tab programmatically
    initialSelectedTab: "Home",
    labels: const ["Dashboard", "Home", "Profile", "Settings"],
    icons: const [Icons.dashboard, Icons.home, Icons.people_alt, Icons.settings],

    // optional badges, length must be same with labels
    badges: [
      // Default Motion Badge Widget
      const MotionBadgeWidget(
        text: '10+',
        textColor: Colors.white, // optional, default to Colors.white
        color: Colors.red, // optional, default to Colors.red
        size: 18, // optional, default to 18
      ),

      // custom badge Widget
      Container(
        color: Colors.black,
        padding: const EdgeInsets.all(2),
        child: const Text(
          '11',
          style: TextStyle(
            fontSize: 14,
            color: Colors.white,
          ),
        ),
      ),

      // allow null
      null,

      // Default Motion Badge Widget with indicator only
      const MotionBadgeWidget(
        isIndicator: true,
        color: Colors.blue, // optional, default to Colors.red
        size: 5, // optional, default to 5,
        show: true, // true / false
      ),
    ],
    tabSize: 50,
    tabBarHeight: 55,
    textStyle: const TextStyle(
      fontSize: 12,
      color: Colors.black,
      fontWeight: FontWeight.w500,
    ),
    tabIconColor: Colors.blue[600],
    tabIconSize: 28.0,
    tabIconSelectedSize: 26.0,
    tabSelectedColor: Colors.blue[900],
    tabIconSelectedColor: Colors.white,
    tabBarColor: Colors.white,
    onTabItemSelected: (int value) {
      setState(() {
        // _tabController!.index = value;
        _motionTabBarController!.index = value;
      });
    },
  ),

add TabBarView to Scaffold body

  body: TabBarView(
    physics: NeverScrollableScrollPhysics(), // swipe navigation handling is not supported
    // controller: _tabController,
    controller: _motionTabBarController,
    children: <Widget>[
      const Center(
        child: Text("Dashboard"),
      ),
      const Center(
        child: Text("Home"),
      ),
      const Center(
        child: Text("Profile"),
      ),
      const Center(
        child: Text("Settings"),
      ),
    ],
  ),

to change tabs programmatically

...

ElevatedButton(
  // set MotionTabBarController index to new tab index
  onPressed: () => _motionTabBarController.index = 0,
  child: const Text('Dashboard Page'),
),
ElevatedButton(
  // set MotionTabBarController index to new tab index
  onPressed: () => _motionTabBarController.index = 1,
  child: const Text('Home Page'),
),

...

Catch me up on LinkedIn @Rezaul Islam

πŸ’™ to CodeπŸ‘¨πŸ½β€πŸ’» Flutter Expert β€’ Dart Kotlin Swift Node Js β€’ Android β€’ Full Stack Developer

motion-tab-bar's People

Contributors

alexbolot avatar therezacuet 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

motion-tab-bar's Issues

bug in Flutter 3.16.3

Flutter 3.16.3 β€’ channel stable β€’ https://github.com/flutter/flutter.git
Framework β€’ revision b0366e0a3f (4 weeks ago) β€’ 2023-12-05 19:46:39 -0800
Engine β€’ revision 54a7145303
Tools β€’ Dart 3.2.3 β€’ DevTools 2.28.4

demo project can not run

animateTo not working

animateTo of the tabcontroller does not trigger the tab bar animation. The screen however does get updated

Bar background color?

Any chance that we can set the bar background color? I have done my own "dark mode" and need to be able to set backgroundcolor: _myActiveBackgroundColor (as an example).

Not using safe area on iphone with bottom handel

Using the simple example i implemented Motion tab bar on an iphone with bottom handle bar line iphone X and it is observed that there is not much padding between the bottom handle and the tab title.

Screenshot 2020-07-09 at 11 50 46 PM

And when MotionTabBar is wrapped inside SafeArea or BottomAppBar widget it seems that the whole tab bar breaks

Screenshot 2020-07-09 at 11 55 09 PM

Page transition activate initState of in-between pages

The current tab is 1, if i want to move to 5th tab, if tab3 and tab4 have initState function, during the transition from tab1 to tab5, it activate the initState function of tab3 and tab4. This cause some issue. Is there any way to disable it.
Thank you.

Can not set active tab.

Why can't I set an active index myself.
I want to move back to home screen when I press back button on mobile device but there is no option to set active index by myself.
Looking forward for your replay.

example bug

example bug
example project cannot run
example project cannot run
example project cannot run
example project cannot run
example project cannot run

animateTo isn't working

I'm using the following code to change to displayed tab on swipe-right or swipe-left via code. Please note the _tabController.animateTo:

        body: GestureDetector(
          onHorizontalDragEnd: (drawEndDetails) {
            print(drawEndDetails);
            if (drawEndDetails.primaryVelocity > 0.0 && _tabController.index > 0) {
              setState(() => _tabController.animateTo(_tabController.index - 1));
            } else if (drawEndDetails.primaryVelocity < 0.0 && _tabController.index < _labels.length - 1) {
              setState(() => _tabController.animateTo(_tabController.index + 1));
            }
          },
          child: MotionTabBarView(
            controller: _tabController,
            children: [
              ContactCreateHistory(encounter: widget._encounter),
              ContactCreateContacts(encounter: widget._encounter),
              ContactCreateMaps(encounter: widget._encounter),
              ContactCreateFormular(encounter: widget._encounter),
            ],
          ),
        ),

The displayed content is updated correctly, but not the tab-display. it is not animating nor updated.

Before swipe, on the first tab:
image
After swipe, tab-content updated to second tab, should be focusing red circled tab:
image

Am I doing something wrong?

demo error

======== Exception caught by widgets library =======================================================
The following LateError was thrown building MotionTabBar(dirty, dependencies: [Directionality], state: _MotionTabBarState#0dda9):
LateInitializationError: Field 'labels' has not been initialized.

Switch TAB via Function

Hi,

Is it possible to change TAB via function?

For example, I click a button, and change the TAB as if I clicked it.

Thanks.

Contributing

Hi Rezaul !
I've been using this repository for a flutter project, and I had to make changes to the MotionTabBar class you provide. I think it could be interesting that I share with you my modifications through a Pull Request, if you're interested in accepting contribution to you repository πŸ˜ƒ

If it's OK for you, let me know πŸ˜ƒ

Alexandre

Null Safety

Hi!

Thanks for this package, do you plan to migrate it to null safety?

Thanks
Best regards

Abandoned package?

Has this package been abandoned? There is zero replies from the developer.

Padding needed on iOS, overlapping occurs

Hi,

Padding is needed on iOS. As you can see on the attached image, the lower iOS "Action Bar" overlaps the navigation texts. Maybe some additional padding could be added?
IMG_5283

initialIndex of the bottomNavigationBar?

Hi dev, the initial tab is still fixed to index 1 in view even the initialIndex of _tabController is set to 0.

  @override
  void initState() {
    super.initState();
    _tabController = new MotionTabController(initialIndex: 0,vsync: this);
  }

How to deactivate bulge animation

I have four buttons in Bottom Nav bar, I want it to be deactivated and be plain when it is not in those specific pages. Any way I can do it now?

issues in animation

i have problem in animation
recive a error
Capture
But shifts are made between pages

Hide tab Bar on Scroll

How to auto-hide tab bar on the scroll?
Also, the Tab option is limited to 3, it would be great if we can make it dynamic base MotionTabBar Label's count.

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.