-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from wjun94/master
[!] 底部单击添加颜色变化,暴露tab单击事件,封装AppBar,底部tab通过传参数配置
- Loading branch information
Showing
5 changed files
with
350 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,96 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:tap_water_tab_bar/tab_item.dart'; | ||
|
||
import 'TapWaterTabbar.dart'; | ||
import 'widget/navigation_bar.dart'; | ||
// import 'TapWaterTabbar.dart'; | ||
import 'tap_water_tab_bar.dart'; | ||
import './tab_item.dart'; | ||
|
||
void main() => runApp(MyApp()); | ||
|
||
class MyApp extends StatelessWidget { | ||
// This widget is the root of your application. | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Flutter Demo', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
), | ||
home: TapWaterTabbar(isButton: true, tabItems: [ | ||
TabItemInfo(title: '微信', icon: Icons.ac_unit, selectedColor: Colors.blue), | ||
TabItemInfo(title: '微信', icon: Icons.ac_unit, selectedColor: Colors.blue), | ||
TabItemInfo(title: ''), | ||
TabItemInfo(title: '微信', icon: Icons.ac_unit, selectedColor: Colors.blue), | ||
TabItemInfo(title: '微信', icon: Icons.ac_unit, selectedColor: Colors.blue), | ||
]), | ||
); | ||
title: 'Flutter Demo', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
), | ||
home: _MyAppPage()); | ||
} | ||
} | ||
|
||
class _MyAppPage extends StatefulWidget { | ||
_MyAppPage({Key key}) : super(key: key); | ||
|
||
@override | ||
_MyAppPageState createState() => new _MyAppPageState(); | ||
} | ||
|
||
class _MyAppPageState extends State<_MyAppPage> { | ||
int _index = 0; | ||
var _pages = [ | ||
Align( | ||
alignment: Alignment.center, | ||
child: Text('页面1'), | ||
), | ||
Align( | ||
alignment: Alignment.center, | ||
child: Text('页面2'), | ||
), | ||
Align( | ||
alignment: Alignment.center, | ||
child: Text('页面3'), | ||
), | ||
Align( | ||
alignment: Alignment.center, | ||
child: Text('页面4'), | ||
), | ||
Align( | ||
alignment: Alignment.center, | ||
child: Text('页面5'), | ||
), | ||
]; | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: NavigationBar(), | ||
body: Stack( | ||
children: <Widget>[ | ||
_pages[_index], | ||
WaterTabBar( | ||
isButton: true, | ||
btmNavbar: [ | ||
TabItemInfo( | ||
title: '微信1', | ||
icon: Icons.ac_unit, | ||
activeIcon: Icons.backspace, | ||
selectedColor: Colors.green), | ||
TabItemInfo( | ||
title: '微信2', | ||
icon: Icons.ac_unit, | ||
activeIcon: Icons.cached, | ||
selectedColor: Colors.green), | ||
TabItemInfo( | ||
title: '微信3', | ||
icon: Icons.ac_unit, | ||
activeIcon: Icons.edit, | ||
selectedColor: Colors.green), | ||
TabItemInfo( | ||
title: '微信4', | ||
icon: Icons.ac_unit, | ||
activeIcon: Icons.cached, | ||
selectedColor: Colors.green), | ||
], | ||
onTabClick: onTabClick), | ||
], | ||
)); | ||
} | ||
|
||
void onTabClick(TabItemInfo node) { | ||
setState(() { | ||
_index = node.index; | ||
}); | ||
print('$node'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.