From 208701b96dab843d644f3821f92b85d0a18c4d6b Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 3 Nov 2020 09:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0AKU=20TAB=20BAR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/home/business/business_page.dart | 16 ++---- lib/ui/home/home_page.dart | 6 ++- .../business_and_fix_page.dart | 53 +++++++++++++++++-- lib/ui/widgets/inner/aku_tab_bar.dart | 34 ++++++++++++ 4 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 lib/ui/widgets/inner/aku_tab_bar.dart diff --git a/lib/ui/home/business/business_page.dart b/lib/ui/home/business/business_page.dart index a0bf4d6..a33e928 100644 --- a/lib/ui/home/business/business_page.dart +++ b/lib/ui/home/business/business_page.dart @@ -1,5 +1,6 @@ import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:flutter/material.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; @@ -38,20 +39,9 @@ class _BusinessPageState extends State return AkuScaffold( title: '全部事项', appBarBottom: PreferredSize( - child: TabBar( - labelColor: AppStyle.primaryTextColor, - unselectedLabelColor: AppStyle.minorTextColor, - labelStyle: TextStyle( - fontSize: 28.w, - fontWeight: FontWeight.bold, - ), - unselectedLabelStyle: TextStyle( - fontWeight: FontWeight.normal, - ), - indicatorColor: AppStyle.primaryColor, - indicatorSize: TabBarIndicatorSize.label, + child: AkuTabBar( controller: _tabController, - tabs: _tabs.map((e) => Tab(text: e)).toList(), + tabs: _tabs, ), preferredSize: Size.fromHeight(88.w), ), diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index 4aa55a9..c91c850 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -8,6 +8,7 @@ import 'package:aku_community_manager/ui/home/business/business_page.dart'; import 'package:aku_community_manager/ui/home/messages/message.dart'; import 'package:aku_community_manager/ui/home/application/applications_page.dart'; import 'package:aku_community_manager/ui/home/personal_draw.dart'; +import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and_fix_page.dart'; import 'package:aku_community_manager/ui/tool_pages/scan_page.dart'; import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; @@ -293,7 +294,10 @@ class _HomePageState extends State { _menuButton( R.ASSETS_HOME_IC_VISITORS_PNG, '访客管理', HomePage()), _menuButton( - R.ASSETS_HOME_IC_SERVICE_PNG, '报事报修', HomePage()), + R.ASSETS_HOME_IC_SERVICE_PNG, + '报事报修', + BusinessAndFixPage(), + ), _menuButton( R.ASSETS_HOME_IC_ALL_PNG, '全部应用', ApplicationPage()), ], diff --git a/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart b/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart index 9c46ea8..ec82f4b 100644 --- a/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart +++ b/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart @@ -1,5 +1,10 @@ +import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; +import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/tools/screen_tool.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class BusinessAndFixPage extends StatefulWidget { BusinessAndFixPage({Key key}) : super(key: key); @@ -8,9 +13,51 @@ class BusinessAndFixPage extends StatefulWidget { _BusinessAndFixPageState createState() => _BusinessAndFixPageState(); } -class _BusinessAndFixPageState extends State { +class _BusinessAndFixPageState extends State + with TickerProviderStateMixin { + TabController _tabController; + + List get _tabs { + final userProvider = Provider.of(context, listen: false); + switch (userProvider.userInfoModel.role) { + case USER_ROLE.MANAGER: + return []; + break; + case USER_ROLE.FIXER: + return []; + break; + case USER_ROLE.SECURITY: + return []; + break; + default: + return []; + break; + } + } + + @override + void initState() { + _tabController = TabController(length: _tabs.length, vsync: this); + super.initState(); + } + + @override + void dispose() { + _tabController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return AkuScaffold(); + return AkuScaffold( + title: '报事报修', + bottom: PreferredSize( + preferredSize: Size.fromHeight(88.w), + child: AkuTabBar( + controller: _tabController, + tabs: _tabs, + ), + ), + ); } -} \ No newline at end of file +} diff --git a/lib/ui/widgets/inner/aku_tab_bar.dart b/lib/ui/widgets/inner/aku_tab_bar.dart new file mode 100644 index 0000000..ba62e58 --- /dev/null +++ b/lib/ui/widgets/inner/aku_tab_bar.dart @@ -0,0 +1,34 @@ +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community_manager/tools/screen_tool.dart'; + +class AkuTabBar extends StatefulWidget { + final TabController controller; + final List tabs; + AkuTabBar({Key key, @required this.controller, @required this.tabs}) + : super(key: key); + + @override + _AkuTabBarState createState() => _AkuTabBarState(); +} + +class _AkuTabBarState extends State { + @override + Widget build(BuildContext context) { + return TabBar( + labelColor: AppStyle.primaryTextColor, + unselectedLabelColor: AppStyle.minorTextColor, + labelStyle: TextStyle( + fontSize: 28.w, + fontWeight: FontWeight.bold, + ), + unselectedLabelStyle: TextStyle( + fontWeight: FontWeight.normal, + ), + indicatorColor: AppStyle.primaryColor, + indicatorSize: TabBarIndicatorSize.label, + controller: widget.controller, + tabs: widget.tabs.map((e) => Tab(text: e)).toList(), + ); + } +}