186 lines
6.6 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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';
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_state.dart';
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart';
import 'package:star_lock/tools/commonItem.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/submitBtn.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
import 'lowBatteryReminder_logic.dart';
class LowBatteryReminderPage extends StatefulWidget {
const LowBatteryReminderPage({Key? key}) : super(key: key);
@override
State<LowBatteryReminderPage> createState() => _LowBatteryReminderPageState();
}
class _LowBatteryReminderPageState extends State<LowBatteryReminderPage> {
final LowBatteryReminderLogic logic = Get.put(LowBatteryReminderLogic());
final LowBatteryReminderState state = Get.find<LowBatteryReminderLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: '低电量提醒'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(30.w),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
'打开提醒后当锁电量低于20%、10%和5%系统会给指定对象发送提醒消息。电量读取方式网关读取或APP读取。'.tr,
style: TextStyle(
fontSize: 20.sp,
color: AppColors.darkGrayTextColor,
),
softWrap: true,
))
],
),
SizedBox(
height: 20.h,
),
CommonItem(
leftTitel: '低电量提醒'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: false,
isHaveRightWidget: true,
rightWidget: _lowBatterySwitch(),
),
Visibility(
visible: state.isLowBatteryNotify.value,
child: Column(
children: <Widget>[
SizedBox(
height: 20.h,
),
GestureDetector(
onTap: () {
Get.toNamed(Routers.notificationModePage, arguments: <String, MsgNoticeData>{
'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(
children: <Widget>[
CommonItem(
leftTitel: '提醒方式'.tr,
rightTitle: '',
isHaveLine: false,
isHaveRightWidget: false,
isHaveDirection: true,
),
_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()),
],
),
),
),
],
),
),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '保存'.tr,
onClick: () async {
bool? isVip = await Storage.getBool(saveIsVip);
if (isVip == false) {
ShowCupertinoAlertView().advancedFeatureAlert();
} else {
logic.lockNoticeSettingAccountList();
}
},
),
SizedBox(
height: 60.h,
),
],
),
),
),
);
}
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(
children: <Widget>[
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() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isLowBatteryNotify.value,
onChanged: (bool value) {
setState(() {
state.isLowBatteryNotify.value = value;
});
},
);
}
}