From 42d9d97adebe84ff6955e691d92a7eacf1bf4a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 25 Jan 2024 17:40:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8A=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E5=88=B7=E6=96=B0=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=92=A5=E5=8C=99?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=97=E8=A1=A8item=E9=83=BD=E8=83=BD?= =?UTF-8?q?=E5=B7=A6=E6=BB=91bug=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=97=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=AB=98=E5=BA=A6=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/baseWidget.dart | 23 -- .../authorizedAdminList_page.dart | 17 +- .../card/cardList/cardList_logic.dart | 24 +- .../card/cardList/cardList_page.dart | 168 +++++++------- .../checkingInSetHolidays_page.dart | 8 +- .../checkingInList/checkingInList_page.dart | 6 +- .../checkingInStaffList_page.dart | 2 +- .../electronicKeyList_logic.dart | 21 +- .../electronicKeyList_page.dart | 213 +++++++---------- .../lockUserList/lockUserList_page.dart | 2 +- .../face/faceList/faceList_page.dart | 2 +- .../fingerprintList_logic.dart | 23 +- .../fingerprintList/fingerprintList_page.dart | 171 +++++++------- .../lockOperatingRecord_page.dart | 2 +- .../lockSelectGrouping_page.dart | 2 +- .../nearbyDoorMagnetic_page.dart | 2 +- .../selectWirelessKeyboard_page.dart | 2 +- .../wirelessKeyboard_page.dart | 2 +- .../passwordKeyList_logic.dart | 18 +- .../passwordKeyList/passwordKeyList_page.dart | 218 ++++++++---------- .../passwordKeyList_state.dart | 2 - .../remoteControlList_page.dart | 2 +- .../videoLog/videoLog/videoLog_page.dart | 2 +- .../videoLogDownLoad_page.dart | 2 +- .../lockMian/lockList/lockList_logic.dart | 2 - .../lockMian/lockMain/lockMain_logic.dart | 77 +------ .../main/lockMian/lockMain/lockMain_page.dart | 24 +- .../messageList/messageList_logic.dart | 30 ++- .../message/messageList/messageList_page.dart | 69 +++++- .../messageList/messageList_state.dart | 2 - .../authorityManagement_page.dart | 4 +- .../authorizedAdministratorList_page.dart | 2 +- .../groupEditLock/groupEditLock_page.dart | 2 +- .../lockItemList_page.dart | 2 +- .../lockGroupList/lockGroupList_page.dart | 2 +- .../lockUserManageList_page.dart | 2 +- .../selectGetewayList_page.dart | 2 +- .../transferSmartLock_page.dart | 2 +- star_lock/lib/network/api.dart | 1 + star_lock/lib/network/api_provider.dart | 7 + star_lock/lib/network/api_repository.dart | 8 + star_lock/lib/tools/EasyRefreshTool.dart | 64 +++++ star_lock/lib/tools/baseGetXController.dart | 2 + star_lock/lib/tools/noData.dart | 47 ++-- star_lock/lib/tools/refreshHeadFoot.dart | 49 ---- star_lock/pubspec.yaml | 4 +- 46 files changed, 654 insertions(+), 684 deletions(-) create mode 100644 star_lock/lib/tools/EasyRefreshTool.dart delete mode 100644 star_lock/lib/tools/refreshHeadFoot.dart diff --git a/star_lock/lib/baseWidget.dart b/star_lock/lib/baseWidget.dart index f7fe1ed0..4315f18e 100644 --- a/star_lock/lib/baseWidget.dart +++ b/star_lock/lib/baseWidget.dart @@ -1,12 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/translations/trans_lib.dart'; -import 'tools/refreshHeadFoot.dart'; - mixin BaseWidget { double fs(double value) => value.sp; double w(double width) => width.w; @@ -47,24 +44,4 @@ mixin BaseWidget { ), ); } - - SmartRefresher smartRefresher(RefreshController refreshController,{ - Widget? child, - Function()? onRefresh, - Function()? onLoading, - bool enablePullDown = true, - bool enablePullUp = false, - bool enableTwoLevel = false, - }) => SmartRefresher( - controller: refreshController, - onRefresh: onRefresh, - onLoading: onLoading, - enablePullUp: enablePullUp, - enablePullDown: enablePullDown, - enableTwoLevel: enableTwoLevel, - header: const HeaderWidget(), - footer: const FooterWidget(), - child: child, - ); - } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 3dc1d880..0cb5ffe3 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -54,9 +54,7 @@ class _AuthorizedAdminListPageState extends State { body: Column( children: [ Expanded( - child: Obx(() => state.itemDataList.value.isEmpty - ? const NoData() - : _buildMainUI(state.itemDataList.value))), + child:_buildMainUI()), SizedBox( height: 20.h, ), @@ -82,14 +80,13 @@ class _AuthorizedAdminListPageState extends State { )); } - Widget _buildMainUI(itemData) { - List getItemData = itemData; - return getItemData.isEmpty - ? const NoData() + Widget _buildMainUI() { + return state.itemDataList.value.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 90) : ListView.separated( - itemCount: getItemData.length, + itemCount: state.itemDataList.value.length, itemBuilder: (c, index) { - ElectronicKeyListItem indexEntity = getItemData[index]; + ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; String useDateStr = ''; //使用期限 String keyStatus = ''; //钥匙状态 @@ -107,7 +104,7 @@ class _AuthorizedAdminListPageState extends State { isAdminKey = false; } - if (index < getItemData.length) { + if (index < state.itemDataList.value.length) { return LeftSlideActions( // key: Key(indexEntity.lockId!.toString()), actionsWidth: 60, diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart index ce17ea23..e4b47186 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -15,6 +15,7 @@ import '../../../../blue/sender_manage.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; +import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart'; import 'cardList_state.dart'; class CardListLogic extends BaseGetXController { @@ -299,16 +300,26 @@ class CardListLogic extends BaseGetXController { } // 获取IC卡列表 - void getICCardListData() async{ - var entity = await ApiRepository.to.getICCardListData( + Future getICCardListData() async{ + FingerprintListDataEntity entity = await ApiRepository.to.getICCardListData( lockId: state.lockId.value.toString(), - pageNo: '1', - pageSize: '20', + pageNo: pageNo.toString(), + pageSize: pageSize, searchStr: state.searchController.text, ); if(entity.errorCode!.codeIsSuccessful){ - state.fingerprintItemListData.value = entity.data!.list!; + if (pageNo == 1) { + state.fingerprintItemListData.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.fingerprintItemListData.value.addAll(entity.data!.list!); + print("state.itemDataList.value.length:${state.fingerprintItemListData.value.length}"); + pageNo++; + } + } } + return entity; } // 删除所有IC卡 @@ -359,9 +370,6 @@ class CardListLogic extends BaseGetXController { _initReplySubscription(); _initRefreshAction(); - - // 卡 - getICCardListData(); } } diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart index 1f54793a..12c997c9 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -3,11 +3,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../blue/blue_manage.dart'; +import '../../../../tools/EasyRefreshTool.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; @@ -31,6 +33,22 @@ class _CardListPageState extends State with RouteAware { final logic = Get.put(CardListLogic()); final state = Get.find().state; + Future getHttpData() async { + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.getICCardListData().then((FingerprintListDataEntity value){ + setState(() {}); + }); + } + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -57,34 +75,43 @@ class _CardListPageState extends State with RouteAware { ), ], ), - body: Column( - children: [ - KeySearchWidget( - editingController: state.searchController, - onSubmittedAction: () { - logic.getICCardListData(); - }, - ), - SizedBox(height: 20.h), - Expanded(child: _buildMainUI()), - AddBottomWhiteBtn( - btnName: - '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}', - onClick: () async { - var data = - await Get.toNamed(Routers.addCardTypeManagePage, arguments: { - "lockId": state.lockId.value, - "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Column( + children: [ + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { logic.getICCardListData(); - } - }, - ), - SizedBox( - height: 64.h, - ) - ], + }, + ), + SizedBox(height: 20.h), + Expanded(child: _buildMainUI()), + AddBottomWhiteBtn( + btnName: + '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}', + onClick: () async { + var data = + await Get.toNamed(Routers.addCardTypeManagePage, arguments: { + "lockId": state.lockId.value, + "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); + if (data != null) { + logic.getICCardListData(); + } + }, + ), + SizedBox( + height: 64.h, + ) + ], + ), ), ); } @@ -95,37 +122,37 @@ class _CardListPageState extends State with RouteAware { itemCount: state.fingerprintItemListData.value.length, itemBuilder: (c, index) { FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; - if (index < state.fingerprintItemListData.value.length) { - return LeftSlideActions( - key: Key(fingerprintItemData.cardName!), - actionsWidth: 60, - actions: [ - _buildDeleteBtn(fingerprintItemData), + return Slidable( + key:ValueKey(fingerprintItemData.fingerprintId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + showIosTipViewDialog(context); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), ], - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(1)), - ), - child: _keyItem( - 'images/icon_card.png', - fingerprintItemData.cardName!, - (fingerprintItemData.cardType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", - fingerprintItemData.validTimeStr!, - // fingerprintItemData.cardType! == 1 - // ? "永久" - // : - // "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", - () async { - var data = await Get.toNamed( - Routers.cardDetailPage, arguments: { - "fingerprintItemData": fingerprintItemData, - }); - if (data != null) { - logic.getICCardListData(); - } - }), - ); - } - return const SizedBox.shrink(); + ), + child: _keyItem( + 'images/icon_card.png', + fingerprintItemData.cardName!, + (fingerprintItemData.cardType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", + fingerprintItemData.validTimeStr!, + () async { + var data = await Get.toNamed( + Routers.cardDetailPage, arguments: { + "fingerprintItemData": fingerprintItemData, + }); + if (data != null) { + logic.getICCardListData(); + } + }), + ); }, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -133,32 +160,7 @@ class _CardListPageState extends State with RouteAware { color: AppColors.greyLineColor, ); }, - ) : const NoData()); - } - - Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) { - return GestureDetector( - onTap: () { - // 省略: 弹出是否删除的确认对话框。 - state.deletKeyID = fingerprintItemData.cardId.toString(); - state.deletCardNo = int.parse(fingerprintItemData.cardNumber!); - showIosTipViewDialog(context); - }, - child: Container( - width: 60, - color: const Color(0xFFF20101), - alignment: Alignment.center, - child: const Text( - '删除', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.white, - height: 1, - ), - ), - ), - ); + ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)); } void showIosTipViewDialog(BuildContext context) { diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart index 714fda1e..123158f5 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_page.dart @@ -1,10 +1,4 @@ import 'package:flutter/material.dart'; -// import 'package:flutter_pickers/pickers.dart'; -// import 'package:flutter_pickers/style/default_style.dart'; -// import 'package:flutter_pickers/style/picker_style.dart'; -// import 'package:flutter_pickers/time_picker/model/date_mode.dart'; -// import 'package:flutter_pickers/time_picker/model/pduration.dart'; -// import 'package:flutter_pickers/time_picker/model/suffix.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/noData.dart'; @@ -72,7 +66,7 @@ class _CheckingInSetHolidaysPageState extends State { state.holidaysListData.value![index]; return _checkingInListMouthItem(holidaysMonthListData); }) - : const NoData(); + : NoData(); })); } diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart index 66ae6155..43c7c29d 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -66,7 +66,7 @@ class _CheckingInListPageState extends State { Widget topInfo() { return Container( width: 1.sw, - // height: 370.h, + height: 280.h, color: Colors.white, child: Column( children: [ @@ -270,7 +270,7 @@ class _CheckingInListPageState extends State { separatorBuilder: (context, index) { return const Divider(height: 1, color: AppColors.greyLineColor); }, - ) :const NoData()); + ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight*2 - 64.h - 280.h - 90.h,)); } Widget bottomMonthList() { @@ -289,7 +289,7 @@ class _CheckingInListPageState extends State { separatorBuilder: (context, index) { return const Divider(height: 1, color: AppColors.greyLineColor); }, - ) :const NoData()); + ) : NoData(noDataHeight: 1.sh - - ScreenUtil().statusBarHeight - 280.h - 90.h,)); } Widget _checkingInListItem(int index, String? headUrl, String? name, Function() action) { diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index f4822c95..be4fc957 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -71,7 +71,7 @@ class _CheckingInStaffListPageState extends State { return const Divider( height: 1, indent: 20, color: AppColors.greyLineColor); }, - ) :const NoData()), + ) : NoData()), )); } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index affcae97..cffedf02 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -7,27 +7,30 @@ class ElectronicKeyListLogic extends BaseGetXController { final ElectronicKeyListState state = ElectronicKeyListState(); //请求电子钥匙列表 - Future> mockNetworkDataRequest() async { + Future mockNetworkDataRequest() async { ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( '0', state.keyInfo.value.keyId.toString(), '', state.keyInfo.value.lockId.toString(), '', - state.pageNum.toString(), - state.pageSize.toString(), + pageNo.toString(), + pageSize.toString(), '0', '0', state.searchController.text); - List dataList = []; if (entity.errorCode!.codeIsSuccessful) { - print("电子钥匙列表成功:${entity.data?.itemList}"); - if (entity.data != null) { - dataList = entity.data!.itemList; + if (pageNo == 1) { + state.itemDataList.value = entity.data!.itemList!; + pageNo++; + } else { + if (entity.data!.itemList!.isNotEmpty) { + state.itemDataList.value.addAll(entity.data!.itemList!); + pageNo++; + } } } - state.itemDataList.value = dataList; - return dataList; + return entity; } //电子钥匙重置请求 diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index b64f884c..59bf9242 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -1,8 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; @@ -10,6 +10,7 @@ import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/EasyRefreshTool.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/showIosTipView.dart'; @@ -27,12 +28,10 @@ class ElectronicKeyListPage extends StatefulWidget { class _ElectronicKeyListPageState extends State { final logic = Get.put(ElectronicKeyListLogic()); final state = Get.find().state; - late RefreshController _refreshController; @override void initState() { super.initState(); - _refreshController = RefreshController(initialRefresh: true); mockRequest(); } @@ -41,7 +40,9 @@ class _ElectronicKeyListPageState extends State { // 获取是否是演示模式 演示模式不获取接口 var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - logic.mockNetworkDataRequest(); + logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value){ + setState(() {}); + }); } } @@ -71,116 +72,60 @@ class _ElectronicKeyListPageState extends State { ), ], ), - body: Column( - children: [ - // _searchWidget(), - KeySearchWidget( - editingController: state.searchController, - onSubmittedAction: () { - logic.mockNetworkDataRequest(); - }, - ), - SizedBox( - height: 20.h, - ), - Expanded( - child: Obx(() => state.itemDataList.value.isEmpty - ? const NoData() - : _buildMainUI(state.itemDataList.value))), - AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.sendKey!.tr, - onClick: () { - Navigator.pushNamed( - context, Routers.sendElectronicKeyManagePage, - arguments: { - // "lockMainEntity": state.lockMainEntity.value, - "keyInfo": state.keyInfo.value - }).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }, - ), - SizedBox( - height: 64.h, - ) - ], + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + mockRequest(); + }, + onLoad: (){ + mockRequest(); + }, + child: Column( + children: [ + // _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.mockNetworkDataRequest(); + }, + ), + SizedBox( + height: 20.h, + ), + Expanded( + child: _buildMainUI()), + AddBottomWhiteBtn( + btnName: TranslationLoader.lanKeys!.sendKey!.tr, + onClick: () { + Navigator.pushNamed( + context, Routers.sendElectronicKeyManagePage, + arguments: { + // "lockMainEntity": state.lockMainEntity.value, + "keyInfo": state.keyInfo.value + }).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }, + ), + SizedBox( + height: 64.h, + ) + ], + ), )); } - ///加载更多函数 - Future _loadMore() async { - if (state.pageNum.value == 1) { - if (state.itemDataList.value.length < 10) { - _refreshController.loadComplete(); - } else { - state.pageNum.value++; - await logic.mockNetworkDataRequest(); - _refreshController.loadComplete(); - } - } else { - state.pageNum.value++; - await logic.mockNetworkDataRequest(); - _refreshController.loadComplete(); - } - } - - ///刷新函数 - Future _refresh() async { - state.pageNum.value = 1; - await logic.mockNetworkDataRequest(); - _refreshController.refreshCompleted(); - } - - // Widget _searchWidget() { - // return Container( - // height: 60.h, - // margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - // decoration: BoxDecoration( - // color: Colors.white, borderRadius: BorderRadius.circular(5)), - // child: TextField( - // //输入框一行 - // maxLines: 1, - // // controller: _controller, - // autofocus: false, - // controller: state.searchController, - // onSubmitted: (value) { - // logic.mockNetworkDataRequest(); - // }, - // decoration: InputDecoration( - // //输入里面输入文字内边距设置 - // contentPadding: const EdgeInsets.only( - // top: 18.0, left: -19.0, right: -15.0, bottom: 2), - // hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - // hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - // //不需要输入框下划线 - // border: InputBorder.none, - // //左边图标设置 - // icon: Padding( - // padding: EdgeInsets.only( - // top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - // child: Image.asset( - // 'images/main/icon_main_search.png', - // width: 40.w, - // height: 40.w, - // ), - // ), - // ), - // style: - // TextStyle(fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), - // ), - // ); - // } - - Widget _buildMainUI(itemData) { - List getItemData = itemData; - return ListView.separated( + Widget _buildMainUI() { + return Obx(() => state.itemDataList.value.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : ListView.separated( shrinkWrap: true, - itemCount: getItemData.length, + itemCount: state.itemDataList.value.length, itemBuilder: (c, index) { - ElectronicKeyListItem indexEntity = getItemData[index]; + ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; String useDateStr = ''; //使用期限 String keyStatus = ''; //钥匙状态 @@ -198,29 +143,33 @@ class _ElectronicKeyListPageState extends State { isAdminKey = false; } - if (index < getItemData.length) { - return LeftSlideActions( - key: Key(indexEntity.lockAlias!), - actionsWidth: 60, - actions: [ - _buildDeleteBtn(indexEntity.keyId.toString()), + return Slidable( + key:ValueKey(indexEntity.keyId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + showIosTipViewDialog(context, indexEntity.keyId!.toString()); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), ], - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(1)), - ), - child: _electronicKeyItem('images/controls_user.png', - indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { - Navigator.pushNamed(context, Routers.electronicKeyDetailPage, - arguments: {"itemData": indexEntity}).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }), - ); - } - return const SizedBox.shrink(); + ), + child: _electronicKeyItem('images/controls_user.png', + indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { + Navigator.pushNamed(context, Routers.electronicKeyDetailPage, + arguments: {"itemData": indexEntity}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }), + ); }, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -228,7 +177,7 @@ class _ElectronicKeyListPageState extends State { color: AppColors.greyLineColor, ); }, - ); + )); } Widget _buildDeleteBtn(String keyId) { diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart index eb6a1846..6c54b520 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart @@ -58,7 +58,7 @@ class _LockUserListPageState extends State { ), Expanded( child: dataList.isEmpty - ? const NoData() + ? NoData() : ListView.separated( itemBuilder: (context, index) { LockUserData indexEntity = dataList[index]; diff --git a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart index d427e482..35f5fed2 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -137,7 +137,7 @@ class _FaceListState extends State { ); }, ) - : const NoData()); + : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 170.h)); } } diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index fd642e6e..33aed524 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -15,6 +15,7 @@ import '../../../../blue/sender_manage.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; +import 'fingerprintListData_entity.dart'; import 'fingerprintList_state.dart'; class FingerprintListLogic extends BaseGetXController{ @@ -331,16 +332,26 @@ class FingerprintListLogic extends BaseGetXController{ } // 获取指纹列表 - void getFingerprintsListData() async{ - var entity = await ApiRepository.to.getFingerprintsListData( + Future getFingerprintsListData() async{ + FingerprintListDataEntity entity = await ApiRepository.to.getFingerprintsListData( lockId: state.lockId.value.toString(), - pageNo: '1', - pageSize: '20', + pageNo: pageNo.toString(), + pageSize: pageSize.toString(), searchStr: state.searchController.text, ); if(entity.errorCode!.codeIsSuccessful){ - state.fingerprintItemListData.value = entity.data!.list!; + if (pageNo == 1) { + state.fingerprintItemListData.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.fingerprintItemListData.value.addAll(entity.data!.list!); + print("state.itemDataList.value.length:${state.fingerprintItemListData.value.length}"); + pageNo++; + } + } } + return entity; } // 重置所有的指纹 @@ -391,8 +402,6 @@ class FingerprintListLogic extends BaseGetXController{ _initReplySubscription(); _initRefreshAction(); - - getFingerprintsListData(); } } diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 3a0a3dc4..a7da1586 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -3,11 +3,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../blue/blue_manage.dart'; +import '../../../../tools/EasyRefreshTool.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; @@ -31,6 +33,22 @@ class _FingerprintListPageState extends State with RouteAwa final logic = Get.put(FingerprintListLogic()); final state = Get.find().state; + Future getHttpData() async { + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.getFingerprintsListData().then((FingerprintListDataEntity value){ + setState(() {}); + }); + } + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -57,33 +75,42 @@ class _FingerprintListPageState extends State with RouteAwa ), ], ), - body: Column( - children: [ - KeySearchWidget( - editingController: state.searchController, - onSubmittedAction: () { - logic.getFingerprintsListData(); - }, - ), - SizedBox( - height: 20.h, - ), - Expanded(child: _buildMainUI()), - AddBottomWhiteBtn( - btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', - onClick: () async { - var data = - await Get.toNamed(Routers.addFingerprintTypeManagePage, arguments: { - "lockId": state.lockId.value, - "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Column( + children: [ + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { logic.getFingerprintsListData(); - } - }, - ), - SizedBox(height: 64.h) - ], + }, + ), + SizedBox( + height: 20.h, + ), + Expanded(child: _buildMainUI()), + AddBottomWhiteBtn( + btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', + onClick: () async { + var data = + await Get.toNamed(Routers.addFingerprintTypeManagePage, arguments: { + "lockId": state.lockId.value, + "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); + if (data != null) { + logic.getFingerprintsListData(); + } + }, + ), + SizedBox(height: 64.h) + ], + ), ), ); } @@ -95,37 +122,41 @@ class _FingerprintListPageState extends State with RouteAwa itemBuilder: (c, index) { FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; // 指纹 - if (index < state.fingerprintItemListData.value.length) { - return LeftSlideActions( - key: Key(fingerprintItemData.fingerprintName!), - actionsWidth: 60, - actions: [ - _buildDeleteBtn(fingerprintItemData), + return Slidable( + key:ValueKey(fingerprintItemData.fingerprintId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + showIosTipViewDialog(context); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), ], - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(1)), - ), - child: _keyItem( - 'images/icon_fingerprint.png', - fingerprintItemData.fingerprintName!, - (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", - fingerprintItemData.validTimeStr!, - // fingerprintItemData.fingerprintType! == 1 - // ? "永久" - // : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", - () async { - var data = await Get.toNamed( - Routers.fingerprintDetailPage, - arguments: { - "fingerprintItemData": fingerprintItemData, - }); - if (data != null) { - logic.getFingerprintsListData(); - } - }), - ); - } - return const SizedBox.shrink(); + ), + child: _keyItem( + 'images/icon_fingerprint.png', + fingerprintItemData.fingerprintName!, + (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", + fingerprintItemData.validTimeStr!, + // fingerprintItemData.fingerprintType! == 1 + // ? "永久" + // : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", + () async { + var data = await Get.toNamed( + Routers.fingerprintDetailPage, + arguments: { + "fingerprintItemData": fingerprintItemData, + }); + if (data != null) { + logic.getFingerprintsListData(); + } + }), + ); }, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -133,33 +164,7 @@ class _FingerprintListPageState extends State with RouteAwa color: AppColors.greyLineColor, ); }, - ) - : const NoData()); - } - - Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) { - return GestureDetector( - onTap: () { - // 省略: 弹出是否删除的确认对话框。 - state.deletKeyID = fingerprintItemData.fingerprintId.toString(); - state.deletFingerNo = int.parse(fingerprintItemData.fingerprintNumber!); - showIosTipViewDialog(context); - }, - child: Container( - width: 60, - color: const Color(0xFFF20101), - alignment: Alignment.center, - child: const Text( - '删除', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.white, - height: 1, - ), - ), - ), - ); + ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)); } void showIosTipViewDialog(BuildContext context) { diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart index f3fd5131..2cabfc33 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart @@ -139,7 +139,7 @@ class _LockOperatingRecordPageState extends State { color: AppColors.greyLineColor, ); }, - ) : const NoData()); + ) : NoData()); } Widget _dateItem(String lockDate) { diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/lockSelectGrouping/lockSelectGrouping_page.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/lockSelectGrouping/lockSelectGrouping_page.dart index 667779de..c93a35c9 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/lockSelectGrouping/lockSelectGrouping_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/lockSelectGrouping/lockSelectGrouping_page.dart @@ -76,7 +76,7 @@ class _LockSelectGroupingPageState extends State { action: () { logic.setLockGroupRequest(itemData); }); - }) : const NoData()); + }) : NoData()); } void showCupertinoAlertDialog(BuildContext context) { diff --git a/star_lock/lib/main/lockDetail/lockSet/doorMagnetic/nearbyDoorMagnetic/nearbyDoorMagnetic_page.dart b/star_lock/lib/main/lockDetail/lockSet/doorMagnetic/nearbyDoorMagnetic/nearbyDoorMagnetic_page.dart index db766ed6..f964823e 100644 --- a/star_lock/lib/main/lockDetail/lockSet/doorMagnetic/nearbyDoorMagnetic/nearbyDoorMagnetic_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/doorMagnetic/nearbyDoorMagnetic/nearbyDoorMagnetic_page.dart @@ -25,7 +25,7 @@ class _NearbyDoorMagneticPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor), body: dataList.isEmpty - ? const NoData() + ? NoData() : ListView.builder( itemCount: dataList.length, itemBuilder: (c, index) { diff --git a/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/selectWirelessKeyboard/selectWirelessKeyboard_page.dart b/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/selectWirelessKeyboard/selectWirelessKeyboard_page.dart index 5a6833be..1919e78d 100644 --- a/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/selectWirelessKeyboard/selectWirelessKeyboard_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/selectWirelessKeyboard/selectWirelessKeyboard_page.dart @@ -27,7 +27,7 @@ class _SelectWirelessKeyboardPageState extends State haveBack: true, backgroundColor: AppColors.mainColor), body: dataList.isEmpty - ? const NoData() + ? NoData() : ListView.builder( itemCount: 20, itemBuilder: (c, index) { diff --git a/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart b/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart index b4eeb56a..b04eca44 100644 --- a/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart @@ -58,7 +58,7 @@ class _WirelessKeyboardPageState extends State { Widget _buildMainUI() { return dataList.isEmpty - ? const NoData() + ? NoData() : ListView.builder( itemCount: 10, itemBuilder: (c, index) { diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index c8e66037..e62dc307 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -12,16 +12,26 @@ class PasswordKeyListLogic extends BaseGetXController { final PasswordKeyListState state = PasswordKeyListState(); //请求密码钥匙列表 - void mockNetworkDataRequest() async { + Future mockNetworkDataRequest() async { PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList( state.keyInfo.value.keyStatus.toString(), state.keyInfo.value.lockId.toString(), - state.pageNum.toString(), - state.pageSize.toString(), + pageNo.toString(), + pageSize.toString(), state.searchController.text); if (entity.errorCode!.codeIsSuccessful) { - state.itemDataList.value = entity.data!.itemList!; + if (pageNo == 1) { + state.itemDataList.value = entity.data!.itemList!; + pageNo++; + } else { + if (entity.data!.itemList!.isNotEmpty) { + state.itemDataList.value.addAll(entity.data!.itemList!); + print("state.itemDataList.value.length:${state.itemDataList.value.length}"); + pageNo++; + } + } } + return entity; } //密码钥匙重置请求 diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 178a56a1..36d5f08d 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -1,14 +1,15 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/EasyRefreshTool.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/showIosTipView.dart'; @@ -27,21 +28,20 @@ class _PasswordKeyListPageState extends State { final logic = Get.put(PasswordKeyListLogic()); final state = Get.find().state; - late RefreshController _refreshController; + Future getHttpData() async { + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.mockNetworkDataRequest().then((PasswordKeyListEntity value){ + setState(() {}); + }); + } + } @override void initState() { super.initState(); - _refreshController = RefreshController(initialRefresh: true); - mockRequest(); - } - Future mockRequest() async { - // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if (isDemoMode == false) { - logic.mockNetworkDataRequest(); - } + getHttpData(); } @override @@ -69,129 +69,95 @@ class _PasswordKeyListPageState extends State { ), ], ), - body: Column( - children: [ - // _searchWidget(), - KeySearchWidget( - editingController: state.searchController, - onSubmittedAction: () { - logic.mockNetworkDataRequest(); - }, - ), - SizedBox( - height: 20.h, - ), - Expanded( - child: Obx(() => state.itemDataList.value.isEmpty - ? const NoData() - : _buildMainUI(state.itemDataList.value))), - SizedBox( - height: 20.h, - ), - AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.getPassword!.tr, - onClick: () { - Navigator.pushNamed(context, Routers.passwordKeyManagePage, - arguments: {"keyInfo": state.keyInfo.value}).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - } - }); - }), - SizedBox( - height: 42.h, - ) - ], + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Column( + children: [ + // _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.mockNetworkDataRequest(); + }, + ), + SizedBox( + height: 20.h, + ), + Expanded( + child: _buildMainUI()), + SizedBox( + height: 20.h, + ), + AddBottomWhiteBtn( + btnName: TranslationLoader.lanKeys!.getPassword!.tr, + onClick: () { + Navigator.pushNamed(context, Routers.passwordKeyManagePage, + arguments: {"keyInfo": state.keyInfo.value}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + } + }); + }), + SizedBox( + height: 42.h, + ) + ], + ), )); } - // ///加载更多函数 - // Future _loadMore() async { - // if (state.pageNum.value == 1) { - // if (state.itemDataList.length < 10) { - // _refreshController.loadComplete(); - // } else { - // state.pageNum.value++; - // await logic.mockNetworkDataRequest(); - // _refreshController.loadComplete(); - // } - // } else { - // state.pageNum.value++; - // await logic.mockNetworkDataRequest(); - // _refreshController.loadComplete(); - // } - // } - - // ///刷新函数 - // Future _refresh() async { - // state.pageNum.value = 1; - // await logic.mockNetworkDataRequest(); - // _refreshController.refreshCompleted(); - // } - - Widget _buildMainUI(itemData) { - List getItemData = itemData; - return ListView.separated( - itemCount: getItemData.length, + Widget _buildMainUI() { + return Obx(() => state.itemDataList.value.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.itemDataList.value.length, itemBuilder: (c, index) { - PasswordKeyListItem passwordKeyListItem = getItemData[index]; - String useDateStr = ''; //使用期限 + PasswordKeyListItem passwordKeyListItem = state.itemDataList.value[index]; + String useDateStr = ''; //使用期限 - //使用期限 - useDateStr = logic.getUseDateStr(passwordKeyListItem); - - if (index < getItemData.length) { - return LeftSlideActions( - key: Key(passwordKeyListItem.keyboardPwdName!), - actionsWidth: 60, - actions: [ - _buildDeleteBtn(passwordKeyListItem), - ], - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(1)), - ), - child: _electronicKeyItem(index, 'images/icon_password.png', passwordKeyListItem.keyboardPwdName!, useDateStr, () { - Navigator.pushNamed(context, Routers.passwordKeyDetailPage, - arguments: {"itemData": passwordKeyListItem}).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - } - }); - }), - ); - } - return const SizedBox.shrink(); + //使用期限 + useDateStr = logic.getUseDateStr(passwordKeyListItem); + return Slidable( + key:ValueKey(passwordKeyListItem.keyboardPwdId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + showIosTipViewDialog(context, passwordKeyListItem); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), + ], + ), + child: _electronicKeyItem(index, 'images/icon_password.png', passwordKeyListItem.keyboardPwdName!, useDateStr, () { + Navigator.pushNamed(context, Routers.passwordKeyDetailPage, + arguments: {"itemData": passwordKeyListItem}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + } + }); + }), + ); }, separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ); - } - - Widget _buildDeleteBtn(PasswordKeyListItem passwordKeyListItem) { - return GestureDetector( - onTap: () { - // 省略: 弹出是否删除的确认对话框。 - showIosTipViewDialog(context, passwordKeyListItem); - }, - child: Container( - width: 60, - color: const Color(0xFFF20101), - alignment: Alignment.center, - child: const Text( - '删除', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.white, + return const Divider( height: 1, - ), - ), - ), - ); + color: AppColors.greyLineColor, + ); + }, + ), + )); } void showIosTipViewDialog( diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart index e1064702..66e47686 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart @@ -6,8 +6,6 @@ import '../../../lockMian/entity/lockListInfo_entity.dart'; class PasswordKeyListState { final keyInfo = LockListInfoItemEntity().obs; - var pageNum = 1.obs; //请求页码 - final pageSize = 20.obs; //请求每页数据条数 final itemDataList = [].obs; final TextEditingController searchController = TextEditingController(); diff --git a/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart b/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart index 07a89927..41cf9980 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart @@ -108,7 +108,7 @@ class _RemoteControlListPageState extends State { Widget _buildMainUI() { String typeImgName = 'images/icon_card.png'; - return const NoData(); + return NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h); } Widget _buildDeleteBtn(String idStr) { diff --git a/star_lock/lib/main/lockDetail/videoLog/videoLog/videoLog_page.dart b/star_lock/lib/main/lockDetail/videoLog/videoLog/videoLog_page.dart index 69236e8a..fdd99d6d 100644 --- a/star_lock/lib/main/lockDetail/videoLog/videoLog/videoLog_page.dart +++ b/star_lock/lib/main/lockDetail/videoLog/videoLog/videoLog_page.dart @@ -80,7 +80,7 @@ class _VideoLogPageState extends State { )), mainListView(index) ],); - }): const NoData() + }): NoData() ) ), ], diff --git a/star_lock/lib/main/lockDetail/videoLog/videoLogDownLoad/videoLogDownLoad_page.dart b/star_lock/lib/main/lockDetail/videoLog/videoLogDownLoad/videoLogDownLoad_page.dart index d5916fc1..520ec302 100644 --- a/star_lock/lib/main/lockDetail/videoLog/videoLogDownLoad/videoLogDownLoad_page.dart +++ b/star_lock/lib/main/lockDetail/videoLog/videoLogDownLoad/videoLogDownLoad_page.dart @@ -45,7 +45,7 @@ class _VideoLogDownLoadPageState extends State { )), mainListView(index) ],); - }): const NoData(), + }): NoData(), ), ], ), diff --git a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart index 23f59875..af8a9457 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart @@ -1,7 +1,5 @@ import 'package:star_lock/tools/baseGetXController.dart'; -import '../../../common/XSConstantMacro/XSConstantMacro.dart'; -import '../entity/lockListInfo_entity.dart'; import 'lockList_state.dart'; class LockListLogic extends BaseGetXController{ diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart index 0d3b4c16..d501fa8d 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -1,12 +1,7 @@ import 'dart:async'; -import 'dart:typed_data'; import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:get/get.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:star_lock/talk/udp/udp_senderManage.dart'; -import '../../../blue/io_tool/manager_event_bus.dart'; import '../../../network/api_repository.dart'; import '../../../talk/udp/udp_help.dart'; import '../../../tools/baseGetXController.dart'; @@ -17,70 +12,12 @@ import 'lockMain_state.dart'; class LockMainLogic extends BaseGetXController { final LockMainState state = LockMainState(); - var page = 1; - // final RefreshController refreshController = RefreshController( - // initialRefresh: false - // ); - - /// 下拉刷新方法 - // void onRefresh() { - // page = 1; - // getLockInfo(); - // } - // - // void onLoading() { - // getLockInfo(); - // } - - // void getLockInfo() async{ - // var entity = await ApiRepository.to.getLockInfo( - // lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(), - // pageNo:page.toString(), - // ); - // if(entity.errorCode!.codeIsSuccessful){ - // // if (page == 0) { - // // refreshController.refreshCompleted(); - // // } else { - // // if (entity.data!.keyInfos!.isEmpty) { - // // refreshController.loadNoData(); - // // } else { - // // refreshController.loadComplete(); - // // } - // // } - // // page++; - // - // if(entity.data!.keyInfos!.isEmpty){ - // state.dataLength.value = 0; - // }else if(entity.data!.keyInfos!.length == 1){ - // state.dataLength.value = 1; - // }else{ - // state.dataLength.value = 2; - // } - // state.lockMainEntity.value = entity; - // }else{ - // // refreshController.loadFailed(); - // } - // // refreshController.refreshCompleted(); - // } - - // Future - void getStarLockInfo() async{ - var entity = await ApiRepository.to.getStarLockListInfo( - pageNo:page, - pageSize:20, + Future getStarLockInfo() async{ + LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo( + pageNo:pageNo, + pageSize:50, ); if(entity.errorCode!.codeIsSuccessful){ - // if (page == 0) { - // refreshController.refreshCompleted(); - // } else { - // if (entity.data!.keyInfos!.isEmpty) { - // refreshController.loadNoData(); - // } else { - // refreshController.loadComplete(); - // } - // } - // page++; - // Future.delayed(const Duration(milliseconds: 200)); if(entity.data!.groupList!.isEmpty){ state.dataLength.value = 0; }else if(entity.data!.groupList!.length == 1){ @@ -98,10 +35,8 @@ class LockMainLogic extends BaseGetXController { }else{ print("首页锁列表请求失败"); state.dataLength.value = 0; - // refreshController.loadFailed(); - // return entity.data!; } - // refreshController.refreshCompleted(); + return entity; } late StreamSubscription _teamEvent; @@ -173,8 +108,6 @@ class LockMainLogic extends BaseGetXController { connectListener(); // 获取网络连接状态 getConnectType(); - - getStarLockInfo(); } @override diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index f6dcdc47..91cd56cd 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -8,6 +8,7 @@ import 'package:star_lock/tools/submitBtn.dart'; import '../../../appRouters.dart'; import '../../../baseWidget.dart'; import '../../../mine/mine/starLockMine_page.dart'; +import '../../../tools/EasyRefreshTool.dart'; import '../../../tools/storage.dart'; import '../../../tools/titleAppBar.dart'; import '../../../translations/trans_lib.dart'; @@ -28,6 +29,19 @@ class _StarLockMainPageState extends State with BaseWidget { final logic = Get.put(LockMainLogic()); final state = Get.find().state; + void getHttpData(){ + logic.getStarLockInfo().then((LockListInfoEntity value){ + setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -77,7 +91,13 @@ class _StarLockMainPageState extends State with BaseWidget { // } // }, // ), - body: Obx(() => getDataReturnUI(state.dataLength.value)), + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + child: Obx(() => getDataReturnUI(state.dataLength.value)) + ), // body:smartRefresher( // logic.refreshController, // onRefresh:logic.onRefresh, @@ -106,7 +126,7 @@ class _StarLockMainPageState extends State with BaseWidget { returnWidget = LockListPage(lockListInfoGroupEntity: state.lockListInfoEntity.value.data!); break; default: - returnWidget = const NoData(); + returnWidget = NoData(); break; } // Future.delayed(const Duration(seconds: 1)); diff --git a/star_lock/lib/mine/message/messageList/messageList_logic.dart b/star_lock/lib/mine/message/messageList/messageList_logic.dart index fa929e76..044c8781 100644 --- a/star_lock/lib/mine/message/messageList/messageList_logic.dart +++ b/star_lock/lib/mine/message/messageList/messageList_logic.dart @@ -10,13 +10,31 @@ import 'messageList_state.dart'; class MessageListLogic extends BaseGetXController { final MessageListState state = MessageListState(); - //请求密码钥匙列表 - void messageListDataRequest() async { + //请求消息列表 + Future messageListDataRequest() async { MessageListEntity entity = await ApiRepository.to.messageListLoadData( - pageNo:state.pageNum.toString(), - pageSize:state.pageSize.toString()); + pageNo:pageNo.toString(), + pageSize:pageSize); if (entity.errorCode!.codeIsSuccessful) { - state.itemDataList.value = entity.data!.list!; + if (pageNo == 1) { + state.itemDataList.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.itemDataList.value.addAll(entity.data!.list!); + print("state.itemDataList.value.length:${state.itemDataList.value.length}"); + pageNo++; + } + } + } + return entity; + } + + // 删除消息 + void deletMessageDataRequest(String messageId) async { + MessageListEntity entity = await ApiRepository.to.deletMessageLoadData(messageId:messageId); + if (entity.errorCode!.codeIsSuccessful) { + messageListDataRequest(); } } @@ -33,7 +51,7 @@ class MessageListLogic extends BaseGetXController { void onReady() { // TODO: implement onReady super.onReady(); - messageListDataRequest(); + // messageListDataRequest(); _readMessageRefreshUIAction(); } diff --git a/star_lock/lib/mine/message/messageList/messageList_page.dart b/star_lock/lib/mine/message/messageList/messageList_page.dart index 97d4a88a..30aa376e 100644 --- a/star_lock/lib/mine/message/messageList/messageList_page.dart +++ b/star_lock/lib/mine/message/messageList/messageList_page.dart @@ -1,3 +1,4 @@ +import 'package:easy_refresh/easy_refresh.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -5,11 +6,14 @@ import 'package:star_lock/tools/noData.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; +import '../../../network/api_repository.dart'; +import '../../../tools/EasyRefreshTool.dart'; import '../../../tools/dateTool.dart'; import '../../../tools/titleAppBar.dart'; import '../../../translations/trans_lib.dart'; import 'messageList_entity.dart'; import 'messageList_logic.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; class MessageListPage extends StatefulWidget { const MessageListPage({Key? key}) : super(key: key); @@ -18,10 +22,23 @@ class MessageListPage extends StatefulWidget { State createState() => _MessageListPageState(); } -class _MessageListPageState extends State { +class _MessageListPageState extends State with TickerProviderStateMixin { final logic = Get.put(MessageListLogic()); final state = Get.find().state; + void getHttpData(){ + logic.messageListDataRequest().then((MessageListEntity value){ + setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -30,16 +47,46 @@ class _MessageListPageState extends State { barTitle: TranslationLoader.lanKeys!.message!.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: Obx(() => state.itemDataList.isEmpty - ? const NoData() - : ListView.builder( - itemCount: 10, - itemBuilder: (c, index) { - MessageItemEntity messageItemEntity = state.itemDataList[index]; - return _selectGatewayListListItem(messageItemEntity, () { - Get.toNamed(Routers.messageDetailPage, arguments: {"messageItemEntity": messageItemEntity}); - }); - })), + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Obx(() { + return state.itemDataList.value.isEmpty + ? NoData() + : SlidableAutoCloseBehavior( + child: ListView.builder( + itemCount: state.itemDataList.value.length, + itemBuilder: (c, index) { + MessageItemEntity messageItemEntity = state.itemDataList.value[index]; + return Slidable( + key:ValueKey(messageItemEntity.id), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + logic.deletMessageDataRequest(messageItemEntity.id!); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), + ], + ), + child: _selectGatewayListListItem(messageItemEntity, () { + Get.toNamed(Routers.messageDetailPage, arguments: {"messageItemEntity": messageItemEntity}); + }), + ); + }), + ); + }) + ), ); } diff --git a/star_lock/lib/mine/message/messageList/messageList_state.dart b/star_lock/lib/mine/message/messageList/messageList_state.dart index eec1e217..4bb908a5 100644 --- a/star_lock/lib/mine/message/messageList/messageList_state.dart +++ b/star_lock/lib/mine/message/messageList/messageList_state.dart @@ -3,8 +3,6 @@ import 'package:get/get.dart'; import 'messageList_entity.dart'; class MessageListState{ - var pageNum = 1.obs; //请求页码 - final pageSize = 20.obs; //请求每页数据条数 final itemDataList = [].obs; } \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart b/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart index 92ce0192..60ee2ba1 100644 --- a/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart +++ b/star_lock/lib/mine/mineSet/authorityManagement/authorityManagement_page.dart @@ -86,8 +86,8 @@ class _AuthorityManagementPageState extends State ), ), body: TabBarView(controller: _tabController, children: [ - dataList.isEmpty ? const NoData() : _permissionNameList(), - dataList.isEmpty ? const NoData() : _permissionDeviceList() + dataList.isEmpty ? NoData() : _permissionNameList(), + dataList.isEmpty ? NoData() : _permissionDeviceList() ]))); } diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_page.dart index 4855262b..99ef93b1 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministratorList_page.dart @@ -148,7 +148,7 @@ class _AuthorizedAdministratorListPageState Widget _buildMainUI(List itemList) { return itemList.isEmpty - ? const NoData() + ? NoData() : ListView.builder( itemCount: itemList.length, itemBuilder: (c, index) { diff --git a/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart index 55c9d152..55f28798 100644 --- a/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart +++ b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart @@ -75,7 +75,7 @@ class _GroupEditLockPageState extends State { color: AppColors.greyLineColor, ); }, - ) : const NoData(); + ) : NoData(); } Widget _listItemView(LockListItem itemData) { diff --git a/star_lock/lib/mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart b/star_lock/lib/mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart index 59697de9..7a31bd65 100644 --- a/star_lock/lib/mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart +++ b/star_lock/lib/mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart @@ -92,7 +92,7 @@ class _LockItemListPageState extends State { Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0}); }, )), - const NoData(), + NoData(), ], )); } diff --git a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart index 33158296..f238f4f6 100644 --- a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart +++ b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart @@ -48,7 +48,7 @@ class _LockGroupListPageState extends State { backgroundColor: AppColors.mainColor), body: Column( children: [ - Expanded(child: Obx(() => state.itemDataList.value.isEmpty ? const NoData(): _buildMainUI())), + Expanded(child: Obx(() => state.itemDataList.value.isEmpty ? NoData(): _buildMainUI())), ], ), ); diff --git a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart index 680f972f..141f9df4 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart @@ -119,7 +119,7 @@ class _LockUserManageListPageState extends State { Widget _buildMainUI() { return state.dataList.isEmpty - ? const NoData() + ? NoData() : ListView.separated( itemCount: state.dataList.length, itemBuilder: (c, index) { diff --git a/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart index e117da1a..6bc1cf3d 100644 --- a/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart +++ b/star_lock/lib/mine/mineSet/transferGateway/selectGetewayList_page.dart @@ -87,7 +87,7 @@ class _SelectGetewayListPageState extends State { } }); }); - }):const NoData()); + }): NoData()); } Widget _electronicKeyItem(GetewayItemData getewayItemData, Function() action) { diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart index 0ad823f9..7b61c1ea 100644 --- a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart +++ b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart @@ -135,7 +135,7 @@ class _TransferSmartLockPageState extends State { } }); }); - }):const NoData()); + }): NoData()); } Widget _electronicKeyItem(TransferSmartLockItemData transferSmartLockItemData, Function() action) { diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 75f117d8..69356aa4 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -171,4 +171,5 @@ abstract class Api { final String messageListURL = '/notifications/list'; //消息列表 final String readMessageURL = '/notifications/markAsRead'; //读取消息 + final String deletMessageURL = '/notifications/delete'; //删除消息 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 7112377c..6b398bca 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -1474,6 +1474,13 @@ class ApiProvider extends BaseProvider { 'id': messageId, })); + // 删除消息 + Future deletMessageLoadData(String messageId) => + post(deletMessageURL.toUrl, + jsonEncode({ + 'id': messageId, + })); + } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 2e2546e4..7773a3a8 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -1485,4 +1485,12 @@ class ApiRepository { return MessageListEntity.fromJson(res.body); } + // 删除消息 + Future deletMessageLoadData({ + required String messageId, + }) async { + final res = await apiProvider.deletMessageLoadData(messageId); + return MessageListEntity.fromJson(res.body); + } + } diff --git a/star_lock/lib/tools/EasyRefreshTool.dart b/star_lock/lib/tools/EasyRefreshTool.dart new file mode 100644 index 00000000..22e5a744 --- /dev/null +++ b/star_lock/lib/tools/EasyRefreshTool.dart @@ -0,0 +1,64 @@ +import 'package:easy_refresh/easy_refresh.dart'; +import 'package:flutter/cupertino.dart'; + + +/* +* 下拉刷新封装 +* +* +* +* child 显示组件 +* onRefresh 上拉刷新 +* onLoad 下拉刷新 +* isMore 是否存在分页 +* page 页数 +* +* */ + + +GlobalKey<_EasyRefreshToolState> childKey = GlobalKey(); + +class EasyRefreshTool extends StatefulWidget { + Widget child; + Function? onRefresh; + Function? onLoad; + late int isMore; + late int page; + + EasyRefreshTool({Key? key,required this.child,this.onRefresh,this.onLoad,this.isMore=0,this.page=0}) : super(key: key); + + @override + State createState() => _EasyRefreshToolState(); +} + +class _EasyRefreshToolState extends State { + late EasyRefreshController _controller; + + @override + void initState() { + // TODO: implement initState + super.initState(); + _controller = EasyRefreshController(); + } + + @override + Widget build(BuildContext context) { + return EasyRefresh( + controller: _controller, + header: const MaterialHeader(), + footer: const MaterialFooter(), + onRefresh: widget.onRefresh!=null?() async { + if(widget.onRefresh != null){ + widget.onRefresh!(); + } + }:null, + onLoad: widget.onLoad!=null?() async { + + // if(widget.isMore>0){ + widget.onLoad!(); + // } + }:null, + child: widget.child, + ); + } +} diff --git a/star_lock/lib/tools/baseGetXController.dart b/star_lock/lib/tools/baseGetXController.dart index e3d38d8f..dc9d0190 100644 --- a/star_lock/lib/tools/baseGetXController.dart +++ b/star_lock/lib/tools/baseGetXController.dart @@ -13,6 +13,8 @@ class BaseGetXController extends GetxController{ int currentTimeSeconds = 0; bool currentPage = true; + var pageNo = 1; + var pageSize = "20"; @override void onReady() { diff --git a/star_lock/lib/tools/noData.dart b/star_lock/lib/tools/noData.dart index fed8b5f4..ef6f77c2 100644 --- a/star_lock/lib/tools/noData.dart +++ b/star_lock/lib/tools/noData.dart @@ -6,31 +6,34 @@ import 'package:star_lock/app_settings/app_colors.dart'; import '../translations/trans_lib.dart'; class NoData extends StatelessWidget { - const NoData({Key? key}) : super(key: key); + double? noDataHeight; + NoData({Key? key, this.noDataHeight}) : super(key: key); @override Widget build(BuildContext context) { - return SizedBox( - width: 1.sw, - height: 1.sh - ScreenUtil().statusBarHeight, - // height: 1.sw, - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - 'images/icon_noData.png', - width: 160.w, - height: 180.h, - ), - Text( - TranslationLoader.lanKeys!.noData!.tr, - style: - TextStyle(color: AppColors.darkGrayTextColor, fontSize: 22.sp), - ) - ], - )), + return SingleChildScrollView( + child: SizedBox( + width: 1.sw, + height: noDataHeight ?? 1.sh - ScreenUtil().statusBarHeight, + // height: 1.sw, + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + 'images/icon_noData.png', + width: 160.w, + height: 180.h, + ), + Text( + TranslationLoader.lanKeys!.noData!.tr, + style: + TextStyle(color: AppColors.darkGrayTextColor, fontSize: 22.sp), + ) + ], + )), + ), ); } } diff --git a/star_lock/lib/tools/refreshHeadFoot.dart b/star_lock/lib/tools/refreshHeadFoot.dart deleted file mode 100644 index 5833a5aa..00000000 --- a/star_lock/lib/tools/refreshHeadFoot.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; - -//用于下拉刷新 头布局 -class HeaderWidget extends StatelessWidget { - const HeaderWidget({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return const WaterDropHeader( - refresh: CupertinoActivityIndicator(), - complete: CupertinoActivityIndicator(), - idleIcon: CupertinoActivityIndicator(), - // waterDropColor: null, - ); - } -} -//用于上拉加载 底部布局 -class FooterWidget extends StatelessWidget { - const FooterWidget({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return CustomFooter( - builder: (BuildContext context, LoadStatus? mode) { - Widget body; - if (mode == LoadStatus.idle) { - body = const Text("上拉加载"); - } else if (mode == LoadStatus.loading) { - body = const CupertinoActivityIndicator(); - } else if (mode == LoadStatus.failed) { - body = const Text("加载失败"); - } else if (mode == LoadStatus.canLoading) { - body = const Text("加载更多"); - } else if(mode == LoadStatus.noMore){ - body = const Text("没有更多数据"); - }else{ - // body = Text("没有更多数据"); - body = Text(""); - } - return Container( - height: 55.0, - child: Center(child: body), - ); - }, - ); - } -} diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 1a745978..c42eeee6 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -92,7 +92,7 @@ dependencies: date_format: ^2.0.7 # 下拉刷新 - pull_to_refresh: ^2.0.0 + easy_refresh: ^3.3.4 #高德地图定位 amap_flutter_location: ^3.0.0 @@ -136,6 +136,8 @@ dependencies: connectivity_plus: ^5.0.2 flutter_advanced_calendar: ^1.4.1 timelines: ^0.1.0 + #侧滑删除 + flutter_slidable: ^3.0.1 dev_dependencies: flutter_test: