From a07313e46eaff6b6702f8dfe1552eedccc5f63d3 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Thu, 20 May 2021 17:18:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=BF=E5=8C=96=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../green_manage/green_manage_card.dart | 152 ++++++++++++++++++ .../green_manage/green_manage_map.dart | 29 ++++ .../green_manage/green_manage_page.dart | 144 +++-------------- .../green_manage/green_manage_view.dart | 19 +++ 4 files changed, 221 insertions(+), 123 deletions(-) create mode 100644 lib/ui/manage_pages/green_manage/green_manage_card.dart create mode 100644 lib/ui/manage_pages/green_manage/green_manage_map.dart create mode 100644 lib/ui/manage_pages/green_manage/green_manage_view.dart diff --git a/lib/ui/manage_pages/green_manage/green_manage_card.dart b/lib/ui/manage_pages/green_manage/green_manage_card.dart new file mode 100644 index 0000000..f8e89f5 --- /dev/null +++ b/lib/ui/manage_pages/green_manage/green_manage_card.dart @@ -0,0 +1,152 @@ +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/aku_divider.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/green_manage/green_manage_map.dart'; +import 'package:aku_ui/common_widgets/aku_button.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:aku_community_manager/tools/extensions/list_extension_tool.dart'; + +class GreenManageCard extends StatefulWidget { + final int index; + GreenManageCard({Key key, this.index}) : super(key: key); + + @override + _GreenManageCardState createState() => _GreenManageCardState(); +} + +class _GreenManageCardState extends State { + @override + Widget build(BuildContext context) { + return AkuButton( + onPressed: () { + // Get.to(GreenManageDetailsPage(cardModel)); + }, + child: Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w), + color: Color(0xFFFFFFFF), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + alignment: Alignment.centerLeft, + child: Row( + children: [ + Text( + 'cardModel.title', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 32.w, + fontWeight: FontWeight.bold), + ), + Spacer(), + GreenManageMap.statusString(widget.index + 1) + .text + .size(28.sp) + .color(GreenManageMap.statusColor(widget.index + 1)) + .bold + .make(), + ], + ), + ), + 16.w.heightBox, + AkuDivider.horizontal(), + 24.w.heightBox, + ...[ + Row( + children: [ + Image.asset( + R.ASSETS_MANAGE_IC_RENWU_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text('工作内容', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + )), + Spacer(), + Text( + 'cardModel.task', + style: AppStyle().primaryStyle, + ), + ], + ), + Row( + children: [ + Image.asset( + R.ASSETS_MESSAGE_IC_PEOPLE_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text('负责人员', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + )), + Spacer(), + Text( + 'cardModel.name', + style: AppStyle().primaryStyle, + ), + ], + ), + Row( + children: [ + Image.asset( + R.ASSETS_MANAGE_IC_TIME_PNG, + width: 40.w, + height: 40.w, + ), + AkuBox.w(4), + Text('时间期限', + style: TextStyle( + color: AppStyle.primaryTextColor, fontSize: 28.sp)), + Spacer(), + Text( + '${'cardModel.timestart'}至${'cardModel.timeend'}', + style: AppStyle().primaryStyle, + ), + ], + ), + ].sepWidget(separate: 16.w.heightBox), + ..._buttomButtons() + ], + ), + ), + ); + } + + List _buttomButtons() { + return widget.index != 0 + ? [SizedBox()] + : [ + 40.w.heightBox, + Row( + children: [ + '请在期限前完成绿化任务'.text.size(24.sp).color(kTextSubColor).make(), + Spacer(), + AkuButton( + color: kPrimaryColor, + radius: 74.w, + padding: + EdgeInsets.symmetric(vertical: 8.w, horizontal: 24.w), + height: 52.w, + child: '确认完成' + .text + .size(26.sp) + .color(kTextPrimaryColor) + .bold + .make(), + onPressed: () {}, + ) + ], + ) + ]; + } +} diff --git a/lib/ui/manage_pages/green_manage/green_manage_map.dart b/lib/ui/manage_pages/green_manage/green_manage_map.dart new file mode 100644 index 0000000..ffc197c --- /dev/null +++ b/lib/ui/manage_pages/green_manage/green_manage_map.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class GreenManageMap { + static String statusString(int status) { + switch (status) { + case 1: + return '待处理'; + case 2: + return '未完成'; + case 3: + return '已完成'; + default: + return '未知'; + } + } + + static Color statusColor(int status) { + switch (status) { + case 1: + return Color(0xFFFF8200); + case 2: + return Color(0xFFE60E0E); + case 3: + return Color(0xFF999999); + default: + return Colors.black; + } + } +} diff --git a/lib/ui/manage_pages/green_manage/green_manage_page.dart b/lib/ui/manage_pages/green_manage/green_manage_page.dart index b93b454..0a67ded 100644 --- a/lib/ui/manage_pages/green_manage/green_manage_page.dart +++ b/lib/ui/manage_pages/green_manage/green_manage_page.dart @@ -1,19 +1,13 @@ // Flutter imports: +import 'package:aku_community_manager/ui/manage_pages/green_manage/green_manage_view.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:flutter/material.dart'; // Package imports: -import 'package:aku_ui/common_widgets/aku_common_widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:provider/provider.dart'; // Project imports: -import 'package:aku_community_manager/const/resource.dart'; -import 'package:aku_community_manager/mock_models/manage_models/manage_model.dart'; -import 'package:aku_community_manager/provider/manage_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/manage_pages/green_manage/green_manage_details_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; class GreenManagePage extends StatefulWidget { @@ -23,125 +17,29 @@ class GreenManagePage extends StatefulWidget { _GreenManagePageState createState() => _GreenManagePageState(); } -class _GreenManagePageState extends State { +class _GreenManagePageState extends State with TickerProviderStateMixin { + List _tabs=['待处理','未完成','已完成']; + TabController _tabController; + + @override + void initState() { + super.initState(); + _tabController=TabController(length: _tabs.length, vsync: this); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { - final greenManageProvider = Provider.of(context); return AkuScaffold( title: '绿化管理', - body: ListView.builder( - itemBuilder: (context, index) { - return _greenManageCard(greenManageProvider.greenManageModels[index]); - }, - padding: EdgeInsets.only(left: 32.w, right: 32.w, bottom: 40.w), - itemCount: greenManageProvider.greenManageModels.length, - ), - ); - } - - ///绿化管理页面卡片 - Widget _greenManageCard(GreenManageCardModel cardModel) { - return Column( - children: [ - AkuBox.h(16), - //跳转管理详情按钮 - AkuButton( - onPressed: () { - Get.to(GreenManageDetailsPage(cardModel)); - }, - child: Container( - height: 302.w, - width: 686.w, - padding: EdgeInsets.only( - left: 24.w, - right: 24.w, - bottom: 40.w, - ), - color: Color(0xFFFFFFFF), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - height: 93.w, - alignment: Alignment.centerLeft, - child: Text( - cardModel.title, - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 32.w, - fontWeight: FontWeight.bold), - ), - ), - Divider( - height: 1.w, - ), - AkuBox.h(24), - Row( - children: [ - Image.asset( - R.ASSETS_MANAGE_IC_RENWU_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text('任务概要', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - )), - Spacer(), - Text( - cardModel.task, - style: AppStyle().primaryStyle, - ), - ], - ), - Spacer(), - Row( - children: [ - Image.asset( - R.ASSETS_MANAGE_IC_TIME_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text('时间期限', - style: TextStyle( - color: AppStyle.primaryTextColor, fontSize: 28.sp)), - Spacer(), - Text( - '${cardModel.timestart}至${cardModel.timeend}', - style: AppStyle().primaryStyle, - ), - ], - ), - Spacer(), - Row( - children: [ - Image.asset( - R.ASSETS_MESSAGE_IC_PEOPLE_PNG, - width: 40.w, - height: 40.w, - ), - AkuBox.w(4), - Text('负责人员', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - )), - Spacer(), - Text( - cardModel.name, - style: AppStyle().primaryStyle, - ), - ], - ), - ], - ), - ), - ), - ], + appBarBottom: PreferredSize(preferredSize: Size.fromHeight(88.w), child: AkuTabBar(controller: _tabController, tabs: _tabs)), + body: TabBarView(controller: _tabController, children: List.generate(_tabs.length, (index) => GreenManageView( + index:index, + ),),), ); } } diff --git a/lib/ui/manage_pages/green_manage/green_manage_view.dart b/lib/ui/manage_pages/green_manage/green_manage_view.dart new file mode 100644 index 0000000..daf75ef --- /dev/null +++ b/lib/ui/manage_pages/green_manage/green_manage_view.dart @@ -0,0 +1,19 @@ +import 'package:aku_community_manager/ui/manage_pages/green_manage/green_manage_card.dart'; +import 'package:flutter/material.dart'; + +class GreenManageView extends StatefulWidget { + final int index; + GreenManageView({Key key, this.index}) : super(key: key); + + @override + _GreenManageViewState createState() => _GreenManageViewState(); +} + +class _GreenManageViewState extends State { + @override + Widget build(BuildContext context) { + return ListView( + children: [GreenManageCard(index: widget.index,)], + ); + } +}