2024-08-21 18:31:19 +08:00
|
|
|
|
|
2023-11-13 09:47:19 +08:00
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
import 'package:star_lock/appRouters.dart';
|
2024-08-21 18:31:19 +08:00
|
|
|
|
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_state.dart';
|
|
|
|
|
|
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart';
|
2023-11-13 09:47:19 +08:00
|
|
|
|
import 'package:star_lock/tools/commonItem.dart';
|
2024-08-21 18:31:19 +08:00
|
|
|
|
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
2024-04-30 15:33:38 +08:00
|
|
|
|
import 'package:star_lock/tools/storage.dart';
|
2023-11-13 09:47:19 +08:00
|
|
|
|
import 'package:star_lock/tools/submitBtn.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
|
|
|
|
import '../../../../../tools/titleAppBar.dart';
|
2023-11-24 14:23:36 +08:00
|
|
|
|
import 'lowBatteryReminder_logic.dart';
|
2023-11-13 09:47:19 +08:00
|
|
|
|
|
|
|
|
|
|
class LowBatteryReminderPage extends StatefulWidget {
|
|
|
|
|
|
const LowBatteryReminderPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<LowBatteryReminderPage> createState() => _LowBatteryReminderPageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _LowBatteryReminderPageState extends State<LowBatteryReminderPage> {
|
2024-08-21 18:31:19 +08:00
|
|
|
|
final LowBatteryReminderLogic logic = Get.put(LowBatteryReminderLogic());
|
|
|
|
|
|
final LowBatteryReminderState state = Get.find<LowBatteryReminderLogic>().state;
|
2023-11-13 09:47:19 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
|
|
|
|
appBar: TitleAppBar(
|
2024-04-20 16:58:31 +08:00
|
|
|
|
barTitle: '低电量提醒'.tr,
|
2023-11-13 09:47:19 +08:00
|
|
|
|
haveBack: true,
|
|
|
|
|
|
backgroundColor: AppColors.mainColor),
|
2024-04-24 17:11:42 +08:00
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: EdgeInsets.all(30.w),
|
|
|
|
|
|
child: Column(
|
2024-08-21 18:31:19 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-24 17:11:42 +08:00
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
2024-08-21 18:31:19 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-24 17:11:42 +08:00
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text(
|
2024-08-21 18:31:19 +08:00
|
|
|
|
'打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。'.tr,
|
2024-04-24 17:11:42 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 20.sp,
|
|
|
|
|
|
color: AppColors.darkGrayTextColor,
|
|
|
|
|
|
),
|
|
|
|
|
|
softWrap: true,
|
|
|
|
|
|
))
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 20.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
CommonItem(
|
2024-04-20 16:58:31 +08:00
|
|
|
|
leftTitel: '低电量提醒'.tr,
|
2023-11-13 09:47:19 +08:00
|
|
|
|
rightTitle: '',
|
|
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isHaveDirection: false,
|
|
|
|
|
|
isHaveRightWidget: true,
|
2024-04-24 17:11:42 +08:00
|
|
|
|
rightWidget: _lowBatterySwitch(),
|
|
|
|
|
|
),
|
|
|
|
|
|
Visibility(
|
2023-11-13 09:47:19 +08:00
|
|
|
|
visible: state.isLowBatteryNotify.value,
|
|
|
|
|
|
child: Column(
|
2024-08-21 18:31:19 +08:00
|
|
|
|
children: <Widget>[
|
2023-11-13 09:47:19 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 20.h,
|
|
|
|
|
|
),
|
2024-04-24 17:11:42 +08:00
|
|
|
|
GestureDetector(
|
|
|
|
|
|
onTap: () {
|
2024-08-21 18:31:19 +08:00
|
|
|
|
Get.toNamed(Routers.notificationModePage, arguments: <String, MsgNoticeData>{
|
2024-04-24 17:11:42 +08:00
|
|
|
|
'msgNoticeInfo': state.msgNoticeInfo.value,
|
|
|
|
|
|
})?.then((val) {
|
|
|
|
|
|
if (val != null) {
|
|
|
|
|
|
state.emailListStr.value =
|
|
|
|
|
|
logic.getEmailListStr(val);
|
|
|
|
|
|
state.phontListStr.value =
|
|
|
|
|
|
logic.getPhoneListStr(val);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
margin: EdgeInsets.only(bottom: 10.h),
|
|
|
|
|
|
child: Column(
|
2024-08-21 18:31:19 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-24 17:11:42 +08:00
|
|
|
|
CommonItem(
|
|
|
|
|
|
leftTitel: '提醒方式'.tr,
|
2024-08-21 18:31:19 +08:00
|
|
|
|
rightTitle: '',
|
2024-04-24 17:11:42 +08:00
|
|
|
|
isHaveLine: false,
|
|
|
|
|
|
isHaveRightWidget: false,
|
|
|
|
|
|
isHaveDirection: true,
|
2023-11-13 09:47:19 +08:00
|
|
|
|
),
|
2024-04-24 17:11:42 +08:00
|
|
|
|
_buildNotifyContain('APP推送'.tr, '管理员'.tr),
|
|
|
|
|
|
Obx(() => state.emailListStr.value.isNotEmpty
|
|
|
|
|
|
? _buildNotifyContain(
|
|
|
|
|
|
'邮件提醒'.tr, state.emailListStr.value)
|
|
|
|
|
|
: Container()),
|
|
|
|
|
|
Obx(() => state.phontListStr.value.isNotEmpty
|
|
|
|
|
|
? _buildNotifyContain(
|
|
|
|
|
|
'短信提醒'.tr, state.phontListStr.value)
|
|
|
|
|
|
: Container()),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2023-11-13 09:47:19 +08:00
|
|
|
|
),
|
2024-04-24 17:11:42 +08:00
|
|
|
|
),
|
2023-11-13 09:47:19 +08:00
|
|
|
|
],
|
2024-04-24 17:11:42 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 20.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
SubmitBtn(
|
|
|
|
|
|
btnName: '保存'.tr,
|
2024-04-30 15:33:38 +08:00
|
|
|
|
onClick: () async {
|
2024-08-21 18:31:19 +08:00
|
|
|
|
bool? isVip = await Storage.getBool(saveIsVip);
|
2024-04-30 15:33:38 +08:00
|
|
|
|
if (isVip == false) {
|
2024-05-09 11:01:38 +08:00
|
|
|
|
ShowCupertinoAlertView().advancedFeatureAlert();
|
2024-04-30 15:33:38 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
logic.lockNoticeSettingAccountList();
|
|
|
|
|
|
}
|
2024-04-24 17:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 60.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2023-11-13 09:47:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-24 17:11:42 +08:00
|
|
|
|
Widget _buildNotifyContain(String notifyTitle, String notifyContent) {
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
padding:
|
|
|
|
|
|
EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h),
|
|
|
|
|
|
margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: AppColors.mainBackgroundColor,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(6.0.w),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
2024-08-21 18:31:19 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-24 17:11:42 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
notifyTitle,
|
|
|
|
|
|
style: TextStyle(color: Colors.black, fontSize: 20.sp),
|
|
|
|
|
|
),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
|
width: 20.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
notifyContent,
|
|
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.placeholderTextColor,
|
|
|
|
|
|
fontSize: 20.sp,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CupertinoSwitch _lowBatterySwitch() {
|
2023-11-13 09:47:19 +08:00
|
|
|
|
return CupertinoSwitch(
|
|
|
|
|
|
activeColor: CupertinoColors.activeBlue,
|
|
|
|
|
|
trackColor: CupertinoColors.systemGrey5,
|
|
|
|
|
|
thumbColor: CupertinoColors.white,
|
|
|
|
|
|
value: state.isLowBatteryNotify.value,
|
2024-08-21 18:31:19 +08:00
|
|
|
|
onChanged: (bool value) {
|
2023-11-13 09:47:19 +08:00
|
|
|
|
setState(() {
|
|
|
|
|
|
state.isLowBatteryNotify.value = value;
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|