From 4bbf39baba746deb1cde4370b7ffb542ab25d0e0 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 5 Nov 2020 16:18:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A3=85=E4=BF=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 14 +- .../decoration/decoration_data.dart | 1 + lib/mock_models/fix/fixer_model.dart | 15 ++ lib/provider/fix_provider.dart | 2 + .../decoration_check_row.dart | 9 +- .../decoration_department_page.dart | 188 +++++++++++++ .../decoration_manager_detail_page.dart | 253 +++++++++++++++--- lib/ui/widgets/inner/show_bottom_sheet.dart | 60 +++-- pubspec.lock | 12 + pubspec.yaml | 2 + 10 files changed, 492 insertions(+), 64 deletions(-) create mode 100644 lib/ui/sub_pages/decoration_manager/decoration_department_page.dart diff --git a/lib/main.dart b/lib/main.dart index 9206018..ffb8505 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,7 +4,9 @@ import 'package:aku_community_manager/provider/manage_provider.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/ui/home/home_page.dart'; import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; @@ -21,8 +23,8 @@ class MyApp extends StatelessWidget { ChangeNotifierProvider(create: (context) => UserProvider()), ChangeNotifierProvider(create: (context) => AppProvider()), ChangeNotifierProvider(create: (context) => FixProvider()), - ChangeNotifierProvider(create: (context)=> GreenManageProvider()), - ChangeNotifierProvider(create: (context)=>InspectionManageProvider()), + ChangeNotifierProvider(create: (context) => GreenManageProvider()), + ChangeNotifierProvider(create: (context) => InspectionManageProvider()), ], child: GetMaterialApp( title: '小蜜蜂管家', @@ -31,6 +33,14 @@ class MyApp extends StatelessWidget { navigatorObservers: [ BotToastNavigatorObserver(), ], + localizationsDelegates: [ + GlobalCupertinoLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: [ + const Locale('zh'), + ], ), ); } diff --git a/lib/mock_models/decoration/decoration_data.dart b/lib/mock_models/decoration/decoration_data.dart index bc321b3..e607017 100644 --- a/lib/mock_models/decoration/decoration_data.dart +++ b/lib/mock_models/decoration/decoration_data.dart @@ -18,6 +18,7 @@ class DecorationData { userName: '李惠政', phone: '19298540192', ), + cycleCheck: CycleCheck(), ), DecorationModel( decorationDate: DateTime(2020, 1, 23, 12, 23, 0), diff --git a/lib/mock_models/fix/fixer_model.dart b/lib/mock_models/fix/fixer_model.dart index dbf0528..1c8834b 100644 --- a/lib/mock_models/fix/fixer_model.dart +++ b/lib/mock_models/fix/fixer_model.dart @@ -7,6 +7,9 @@ enum FIXER_TYPE { ///水泥组 CEMENT, + + ///物业组 + PROPERTY, } class FixerModel { @@ -28,6 +31,8 @@ class FixerTypedModel { case FIXER_TYPE.CEMENT: return '水泥组'; break; + case FIXER_TYPE.PROPERTY: + return '物业组'; default: return ''; } @@ -66,4 +71,14 @@ class FixerTypedModel { ], ), ]; + + static List propertyModels = [ + FixerTypedModel( + type: FIXER_TYPE.PROPERTY, + fixers: [ + FixerModel(name: '李国师傅', phone: '18923747283'), + FixerModel(name: '章则林师傅', phone: '18910298345'), + ], + ), + ]; } diff --git a/lib/provider/fix_provider.dart b/lib/provider/fix_provider.dart index 7a91953..9633809 100644 --- a/lib/provider/fix_provider.dart +++ b/lib/provider/fix_provider.dart @@ -58,5 +58,7 @@ class FixProvider extends ChangeNotifier { } List _fixerModels = FixerTypedModel.models; + List _propertyModels = FixerTypedModel.propertyModels; List get fixerModels => _fixerModels; + List get propertyModels => _propertyModels; } diff --git a/lib/ui/sub_pages/decoration_manager/decoration_check_row.dart b/lib/ui/sub_pages/decoration_manager/decoration_check_row.dart index 43514c1..3fcaf9e 100644 --- a/lib/ui/sub_pages/decoration_manager/decoration_check_row.dart +++ b/lib/ui/sub_pages/decoration_manager/decoration_check_row.dart @@ -8,7 +8,9 @@ import 'package:aku_community_manager/tools/screen_tool.dart'; class DecorationCheckRow extends StatefulWidget { final List details; final Function(List details) onChange; - DecorationCheckRow({Key key, @required this.details, this.onChange}) + final bool canTap; + DecorationCheckRow( + {Key key, @required this.details, this.onChange, this.canTap = false}) : super(key: key); @override @@ -35,9 +37,10 @@ class _DecorationCheckRowState extends State { scrollDirection: Axis.horizontal, itemBuilder: (context, index) { return GestureDetector( - onTap: widget.onChange == null + onTap: !widget.canTap ? null : () { + widget.onChange(_checkedDetails); setState(() { _checkedDetails.indexOf(_tempCheckDetails[index]) != -1 ? _checkedDetails.remove(_tempCheckDetails[index]) @@ -48,7 +51,7 @@ class _DecorationCheckRowState extends State { color: Colors.transparent, child: DecorationCheckCardWidget( type: _tempCheckDetails[index], - checked: widget.onChange == null + checked: !widget.canTap ? false : _checkedDetails.indexOf(_tempCheckDetails[index]) != -1, ), diff --git a/lib/ui/sub_pages/decoration_manager/decoration_department_page.dart b/lib/ui/sub_pages/decoration_manager/decoration_department_page.dart new file mode 100644 index 0000000..c981799 --- /dev/null +++ b/lib/ui/sub_pages/decoration_manager/decoration_department_page.dart @@ -0,0 +1,188 @@ +import 'package:aku_community_manager/const/resource.dart'; +import 'package:aku_community_manager/mock_models/decoration/decoration_model.dart'; +import 'package:aku_community_manager/mock_models/fix/fix_model.dart'; +import 'package:aku_community_manager/mock_models/fix/fixer_model.dart'; +import 'package:aku_community_manager/provider/fix_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_community_manager/tools/screen_tool.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:expandable/expandable.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; + +class DecorationDepartmentPage extends StatefulWidget { + final DecorationModel model; + DecorationDepartmentPage({Key key, @required this.model}) : super(key: key); + + @override + _DecorationDepartmentPageState createState() => + _DecorationDepartmentPageState(); +} + +class _DecorationDepartmentPageState extends State { + FixerModel _pickedFixer; + @override + Widget build(BuildContext context) { + final fixProvider = Provider.of(context); + + return AkuScaffold( + title: '装修指派', + body: ListView.builder( + padding: EdgeInsets.symmetric(vertical: 16.w), + itemBuilder: (context, index) { + return _buildItem(fixProvider.propertyModels[index], index); + }, + itemCount: fixProvider.propertyModels.length, + ), + bottom: AkuMaterialButton( + height: 96.w, + onPressed: _pickedFixer == null + ? null + : () { + widget.model.cycleCheck.authPerson = _pickedFixer; + Get.back(); + }, + color: AppStyle.primaryColor, + nullColor: AppStyle.primaryColor.withOpacity(0.5), + child: Text( + '选择完成', + style: TextStyle( + color: _pickedFixer == null + ? AppStyle.minorTextColor + : AppStyle.primaryTextColor, + fontSize: 32.w, + fontWeight: FontWeight.bold, + ), + ), + ), + ); + } + + _buildItem(FixerTypedModel model, int index) { + return Container( + decoration: BoxDecoration( + border: Border( + top: index == 0 + ? BorderSide.none + : BorderSide(color: Color(0xFFE8E8E8), width: 1.w), + bottom: BorderSide(color: Color(0xFFE8E8E8), width: 1.w), + ), + ), + child: Material( + color: Colors.white, + child: ExpandablePanel( + controller: ExpandableController(initialExpanded: true), + header: Container( + height: 96.w, + alignment: Alignment.centerLeft, + padding: EdgeInsets.symmetric(horizontal: 32.w), + child: Text( + model.typeName, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 32.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + collapsed: SizedBox(), + expanded: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Divider( + color: Color(0xFFE8E8E8), + height: 1.w, + thickness: 1.w, + ), + ...model.fixers.map((e) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + AkuMaterialButton( + height: 96.w, + onPressed: () { + if (_pickedFixer?.name != e.name) { + _pickedFixer = e; + } else { + _pickedFixer = null; + } + setState(() {}); + }, + child: Row( + children: [ + AkuBox.w(72), + Checkbox( + checkColor: AppStyle.primaryTextColor, + activeColor: AppStyle.primaryColor, + value: _pickedFixer?.name == e.name, + onChanged: (state) { + if (_pickedFixer == null) { + _pickedFixer = e; + } else { + _pickedFixer = null; + } + setState(() {}); + }, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + ), + Image.asset( + R.ASSETS_MESSAGE_IC_PEOPLE_PNG, + height: 40.w, + width: 40.w, + ), + Text( + e.name, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.w, + fontWeight: FontWeight.bold, + ), + ), + Spacer(), + Image.asset( + R.ASSETS_MESSAGE_IC_PHONE_PNG, + height: 40.w, + width: 40.w, + ), + Text( + e.phone, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.w, + fontWeight: FontWeight.bold, + ), + ), + AkuBox.w(101), + ], + ), + ), + model.fixers.last == e + ? SizedBox() + : Divider( + indent: 32.w, + endIndent: 32.w, + height: 1.w, + thickness: 1.w, + color: Color(0xFFE8E8E8), + ), + ], + ); + }).toList() + ], + ), + theme: ExpandableThemeData( + tapHeaderToExpand: true, + iconPlacement: ExpandablePanelIconPlacement.right, + iconPadding: EdgeInsets.only(top: 32.w, right: 32.w), + iconSize: 32.w, + iconColor: AppStyle.minorTextColor, + ), + ), + ), + ); + } +} diff --git a/lib/ui/sub_pages/decoration_manager/decoration_manager_detail_page.dart b/lib/ui/sub_pages/decoration_manager/decoration_manager_detail_page.dart index e2fa350..e44f94b 100644 --- a/lib/ui/sub_pages/decoration_manager/decoration_manager_detail_page.dart +++ b/lib/ui/sub_pages/decoration_manager/decoration_manager_detail_page.dart @@ -3,14 +3,20 @@ 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/decoration_manager/decoration_check_row.dart'; import 'package:aku_community_manager/ui/sub_pages/decoration_manager/decoration_checkbox.dart'; +import 'package:aku_community_manager/ui/sub_pages/decoration_manager/decoration_department_page.dart'; import 'package:aku_community_manager/ui/sub_pages/decoration_manager/decoration_util.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_community_manager/ui/widgets/inner/aku_title_box.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:aku_community_manager/const/resource.dart'; +import 'package:aku_community_manager/ui/widgets/inner/show_bottom_sheet.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:common_utils/common_utils.dart'; import 'package:expandable/expandable.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; class DecorationManagerDetailPage extends StatefulWidget { final DecorationModel model; @@ -24,6 +30,7 @@ class DecorationManagerDetailPage extends StatefulWidget { class _DecorationManagerDetailStatePage extends State { + bool get isWaitHandOut => widget.model.type == DecorationType.WAIT_HAND_OUT; @override Widget build(BuildContext context) { return AkuScaffold( @@ -32,9 +39,13 @@ class _DecorationManagerDetailStatePage padding: EdgeInsets.symmetric(vertical: 16.w), children: [ _buildInfo(), - _buildFinishWorkCheck(), + widget.model.workFinishCheck == null + ? SizedBox() + : _buildFinishWorkCheck(), _buildCycleCheck(), - _buildCheckDetail(), + widget.model.type == DecorationType.WAIT_HAND_OUT + ? SizedBox() + : _buildCheckDetail(), ], ), ); @@ -209,13 +220,13 @@ class _DecorationManagerDetailStatePage ), _buildRow( title: '接受人', - subTitle: widget.model.workFinishCheck.authPerson.name, + subTitle: widget.model.workFinishCheck?.authPerson?.name, ), _buildRow(title: '所属项目', subTitle: '装修管理'), _buildRow( title: '开始日期', subTitle: DateUtil.formatDate( - widget.model.workFinishCheck.startDate, + widget.model.workFinishCheck?.startDate, format: 'yyyy-MM-dd', ), ), @@ -232,7 +243,7 @@ class _DecorationManagerDetailStatePage ), ), DecorationCheckRow( - details: widget.model.workFinishCheck.checkDetails, + details: widget.model.workFinishCheck?.checkDetails, onChange: (details) {}, ), ], @@ -253,15 +264,164 @@ class _DecorationManagerDetailStatePage ), _buildRow( title: '接受人', - subTitle: widget.model.cycleCheck.authPerson.name, + subTitle: widget.model.cycleCheck?.authPerson?.name, + onTap: isWaitHandOut + ? () { + Get.to(DecorationDepartmentPage( + model: widget.model, + )).then((value) => setState(() {})); + } + : null, ), _buildRow(title: '所属项目', subTitle: '装修管理'), _buildRow( title: '开始日期', subTitle: DateUtil.formatDate( - widget.model.cycleCheck.startDate, + widget.model.cycleCheck?.startDate, format: 'yyyy-MM-dd', ), + onTap: isWaitHandOut + ? () { + showAkuSheet( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + AkuBox.h(96), + AkuBackButton.text(), + Spacer(), + Text( + '开始日期', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 32.sp, + fontWeight: FontWeight.bold, + ), + ), + Spacer(), + AkuMaterialButton( + minWidth: (64 + 56).w, + onPressed: () { + Get.back(); + }, + child: Text( + '确定', + style: TextStyle( + color: AppStyle.secondaryColor, + fontSize: 28.sp, + ), + ), + ), + ], + ), + Container( + height: 500.w, + child: CupertinoDatePicker( + onDateTimeChanged: (dateTime) { + widget.model.cycleCheck.startDate = dateTime; + }, + ), + ), + ], + ), + ).then((value) { + setState(() {}); + }); + } + : null, + ), + _buildRow( + title: '检查周期', + subTitle: widget.model.cycleCheck.checkCycle == null + ? null + : '${widget.model.cycleCheck.checkCycle}天', + onTap: isWaitHandOut + ? () { + showAkuSheet( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + AkuBox.h(96), + AkuBackButton.text(), + Spacer(), + Text( + '检查周期', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 32.sp, + fontWeight: FontWeight.bold, + ), + ), + Spacer(), + AkuMaterialButton( + minWidth: (64 + 56).w, + onPressed: () { + Get.back(); + }, + child: Text( + '确定', + style: TextStyle( + color: AppStyle.secondaryColor, + fontSize: 28.sp, + ), + ), + ), + ], + ), + Container( + height: 500.w, + child: CupertinoPicker( + children: [ + Center( + child: Text('1天'), + ), + Center( + child: Text('3天'), + ), + Center( + child: Text('7天'), + ), + Center( + child: Text('14天'), + ), + Center( + child: Text('30天'), + ), + ], + itemExtent: 88.w, + onSelectedItemChanged: (int value) { + int realValue = 0; + switch (value) { + case 0: + realValue = 1; + break; + case 1: + realValue = 3; + break; + case 2: + realValue = 7; + break; + case 3: + realValue = 14; + break; + case 4: + realValue = 30; + break; + } + widget.model.cycleCheck.checkCycle = realValue; + }, + ), + ), + ], + ), + ).then((value) { + setState(() {}); + }); + } + : null, ), Padding( padding: EdgeInsets.symmetric( @@ -275,7 +435,19 @@ class _DecorationManagerDetailStatePage ), ), ), - DecorationCheckRow(details: widget.model.cycleCheck.checkDetails), + DecorationCheckRow( + details: [ + CHECK_TYPE.ELECTRIC, + CHECK_TYPE.WATER, + CHECK_TYPE.WALL, + CHECK_TYPE.DOOR_AND_WINDOWS, + CHECK_TYPE.SECURITY, + ], + onChange: (details) { + widget.model.cycleCheck.checkDetails = details; + }, + canTap: isWaitHandOut, + ) ], ); } @@ -407,33 +579,50 @@ class _DecorationManagerDetailStatePage _buildRow({ String title, String subTitle, + VoidCallback onTap, }) { - return Container( - decoration: BoxDecoration( - border: - Border(bottom: BorderSide(color: Color(0xFFE8E8E8), width: 1.w)), - ), + return Material( + color: Colors.transparent, child: InkWell( - child: Row( - children: [ - AkuBox.h(96), - Text( - title, - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.w, - ), - ), - Spacer(), - Text( - subTitle, - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.w, - fontWeight: FontWeight.bold, - ), + onTap: onTap, + child: Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide(color: Color(0xFFE8E8E8), width: 1.w)), + ), + child: InkWell( + child: Row( + children: [ + AkuBox.h(96), + Text( + title, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.w, + ), + ), + Spacer(), + Text( + TextUtil.isEmpty(subTitle) ? '请选择' : subTitle, + style: TextStyle( + color: TextUtil.isEmpty(subTitle) + ? AppStyle.minorTextColor + : AppStyle.primaryTextColor, + fontSize: 28.w, + fontWeight: FontWeight.bold, + ), + ), + onTap == null ? SizedBox() : AkuBox.w(24), + onTap == null + ? SizedBox() + : Icon( + Icons.arrow_forward_ios, + size: 32.w, + color: AppStyle.minorTextColor, + ), + ], ), - ], + ), ), ), ); diff --git a/lib/ui/widgets/inner/show_bottom_sheet.dart b/lib/ui/widgets/inner/show_bottom_sheet.dart index e1c3d6c..bdc51a9 100644 --- a/lib/ui/widgets/inner/show_bottom_sheet.dart +++ b/lib/ui/widgets/inner/show_bottom_sheet.dart @@ -6,7 +6,7 @@ import 'package:get/get.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; ///show bottom sheet -showAkuSheet({ +Future showAkuSheet({ Widget child, }) async { await Get.bottomSheet( @@ -20,12 +20,7 @@ showAkuSheet({ ); } -Future showItemSheet({ - String title, - List items, - String selectItem, - Function(String result) onTap, -}) async { +Future showNormalSheet(String title, List children) async { await showAkuSheet( child: Column( mainAxisSize: MainAxisSize.min, @@ -49,27 +44,38 @@ Future showItemSheet({ Spacer(), ], ), - ...items.map((e) { - return AkuMaterialButton( - height: 96.w, - minWidth: double.infinity, - onPressed: () { - Get.back(); - onTap(e); - }, - child: Text( - e, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 32.sp, - color: e == selectItem - ? AppStyle.secondaryColor - : AppStyle.primaryTextColor, - ), - ), - ); - }).toList(), + ...children, ], ), ); } + +Future showItemSheet({ + String title, + List items, + String selectItem, + Function(String result) onTap, +}) async { + await showNormalSheet( + title, + items.map((e) { + return AkuMaterialButton( + height: 96.w, + minWidth: double.infinity, + onPressed: () { + Get.back(); + onTap(e); + }, + child: Text( + e, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 32.sp, + color: e == selectItem + ? AppStyle.secondaryColor + : AppStyle.primaryTextColor, + ), + ), + ); + }).toList()); +} diff --git a/pubspec.lock b/pubspec.lock index f59367b..d2f6c2f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -141,6 +141,11 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.6" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -202,6 +207,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.1" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.16.1" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d5ad5f5..e0b15bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,8 @@ environment: dependencies: flutter: sdk: flutter + flutter_localizations: + sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.