From 9df9833435d88b7726550b8349cd52ad1449624f Mon Sep 17 00:00:00 2001
From: X-Liang <1129584401@qq.com>
Date: Wed, 24 Jul 2019 11:39:22 +0800
Subject: [PATCH 01/12] no message
---
lib/TapWaterTabbar.dart | 72 +++++++-----------------
lib/main.dart | 14 +++--
lib/tab_item.dart | 110 +++++++++++++++++++++++--------------
lib/tap_water_tab_bar.dart | 90 ++++++++++++++++++++----------
4 files changed, 159 insertions(+), 127 deletions(-)
diff --git a/lib/TapWaterTabbar.dart b/lib/TapWaterTabbar.dart
index 39de6cb..627db97 100644
--- a/lib/TapWaterTabbar.dart
+++ b/lib/TapWaterTabbar.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
+import 'package:tap_water_tab_bar/tab_item.dart';
import 'package:tap_water_tab_bar/tap_water_tab_bar.dart';
import 'firstvc.dart';
@@ -27,18 +28,18 @@ class NavigationIconView {
class TapWaterTabbar extends StatefulWidget {
final bool isButton;
- final List
[**@DargonLee**]( https://github.com/DargonLee ) [《TabBar基础版本,不带加号按钮 issue#11》]( https://github.com/iteatimeteam/tap_water/issues/11 )
+ |
[**@DargonLee**]( https://github.com/DargonLee ) [《TabBar基础版本,不带加号按钮 issue#11》]( https://github.com/iteatimeteam/tap_water/issues/11 )
 |
[@苏筱雅]( https://github.com/SuXiaoya ) [《TabBar 加号按钮未封装版本,带加号按钮 #8》]( https://github.com/iteatimeteam/tap_water/issues/8 )
From 5a302216f60d30d03fbecb4b8c7297dbd9ebfbb2 Mon Sep 17 00:00:00 2001
From: Elon Chan
Date: Thu, 25 Jul 2019 10:33:41 +0800
Subject: [PATCH 07/12] [update][dev]update pr template
---
.github/pull_request_template.md | 8 ++++++++
README.md | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 01f5218..c62a2d4 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -10,6 +10,14 @@ Thanks for considering to this repository. Before you submit your issue, please
- [ ] I have read [《[EN]Style guide for Flutter repo [CN]Flutter项目代码规范、规约选型》](https://github.com/iteatimeteam/tap_water/issues/1).
- [ ] 我遵守以下 Merge 规则:PR提交后,邀请群组中任意一人进行 review,即可合并。让 reviewer 在 PR 所在页面写下 review 意见表示通过,即可合并。最简单写一句 LGTM 也可以。不按照本规则执行,自己 PR 自己 Merge 并引入问题,会被收回 Merge 权限。
+- [ ] I have added screenshots for main devices.
+
+## screenshots
+
+
+ iPhoneX+ | iPhone (except for iPhoneX+) | android
+ :-------------:|:-------------:|:-------------:
+ |  | 
diff --git a/README.md b/README.md
index 982e065..faf41a3 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,6 @@ updated
演示 | 主要代码贡献方及介绍
:-------------:|:-------------:
-|  |
[**@DargonLee**]( https://github.com/DargonLee ) [《TabBar基础版本,不带加号按钮 issue#11》]( https://github.com/iteatimeteam/tap_water/issues/11 )
+ |
[**@DargonLee**]( https://github.com/DargonLee ) [《TabBar基础版本,不带加号按钮 issue#11》]( https://github.com/iteatimeteam/tap_water/issues/11 )
 |
[@苏筱雅]( https://github.com/SuXiaoya ) [《TabBar 加号按钮未封装版本,带加号按钮 #8》]( https://github.com/iteatimeteam/tap_water/issues/8 )
From d3642cea359e70c82df101691d14cac255823ad8 Mon Sep 17 00:00:00 2001
From: Elon Chan
Date: Thu, 25 Jul 2019 11:30:36 +0800
Subject: [PATCH 08/12] [update][dev]update pr template.
---
.github/pull_request_template.md | 6 ++----
ios/Runner.xcodeproj/project.pbxproj | 4 ++++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index c62a2d4..7d62d3d 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -5,16 +5,14 @@
## CheckList
-
Thanks for considering to this repository. Before you submit your issue, please confirm these boxes are checked.
- [ ] I have read [《[EN]Style guide for Flutter repo [CN]Flutter项目代码规范、规约选型》](https://github.com/iteatimeteam/tap_water/issues/1).
-- [ ] 我遵守以下 Merge 规则:PR提交后,邀请群组中任意一人进行 review,即可合并。让 reviewer 在 PR 所在页面写下 review 意见表示通过,即可合并。最简单写一句 LGTM 也可以。不按照本规则执行,自己 PR 自己 Merge 并引入问题,会被收回 Merge 权限。
-- [ ] I have added screenshots for main devices.
+- [ ] [EN]I have added screenshots for main devices if this PR includes UI updates. [CN]UI改动,需要将主要设备截图,表明本此 PR 的 UI 改动。
+- [ ] [CN]我遵守以下 Merge 规则:PR 提交后,邀请群组中任意一人进行 review,即可合并。让 reviewer 在 PR 所在页面写下 review 意见表示通过,即可合并。最简单写一句 LGTM 也可以。不按照本规则执行,自己 PR 自己 Merge 并引入问题,会被收回 Merge 权限。如无 merge 权限,请联系 @ChenYilong 执行 merge 操作。
## screenshots
-
iPhoneX+ | iPhone (except for iPhoneX+) | android
:-------------:|:-------------:|:-------------:
 |  | 
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index fedb2ce..9a0c872 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
+ 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
@@ -40,6 +41,7 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
+ 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
@@ -73,6 +75,7 @@
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
+ 2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
@@ -185,6 +188,7 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
+ 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
From 8bcbfda152c68b629e3d77029d03287b73a1d67e Mon Sep 17 00:00:00 2001
From: Elon Chan
Date: Thu, 25 Jul 2019 11:53:20 +0800
Subject: [PATCH 09/12] [update][dev]update pr template
---
.github/pull_request_template.md | 2 +-
README.md | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 7d62d3d..feb6b3c 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -15,7 +15,7 @@ Thanks for considering to this repository. Before you submit your issue, please
iPhoneX+ | iPhone (except for iPhoneX+) | android
:-------------:|:-------------:|:-------------:
- |  | 
+ |  | 
diff --git a/README.md b/README.md
index faf41a3..5803bdf 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,6 @@ updated
演示 | 主要代码贡献方及介绍
:-------------:|:-------------:
- |
[**@DargonLee**]( https://github.com/DargonLee ) [《TabBar基础版本,不带加号按钮 issue#11》]( https://github.com/iteatimeteam/tap_water/issues/11 )
- |
[@苏筱雅]( https://github.com/SuXiaoya ) [《TabBar 加号按钮未封装版本,带加号按钮 #8》]( https://github.com/iteatimeteam/tap_water/issues/8 )
+ |
[**@DargonLee**]( https://github.com/DargonLee ) [《TabBar基础版本,不带加号按钮 issue#11》]( https://github.com/iteatimeteam/tap_water/issues/11)
+ |
[@苏筱雅]( https://github.com/SuXiaoya ) [《TabBar 加号按钮未封装版本,带加号按钮 #8》]( https://github.com/iteatimeteam/tap_water/issues/8 )
From fa4e8f9d54bb1bdaee5559f992f9b46816e4373c Mon Sep 17 00:00:00 2001
From: wjun94
Date: Thu, 1 Aug 2019 13:34:40 +0800
Subject: [PATCH 10/12] =?UTF-8?q?[!]=20=E5=88=A0=E9=99=A4=E6=97=A0?=
=?UTF-8?q?=E7=94=A8=E6=96=87=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0iphonex?=
=?UTF-8?q?=E9=80=82=E9=85=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ios/Runner.xcodeproj/project.pbxproj | 4 -
lib/TapWaterTabbar.dart | 213 ---------------------------
lib/main.dart | 73 ++++-----
lib/tab_item.dart | 124 ----------------
lib/tap_water_tab_bar.dart | 163 ++++++++++----------
5 files changed, 125 insertions(+), 452 deletions(-)
delete mode 100644 lib/TapWaterTabbar.dart
delete mode 100644 lib/tab_item.dart
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 9a0c872..fedb2ce 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
- 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
@@ -41,7 +40,6 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
- 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
@@ -75,7 +73,6 @@
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
- 2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
@@ -188,7 +185,6 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
- 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
diff --git a/lib/TapWaterTabbar.dart b/lib/TapWaterTabbar.dart
deleted file mode 100644
index 2d6f70c..0000000
--- a/lib/TapWaterTabbar.dart
+++ /dev/null
@@ -1,213 +0,0 @@
-/** 该页面以废弃 */
-
-import 'package:flutter/material.dart';
-import 'package:tap_water_tab_bar/tab_item.dart';
-import 'package:tap_water_tab_bar/tap_water_tab_bar.dart';
-
-import 'firstvc.dart';
-
-//enum ActionsItems {
-// Group_chat,
-// Add_friend,
-// Scan,
-// Payment,
-//}
-
-class NavigationIconView {
- final BottomNavigationBarItem item;
- NavigationIconView({
- Key key,
- String title,
- Widget icon,
- Widget avtiveIcon,
- }) : item = new BottomNavigationBarItem(
- icon: icon,
- activeIcon: avtiveIcon,
- title: new Text(title),
- backgroundColor: Colors.white,
- );
-}
-
-class TapWaterTabbar extends StatefulWidget {
- final bool isButton;
- final List tabItems;
- TapWaterTabbar({this.tabItems, this.isButton = false}) {
-// final int _len = this.btmNavbar.length;
-// // final int _len = 5;
-// if (this.isButton) {
-// if (_len % 2 == 0) {
-// this.btmNavbar.insert(_len ~/ 2, null);
-// } else {
-// this.btmNavbar.insert(_len ~/ 2 + 1, null);
-// this.btmNavbar.insert(_len ~/ 2 + 2, null);
-// }
-// }
- }
-
- @override
- _TapWaterTabbarState createState() => _TapWaterTabbarState();
-}
-
-class _TapWaterTabbarState extends State {
- PageController _pageController;
- int _currentIndex = 0;
- List _navgationViews;
- List _pages;
- //添加图片地址,需要动态更换图片
- String bigImg = 'images/post_normal.png';
- int page = 0;
- @override
- void initState() {
- super.initState();
-
- _pageController = PageController(initialPage: _currentIndex);
- _pages = [
- DemoWidget("first"),
- DemoWidget("two"),
- DemoWidget("five"),
- DemoWidget("three"),
- DemoWidget("four"),
- ];
- }
-
- _buildPopupMenuItem(Widget icon, String title) {
- return Row(
- children: [
- icon,
- Container(
- width: 20,
- ),
- Text(
- title,
- style: TextStyle(
- color: Colors.white,
- ),
- )
- ],
- );
- }
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- elevation: 0.0,
- title: Text('微信'),
- actions: [
- IconButton(
- icon: Icon(Icons.search),
- onPressed: () {
- print('xxx');
- },
- ),
- Container(width: 5.0),
- PopupMenuButton(
- icon: Icon(Icons.add),
- itemBuilder: (BuildContext context) {
- return >[
- PopupMenuItem(
- child: _buildPopupMenuItem(
- Icon(
- Icons.search,
- color: Colors.white,
- ),
- "发起群聊"),
- value: "group_chat",
- ),
- PopupMenuItem(
- child: _buildPopupMenuItem(
- Icon(
- Icons.add_circle,
- color: Colors.white,
- ),
- "添加朋友"),
- value: "add_friend",
- ),
- PopupMenuItem(
- child: _buildPopupMenuItem(
- Icon(
- Icons.scanner,
- color: Colors.white,
- ),
- "扫一扫"),
- value: "scan",
- ),
- PopupMenuItem(
- child: _buildPopupMenuItem(
- Icon(
- Icons.payment,
- color: Colors.white,
- ),
- "收付款"),
- value: "pay",
- ),
- ];
- },
- onSelected: (String selected) {
- print('点击了$selected');
- },
- ),
- Container(width: 5.0)
- ],
- ),
- body: Stack(
- children: [
- Padding(
- padding: const EdgeInsets.only(bottom: 50),
- child: PageView.builder(
- itemBuilder: (BuildContext context, int index) {
- return _pages[index];
- },
- controller: _pageController,
- itemCount: _pages.length,
- onPageChanged: (int index) {
- setState(() {
- _currentIndex = index;
- });
- },
- ),
- ),
- Align(
- alignment: Alignment.bottomCenter,
- child: WaterTabBar(
- isButton: widget.isButton,
- tabItemInfos: widget.tabItems,
- selectedCallback: (int index) {
- print(index);
- },
- ),
- ),
- ],
- ),
- );
- }
-
- void onTap(int index) {
- if (index != 2) {
- setState(() {
- this.bigImg = 'images/post_normal.png';
- });
- } else {
- setState(() {
- this.bigImg = 'images/post_highlight.png';
- });
- }
-
- _pageController.jumpToPage(index);
- }
-
- //添加图片的点击事件
- void onBigImgTap() {
- setState(() {
- this.page = 2;
- this.bigImg = 'images/post_highlight.png';
- onTap(2);
- });
- }
-
- void onPageChanged(int page) {
- setState(() {
- this.page = page;
- });
- }
-}
diff --git a/lib/main.dart b/lib/main.dart
index b149f5e..a7528aa 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'widget/navigation_bar.dart';
// import 'TapWaterTabbar.dart';
import 'tap_water_tab_bar.dart';
-import './tab_item.dart';
void main() => runApp(MyApp());
@@ -50,47 +49,51 @@ class _MyAppPageState extends State<_MyAppPage> {
alignment: Alignment.center,
child: Text('页面5'),
),
+ Align(
+ alignment: Alignment.center,
+ child: Text('页面6'),
+ ),
];
@override
Widget build(BuildContext context) {
- return Scaffold(
+ return WaterTabBar(
+ isButton: true,
appBar: NavigationBar(),
- body: Stack(
- children: [
- _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),
- ],
- ));
+ body: _pages[_index],
+ btmNavbar: [
+ NavigationIconView(
+ title: '微信1',
+ icon: Icon(Icons.ac_unit),
+ activeIcon: Icon(Icons.backspace),
+ ),
+ NavigationIconView(
+ title: '微信2',
+ icon: Icon(Icons.ac_unit),
+ activeIcon: Icon(Icons.cached),
+ ),
+ NavigationIconView(
+ title: '微信3',
+ icon: Icon(Icons.ac_unit),
+ activeIcon: Icon(Icons.edit),
+ ),
+ NavigationIconView(
+ title: '微信4',
+ icon: Icon(Icons.ac_unit),
+ activeIcon: Icon(Icons.cached),
+ ),
+ // NavigationIconView(
+ // title: '微信6',
+ // icon: Icon(Icons.ac_unit),
+ // activeIcon: Icon(Icons.cached),
+ // ),
+ ],
+ onTabClick: onTabClick);
}
- void onTabClick(TabItemInfo node) {
+ void onTabClick(int index) {
setState(() {
- _index = node.index;
+ _index = index;
});
- print('$node');
+ print('$index');
}
}
diff --git a/lib/tab_item.dart b/lib/tab_item.dart
deleted file mode 100644
index 9c3e462..0000000
--- a/lib/tab_item.dart
+++ /dev/null
@@ -1,124 +0,0 @@
-import 'package:flutter/material.dart';
-
-class TabItemInfo {
- final String title;
- final IconData icon;
- final IconData activeIcon;
- final Color normalColor;
- int index;
- final Color selectedColor;
- TabItemInfo(
- {this.title,
- this.index,
- this.icon,
- this.activeIcon,
- this.normalColor = Colors.grey,
- this.selectedColor = Colors.blue});
-}
-
-class TabItem extends StatefulWidget {
- final TabItemInfo itemInfo;
- String get title {
- if (itemInfo != null) {
- return itemInfo.title;
- }
- }
-
- IconData get icon {
- if (itemInfo != null) {
- return itemInfo.icon;
- }
- }
-
- IconData get activeIcon {
- if (itemInfo != null) {
- return itemInfo.activeIcon;
- }
- }
-
- Color get selectedColor {
- if (itemInfo != null) {
- return itemInfo.selectedColor;
- }
- }
-
- Color get normalColor {
- if (itemInfo != null) {
- return itemInfo.normalColor;
- }
- }
-
- int get index {
- if (itemInfo != null) {
- return itemInfo.index;
- }
- }
-
- final Function onTabClick;
- final bool isSelected;
- TabItem({
- this.itemInfo,
- this.onTabClick,
- this.isSelected,
- });
- @override
- State createState() => _TabItem();
-}
-
-class _TabItem extends State {
- @override
- Widget build(BuildContext context) {
- // final _themeColor = widget.isSelected ? widget.selectedColor : widget.normalColor;
- return Expanded(
- child: GestureDetector(
- onTap: _onTab,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- mainAxisSize: MainAxisSize.min,
- children: [
- Flexible(
- child: widget.icon != null
- ? Container(
- child: Padding(
- padding: const EdgeInsets.only(top: 5),
- child: Icon(
- widget.isSelected ? widget.activeIcon : widget.icon,
- color: widget.isSelected
- ? widget.selectedColor
- : widget.normalColor,
- ),
- ),
- )
- : Container(),
- ),
- Flexible(
- child: Container(
- child: Align(
- alignment: Alignment(0, 0),
- child: Padding(
- padding: const EdgeInsets.all(0),
- child: widget.title != null
- ? Text(
- widget.title,
- style: TextStyle(
- color: widget.isSelected
- ? widget.selectedColor
- : widget.normalColor,
- fontWeight: FontWeight.w600,
- fontSize: 10),
- )
- : Container(),
- ),
- ),
- ),
- )
- ],
- )),
- );
- }
-
- void _onTab() {
- widget.onTabClick(widget.itemInfo);
- }
-}
diff --git a/lib/tap_water_tab_bar.dart b/lib/tap_water_tab_bar.dart
index 3f52fd3..193297d 100644
--- a/lib/tap_water_tab_bar.dart
+++ b/lib/tap_water_tab_bar.dart
@@ -1,27 +1,54 @@
import 'package:flutter/material.dart';
-import 'package:tap_water_tab_bar/tab_item.dart';
+
+class NavigationIconView {
+ final BottomNavigationBarItem item;
+ NavigationIconView({
+ Key key,
+ final String title = '',
+ final Widget icon,
+ final Widget activeIcon,
+ }) : item = BottomNavigationBarItem(
+ icon: icon,
+ activeIcon: activeIcon,
+ title: Text(
+ title,
+ ),
+ backgroundColor: Colors.white,
+ );
+}
class WaterTabBar extends StatefulWidget {
final bool isButton;
- List btmNavbar = [];
+ final Widget appBar;
+ final Widget body;
+ List btmNavbar = [];
final Function onTabClick;
- int len = 0;
- WaterTabBar({Key key, this.btmNavbar, this.isButton = false, this.onTabClick})
+ int btnIndex;
+ int len;
+ WaterTabBar(
+ {Key key,
+ this.body,
+ this.appBar,
+ this.btmNavbar,
+ this.isButton = false,
+ this.onTabClick})
: super(key: key) {
- // 解决点击页面问题
- this
- .btmNavbar
- .asMap()
- .map((int i, TabItemInfo v) => MapEntry(i, v.index = i));
- this.len = this.btmNavbar.length;
-
- /// 解决tab为基数问题
+ // 解决tab为基数问题
if (this.isButton) {
- if (len % 2 == 0) {
- this.btmNavbar.insert(len ~/ 2, null);
+ this.len = this.btmNavbar.length;
+ if (this.len % 2 == 0) {
+ // btmNavbar偶数
+ this.btnIndex = this.len ~/ 2;
+ this.btmNavbar.insert(this.len ~/ 2,
+ NavigationIconView(icon: Icon(Icons.ac_unit, size: 0)));
} else {
- this.btmNavbar.insert(len ~/ 2 + 1, null);
- this.btmNavbar.insert(len ~/ 2 + 2, null);
+ // btmNavbar基数
+ this.btnIndex = this.len ~/ 2 + 1;
+ this.btmNavbar.insert(this.len ~/ 2 + 1,
+ NavigationIconView(icon: Icon(Icons.ac_unit, size: 0)));
+ this
+ .btmNavbar
+ .add(NavigationIconView(icon: Icon(Icons.ac_unit, size: 0)));
}
}
}
@@ -31,73 +58,57 @@ class WaterTabBar extends StatefulWidget {
class _WaterTabBarState extends State {
int _activeIndex = 0;
- String _bigImg = 'images/post_normal.png';
+ Color _addBgc = Colors.grey;
@override
Widget build(BuildContext context) {
- return Stack(
- children: [
- Align(
- alignment: Alignment.bottomCenter,
- child: Stack(
- overflow: Overflow.visible,
- alignment: Alignment.bottomCenter,
- children: [
- Container(
- height: 60,
- decoration: BoxDecoration(
- color: Colors.white,
- boxShadow: [
- BoxShadow(
- color: Colors.black12,
- offset: Offset(0, -1),
- blurRadius: 8)
- ],
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- mainAxisSize: MainAxisSize.max,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: widget.btmNavbar
- .asMap()
- .map((int i, TabItemInfo v) => MapEntry(
- i,
- v != null
- ? TabItem(
- itemInfo: v,
- isSelected: v.index == _activeIndex,
- onTabClick: _onTabClick)
- : (widget.isButton ? TabItem() : Text(''))))
- .values
- .toList(),
- ),
- ),
- Positioned(
- child: widget.isButton
- ? Container(
- margin: const EdgeInsets.only(bottom: 30),
- width: 60,
- child: GestureDetector(
- onTap: () {
- _onTabClick(TabItemInfo(
- title: 'onButton', index: widget.len));
- },
- child: Image.asset(_bigImg)),
- )
- : Text(''),
- ),
- ],
- )),
- ],
+ var _items = BottomNavigationBar(
+ // 底部导航栏
+ items: widget.btmNavbar
+ .map((NavigationIconView navigationIconView) =>
+ navigationIconView.item)
+ .toList(),
+ currentIndex: _activeIndex,
+ fixedColor: Colors.blue,
+ type: BottomNavigationBarType.fixed,
+ onTap: _onTabClick,
+ );
+ return Scaffold(
+ appBar: widget.appBar,
+ body: widget.body,
+ bottomNavigationBar: _items,
+ floatingActionButton: widget.isButton
+ ? FloatingActionButton(
+ elevation: 6,
+ highlightElevation: 6,
+ child: Icon(
+ Icons.add,
+ color: Colors.white,
+ size: 36,
+ ),
+ onPressed: () {
+ _onTabClick(widget.btnIndex);
+ },
+ shape: CircleBorder(
+ side: BorderSide(color: Colors.white, width: 3.5)),
+ backgroundColor: _addBgc)
+ : Text(''),
+ floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
);
}
- void _onTabClick(TabItemInfo node) {
+ void _onTabClick(int index) {
+ if (widget.isButton) {
+ if (index == widget.len + 1) {
+ index -= 1;
+ }
+ setState(() {
+ _addBgc = index == widget.btnIndex ? Colors.blue : Colors.grey;
+ });
+ }
setState(() {
- _activeIndex = node.index;
- _bigImg =
- node.title == 'onButton' ? 'images/post_highlight.png' : 'images/post_normal.png';
+ _activeIndex = index;
});
- widget.onTabClick(node);
+ widget.onTabClick(_activeIndex);
}
}
From c8b7dfa4b4756e53abba40d423349fc170211b45 Mon Sep 17 00:00:00 2001
From: wjun94
Date: Thu, 1 Aug 2019 14:38:55 +0800
Subject: [PATCH 11/12] =?UTF-8?q?[!]=20=E6=B7=BB=E5=8A=A0=E5=BA=95?=
=?UTF-8?q?=E9=83=A8=E9=80=89=E4=B8=AD=E9=A2=9C=E8=89=B2=E5=92=8Cbuttom?=
=?UTF-8?q?=E9=A2=9C=E8=89=B2=E5=B1=9E=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/main.dart | 1 +
lib/tap_water_tab_bar.dart | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/lib/main.dart b/lib/main.dart
index a7528aa..8e82442 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -58,6 +58,7 @@ class _MyAppPageState extends State<_MyAppPage> {
Widget build(BuildContext context) {
return WaterTabBar(
isButton: true,
+ selectedColor: Colors.green,
appBar: NavigationBar(),
body: _pages[_index],
btmNavbar: [
diff --git a/lib/tap_water_tab_bar.dart b/lib/tap_water_tab_bar.dart
index 193297d..6e13f65 100644
--- a/lib/tap_water_tab_bar.dart
+++ b/lib/tap_water_tab_bar.dart
@@ -19,10 +19,20 @@ class NavigationIconView {
class WaterTabBar extends StatefulWidget {
final bool isButton;
+
+ /// 是否有加号按钮
final Widget appBar;
+
+ /// appBar Widget
final Widget body;
+
+ /// body Widget
List btmNavbar = [];
final Function onTabClick;
+
+ /// 组件通信
+ final Color selectedColor;
+ final Color buttonSelectedColor;
int btnIndex;
int len;
WaterTabBar(
@@ -30,6 +40,8 @@ class WaterTabBar extends StatefulWidget {
this.body,
this.appBar,
this.btmNavbar,
+ this.selectedColor = Colors.blue,
+ this.buttonSelectedColor = Colors.blue,
this.isButton = false,
this.onTabClick})
: super(key: key) {
@@ -69,7 +81,7 @@ class _WaterTabBarState extends State {
navigationIconView.item)
.toList(),
currentIndex: _activeIndex,
- fixedColor: Colors.blue,
+ fixedColor: widget.selectedColor,
type: BottomNavigationBarType.fixed,
onTap: _onTabClick,
);
@@ -103,12 +115,15 @@ class _WaterTabBarState extends State {
index -= 1;
}
setState(() {
- _addBgc = index == widget.btnIndex ? Colors.blue : Colors.grey;
+ _addBgc =
+ index == widget.btnIndex ? widget.buttonSelectedColor : Colors.grey;
});
}
setState(() {
_activeIndex = index;
});
- widget.onTabClick(_activeIndex);
+ if (widget.onTabClick != null) {
+ widget.onTabClick(_activeIndex);
+ }
}
}
From 1f825e2824db17d4484bde2bccfda178d2344a51 Mon Sep 17 00:00:00 2001
From: wjun94
Date: Thu, 1 Aug 2019 14:45:56 +0800
Subject: [PATCH 12/12] =?UTF-8?q?[!]=20=E6=B7=BB=E5=8A=A0=E6=B3=A8?=
=?UTF-8?q?=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/tap_water_tab_bar.dart | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/lib/tap_water_tab_bar.dart b/lib/tap_water_tab_bar.dart
index 6e13f65..80c3f20 100644
--- a/lib/tap_water_tab_bar.dart
+++ b/lib/tap_water_tab_bar.dart
@@ -18,22 +18,31 @@ class NavigationIconView {
}
class WaterTabBar extends StatefulWidget {
+ /// 是否有加号按钮
final bool isButton;
- /// 是否有加号按钮
+ /// appBar Widget
final Widget appBar;
- /// appBar Widget
+ /// 主体内容
final Widget body;
- /// body Widget
+ /// 底部按钮配置
List btmNavbar = [];
- final Function onTabClick;
/// 组件通信
+ final Function onTabClick;
+
+ /// 底部button选中颜色
final Color selectedColor;
+
+ /// +号按钮选中颜色
final Color buttonSelectedColor;
+
+ /// +号按钮索引
int btnIndex;
+
+ /// btmNavbar数组长度
int len;
WaterTabBar(
{Key key,
@@ -69,13 +78,15 @@ class WaterTabBar extends StatefulWidget {
}
class _WaterTabBarState extends State {
+ /// 选中的索引
int _activeIndex = 0;
+ /// +号按钮背景色
Color _addBgc = Colors.grey;
@override
Widget build(BuildContext context) {
var _items = BottomNavigationBar(
- // 底部导航栏
+ /// 底部导航栏
items: widget.btmNavbar
.map((NavigationIconView navigationIconView) =>
navigationIconView.item)
@@ -109,6 +120,7 @@ class _WaterTabBarState extends State {
);
}
+ /// 单击事件
void _onTabClick(int index) {
if (widget.isButton) {
if (index == widget.len + 1) {