1,电子钥匙状态管理

2,演示模式下 电子钥匙模块、密码模块、授权管理员模块处理
3,删除密码、授权管理员 回到列表页 未更新问题修复
4,发送电子钥匙完成后页面 要统一显示分享(同密码)
This commit is contained in:
Daisy 2023-10-18 15:50:51 +08:00
parent 541940b782
commit 860300e16a
14 changed files with 567 additions and 203 deletions

View File

@ -0,0 +1,48 @@
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
class AuthorizedAdminListLogic extends BaseGetXController {
final AuthorizedAdminListState state = AuthorizedAdminListState();
//
Future<List<ElectronicKeyListItem>> 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(),
'0',
'0');
List<ElectronicKeyListItem> dataList = [];
if (entity.errorCode!.codeIsSuccessful) {
print("电子钥匙列表成功:${entity.data?.itemList}");
if (entity.data != null) {
dataList = entity.data!.itemList;
}
}
state.itemDataList.value = dataList;
return dataList;
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
}
}

View File

@ -2,11 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -23,27 +22,75 @@ class AuthorizedAdminListPage extends StatefulWidget {
} }
class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> { class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
late KeyInfos keyInfo; final logic = Get.put(AuthorizedAdminListLogic());
late LockMainEntity lockMainEntity; final state = Get.find<AuthorizedAdminListLogic>().state;
// late KeyInfos keyInfo;
// late LockMainEntity lockMainEntity;
@override
void initState() {
super.initState();
mockRequest();
}
Future<void> mockRequest() async {
//
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
logic.mockNetworkDataRequest();
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments; // dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["lockMainEntity"] != null)) { // if (obj != null && (obj["lockMainEntity"] != null)) {
lockMainEntity = obj["lockMainEntity"]; // lockMainEntity = obj["lockMainEntity"];
} // }
if (obj != null && (obj["keyInfo"] != null)) { // if (obj != null && (obj["keyInfo"] != null)) {
keyInfo = obj["keyInfo"]; // keyInfo = obj["keyInfo"];
} // }
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr, barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
), ),
body: FutureBuilder<List<ElectronicKeyListItem>>( body: Column(
children: [
Expanded(
child: Obx(() => state.itemDataList.value.isEmpty
? const NoData()
: _buildMainUI(state.itemDataList.value))),
SizedBox(
height: 20.h,
),
AddBottomWhiteBtn(
btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr,
onClick: () {
Navigator.pushNamed(context, Routers.authorizedAdminManagePage,
arguments: {
"lockMainEntity": state.lockMainEntity.value,
"keyInfo": state.keyInfo.value
}).then((val) {
if (val != null) {
logic.mockNetworkDataRequest();
setState(() {});
}
});
},
),
SizedBox(
height: 64.h,
)
],
)
/*
FutureBuilder<List<ElectronicKeyListItem>>(
future: mockNetworkDataRequest(), future: mockNetworkDataRequest(),
builder: (BuildContext context, builder: (BuildContext context,
AsyncSnapshot<List<ElectronicKeyListItem>> snapshot) { AsyncSnapshot<List<ElectronicKeyListItem>> snapshot) {
@ -90,31 +137,32 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
return Container(); return Container();
} }
}), }),
); */
);
} }
// keyRight=1 // // keyRight=1
Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async { // Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async {
ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( // ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList(
'0', // '0',
keyInfo.keyId.toString(), // keyInfo.keyId.toString(),
'', // '',
keyInfo.lockId.toString(), // keyInfo.lockId.toString(),
'', // '',
'1', // '1',
'20', // '20',
'0', // '0',
'1'); // '1');
if (entity.errorCode!.codeIsSuccessful) { // if (entity.errorCode!.codeIsSuccessful) {
print("电子钥匙列表成功:${entity.data?.itemList}"); // print("电子钥匙列表成功:${entity.data?.itemList}");
} // }
if (entity.data != null) { // if (entity.data != null) {
return entity.data!.itemList; // return entity.data!.itemList;
} else { // } else {
List<ElectronicKeyListItem> dataList = []; // List<ElectronicKeyListItem> dataList = [];
return dataList; // return dataList;
} // }
} // }
Widget _buildMainUI(itemData) { Widget _buildMainUI(itemData) {
List<ElectronicKeyListItem> getItemData = itemData; List<ElectronicKeyListItem> getItemData = itemData;
@ -143,7 +191,12 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
return _electronicKeyItem('images/controls_user.png', return _electronicKeyItem('images/controls_user.png',
indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () {
Navigator.pushNamed(context, Routers.electronicKeyDetailPage, Navigator.pushNamed(context, Routers.electronicKeyDetailPage,
arguments: {'itemData': indexEntity}); arguments: {'itemData': indexEntity}).then((val) {
if (val != null) {
logic.mockNetworkDataRequest();
setState(() {});
}
});
}); });
}); });
} }

View File

@ -0,0 +1,17 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
class AuthorizedAdminListState {
final keyInfo = KeyInfos().obs;
final lockMainEntity = LockMainEntity().obs;
var pageNum = 1.obs; //
final pageSize = 20.obs; //
final itemDataList = <ElectronicKeyListItem>[].obs;
AuthorizedAdminListState() {
Map map = Get.arguments;
lockMainEntity.value = map["lockMainEntity"];
keyInfo.value = map["keyInfo"];
}
}

View File

@ -8,7 +8,6 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/jh_pop_menus.dart'; import 'package:star_lock/tools/jh_pop_menus.dart';
import 'package:star_lock/tools/showCupertinoAlert.dart';
import 'package:star_lock/tools/toast.dart'; import 'package:star_lock/tools/toast.dart';
import '../../../../../appRouters.dart'; import '../../../../../appRouters.dart';

View File

@ -19,15 +19,15 @@ class ElectronicKeyListLogic extends BaseGetXController {
state.pageSize.toString(), state.pageSize.toString(),
'0', '0',
'0'); '0');
List<ElectronicKeyListItem> dataList = [];
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
print("电子钥匙列表成功:${entity.data?.itemList}"); print("电子钥匙列表成功:${entity.data?.itemList}");
if (entity.data != null) {
dataList = entity.data!.itemList;
}
} }
if (entity.data != null) { state.itemDataList.value = dataList;
return entity.data!.itemList; return dataList;
} else {
List<ElectronicKeyListItem> dataList = [];
return dataList;
}
} }
// //

View File

@ -7,6 +7,7 @@ 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/electronicKeyList_logic.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/submitBtn.dart'; import '../../../../tools/submitBtn.dart';
@ -24,35 +25,76 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
final logic = Get.put(ElectronicKeyListLogic()); final logic = Get.put(ElectronicKeyListLogic());
final state = Get.find<ElectronicKeyListLogic>().state; final state = Get.find<ElectronicKeyListLogic>().state;
late RefreshController _refreshController; late RefreshController _refreshController;
late List<ElectronicKeyListItem> itemDataList = []; // late List<ElectronicKeyListItem> itemDataList = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_refreshController = RefreshController(initialRefresh: true); _refreshController = RefreshController(initialRefresh: true);
mockRequest();
}
Future<void> mockRequest() async {
//
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
logic.mockNetworkDataRequest();
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.electronicKey!.tr, barTitle: TranslationLoader.lanKeys!.electronicKey!.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
actionsList: [ actionsList: [
TextButton( TextButton(
child: Text( child: Text(
TranslationLoader.lanKeys!.reset!.tr, TranslationLoader.lanKeys!.reset!.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp), style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {
_showDialog(context);
},
), ),
onPressed: () { ],
_showDialog(context); ),
}, body: Column(
), children: [
], _searchWidget(),
), SizedBox(
body: FutureBuilder<List<ElectronicKeyListItem>>( 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,
)
],
)
/*
FutureBuilder<List<ElectronicKeyListItem>>(
future: logic.mockNetworkDataRequest(), future: logic.mockNetworkDataRequest(),
builder: (BuildContext context, builder: (BuildContext context,
AsyncSnapshot<List<ElectronicKeyListItem>> snapshot) { AsyncSnapshot<List<ElectronicKeyListItem>> snapshot) {
@ -115,13 +157,14 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
return Container(); return Container();
} }
}), }),
); */
);
} }
/// ///
Future<void> _loadMore() async { Future<void> _loadMore() async {
if (state.pageNum.value == 1) { if (state.pageNum.value == 1) {
if (itemDataList.length < 10) { if (state.itemDataList.value.length < 10) {
_refreshController.loadComplete(); _refreshController.loadComplete();
} else { } else {
state.pageNum.value++; state.pageNum.value++;
@ -209,7 +252,6 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
setState(() {}); setState(() {});
} }
}); });
;
}); });
}, },
separatorBuilder: (BuildContext context, int index) { separatorBuilder: (BuildContext context, int index) {

View File

@ -1,12 +1,13 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart';
class ElectronicKeyListState { class ElectronicKeyListState {
final keyInfo = KeyInfos().obs; final keyInfo = KeyInfos().obs;
final lockMainEntity = LockMainEntity().obs; final lockMainEntity = LockMainEntity().obs;
var pageNum = 1.obs; // var pageNum = 1.obs; //
final pageSize = 20.obs; // final pageSize = 20.obs; //
final itemDataList = <ElectronicKeyListItem>[].obs;
ElectronicKeyListState() { ElectronicKeyListState() {
Map map = Get.arguments; Map map = Get.arguments;

View File

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_pickers/pickers.dart'; import 'package:flutter_pickers/pickers.dart';
import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -28,6 +29,7 @@ class SendElectronicKeyPage extends StatefulWidget {
class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> { class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
final logic = Get.put(SendElectronicKeyLogic()); final logic = Get.put(SendElectronicKeyLogic());
final state = Get.find<SendElectronicKeyLogic>().state; final state = Get.find<SendElectronicKeyLogic>().state;
static const methodChannel = MethodChannel('flutter_native_ios');
@override @override
void initState() { void initState() {
@ -345,21 +347,22 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
height: 10.h, height: 10.h,
), ),
OutLineBtn( OutLineBtn(
btnName: '邮件通知', btnName: '分享',
onClick: () { onClick: () {
Navigator.pushNamed(context, Routers.sendEmailNotificationPage); // Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
_openModalBottomSheet();
}, },
), ),
SizedBox( SizedBox(
height: 10.h, height: 10.h,
), ),
OutLineBtn( // OutLineBtn(
btnName: '微信通知', // btnName: '微信通知',
onClick: () {}, // onClick: () {},
), // ),
SizedBox( // SizedBox(
height: 10.h, // height: 10.h,
), // ),
OutLineBtn( OutLineBtn(
btnName: '标记为已入住', btnName: '标记为已入住',
onClick: () { onClick: () {
@ -484,4 +487,126 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
String intToStr(int v) { String intToStr(int v) {
return (v < 10) ? "0$v" : "$v"; return (v < 10) ? "0$v" : "$v";
} }
Future _openModalBottomSheet() async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
constraints: BoxConstraints(maxHeight: 260.h),
builder: (BuildContext context) {
return Column(
children: [
SizedBox(
width: ScreenUtil().screenWidth,
height: 180.h,
child: ListView(
scrollDirection: Axis.horizontal, //
children: initBottomSheetList()),
),
Container(
height: 8.h,
color: AppColors.greyBackgroundColor,
),
TextButton(
style: ButtonStyle(
overlayColor:
MaterialStateProperty.all<Color>(Colors.white)),
child: Text(
'取消',
style: TextStyle(
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
),
onPressed: () {
Navigator.pop(context);
},
)
],
);
});
}
List<Widget> initBottomSheetList() {
List<Widget> widgetList = [];
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0));
widgetList.add(buildCenter3('images/icon_message.png', '短信', 1));
widgetList.add(buildCenter3('images/icon_email.png', '邮件', 2));
widgetList.add(buildCenter3('images/icon_more.png', '更多', 3));
return widgetList;
}
GestureDetector buildCenter3(
String imageName, String titleStr, int itemIndex) {
return GestureDetector(
child: Container(
width: 120.w,
// height: 64.h,
margin:
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
imageName,
width: 50.w,
height: 50.h,
),
SizedBox(
height: 16.w,
),
Text(
titleStr,
style: TextStyle(
fontSize: ScreenUtil().setSp(20), color: Colors.black),
),
],
),
),
onTap: () => _jumpSmartDeviceRoute(itemIndex),
);
}
_jumpSmartDeviceRoute(int itemIndex) {
switch (itemIndex) {
case 0:
//
{
Navigator.pop(context);
String pwdShareStr = '您好,您的电子钥匙生成成功';
tokNative('flutter_sharePassword_to_ios',
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
print('$result');
});
print('与原生交互');
}
break;
case 1:
//
{}
break;
case 2:
//
{
Navigator.pop(context);
Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
}
break;
case 3:
//
{}
break;
default:
}
}
static Future<dynamic> tokNative(String method,
{required Map arguments}) async {
if (arguments == null) {
return await methodChannel.invokeMethod(method);
} else {
return await methodChannel.invokeMethod(method, arguments);
}
}
} }

View File

@ -515,29 +515,57 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
); );
} }
void showCupertinoAlertDialog( //
BuildContext context, void showCupertinoAlertDialog(widgetContext) {
) { showCupertinoDialog(
showDialog( context: widgetContext,
context: context, builder: (context) {
builder: (BuildContext context) { return CupertinoAlertDialog(
return ShowIosTipView( title: const Text('创建公司号,考勤功能才能使用'),
title: "提示", actions: [
tipTitle: "创建公司号,考勤功能才能使用", CupertinoDialogAction(
sureClick: () { child: Text(TranslationLoader.lanKeys!.cancel!.tr),
// onPressed: () {
Navigator.pop(context); Navigator.of(context).pop();
Get.toNamed(Routers.checkInCreatCompanyPage, },
arguments: state.getKeyInfosData.value); ),
}, CupertinoDialogAction(
cancelClick: () { child: Text(TranslationLoader.lanKeys!.sure!.tr),
Navigator.pop(context); onPressed: () {
}, Navigator.pop(context);
Get.toNamed(Routers.checkInCreatCompanyPage,
arguments: state.getKeyInfosData.value);
},
),
],
); );
}, },
); );
} }
// void showCupertinoAlertDialog(
// BuildContext context,
// ) {
// showDialog(
// context: context,
// builder: (BuildContext context) {
// return ShowIosTipView(
// title: "提示",
// tipTitle: "创建公司号,考勤功能才能使用",
// sureClick: () {
// //
// Navigator.pop(context);
// Get.toNamed(Routers.checkInCreatCompanyPage,
// arguments: state.getKeyInfosData.value);
// },
// cancelClick: () {
// Navigator.pop(context);
// },
// );
// },
// );
// }
void showDeletPasswordAlertDialog( void showDeletPasswordAlertDialog(
BuildContext context, BuildContext context,
) { ) {

View File

@ -1,4 +1,3 @@
import 'package:date_format/date_format.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -193,7 +192,6 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
padding: EdgeInsets.only(top: 25.w, bottom: 25.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () { onClick: () {
deletePwdRequest(); deletePwdRequest();
Navigator.pop(context, true);
}), }),
], ],
), ),
@ -278,6 +276,9 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1); itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "删除成功"); Toast.show(msg: "删除成功");
setState(() {
Navigator.pop(context, true);
});
} }
} }
@ -409,6 +410,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
case 0: case 0:
// //
{ {
Navigator.pop(context);
String pwdShareStr = String pwdShareStr =
'您好,您的密码是:${itemData.keyboardPwd}\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}'; '您好,您的密码是:${itemData.keyboardPwd}\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}';
tokNative('flutter_sharePassword_to_ios', tokNative('flutter_sharePassword_to_ios',
@ -425,6 +427,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
case 2: case 2:
// //
{ {
Navigator.pop(context);
Navigator.pushNamed(context, Routers.sendEmailNotificationPage); Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
} }
break; break;

View File

@ -15,15 +15,15 @@ class PasswordKeyListLogic extends BaseGetXController {
'0', '0',
state.pageNum.toString(), state.pageNum.toString(),
state.pageSize.toString()); state.pageSize.toString());
List<PasswordKeyListItem> dataList = [];
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
print("密码钥匙列表成功:${entity.data?.itemList}"); print("密码钥匙列表成功:${entity.data?.itemList}");
if (entity.data != null) {
dataList = entity.data!.itemList!;
}
} }
if (entity.data != null) { state.itemDataList.value = dataList;
return entity.data!.itemList!; return dataList;
} else {
List<PasswordKeyListItem> dataList = [];
return dataList;
}
} }
// //

View File

@ -6,6 +6,7 @@ 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/passwordKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart';
import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/submitBtn.dart'; import '../../../../tools/submitBtn.dart';
@ -22,7 +23,7 @@ class PasswordKeyListPage extends StatefulWidget {
class _PasswordKeyListPageState extends State<PasswordKeyListPage> { class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
final logic = Get.put(PasswordKeyListLogic()); final logic = Get.put(PasswordKeyListLogic());
final state = Get.find<PasswordKeyListLogic>().state; final state = Get.find<PasswordKeyListLogic>().state;
late List<PasswordKeyListItem> _itemDataList = []; // late List<PasswordKeyListItem> _itemDataList = [];
late RefreshController _refreshController; late RefreshController _refreshController;
@ -30,29 +31,70 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
void initState() { void initState() {
super.initState(); super.initState();
_refreshController = RefreshController(initialRefresh: true); _refreshController = RefreshController(initialRefresh: true);
mockRequest();
}
Future<void> mockRequest() async {
//
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
logic.mockNetworkDataRequest();
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.password!.tr, barTitle: TranslationLoader.lanKeys!.password!.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
actionsList: [ actionsList: [
TextButton( TextButton(
child: Text( child: Text(
TranslationLoader.lanKeys!.reset!.tr, TranslationLoader.lanKeys!.reset!.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp), style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {
_showDialog(context);
},
), ),
onPressed: () { ],
_showDialog(context); ),
}, body: Column(
), children: [
], _searchWidget(),
), SizedBox(
body: FutureBuilder<List<PasswordKeyListItem>>( 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: {
"lockMainEntity": state.lockMainEntity.value,
"keyInfo": state.keyInfo.value
}).then((val) {
if (val != null) {
logic.mockNetworkDataRequest();
}
});
}),
SizedBox(
height: 42.h,
)
],
)
/*
FutureBuilder<List<PasswordKeyListItem>>(
future: logic.mockNetworkDataRequest(), future: logic.mockNetworkDataRequest(),
builder: (BuildContext context, builder: (BuildContext context,
AsyncSnapshot<List<PasswordKeyListItem>> snapshot) { AsyncSnapshot<List<PasswordKeyListItem>> snapshot) {
@ -119,13 +161,14 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
return Container(); return Container();
} }
}), }),
); */
);
} }
/// ///
Future<void> _loadMore() async { Future<void> _loadMore() async {
if (state.pageNum.value == 1) { if (state.pageNum.value == 1) {
if (_itemDataList.length < 10) { if (state.itemDataList.length < 10) {
_refreshController.loadComplete(); _refreshController.loadComplete();
} else { } else {
state.pageNum.value++; state.pageNum.value++;
@ -195,7 +238,12 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
return _electronicKeyItem('images/controls_user.png', return _electronicKeyItem('images/controls_user.png',
indexEntity.keyboardPwdName!, useDateStr, () { indexEntity.keyboardPwdName!, useDateStr, () {
Navigator.pushNamed(context, Routers.passwordKeyDetailPage, Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
arguments: {"itemData": indexEntity}); arguments: {"itemData": indexEntity}).then((val) {
if (val != null) {
logic.mockNetworkDataRequest();
}
});
;
}); });
}, },
separatorBuilder: (BuildContext context, int index) { separatorBuilder: (BuildContext context, int index) {

View File

@ -1,4 +1,5 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
class PasswordKeyListState { class PasswordKeyListState {
@ -6,6 +7,7 @@ class PasswordKeyListState {
final lockMainEntity = LockMainEntity().obs; final lockMainEntity = LockMainEntity().obs;
var pageNum = 1.obs; // var pageNum = 1.obs; //
final pageSize = 20.obs; // final pageSize = 20.obs; //
final itemDataList = <PasswordKeyListItem>[].obs;
PasswordKeyListState() { PasswordKeyListState() {
Map map = Get.arguments; Map map = Get.arguments;

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -26,7 +25,6 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
} }
@override @override
@ -34,25 +32,21 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: "演示模式", barTitle: "演示模式",
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
), ),
body: Container( body: Container(
width: 1.sw, width: 1.sw,
height: 1.sh - ScreenUtil().statusBarHeight * 2, height: 1.sh - ScreenUtil().statusBarHeight * 2,
color: Colors.white, color: Colors.white,
child: Column( child: Column(
children: [ children: [topTip(), topWidget(), Expanded(child: bottomWidget())],
topTip(), ),
topWidget(), ));
Expanded(child: bottomWidget())
],
),
));
} }
Widget topTip(){ Widget topTip() {
return Container( return Container(
// height: 120.h, // height: 120.h,
width: 1.sw, width: 1.sw,
@ -61,7 +55,10 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
children: [ children: [
Row( Row(
children: [ children: [
Expanded(child: Text("提示:当前界面为展示界面,添加设备后才能继续使用", style: TextStyle(fontSize: 24.sp, color: AppColors.mainColor))), Expanded(
child: Text("提示:当前界面为展示界面,添加设备后才能继续使用",
style: TextStyle(
fontSize: 24.sp, color: AppColors.mainColor))),
], ],
), ),
], ],
@ -82,7 +79,7 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
child: Text( child: Text(
"TMH_78f16712781a", "TMH_78f16712781a",
style: style:
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400), TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
)), )),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
@ -112,12 +109,12 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
children: [ children: [
Center( Center(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
gotoLogin(); gotoLogin();
}, },
child: Image.asset('images/main/icon_main_openLockBtn.png', child: Image.asset('images/main/icon_main_openLockBtn.png',
width: 268.w, height: 268.w), width: 268.w, height: 268.w),
)), )),
], ],
), ),
), ),
@ -168,12 +165,13 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
Text( Text(
'超级管理员', '超级管理员',
style: style:
TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor), TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor),
), ),
SizedBox( SizedBox(
width: 80.w, width: 80.w,
), ),
Image.asset('images/main/icon_main_remoteUnlocking_grey.png', Image.asset(
'images/main/icon_main_remoteUnlocking_grey.png',
// state.keyInfos.value.remoteEnable == 1 // state.keyInfos.value.remoteEnable == 1
// ? 'images/main/icon_main_remoteUnlocking.png' // ? 'images/main/icon_main_remoteUnlocking.png'
// : 'images/main/icon_main_remoteUnlocking_grey.png', // : 'images/main/icon_main_remoteUnlocking_grey.png',
@ -189,7 +187,7 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
Text( Text(
'网关设备', '网关设备',
style: style:
TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor), TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor),
), ),
], ],
), ),
@ -227,58 +225,57 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
// //
// if (state.keyInfos.value.isAttendance == 1) { // if (state.keyInfos.value.isAttendance == 1) {
showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png',
TranslationLoader.lanKeys!.checkingIn!.tr, () { TranslationLoader.lanKeys!.checkingIn!.tr, () {
// gotoLogin(); // gotoLogin();
Get.toNamed(Routers.checkingInListPage, arguments: KeyInfos()); Get.toNamed(Routers.checkingInListPage, arguments: KeyInfos());
})); }));
// } // }
var defaultWidgetArr = [ var defaultWidgetArr = [
// //
bottomItem('images/main/icon_main_electronicKey.png', bottomItem('images/main/icon_main_electronicKey.png',
TranslationLoader.lanKeys!.electronicKey!.tr, () { TranslationLoader.lanKeys!.electronicKey!.tr, () {
gotoLogin(); // gotoLogin();
// Get.toNamed(Routers.electronicKeyListPage, arguments: { Get.toNamed(Routers.electronicKeyListPage, arguments: {
// "lockMainEntity": widget.lockMainEntity, "lockMainEntity": LockMainEntity(),
// "keyInfo": widget.keyInfo "keyInfo": KeyInfos()
// }); });
}), }),
// //
bottomItem('images/main/icon_main_password.png', bottomItem('images/main/icon_main_password.png',
TranslationLoader.lanKeys!.password!.tr, () { TranslationLoader.lanKeys!.password!.tr, () {
gotoLogin();
// Get.toNamed(Routers.passwordKeyListPage, arguments: {
// "lockMainEntity": widget.lockMainEntity,
// "keyInfo": widget.keyInfo
// });
}),
// ic卡
bottomItem('images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, () {
// gotoLogin(); // gotoLogin();
Get.toNamed(Routers.otherTypeKeyListPage, arguments: { Get.toNamed(Routers.passwordKeyListPage, arguments: {
"lockId": 0, "lockMainEntity": LockMainEntity(),
"fromType": 0 "keyInfo": KeyInfos()
}); });
}), }),
// ic卡
bottomItem('images/main/icon_main_icCard.png',
TranslationLoader.lanKeys!.card!.tr, () {
// gotoLogin();
Get.toNamed(Routers.otherTypeKeyListPage,
arguments: {"lockId": 0, "fromType": 0});
}),
// //
bottomItem('images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, () { bottomItem('images/main/icon_main_fingerprint.png',
TranslationLoader.lanKeys!.fingerprint!.tr, () {
// gotoLogin(); // gotoLogin();
Get.toNamed(Routers.otherTypeKeyListPage, arguments: { Get.toNamed(Routers.otherTypeKeyListPage,
"lockId": 1, arguments: {"lockId": 1, "fromType": 1});
"fromType": 1
});
}), }),
// //
bottomItem('images/main/icon_main_remoteControl.png', TranslationLoader.lanKeys!.remoteControl!.tr, () { bottomItem('images/main/icon_main_remoteControl.png',
TranslationLoader.lanKeys!.remoteControl!.tr, () {
gotoLogin(); gotoLogin();
// Get.toNamed(Routers.otherTypeKeyListPage, arguments: { // Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
@ -315,25 +312,26 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
// //
bottomItem('images/main/icon_main_authorizedAdmin.png', bottomItem('images/main/icon_main_authorizedAdmin.png',
TranslationLoader.lanKeys!.authorizedAdmin!.tr, () { TranslationLoader.lanKeys!.authorizedAdmin!.tr, () {
gotoLogin(); // gotoLogin();
// Get.toNamed(Routers.authorizedAdminListPage, arguments: { Get.toNamed(Routers.authorizedAdminListPage, arguments: {
// "keyInfo": KeyInfos() "lockMainEntity": LockMainEntity(),
// }); "keyInfo": KeyInfos()
}), });
}),
// //
bottomItem('images/main/icon_main_operatingRecord.png', bottomItem('images/main/icon_main_operatingRecord.png',
TranslationLoader.lanKeys!.operatingRecord!.tr, () { TranslationLoader.lanKeys!.operatingRecord!.tr, () {
// gotoLogin(); // gotoLogin();
Get.toNamed(Routers.lockOperatingRecordPage, arguments: { Get.toNamed(Routers.lockOperatingRecordPage,
"keyInfo": KeyInfos() arguments: {"keyInfo": KeyInfos()});
}); }),
}),
// //
bottomItem( bottomItem(
'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () { 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr,
Get.toNamed(Routers.demoModeLockSetPage); () {
}), Get.toNamed(Routers.demoModeLockSetPage);
}),
]; ];
showWidgetArr.addAll(endWiddget); showWidgetArr.addAll(endWiddget);
return showWidgetArr; return showWidgetArr;
@ -345,7 +343,7 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
return GestureDetector( return GestureDetector(
onTap: onClick, onTap: onClick,
child: Container( child: Container(
// height: 300.h, // height: 300.h,
color: Colors.white, color: Colors.white,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -367,7 +365,7 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
); );
} }
void gotoLogin(){ void gotoLogin() {
// Get.toNamed(Routers.seletLockTypePage); // Get.toNamed(Routers.seletLockTypePage);
Toast.show(msg: "演示模式"); Toast.show(msg: "演示模式");
} }