Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
88cc26a672
@ -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,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@ -54,9 +54,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
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<AuthorizedAdminListPage> {
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildMainUI(itemData) {
|
||||
List<ElectronicKeyListItem> 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<AuthorizedAdminListPage> {
|
||||
isAdminKey = false;
|
||||
}
|
||||
|
||||
if (index < getItemData.length) {
|
||||
if (index < state.itemDataList.value.length) {
|
||||
return LeftSlideActions(
|
||||
// key: Key(indexEntity.lockId!.toString()),
|
||||
actionsWidth: 60,
|
||||
|
||||
@ -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<FingerprintListDataEntity> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<CardListPage> with RouteAware {
|
||||
final logic = Get.put(CardListLogic());
|
||||
final state = Get.find<CardListLogic>().state;
|
||||
|
||||
Future<void> 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<CardListPage> 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<CardListPage> 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<CardListPage> 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) {
|
||||
|
||||
@ -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<CheckingInSetHolidaysPage> {
|
||||
state.holidaysListData.value![index];
|
||||
return _checkingInListMouthItem(holidaysMonthListData);
|
||||
})
|
||||
: const NoData();
|
||||
: NoData();
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
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<CheckingInListPage> {
|
||||
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<CheckingInListPage> {
|
||||
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) {
|
||||
|
||||
@ -71,7 +71,7 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
return const Divider(
|
||||
height: 1, indent: 20, color: AppColors.greyLineColor);
|
||||
},
|
||||
) :const NoData()),
|
||||
) : NoData()),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@ -7,27 +7,30 @@ class ElectronicKeyListLogic extends BaseGetXController {
|
||||
final ElectronicKeyListState state = ElectronicKeyListState();
|
||||
|
||||
//请求电子钥匙列表
|
||||
Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async {
|
||||
Future<ElectronicKeyListEntity> 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<ElectronicKeyListItem> 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;
|
||||
}
|
||||
|
||||
//电子钥匙重置请求
|
||||
|
||||
@ -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<ElectronicKeyListPage> {
|
||||
final logic = Get.put(ElectronicKeyListLogic());
|
||||
final state = Get.find<ElectronicKeyListLogic>().state;
|
||||
late RefreshController _refreshController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_refreshController = RefreshController(initialRefresh: true);
|
||||
|
||||
mockRequest();
|
||||
}
|
||||
@ -41,7 +40,9 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
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<ElectronicKeyListPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
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<void> _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<void> _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<ElectronicKeyListItem> 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<ElectronicKeyListPage> {
|
||||
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<ElectronicKeyListPage> {
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String keyId) {
|
||||
|
||||
@ -58,7 +58,7 @@ class _LockUserListPageState extends State<LockUserListPage> {
|
||||
),
|
||||
Expanded(
|
||||
child: dataList.isEmpty
|
||||
? const NoData()
|
||||
? NoData()
|
||||
: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
LockUserData indexEntity = dataList[index];
|
||||
|
||||
@ -137,7 +137,7 @@ class _FaceListState extends State<FaceList> {
|
||||
);
|
||||
},
|
||||
)
|
||||
: const NoData());
|
||||
: NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 170.h));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<FingerprintListDataEntity> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<FingerprintListPage> with RouteAwa
|
||||
final logic = Get.put(FingerprintListLogic());
|
||||
final state = Get.find<FingerprintListLogic>().state;
|
||||
|
||||
Future<void> 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<FingerprintListPage> 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<FingerprintListPage> 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<FingerprintListPage> 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) {
|
||||
|
||||
@ -139,7 +139,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
) : const NoData());
|
||||
) : NoData());
|
||||
}
|
||||
|
||||
Widget _dateItem(String lockDate) {
|
||||
|
||||
@ -76,7 +76,7 @@ class _LockSelectGroupingPageState extends State<LockSelectGroupingPage> {
|
||||
action: () {
|
||||
logic.setLockGroupRequest(itemData);
|
||||
});
|
||||
}) : const NoData());
|
||||
}) : NoData());
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
|
||||
@ -25,7 +25,7 @@ class _NearbyDoorMagneticPageState extends State<NearbyDoorMagneticPage> {
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: dataList.isEmpty
|
||||
? const NoData()
|
||||
? NoData()
|
||||
: ListView.builder(
|
||||
itemCount: dataList.length,
|
||||
itemBuilder: (c, index) {
|
||||
|
||||
@ -27,7 +27,7 @@ class _SelectWirelessKeyboardPageState extends State<SelectWirelessKeyboardPage>
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: dataList.isEmpty
|
||||
? const NoData()
|
||||
? NoData()
|
||||
: ListView.builder(
|
||||
itemCount: 20,
|
||||
itemBuilder: (c, index) {
|
||||
|
||||
@ -58,7 +58,7 @@ class _WirelessKeyboardPageState extends State<WirelessKeyboardPage> {
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return dataList.isEmpty
|
||||
? const NoData()
|
||||
? NoData()
|
||||
: ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (c, index) {
|
||||
|
||||
@ -12,16 +12,26 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
final PasswordKeyListState state = PasswordKeyListState();
|
||||
|
||||
//请求密码钥匙列表
|
||||
void mockNetworkDataRequest() async {
|
||||
Future<PasswordKeyListEntity> 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;
|
||||
}
|
||||
|
||||
//密码钥匙重置请求
|
||||
|
||||
@ -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<PasswordKeyListPage> {
|
||||
final logic = Get.put(PasswordKeyListLogic());
|
||||
final state = Get.find<PasswordKeyListLogic>().state;
|
||||
|
||||
late RefreshController _refreshController;
|
||||
Future<void> 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<void> mockRequest() async {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
logic.mockNetworkDataRequest();
|
||||
}
|
||||
getHttpData();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -69,129 +69,95 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
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<void> _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<void> _refresh() async {
|
||||
// state.pageNum.value = 1;
|
||||
// await logic.mockNetworkDataRequest();
|
||||
// _refreshController.refreshCompleted();
|
||||
// }
|
||||
|
||||
Widget _buildMainUI(itemData) {
|
||||
List<PasswordKeyListItem> 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(
|
||||
|
||||
@ -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 = <PasswordKeyListItem>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ class _RemoteControlListPageState extends State<RemoteControlListPage> {
|
||||
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) {
|
||||
|
||||
@ -80,7 +80,7 @@ class _VideoLogPageState extends State<VideoLogPage> {
|
||||
)),
|
||||
mainListView(index)
|
||||
],);
|
||||
}): const NoData()
|
||||
}): NoData()
|
||||
)
|
||||
),
|
||||
],
|
||||
|
||||
@ -45,7 +45,7 @@ class _VideoLogDownLoadPageState extends State<VideoLogDownLoadPage> {
|
||||
)),
|
||||
mainListView(index)
|
||||
],);
|
||||
}): const NoData(),
|
||||
}): NoData(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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<LockListInfoGroupEntity>
|
||||
void getStarLockInfo() async{
|
||||
var entity = await ApiRepository.to.getStarLockListInfo(
|
||||
pageNo:page,
|
||||
pageSize:20,
|
||||
Future<LockListInfoEntity> 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
|
||||
|
||||
@ -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<StarLockMainPage> with BaseWidget {
|
||||
final logic = Get.put(LockMainLogic());
|
||||
final state = Get.find<LockMainLogic>().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<StarLockMainPage> 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<StarLockMainPage> with BaseWidget {
|
||||
returnWidget = LockListPage(lockListInfoGroupEntity: state.lockListInfoEntity.value.data!);
|
||||
break;
|
||||
default:
|
||||
returnWidget = const NoData();
|
||||
returnWidget = NoData();
|
||||
break;
|
||||
}
|
||||
// Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
@ -10,13 +10,31 @@ import 'messageList_state.dart';
|
||||
class MessageListLogic extends BaseGetXController {
|
||||
final MessageListState state = MessageListState();
|
||||
|
||||
//请求密码钥匙列表
|
||||
void messageListDataRequest() async {
|
||||
//请求消息列表
|
||||
Future<MessageListEntity> 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();
|
||||
}
|
||||
|
||||
@ -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<MessageListPage> createState() => _MessageListPageState();
|
||||
}
|
||||
|
||||
class _MessageListPageState extends State<MessageListPage> {
|
||||
class _MessageListPageState extends State<MessageListPage> with TickerProviderStateMixin {
|
||||
final logic = Get.put(MessageListLogic());
|
||||
final state = Get.find<MessageListLogic>().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<MessageListPage> {
|
||||
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});
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
})
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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 = <MessageItemEntity>[].obs;
|
||||
|
||||
}
|
||||
@ -86,8 +86,8 @@ class _AuthorityManagementPageState extends State<AuthorityManagementPage>
|
||||
),
|
||||
),
|
||||
body: TabBarView(controller: _tabController, children: [
|
||||
dataList.isEmpty ? const NoData() : _permissionNameList(),
|
||||
dataList.isEmpty ? const NoData() : _permissionDeviceList()
|
||||
dataList.isEmpty ? NoData() : _permissionNameList(),
|
||||
dataList.isEmpty ? NoData() : _permissionDeviceList()
|
||||
])));
|
||||
}
|
||||
|
||||
|
||||
@ -148,7 +148,7 @@ class _AuthorizedAdministratorListPageState
|
||||
|
||||
Widget _buildMainUI(List itemList) {
|
||||
return itemList.isEmpty
|
||||
? const NoData()
|
||||
? NoData()
|
||||
: ListView.builder(
|
||||
itemCount: itemList.length,
|
||||
itemBuilder: (c, index) {
|
||||
|
||||
@ -75,7 +75,7 @@ class _GroupEditLockPageState extends State<GroupEditLockPage> {
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
) : const NoData();
|
||||
) : NoData();
|
||||
}
|
||||
|
||||
Widget _listItemView(LockListItem itemData) {
|
||||
|
||||
@ -92,7 +92,7 @@ class _LockItemListPageState extends State<LockItemListPage> {
|
||||
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
||||
},
|
||||
)),
|
||||
const NoData(),
|
||||
NoData(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class _LockGroupListPageState extends State<LockGroupListPage> {
|
||||
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())),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@ -119,7 +119,7 @@ class _LockUserManageListPageState extends State<LockUserManageListPage> {
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return state.dataList.isEmpty
|
||||
? const NoData()
|
||||
? NoData()
|
||||
: ListView.separated(
|
||||
itemCount: state.dataList.length,
|
||||
itemBuilder: (c, index) {
|
||||
|
||||
@ -87,7 +87,7 @@ class _SelectGetewayListPageState extends State<SelectGetewayListPage> {
|
||||
}
|
||||
});
|
||||
});
|
||||
}):const NoData());
|
||||
}): NoData());
|
||||
}
|
||||
|
||||
Widget _electronicKeyItem(GetewayItemData getewayItemData, Function() action) {
|
||||
|
||||
@ -135,7 +135,7 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
|
||||
}
|
||||
});
|
||||
});
|
||||
}):const NoData());
|
||||
}): NoData());
|
||||
}
|
||||
|
||||
Widget _electronicKeyItem(TransferSmartLockItemData transferSmartLockItemData, Function() action) {
|
||||
|
||||
@ -175,4 +175,5 @@ abstract class Api {
|
||||
|
||||
final String messageListURL = '/notifications/list'; //消息列表
|
||||
final String readMessageURL = '/notifications/markAsRead'; //读取消息
|
||||
final String deletMessageURL = '/notifications/delete'; //删除消息
|
||||
}
|
||||
|
||||
@ -1510,6 +1510,13 @@ class ApiProvider extends BaseProvider {
|
||||
jsonEncode({
|
||||
'id': messageId,
|
||||
}));
|
||||
|
||||
// 删除消息
|
||||
Future<Response> deletMessageLoadData(String messageId) => post(
|
||||
deletMessageURL.toUrl,
|
||||
jsonEncode({
|
||||
'id': messageId,
|
||||
}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -1525,4 +1525,12 @@ class ApiRepository {
|
||||
final res = await apiProvider.readMessageLoadData(messageId);
|
||||
return MessageListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 删除消息
|
||||
Future<MessageListEntity> deletMessageLoadData({
|
||||
required String messageId,
|
||||
}) async {
|
||||
final res = await apiProvider.deletMessageLoadData(messageId);
|
||||
return MessageListEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
64
star_lock/lib/tools/EasyRefreshTool.dart
Normal file
64
star_lock/lib/tools/EasyRefreshTool.dart
Normal file
@ -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<EasyRefreshTool> createState() => _EasyRefreshToolState();
|
||||
}
|
||||
|
||||
class _EasyRefreshToolState extends State<EasyRefreshTool> {
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,8 @@ class BaseGetXController extends GetxController{
|
||||
int currentTimeSeconds = 0;
|
||||
|
||||
bool currentPage = true;
|
||||
var pageNo = 1;
|
||||
var pageSize = "20";
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
|
||||
@ -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),
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user