diff --git a/assets/manage/key.png b/assets/manage/key.png new file mode 100644 index 0000000..c294e62 Binary files /dev/null and b/assets/manage/key.png differ diff --git a/assets/manage/lock.png b/assets/manage/lock.png new file mode 100644 index 0000000..dd541be Binary files /dev/null and b/assets/manage/lock.png differ diff --git a/lib/models/manager/package_manage/package_manage_list_model.dart b/lib/models/manager/package_manage/package_manage_list_model.dart index f3310ca..85a6170 100644 --- a/lib/models/manager/package_manage/package_manage_list_model.dart +++ b/lib/models/manager/package_manage/package_manage_list_model.dart @@ -6,8 +6,8 @@ class PackageManageListModel { String address; String placePosition; int status; - DateTime receiveDate; - DateTime createDate; + String receiveDate; + String createDate; PackageManageListModel( {this.id, diff --git a/lib/ui/home/application/applications_page.dart b/lib/ui/home/application/applications_page.dart index a0d67cc..e2b88b5 100644 --- a/lib/ui/home/application/applications_page.dart +++ b/lib/ui/home/application/applications_page.dart @@ -1,5 +1,6 @@ // Flutter imports: import 'package:aku_community_manager/models/manager/facilities/facilities_page.dart'; +import 'package:aku_community_manager/ui/manage_pages/key_manage/key_manage_page.dart'; import 'package:aku_community_manager/ui/manage_pages/packages_manage/packages_manage_page.dart'; import 'package:flutter/material.dart'; @@ -69,8 +70,9 @@ class _ApplicationPageState extends State AppApplication('借还管理', R.ASSETS_HOME_IC_BORROW_PNG, BorrowManagerPage()), AppApplication('巡检管理', R.ASSETS_HOME_IC_PATROL_PNG, InspectionManagePage()), AppApplication('绿化管理', R.ASSETS_HOME_IC_GREENING_PNG, GreenManagePage()), - AppApplication('设施检查', R.ASSETS_HOME_IC_FACILITIES_PNG,FacilitiesPage() ), - AppApplication('包裹管理', R.ASSETS_PLACEHOLDER_WEBP, PackagesManagePage()) + AppApplication('设施检查', R.ASSETS_HOME_IC_FACILITIES_PNG, FacilitiesPage()), + AppApplication('包裹管理', R.ASSETS_PLACEHOLDER_WEBP, PackagesManagePage()), + AppApplication('钥匙管理', R.ASSETS_PLACEHOLDER_WEBP, KeyManagePage()) ]; @override diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index c8230ba..f12898b 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -181,7 +181,7 @@ class _HomePageState extends State { final userProvider = Provider.of(context); final appProvider = Provider.of(context); var loadingWidget = Center( - child: CircularProgressIndicator(), + // child: CircularProgressIndicator(), ); return AnnotatedRegion( child: Scaffold( diff --git a/lib/ui/manage_pages/key_manage/key_manage_card.dart b/lib/ui/manage_pages/key_manage/key_manage_card.dart new file mode 100644 index 0000000..26a042f --- /dev/null +++ b/lib/ui/manage_pages/key_manage/key_manage_card.dart @@ -0,0 +1,127 @@ +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/aku_divider.dart'; +import 'package:aku_community_manager/ui/manage_pages/key_manage/key_manage_map.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 KeyManageCard extends StatefulWidget { + final int index; + KeyManageCard({Key key, this.index}) : super(key: key); + + @override + _KeyManageCardState createState() => _KeyManageCardState(); +} + +class _KeyManageCardState extends State { + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(8.w)), + padding: EdgeInsets.all(24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + '3-1-203配电箱' + .text + .size(32.sp) + .color(kTextPrimaryColor) + .bold + .make(), + Spacer(), + KeyManageMap.keyStatus[1].text + .size(28.sp) + .bold + .color(KeyManageMap.keyStatusColor[1]) + .make() + ], + ), + 16.w.heightBox, + AkuDivider.horizontal(), + 24.w.heightBox, + ...[ + _rowTile(R.ASSETS_MANAGE_KEY_PNG, '可申请钥匙数/钥匙总数', + '2/5'.text.size(24.sp).color(kTextSubColor).make()), + _rowTile(R.ASSETS_MANAGE_LOCK_PNG, '对应设备位置', + '2栋1楼2-3'.text.size(24.sp).color(kTextSubColor).make()), + _rowTile(R.ASSETS_OUTDOOR_IC_ADDRESS_PNG, '存放地址', + '物业管理处2号柜'.text.size(24.sp).color(kTextSubColor).make()) + ].sepWidget(separate: 12.w.heightBox), + _getBottomButtons(1), + ], + ), + ); + } + + Widget _getBottomButtons(int status) { + MaterialButton button; + switch (status) { + case 1: + button = _bottomButton('申请钥匙', () {}, Color(0xFFFFC40C), Colors.black); + break; + case 2: + break; + case 3: + button = _bottomButton('确认领取', () {}, Color(0xFFFFC40C), Colors.black); + break; + case 4: + button = _bottomButton('归还钥匙', () {}, Colors.black, Colors.white); + break; + case 5: + button = _bottomButton('重新提交', () {}, Colors.white, Colors.black); + break; + case 6: + button = _bottomButton('联系物业', () {}, Colors.white, Colors.black); + break; + default: + } + return button == null + ? SizedBox() + : Padding( + padding: EdgeInsets.only(top: 40.w), + child: Row( + children: [ + Spacer(), + button, + ], + ), + ); + } + + Widget _bottomButton( + String title, Function onPressed, Color color, Color textColor) { + return MaterialButton( + height: 52.w, + padding: EdgeInsets.symmetric(vertical: 8.w, horizontal: 24.w), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(74.w)), + color: color, + onPressed: onPressed, + elevation: 0, + focusElevation: 0, + hoverElevation: 0, + highlightElevation: 0, + child: title.text.size(26.sp).color(textColor).make(), + ); + } + + Widget _rowTile(String iconPath, String title, Widget content) { + return Row( + children: [ + SizedBox( + width: 40.w, + height: 40.w, + child: Image.asset(iconPath), + ), + 12.w.widthBox, + title.text.size(24.sp).color(kTextSubColor).make(), + Spacer(), + content, + ], + ); + } +} diff --git a/lib/ui/manage_pages/key_manage/key_manage_map.dart b/lib/ui/manage_pages/key_manage/key_manage_map.dart new file mode 100644 index 0000000..103de30 --- /dev/null +++ b/lib/ui/manage_pages/key_manage/key_manage_map.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class KeyManageMap { + static Map keyStatus = { + 1: '可申请', + 2: '审核中', + 3: '已通过', + 4: '使用中', + 5: '已驳回', + 6: '钥匙已空' + }; + static Map keyStatusColor = { + 1: Color(0xFF2576E5), + 2: Color(0xFFFFC40C), + 3: Color(0xFF333333), + 4: Color(0xFFFFC40C), + 5: Color(0xFFE60E0E), + 6: Color(0xFF999999), + }; + +} diff --git a/lib/ui/manage_pages/key_manage/key_manage_page.dart b/lib/ui/manage_pages/key_manage/key_manage_page.dart new file mode 100644 index 0000000..dd32041 --- /dev/null +++ b/lib/ui/manage_pages/key_manage/key_manage_page.dart @@ -0,0 +1,62 @@ +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/ui/manage_pages/key_manage/key_manage_view.dart'; +import 'package:aku_community_manager/ui/manage_pages/packages_manage/add_package_page.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class KeyManagePage extends StatefulWidget { + KeyManagePage({Key key}) : super(key: key); + + @override + _KeyManagePageState createState() => _KeyManagePageState(); +} + +class _KeyManagePageState 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) { + return AkuScaffold( + title: '钥匙管理', + actions: [ + InkWell( + onTap: () { + Get.to(() => AddPackagePage()); + }, + child: '申请记录'.text.size(26.sp).color(kTextPrimaryColor).make(), + ), + ], + appBarBottom: PreferredSize( + child: AkuTabBar(controller: _tabController, tabs: _tabs), + preferredSize: Size.fromHeight(88.w), + ), + body: TabBarView( + controller: _tabController, + children: List.generate( + _tabs.length, + (index) => KeyManageView( + index: index, + )), + ), + bottom: AkuBottomButton(title: '立即申请'), + ); + } +} diff --git a/lib/ui/manage_pages/key_manage/key_manage_view.dart b/lib/ui/manage_pages/key_manage/key_manage_view.dart new file mode 100644 index 0000000..eeed5b4 --- /dev/null +++ b/lib/ui/manage_pages/key_manage/key_manage_view.dart @@ -0,0 +1,25 @@ +import 'package:aku_community_manager/ui/manage_pages/key_manage/key_manage_card.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class KeyManageView extends StatefulWidget { + final int index; + KeyManageView({Key key, this.index}) : super(key: key); + + @override + _KeyManageViewState createState() => _KeyManageViewState(); +} + +class _KeyManageViewState extends State { + @override + Widget build(BuildContext context) { + return ListView( + padding: EdgeInsets.all(32.w), + children: [ + KeyManageCard( + index: widget.index, + ) + ], + ); + } +} diff --git a/lib/ui/manage_pages/packages_manage/add_package_page.dart b/lib/ui/manage_pages/packages_manage/add_package_page.dart index bc76007..c600139 100644 --- a/lib/ui/manage_pages/packages_manage/add_package_page.dart +++ b/lib/ui/manage_pages/packages_manage/add_package_page.dart @@ -1,6 +1,7 @@ import 'package:aku_community_manager/const/api.dart'; 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_bottom_button.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:bot_toast/bot_toast.dart'; @@ -100,23 +101,7 @@ class _AddPackagePageState extends State { ), ), ), - bottom: _bottomButton(), - ); - } - - Widget _bottomButton() { - return Padding( - padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), - child: MaterialButton( - minWidth: double.infinity, - height: 86.w, - color: kPrimaryColor, - elevation: 0, - focusElevation: 0, - hoverElevation: 0, - highlightElevation: 0, - padding: EdgeInsets.symmetric(vertical: 24.w), - onPressed: () async { + bottom: AkuBottomButton(title: '确认提交',onTap: () async { canSubmit ? await addPackage( code: _codeController.text, @@ -125,12 +110,11 @@ class _AddPackagePageState extends State { address: _addressController.text, placePosition: _placeController.text) : null; - }, - child: '确认提交'.text.size(32.sp).color(kTextPrimaryColor).bold.make(), - ), + },), ); } + Future addPackage( {@required String code, @required String addresseeName, diff --git a/lib/ui/manage_pages/packages_manage/packages_manage_card.dart b/lib/ui/manage_pages/packages_manage/packages_manage_card.dart index 83b663d..7ef3f9d 100644 --- a/lib/ui/manage_pages/packages_manage/packages_manage_card.dart +++ b/lib/ui/manage_pages/packages_manage/packages_manage_card.dart @@ -81,7 +81,7 @@ class _PackageManageCardState extends State { _rowTile( R.ASSETS_MANAGE_IC_TIME_PNG, '送达时间', - DateUtil.formatDate(widget.model.createDate, + DateUtil.formatDateStr(widget.model.createDate, format: 'yyyy-MM-dd HH:mm') .text .size(24.sp) diff --git a/lib/ui/manage_pages/packages_manage/packages_manage_page.dart b/lib/ui/manage_pages/packages_manage/packages_manage_page.dart index ba71e4e..e84a917 100644 --- a/lib/ui/manage_pages/packages_manage/packages_manage_page.dart +++ b/lib/ui/manage_pages/packages_manage/packages_manage_page.dart @@ -25,6 +25,12 @@ class _PackagesManagePageState extends State _tabController = TabController(length: _tabs.length, vsync: this); } + @override + void dispose() { + _tabController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return AkuScaffold( @@ -36,8 +42,8 @@ class _PackagesManagePageState extends State height: 40.w, child: Image.asset(R.ASSETS_MANAGE_ADD_PNG), ), - onPressed: () { - Get.to(() => AddPackagePage()); + onPressed: () async { + await Get.to(() => AddPackagePage()); }) ], appBarBottom: PreferredSize( diff --git a/lib/ui/manage_pages/packages_manage/packages_manage_view.dart b/lib/ui/manage_pages/packages_manage/packages_manage_view.dart index 2524e43..6b1f459 100644 --- a/lib/ui/manage_pages/packages_manage/packages_manage_view.dart +++ b/lib/ui/manage_pages/packages_manage/packages_manage_view.dart @@ -17,7 +17,9 @@ class PackagesManageView extends StatefulWidget { class _PackagesManageViewState extends State { EasyRefreshController _refreshController; - List _models; + void callRefresh(){ + _refreshController.callRefresh(); + } @override void initState() { super.initState(); @@ -37,12 +39,15 @@ class _PackagesManageViewState extends State { controller: _refreshController, extraParams: {"collectionStatus": widget.index + 1}, convert: (models) { - return models.tableList + List modelList = models.tableList .map((e) => PackageManageListModel.fromJson(e)) .toList(); + print(modelList); + return modelList; }, builder: (items) { return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 24.w,horizontal: 32.w), itemBuilder: (context, index) { return PackageManageCard( index: widget.index,