117 lines
3.7 KiB
Dart
Executable File
117 lines
3.7 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
|
|
import 'package:star_lock/network/api_repository.dart';
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
|
|
import '../../../app_settings/app_colors.dart';
|
|
import '../../../tools/submitBtn.dart';
|
|
import '../../../tools/titleAppBar.dart';
|
|
|
|
class LockScreenPage extends StatefulWidget {
|
|
const LockScreenPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<LockScreenPage> createState() => _LockScreenPageState();
|
|
}
|
|
|
|
class _LockScreenPageState extends State<LockScreenPage> {
|
|
bool _isOn = true;
|
|
bool _isFirst = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_isFirst = true;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_isFirst) {
|
|
final dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
|
if (obj != null && (obj['isOn'] != null)) {
|
|
final int getValue = obj['isOn'];
|
|
if (getValue == 1) {
|
|
_isOn = true;
|
|
} else {
|
|
_isOn = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '锁屏'.tr,
|
|
// backAction: () {
|
|
// Navigator.pop(context, true);
|
|
// },
|
|
// haveOtherLeftWidget: true,
|
|
// leftWidget: IconButton(
|
|
// icon: const Icon(Icons.arrow_back_ios, color: Colors.white),
|
|
// onPressed: () => Navigator.of(context).pop(true),
|
|
// ),
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Container(
|
|
padding: EdgeInsets.all(30.w),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
'功能开启后,你将可以听到智能锁的提示音。包括电量过低,密码错误等提示。'.tr,
|
|
style: TextStyle(
|
|
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
|
)),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
'${"当前模式".tr} : ${_isOn == true ? '已开启'.tr : '已关闭'.tr}',
|
|
style:
|
|
TextStyle(fontWeight: FontWeight.w600, fontSize: 22.sp),
|
|
)),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 40.h,
|
|
),
|
|
SubmitBtn(
|
|
btnName: _isOn == true
|
|
? '关闭'.tr
|
|
: '开启'.tr,
|
|
onClick: () {
|
|
_isFirst = false;
|
|
setState(() {
|
|
_isOn = !_isOn;
|
|
});
|
|
changeSettingsRequest();
|
|
}),
|
|
],
|
|
),
|
|
));
|
|
}
|
|
|
|
//锁屏/隐藏无效开锁权限 1:锁屏 2:隐藏无效开锁权限
|
|
Future<void> changeSettingsRequest() async {
|
|
final ExpireLockListEntity entity =
|
|
await ApiRepository.to.changeSettings(_isOn == true ? '1' : '2', '1');
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
EasyLoading.showToast('操作成功'.tr, duration: 2000.milliseconds);
|
|
}
|
|
}
|
|
}
|