1,锁详情页面新增权限处理

2,头像权限处理(待完善)
This commit is contained in:
Daisy 2024-03-21 11:36:48 +08:00
parent 04d17f6483
commit d9e93fbdea
4 changed files with 293 additions and 199 deletions

View File

@ -8,6 +8,7 @@ import 'package:intl/intl.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
import 'package:star_lock/tools/appFirstEnterHandle.dart';
import '../../../blue/blue_manage.dart';
import '../../../blue/io_protocol/io_addUser.dart';
@ -50,7 +51,8 @@ class LockDetailLogic extends BaseGetXController {
// }
//
if (reply is SenderReferEventRecordTimeReply && state.ifCurrentScreen.value == true) {
if (reply is SenderReferEventRecordTimeReply &&
state.ifCurrentScreen.value == true) {
_replyReferEventRecordTime(reply);
}
@ -73,7 +75,7 @@ class LockDetailLogic extends BaseGetXController {
// _showFullScreenOverlay(Get.context!);
state.iSClosedUnlockSuccessfulPopup.value = true;
if (state.closedUnlockSuccessfulTimer != null ) {
if (state.closedUnlockSuccessfulTimer != null) {
state.closedUnlockSuccessfulTimer!.cancel();
state.closedUnlockSuccessfulTimer = null;
}
@ -379,7 +381,8 @@ class LockDetailLogic extends BaseGetXController {
eventBus.fire(RefreshLockDetailInfoDataEvent());
});
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
BlueManage()
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
//
@ -411,7 +414,8 @@ class LockDetailLogic extends BaseGetXController {
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer();
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
@ -466,7 +470,8 @@ class LockDetailLogic extends BaseGetXController {
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer();
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
@ -698,17 +703,21 @@ class LockDetailLogic extends BaseGetXController {
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
void _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
// eventBus
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((event) {
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus
.on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((event) {
if (event.type == 0) {
// 0
state.isAttendance.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.attendance = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.attendance =
int.parse(event.setResult);
} else if (event.type == 1) {
// 1
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.appUnlockOnline =
int.parse(event.setResult);
print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}");
print(
"state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}");
} else if (event.type == 2) {
// 2
state.isOpenPassageMode.value = int.parse(event.setResult);
@ -726,19 +735,20 @@ class LockDetailLogic extends BaseGetXController {
});
}
String getKeyStatusTextAndShow(){
String getKeyStatusTextAndShow() {
String text = "";
if (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitIneffective ||
if (state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
text = "你的钥匙${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
text =
"你的钥匙${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
} else {
text = state.isOpenPassageMode.value == 1
? "常开模式启动!长按闭锁"
: TranslationLoader
.lanKeys!.clickUnlockAndHoldDownClose!.tr;
: TranslationLoader.lanKeys!.clickUnlockAndHoldDownClose!.tr;
}
return text;
}
@ -826,6 +836,20 @@ class LockDetailLogic extends BaseGetXController {
return formattedTime;
}
Future<void> positionPermissionAlert() async {
//
if (Platform.isAndroid) {
AppFirstEnterHandle()
.getAppFirstEnter(state.widgetContext, isAgreePosition);
var getFlag = await Storage.getString(isAgreePosition);
if (getFlag == isAgreePosition) {
openBlueSet();
}
} else {
openBlueSet();
}
}
openBlueSet() {
if (!Platform.isIOS) {
getMicrophonePermission().then((value) {
@ -862,7 +886,9 @@ class LockDetailLogic extends BaseGetXController {
// TODO: implement onReady
super.onReady();
openBlueSet();
// openBlueSet();
positionPermissionAlert();
_initReplySubscription();
_initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
@ -886,5 +912,4 @@ class LockDetailLogic extends BaseGetXController {
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
// _scanListDiscoveredDeviceSubscription.cancel();
}
}

View File

@ -35,7 +35,8 @@ class LockDetailPage extends StatefulWidget {
State<LockDetailPage> createState() => _LockDetailPageState();
}
class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin, RouteAware {
class _LockDetailPageState extends State<LockDetailPage>
with TickerProviderStateMixin, RouteAware {
// with RouteAware
final logic = Get.put(LockDetailLogic());
final state = Get.find<LockDetailLogic>().state;
@ -61,6 +62,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
void didChangeDependencies() {
super.didChangeDependencies();
Get.log("LockDetailPage didChangeDependencies2222");
///
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
}
@ -68,12 +70,13 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
StreamSubscription? _lockRefreshLockDetailInfoDataEvent;
void _initRefreshLockDetailInfoDataEventAction() {
// eventBus
_lockRefreshLockDetailInfoDataEvent = eventBus.on<RefreshLockDetailInfoDataEvent>().listen((event) {
_lockRefreshLockDetailInfoDataEvent =
eventBus.on<RefreshLockDetailInfoDataEvent>().listen((event) {
setState(() {});
});
}
void loadData(){
void loadData() {
// print("widget.lockListInfoItemEntity.lockUserNo:${widget.lockListInfoItemEntity.lockUserNo}");
// print("state.lockUserNo:${state.lockUserNo}");
@ -81,17 +84,18 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
state.lockUserNo = state.keyInfos.value.lockUserNo!;
if (state.lockUserNo == 0) {
state.bottomBtnisEable.value = false;
}else{
} else {
state.bottomBtnisEable.value = true;
}
// print("state.keyInfos.value.keyStatus:${state.keyInfos.value.keyStatus}");
if (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitIneffective ||
if (state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
state.openDoorBtnisUneable.value = false;
}else{
} else {
state.openDoorBtnisUneable.value = true;
}
@ -100,28 +104,28 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
state.senderUserId = state.keyInfos.value.senderUserId!;
state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!;
state.isOpenLockNeedOnline.value =
state.keyInfos.value.lockSetting!.appUnlockOnline!;
state.keyInfos.value.lockSetting!.appUnlockOnline!;
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
state.isOpenPassageMode.value = state.keyInfos.value.passageMode!;
state.lockAlias.value = state.keyInfos.value.lockAlias!;
BlueManage().connectDeviceName =
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
List<int> publicKeyData =
state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
var saveStrList = changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList);
//
List<int> privateKeyData =
state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey
List<int> signKeyData =
state.keyInfos.value.bluetooth!.signKey!.cast<int>();
state.keyInfos.value.bluetooth!.signKey!.cast<int>();
var saveSignKeyList = changeIntListToStringList(signKeyData);
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
@ -131,16 +135,29 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
@override
Widget build(BuildContext context) {
state.widgetContext = context;
loadData();
return ListView(
children: [
Visibility(
visible: (
(state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || state.keyInfos.value.keyType == XSConstantMacro.keyTypeLoop) && //
(DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) < 30 && DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) > 0) &&// 030
(state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusNormalUse || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitReceive)// 使
) ? true : false,
visible:
((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime ||
state.keyInfos.value.keyType ==
XSConstantMacro.keyTypeLoop) && //
(DateTool().compareTimeGetDaysFromNow(
state.keyInfos.value.endDate!) <
30 &&
DateTool().compareTimeGetDaysFromNow(
state.keyInfos.value.endDate!) >
0) && // 030
(state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusNormalUse ||
state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitReceive) // 使
)
? true
: false,
child: Container(
// height: 30.h,
color: const Color(0xFFFBEFD4),
@ -148,7 +165,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("钥匙将在${DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!)}天后失效",
Text(
"钥匙将在${DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!)}天后失效",
style: TextStyle(
color: const Color(0xffCBA74B), fontSize: 24.sp))
],
@ -185,21 +203,21 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
),
),
Visibility(
visible: state.iSClosedUnlockSuccessfulPopup.value,
// visible: true,
child: GestureDetector(
onTap: () {
setState(() {
state.iSClosedUnlockSuccessfulPopup.value = false;
});
},
child: Container(
width: 1.sw,
height: 1.sh - ScreenUtil().statusBarHeight * 2,
color: Colors.black.withOpacity(0.3),
child: _unlockSuccessWidget()),
),
)
visible: state.iSClosedUnlockSuccessfulPopup.value,
// visible: true,
child: GestureDetector(
onTap: () {
setState(() {
state.iSClosedUnlockSuccessfulPopup.value = false;
});
},
child: Container(
width: 1.sw,
height: 1.sh - ScreenUtil().statusBarHeight * 2,
color: Colors.black.withOpacity(0.3),
child: _unlockSuccessWidget()),
),
)
]),
],
);
@ -215,73 +233,70 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
SizedBox(
width: 1.sw - 120.w * 2,
child: Center(
child: Text(
state.lockAlias.value,
style: TextStyle(
fontSize: 22.sp,
fontWeight: FontWeight.w400,
color: state.isOpenPassageMode.value == 1
? AppColors.openPassageModeColor
: AppColors.darkGrayTextColor),
))),
child: Text(
state.lockAlias.value,
style: TextStyle(
fontSize: 22.sp,
fontWeight: FontWeight.w400,
color: state.isOpenPassageMode.value == 1
? AppColors.openPassageModeColor
: AppColors.darkGrayTextColor),
))),
Positioned(
child: Column(
children: [
GestureDetector(
onTap: () {
// logic.getStarLockStatus();
showDeletAlertDialog(
context,
DateTool().dateToYMDHNSString(state
.keyInfos.value.electricQuantityDate!
.toString()));
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset(
showElectricIcon(
state.electricQuantity.value),
width: 30.w,
height: 24.w),
SizedBox(width: 2.w),
Text("${state.electricQuantity.value}%",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
Icon(
Icons.info, // 使 warning
color: AppColors.mainColor, //
size: 25.w, // 30
),
SizedBox(width: 20.w),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset(
showElectricIcon(state.electricQuantity.value),
width: 30.w,
height: 24.w),
SizedBox(width: 2.w),
Text("--%",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
Icon(
Icons.info, // 使 warning
color: AppColors.mainColor, //
size: 25.w, // 30
),
SizedBox(width: 20.w),
],
),
],
))
children: [
GestureDetector(
onTap: () {
// logic.getStarLockStatus();
showDeletAlertDialog(
context,
DateTool().dateToYMDHNSString(state
.keyInfos.value.electricQuantityDate!
.toString()));
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset(
showElectricIcon(state.electricQuantity.value),
width: 30.w,
height: 24.w),
SizedBox(width: 2.w),
Text("${state.electricQuantity.value}%",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
Icon(
Icons.info, // 使 warning
color: AppColors.mainColor, //
size: 25.w, // 30
),
SizedBox(width: 20.w),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset(showElectricIcon(state.electricQuantity.value),
width: 30.w, height: 24.w),
SizedBox(width: 2.w),
Text("--%",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
Icon(
Icons.info, // 使 warning
color: AppColors.mainColor, //
size: 25.w, // 30
),
SizedBox(width: 20.w),
],
),
],
))
],
),
SizedBox(height: 30.h),
@ -293,36 +308,43 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
children: [
Center(
child: GestureDetector(
onTap: state.openDoorBtnisUneable.value == true ? () {
// Get.log("点击开锁");
setState(() {
startOpenLock();
});
} : null,
onLongPressStart: state.openDoorBtnisUneable.value == true ? (details) {
Get.log("长按闭锁");
setState(() {
startUnLock();
});
// startUnLock();
}:null,
onTap: state.openDoorBtnisUneable.value == true
? () {
// Get.log("点击开锁");
setState(() {
startOpenLock();
});
}
: null,
onLongPressStart: state.openDoorBtnisUneable.value == true
? (details) {
Get.log("长按闭锁");
setState(() {
startUnLock();
});
// startUnLock();
}
: null,
child: Stack(
children: [
Image.asset(
state.openDoorBtnisUneable.value == false ? 'images/main/icon_main_openLockBtn_grey.png' : (state.isOpenPassageMode.value == 1
children: [
Image.asset(
state.openDoorBtnisUneable.value == false
? 'images/main/icon_main_openLockBtn_grey.png'
: (state.isOpenPassageMode.value == 1
? 'images/main/icon_main_normallyOpenMode_center.png'
: 'images/main/icon_main_openLockBtn_center.png'),
width: 330.w,
height: 330.w,
),
state.openDoorBtnisUneable.value == false ? Positioned(
child: Image.asset(
'images/main/icon_main_openLockBtn_grey.png',
width: 330.w,
height: 330.w,
),
) :
state.openLockBtnState.value == 1
width: 330.w,
height: 330.w,
),
state.openDoorBtnisUneable.value == false
? Positioned(
child: Image.asset(
'images/main/icon_main_openLockBtn_grey.png',
width: 330.w,
height: 330.w,
),
)
: state.openLockBtnState.value == 1
? buildRotationTransition()
: Positioned(
child: Image.asset(
@ -332,8 +354,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
width: 330.w,
height: 330.w,
)),
],
),
],
),
)),
],
),
@ -361,10 +383,10 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
children: [
Text(
logic.getKeyStatusTextAndShow(),
style: TextStyle(
fontSize: 22.sp,
color: AppColors.btnDisableColor,
fontWeight: FontWeight.w500),
style: TextStyle(
fontSize: 22.sp,
color: AppColors.btnDisableColor,
fontWeight: FontWeight.w500),
),
],
),
@ -543,7 +565,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_clockingIn.png',
TranslationLoader.lanKeys!.checkingIn!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.checkingInListPage,
arguments: state.keyInfos.value);
}));
@ -552,14 +575,18 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_operatingRecord.png',
TranslationLoader.lanKeys!.operatingRecord!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.lockOperatingRecordPage,
arguments: {"keyInfo": state.keyInfos.value});
}));
//
showWidgetArr.add(bottomItem('images/main/icon_main_set.png',
TranslationLoader.lanKeys!.set!.tr, state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
showWidgetArr.add(bottomItem(
'images/main/icon_main_set.png',
TranslationLoader.lanKeys!.set!.tr,
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.lockSetPage, arguments: {
"lockId": state.keyInfos.value.lockId,
"isOnlyOneData": state.isOnlyOneData
@ -577,7 +604,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_clockingIn.png',
TranslationLoader.lanKeys!.checkingIn!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.checkingInListPage,
arguments: state.keyInfos.value);
}));
@ -587,7 +615,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_electronicKey.png',
TranslationLoader.lanKeys!.electronicKey!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.electronicKeyListPage,
arguments: {"keyInfo": state.keyInfos.value});
}));
@ -596,7 +625,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_password.png',
TranslationLoader.lanKeys!.password!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.passwordKeyListPage,
arguments: {"keyInfo": state.keyInfos.value});
}));
@ -606,7 +636,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_icCard.png',
TranslationLoader.lanKeys!.card!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
// logic.showToast("普通用户第一次需要在锁旁边操作哦。", something: () {
// logic.showEasyLoading();
// });
@ -621,7 +652,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_fingerprint.png',
TranslationLoader.lanKeys!.fingerprint!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.fingerprintListPage, arguments: {
"lockId": state.keyInfos.value.lockId,
});
@ -633,7 +665,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_remoteControl.png',
TranslationLoader.lanKeys!.remoteControl!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.remoteControlListPage);
}));
}
@ -644,7 +677,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
bottomItem(
'images/main/icon_face.png',
TranslationLoader.lanKeys!.humanFace!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.faceList, arguments: {
"lockId": state.keyInfos.value.lockId,
}); // Toast.show(msg: "功能暂未开放");
@ -658,7 +692,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
bottomItem(
'images/main/icon_catEyes.png',
TranslationLoader.lanKeys!.monitoring!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.realTimePicturePage, arguments: {
"lockName": state.keyInfos.value.lockName,
"isMonitoring": true
@ -672,7 +707,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
showWidgetArr.add(bottomItem(
'images/main/icon_main_authorizedAdmin.png',
TranslationLoader.lanKeys!.authorizedAdmin!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.authorizedAdminListPage,
arguments: {"keyInfo": state.keyInfos.value});
}));
@ -687,7 +723,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
bottomItem(
'images/main/icon_main_operatingRecord.png',
TranslationLoader.lanKeys!.operatingRecord!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
// Get.toNamed(Routers.lockOperatingRecordPage,
// arguments: {"keyInfo": state.keyInfos.value});
Get.toNamed(Routers.doorLockLogPage,
@ -697,7 +734,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
bottomItem(
'images/main/icon_lockDetail_videoLog.png',
TranslationLoader.lanKeys!.videoLog!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
//
Get.toNamed(Routers.videoLogPage);
}),
@ -705,11 +743,16 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
bottomItem(
'images/main/icon_lockDetail_messageReminding.png',
TranslationLoader.lanKeys!.messageReminding!.tr,
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.msgNotificationPage);
}),
//
bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
bottomItem(
'images/main/icon_main_set.png',
TranslationLoader.lanKeys!.set!.tr,
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
// logic.clickItemBtnAction(10);
Get.toNamed(Routers.lockSetPage, arguments: {
"lockId": state.keyInfos.value.lockId,
@ -722,13 +765,18 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
}
//
Widget bottomItem(String iconUrl, String name, bool openDoorBtnisUneable, bool bottomBtnisEable, Function() onClick) {
Widget bottomItem(String iconUrl, String name, bool openDoorBtnisUneable,
bool bottomBtnisEable, Function() onClick) {
var width = 42.w;
var height = 42.h;
return GestureDetector(
onTap:openDoorBtnisUneable ? (bottomBtnisEable ? onClick : () {
logic.showToast("请在锁旁边完成第一次开锁");
}) : null,
onTap: openDoorBtnisUneable
? (bottomBtnisEable
? onClick
: () {
logic.showToast("请在锁旁边完成第一次开锁");
})
: null,
child: Container(
// height: 300.h,
color: Colors.white,
@ -741,9 +789,11 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
child: Image.asset(iconUrl,
width: width,
height: height,
color: openDoorBtnisUneable ? (bottomBtnisEable
? AppColors.mainColor
: AppColors.lockDetailBottomBtnUneable) : AppColors.lockDetailBottomBtnUneable,
color: openDoorBtnisUneable
? (bottomBtnisEable
? AppColors.mainColor
: AppColors.lockDetailBottomBtnUneable)
: AppColors.lockDetailBottomBtnUneable,
fit: BoxFit.fitWidth),
),
SizedBox(height: 10.w),
@ -751,9 +801,11 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
child: Text(name,
style: TextStyle(
fontSize: 20.sp,
color:openDoorBtnisUneable ? (bottomBtnisEable
? AppColors.blackColor
: AppColors.lockDetailBottomBtnUneable) : AppColors.lockDetailBottomBtnUneable),
color: openDoorBtnisUneable
? (bottomBtnisEable
? AppColors.blackColor
: AppColors.lockDetailBottomBtnUneable)
: AppColors.lockDetailBottomBtnUneable),
textAlign: TextAlign.center))
],
)),
@ -762,7 +814,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
listeningAnimations() async {
await Future.delayed(Duration.zero, () {
state.animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this);
state.animationController = AnimationController(
duration: const Duration(seconds: 1), vsync: this);
state.animationController!.repeat();
//StatusListener
state.animationController!.addStatusListener((status) {
@ -994,5 +1047,4 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
// state.animationController!.stop();
// }
}
}

View File

@ -47,6 +47,8 @@ class LockDetailState {
final PageController pageController = PageController();
var currentPage = 0.obs;
late BuildContext widgetContext;
// LockDetailState() {
// Map map = Get.arguments;
// lockCount = map["lockCount"];

View File

@ -1,6 +1,5 @@
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@ -23,16 +22,34 @@ class MinePersonInfoPage extends StatefulWidget {
State<MinePersonInfoPage> createState() => _MinePersonInfoPageState();
}
class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
class _MinePersonInfoPageState extends State<MinePersonInfoPage>
with WidgetsBindingObserver {
final logic = Get.put(MinePersonInfoLogic());
final state = Get.find<MinePersonInfoLogic>().state;
@override
initState() {
super.initState();
WidgetsBinding.instance.addObserver(this); //
logic.getUserInfoRequest();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this); //
super.dispose();
}
//
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.resumed) {
//
checkCameraPermission();
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -177,48 +194,28 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
}
Future<void> requestCameraPermission() async {
//
PermissionStatus status = await Permission.camera.status;
var status = await Permission.camera.status;
if (status.isGranted) {
//
//
selectCamera();
} else {
//
//
status = await Permission.camera.request();
if (status.isGranted) {
//
selectCamera();
} else {
//
//
showPermissionDeniedDialog();
}
}
}
Future<void> requestPhotoPermission() async {
//
PermissionStatus status = await Permission.photos.status;
var status = await Permission.photos.status;
if (status.isGranted) {
//
//
selectImage();
} else {
//
//
status = await Permission.photos.request();
if (status.isGranted) {
//
selectImage();
} else {
//
//
showPermissionDeniedDialog();
}
}
@ -236,8 +233,8 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
TextButton(
child: const Text('去设置'),
onPressed: () {
openAppSettings(); //
Navigator.of(context).pop(); //
openAppSettings(); //
},
),
],
@ -300,6 +297,24 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
}
}
Future<void> checkCameraPermission() async {
var status = await Permission.camera.status;
if (status.isGranted) {
//
} else if (status.isPermanentlyDenied || status.isDenied) {
//
}
}
Future<void> checkPhotosPermission() async {
var status = await Permission.photos.status;
if (status.isGranted) {
//
} else if (status.isPermanentlyDenied || status.isDenied) {
//
}
}
// child: state.mineInfoData.value.headUrl != null
// ? CachedNetworkImage(
// imageUrl: Uri.encodeFull(