All Projects → KarenKaKa → flutter_appbar

KarenKaKa / flutter_appbar

Licence: other
根据动画写一个带背景图片的TabBar,TabBar分隔符,NestedScrollView+TabBar折叠头部

Programming Languages

dart
5743 projects
objective c
16641 projects - #2 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to flutter appbar

react-native-viewpager-carousel
a flexible viewpager library with carousel functionality
Stars: ✭ 39 (-22%)
Mutual labels:  tabbar
TabBar
📱 TabBar – highly customizable tab bar for your SwiftUI application.
Stars: ✭ 105 (+110%)
Mutual labels:  tabbar
react-native-bubble-tabbar
🧼 Bubble Tab Bar Component for React Native which supports React Navigation V5 and TypeScript
Stars: ✭ 43 (-14%)
Mutual labels:  tabbar
QWTabBarTemplate.xctemplate
自定义模版 快速创建带有导航栏和工具栏的工程
Stars: ✭ 44 (-12%)
Mutual labels:  tabbar
MaterialesqueTabBar
UIViewController featuring a customisable Tab Bar working with a UIPageViewController.
Stars: ✭ 17 (-66%)
Mutual labels:  tabbar
react-native-segment-controller
A react-native segment controller(Tab) for both ios and android.
Stars: ✭ 18 (-64%)
Mutual labels:  tabbar
Motion-Tab-Bar
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.
Stars: ✭ 237 (+374%)
Mutual labels:  tabbar
react-native-smartbar
Maybe this is the best tabbar , support android and ios !
Stars: ✭ 29 (-42%)
Mutual labels:  tabbar
MightyTabBar
How tab bars should work.
Stars: ✭ 72 (+44%)
Mutual labels:  tabbar
TabBarInteraction
A tab bar example that animate based on user interaction
Stars: ✭ 72 (+44%)
Mutual labels:  tabbar
clipped-tabbar
No description or website provided.
Stars: ✭ 58 (+16%)
Mutual labels:  tabbar
Bouncy
RecyclerView and NestedScrollView with physics-based bouncy overscroll effect
Stars: ✭ 166 (+232%)
Mutual labels:  nestedscrollview
Flutter-Bottom-Tab-Bar
No description or website provided.
Stars: ✭ 72 (+44%)
Mutual labels:  tabbar
react-native-collapsible-segmented-view
A cross-platform Collapsible Segmented View component for React Native
Stars: ✭ 37 (-26%)
Mutual labels:  tabbar
react-native-curved-bottom-tabbar
Curved Bottom Tabbar React Native
Stars: ✭ 20 (-60%)
Mutual labels:  tabbar
flutter-bottomAppBar
Watch the tutorial video on Youtube ->
Stars: ✭ 15 (-70%)
Mutual labels:  tabbar
buttons tabbar
A Flutter package that implements a TabBar where each label is a toggle button.
Stars: ✭ 49 (-2%)
Mutual labels:  tabbar
SwipeVC
Animated analog to UITabBarController, with cool interactive TabBar
Stars: ✭ 17 (-66%)
Mutual labels:  tabbar
react-native-viewpager-indicator
修改自react-native-scrollable-tab-view,增加了根据文字内容适配下划线长度的功能。
Stars: ✭ 52 (+4%)
Mutual labels:  tabbar
react-native-nested-scroll-view
react-native wrapper for android NestedScrollView
Stars: ✭ 77 (+54%)
Mutual labels:  nestedscrollview

flutter_appbar

利用动画实现一个带背景图片的TabBar,TabBar选中状态有一个背景图片,TabBarView翻页的时候会跟随移动。 效果如下:

image image image

TabBar选中背景图片:

///时间选择
Widget _timeSelection() {
  double width = MediaQuery.of(context).size.width;
  return Stack(
    alignment: Alignment.topLeft,
    children: <Widget>[
      /// 固定整个布局的高,否则选中时间背景显示不全
      Container(
        height: 55,
      ),

      /// 未选中时间背景色
      Container(
        height: 55 - 5.0,
        color: Colors.black,
      ),

      /// 选中时间背景图片
      Positioned(
        width: width / 6,
        height: 55,
        ///一行有6个Tab,每次移动的距离=当前移动到的位置*单个tab的宽
        left: _timeTabController.animation.value * width / 6,
        child: Image.asset(
          "images/time_selected_bg.png",
          fit: BoxFit.fill,
        ),
      ),
      TabBar(
        labelPadding: EdgeInsets.all(0),
        tabs: timeTabs,
        controller: _timeTabController,
        isScrollable: false,
        indicatorColor: Colors.transparent,
      )
    ],
  );
}

TabBar用文字做分隔符

Widget _tabBarItem(String title, {bool showRightImage = true}) {
  return Tab(
      child: Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
      Expanded(
        child: Center(
          child: Text(title),
        ),
      ),

      ///分割符自定义,可以放任何widget
      showRightImage
          ? Text('/', style: TextStyle(color: Color(0xffd0d0d0), fontSize: 23))
          : Text(' ', style: TextStyle(color: Color(0xffd0d0d0), fontSize: 23))
    ],
  ));
}

TabBar用自写任意控件做分隔符

Widget _tabBarItem(String title, {bool showRightImage = true}) {
  return Tab(
      child: Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
      Expanded(
        child: Center(
          child: Text(title),
        ),
      ),

      ///分割符自定义,可以放任何widget
      showRightImage
          ? Container(
              width: 1,
              margin: EdgeInsets.only(top: 15, bottom: 15),
              color: Colors.red,
            )
          : Container(
              width: 1,
              margin: EdgeInsets.only(top: 15, bottom: 15),
            )
    ],
  ));
}

TabBar用本地图片做分隔符

Widget _tabBarItem(String title, {bool showRightImage = true}) {
  return Tab(
      child: Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
      Expanded(
        child: Center(
          child: Text(title),
        ),
      ),

      ///分割符自定义,可以放任何widget
      showRightImage
          ? Container(
              width: 1,
              height: 15,
              child: Image.asset(
                'images/separator.png',
                fit: BoxFit.fitHeight,
                color: Colors.blueAccent,
              ),
            )
          : Container(
              width: 1,
            )
    ],
  ));
}

NestedScrollView+TabBar+TabBarView实现顶部收缩

@override
Widget build(BuildContext context) {
  double statusBarHeight = MediaQuery.of(context).padding.top;

  ///轮播图高度
  double _swiperHeight = 326 + 10.0;

  ///提示头部高度
  double _spikeHeight = 80;

  ///_appBarHeight算的是AppBar的bottom高度,kToolbarHeight是APPBar高,statusBarHeight是状态栏高度
  double _appBarHeight =
      _swiperHeight + _spikeHeight - kToolbarHeight - statusBarHeight;

  return NestedScrollView(
    headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
      return <Widget>[
        SliverOverlapAbsorber(
          handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
          child: SliverAppBar(
            backgroundColor: Color(0xfff1f1f1),
            forceElevated: innerBoxIsScrolled,
            bottom: PreferredSize(
                child: Container(),
                preferredSize: Size.fromHeight(_appBarHeight)),

            ///TabBar顶部收缩的部分
            flexibleSpace: Column(
              children: <Widget>[
                _swiper(),
                _spike(),
              ],
            ),
          ),
        ),

        ///停留在顶部的TabBar
        SliverPersistentHeader(
          delegate: _SliverAppBarDelegate(_timeSelection()),
          pinned: true,
        ),
      ];
    },
    body: TabBarView(controller: _timeTabController, children: <Widget>[
      _listItem(),
      _listItem(),
      _listItem(),
      _listItem(),
      _listItem(),
      _listItem(),
    ]),
  );
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].