diff --git a/lib/mock_models/users/user_info_model.dart b/lib/mock_models/users/user_info_model.dart index 6abd172..2226d3e 100644 --- a/lib/mock_models/users/user_info_model.dart +++ b/lib/mock_models/users/user_info_model.dart @@ -1,10 +1,56 @@ import 'dart:io'; +enum USER_ROLE { + ///管家角色 + MANAGER, + + ///修理师傅角色 + FIXER, + + ///保安角色 + SECURITY, + + ///无角色 + EMPTY, +} + class UserInfoModel { String nickName; File avatar; + USER_ROLE role; UserInfoModel({ this.nickName, this.avatar, + this.role, + }); + + UserInfoModel.empty({ + this.nickName = '', + this.avatar, + this.role = USER_ROLE.EMPTY, + }); + + ///管家角色生成 + ///password 000000 + UserInfoModel.manager({ + this.nickName = '李管家', + this.avatar, + this.role = USER_ROLE.MANAGER, + }); + + ///师傅角色生成 + ///password 000001 + UserInfoModel.fixer({ + this.nickName = '王师傅', + this.avatar, + this.role = USER_ROLE.FIXER, + }); + + ///师傅角色生成 + ///password 000002 + UserInfoModel.security({ + this.nickName = '林保安', + this.avatar, + this.role = USER_ROLE.SECURITY, }); } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 5072b15..8ab535d 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -17,13 +17,16 @@ class UserProvider extends ChangeNotifier { notifyListeners(); } - UserInfoModel _userInfoModel = UserInfoModel( - nickName: '李大海', - avatar: null, - ); + UserInfoModel _userInfoModel = UserInfoModel.empty(); UserInfoModel get userInfoModel => _userInfoModel; + setUserInfo(UserInfoModel model) { + _userInfoModel = model; + _isSigned = true; + notifyListeners(); + } + setNickName(String name) { _userInfoModel.nickName = name; notifyListeners(); diff --git a/lib/ui/home/business/business_card.dart b/lib/ui/home/business/business_card.dart new file mode 100644 index 0000000..039d4d6 --- /dev/null +++ b/lib/ui/home/business/business_card.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:aku_community_manager/tools/screen_tool.dart'; + +class BusinessCard extends StatefulWidget { + BusinessCard({Key key}) : super(key: key); + + @override + _BusinessCardState createState() => _BusinessCardState(); +} + +class _BusinessCardState extends State { + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.symmetric(horizontal: 32.w), + ); + } +} diff --git a/lib/ui/home/business/business_page.dart b/lib/ui/home/business/business_page.dart index d3dfe47..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'; @@ -14,7 +15,7 @@ class BusinessPage extends StatefulWidget { class _BusinessPageState extends State with TickerProviderStateMixin { - List tabs = ['待处理', '处理中', '已处理', '全部']; + List _tabs = ['待处理', '处理中', '已处理', '全部']; TabController _tabController; @override @@ -38,23 +39,25 @@ 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), ), + body: TabBarView( + controller: _tabController, + children: _tabs.map((e) => _buildTabPage(_tabs.indexOf(e))).toList(), + ), + ); + } + + Widget _buildTabPage(int index) { + return ListView.builder( + itemBuilder: (context, index) { + return Text(index.toString()); + }, + itemCount: 50, ); } } diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index 73029ed..c0a29f8 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -9,6 +9,7 @@ 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/visitor_manager/visitor_manager_page.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'; @@ -294,7 +295,10 @@ class _HomePageState extends State { _menuButton( R.ASSETS_HOME_IC_VISITORS_PNG, '访客管理', VisitorManagerPage()), _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/home/personal_draw.dart b/lib/ui/home/personal_draw.dart index a8457af..b3d95a0 100644 --- a/lib/ui/home/personal_draw.dart +++ b/lib/ui/home/personal_draw.dart @@ -84,7 +84,7 @@ class _PersonalDrawState extends State { onTap: () {}, child: userProvider.isSigned ? Text( - '李大海', + userProvider.userInfoModel.nickName, style: TextStyle( color: AppStyle.primaryTextColor, fontSize: 28.sp, diff --git a/lib/ui/login/login_sms_page.dart b/lib/ui/login/login_sms_page.dart index 165ce0e..7de3dda 100644 --- a/lib/ui/login/login_sms_page.dart +++ b/lib/ui/login/login_sms_page.dart @@ -1,5 +1,6 @@ import 'dart:async'; +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'; @@ -7,6 +8,7 @@ import 'package:aku_community_manager/ui/home/home_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_back_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:get/get.dart'; @@ -97,8 +99,16 @@ class _LoginSMSPageState extends State { final userProvider = Provider.of(context, listen: false); if (text == '000000') { - userProvider.setisSigned(true); + userProvider.setUserInfo(UserInfoModel.manager()); Get.offAll(HomePage()); + } else if (text == '000001') { + userProvider.setUserInfo(UserInfoModel.fixer()); + Get.offAll(HomePage()); + } else if (text == '000002') { + userProvider.setUserInfo(UserInfoModel.security()); + Get.offAll(HomePage()); + } else { + if (text.length == 6) BotToast.showText(text: '验证码错误'); } }, ), 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 new file mode 100644 index 0000000..ec82f4b --- /dev/null +++ b/lib/ui/sub_pages/business_and_fix/business_and_fix_page.dart @@ -0,0 +1,63 @@ +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); + + @override + _BusinessAndFixPageState createState() => _BusinessAndFixPageState(); +} + +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( + title: '报事报修', + bottom: PreferredSize( + preferredSize: Size.fromHeight(88.w), + child: AkuTabBar( + controller: _tabController, + tabs: _tabs, + ), + ), + ); + } +} 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(), + ); + } +}