From 03a4388174a76298754fe2edbed408b4580a4902 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 6 Nov 2020 11:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E5=93=81=E6=B8=85=E5=8D=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E9=AA=8C=E8=AF=81=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0tabbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../borrow_manager/all_borrow_goods.dart | 32 ++++++---- .../borrow_item_detail_page.dart | 36 ++++++----- .../borrow_manager/borrow_items_page.dart | 4 +- .../borrow_manager/borrow_manager_page.dart | 59 +++++++++++++------ 4 files changed, 82 insertions(+), 49 deletions(-) diff --git a/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart b/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart index 13ae700..019b096 100644 --- a/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart +++ b/lib/ui/sub_pages/borrow_manager/all_borrow_goods.dart @@ -1,5 +1,7 @@ import 'package:aku_community_manager/mock_models/borrow/borrow_data.dart'; import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; +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/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/sub_pages/borrow_manager/add_borrow_object_page.dart'; @@ -9,6 +11,7 @@ import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:aku_community_manager/const/resource.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:provider/provider.dart'; class AllBorrowGoods extends StatefulWidget { AllBorrowGoods({Key key}) : super(key: key); @@ -20,22 +23,25 @@ class AllBorrowGoods extends StatefulWidget { class _AllBorrowGoodsState extends State { @override Widget build(BuildContext context) { + final userProvider = Provider.of(context); return AkuScaffold( title: '全部物品', actions: [ - AkuMaterialButton( - minWidth: 120.w, - onPressed: () { - Get.to(AddBorrowObjectPage()); - }, - child: Text( - '新增', - style: TextStyle( - fontSize: 28.w, - color: AppStyle.primaryTextColor, - ), - ), - ), + userProvider.userInfoModel.role == USER_ROLE.MANAGER + ? AkuMaterialButton( + minWidth: 120.w, + onPressed: () { + Get.to(AddBorrowObjectPage()); + }, + child: Text( + '新增', + style: TextStyle( + fontSize: 28.w, + color: AppStyle.primaryTextColor, + ), + ), + ) + : SizedBox(), ], body: ListView.builder( padding: EdgeInsets.symmetric( diff --git a/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart index c77df0b..c579cab 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart @@ -1,9 +1,12 @@ import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; +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/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class BorrowItemDetailPage extends StatefulWidget { final SingleBorrowGoods item; @@ -30,24 +33,27 @@ class _BorrowItemDetailPageState extends State { @override Widget build(BuildContext context) { + final userProvider = Provider.of(context); return AkuScaffold( title: '物品详情', actions: [ - AkuMaterialButton( - minWidth: 120.w, - onPressed: () { - setState(() { - _isEditing = !_isEditing; - }); - }, - child: Text( - _isEditing ? '完成' : '编辑', - style: TextStyle( - fontSize: 28.w, - color: AppStyle.primaryTextColor, - ), - ), - ), + userProvider.userInfoModel.role == USER_ROLE.MANAGER + ? AkuMaterialButton( + minWidth: 120.w, + onPressed: () { + setState(() { + _isEditing = !_isEditing; + }); + }, + child: Text( + _isEditing ? '完成' : '编辑', + style: TextStyle( + fontSize: 28.w, + color: AppStyle.primaryTextColor, + ), + ), + ) + : SizedBox(), ], body: ListView( padding: EdgeInsets.symmetric(vertical: 16.w), diff --git a/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart index 4f19a2f..bc2609a 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_items_page.dart @@ -27,7 +27,7 @@ class _BorrowItemPageState extends State { return AkuScaffold( title: '物品查看', actions: [ - userProvider.userInfoModel.role != USER_ROLE.MANAGER + userProvider.userInfoModel.role == USER_ROLE.MANAGER ? AkuMaterialButton( minWidth: 120.w, onPressed: () { @@ -76,7 +76,7 @@ class _BorrowItemPageState extends State { ), ), Spacer(), - userProvider.userInfoModel.role != USER_ROLE.MANAGER + userProvider.userInfoModel.role == USER_ROLE.MANAGER ? AkuMaterialButton( padding: EdgeInsets.symmetric(horizontal: 24.w), onPressed: () { diff --git a/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart b/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart index 4533aa9..59b5619 100644 --- a/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart +++ b/lib/ui/sub_pages/borrow_manager/borrow_manager_page.dart @@ -1,10 +1,9 @@ -import 'package:aku_community_manager/mock_models/borrow/borrow_data.dart'; -import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart'; 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/style/app_style.dart'; import 'package:aku_community_manager/ui/sub_pages/borrow_manager/all_borrow_goods.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:aku_ui/common_widgets/aku_material_button.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -17,28 +16,50 @@ class BorrowManagerPage extends StatefulWidget { _BorrowManagerPageState createState() => _BorrowManagerPageState(); } -class _BorrowManagerPageState extends State { +class _BorrowManagerPageState extends State + with TickerProviderStateMixin { + USER_ROLE get role => + Provider.of(context, listen: false).userInfoModel.role; + TabController _tabController; + List get _tabs { + switch (role) { + case USER_ROLE.MANAGER: + return ['全部', '出借中', '待检查', '已归还']; + default: + return ['全部', '出借中', '已归还']; + } + } + + @override + void initState() { + super.initState(); + _tabController = TabController(length: _tabs.length, vsync: this); + } + @override Widget build(BuildContext context) { - final userProvider = Provider.of(context); return AkuScaffold( title: '物品清单', + appBarBottom: PreferredSize( + child: AkuTabBar( + controller: _tabController, + tabs: _tabs, + ), + preferredSize: Size.fromHeight(96.w)), actions: [ - userProvider.userInfoModel.role != USER_ROLE.MANAGER - ? AkuMaterialButton( - minWidth: 178.w, - onPressed: () { - Get.to(AllBorrowGoods()); - }, - child: Text( - '全部物品', - style: TextStyle( - fontSize: 28.w, - color: AppStyle.primaryTextColor, - ), - ), - ) - : SizedBox(), + AkuMaterialButton( + minWidth: 178.w, + onPressed: () { + Get.to(AllBorrowGoods()); + }, + child: Text( + '全部物品', + style: TextStyle( + fontSize: 28.w, + color: AppStyle.primaryTextColor, + ), + ), + ), ], ); }