Daisy cd44d44fb8 1,电子钥匙发送短信、邮件通知API对接及逻辑处理
2,电子钥匙模块发送系统短信、系统邮件通知对接及自测完成
2024-06-12 13:53:59 +08:00

152 lines
5.5 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/SendEmailNotification_logic.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_entity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart';
import 'package:star_lock/tools/emailNotifyTypeSelectAlert.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/style/default_style.dart';
import 'package:star_lock/translations/trans_lib.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
class SendEmailNotificationPage extends StatefulWidget {
const SendEmailNotificationPage({Key? key}) : super(key: key);
@override
State<SendEmailNotificationPage> createState() =>
_SendEmailNotificationPageState();
}
class _SendEmailNotificationPageState extends State<SendEmailNotificationPage> {
final SendEmailNotificationLogic logic =
Get.put(SendEmailNotificationLogic());
final SendEmailNotificationState state =
Get.find<SendEmailNotificationLogic>().state;
@override
void initState() {
super.initState();
logic.getKeyNoticeTemplate();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: state.channelType.value == 1 ? '短信通知' : '邮件通知',
haveBack: true,
backgroundColor: AppColors.mainColor),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
rightTitle: state.getReceiver.value,
isHaveLine: true,
)),
Obx(() => CommonItem(
leftTitel: '类型',
rightTitle: state.getNotifyTypeText.value,
isHaveDirection: true,
action: () {
EmailNotifyTypeSelectAlert.showEmailNotifyTypeSelectAlert(
isEmail: state.channelType.value == 2,
onSelected: (int value) {
state.notifyTypeSelect.value = value;
});
},
)),
Container(height: 10.h),
Obx(() => CommonItem(
leftTitel: '模板',
rightTitle: state.currentNotifyItem.value.name ?? '',
isHaveDirection: true,
isHaveLine: true,
action: () {
openBottomItemSheet(context);
},
)),
Container(
height: 360.h,
color: Colors.white,
padding: EdgeInsets.only(
left: 20.w, right: 20.w, top: 20.h, bottom: 20.h),
child: TextField(
maxLines: 8,
maxLength: 1000,
textAlign: TextAlign.start,
controller: state.emailController,
style: TextStyle(
color: Colors.black,
fontSize: 22.sp,
),
decoration: InputDecoration(
border: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(20.h)),
///用来配置边框的样式
borderSide: const BorderSide(
///设置边框的颜色
color: Color(0xffB2B2B2),
///设置边框的粗细
width: 0.5,
),
),
///用来配置输入框获取焦点时的颜色
focusedBorder: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(20.h)),
///用来配置边框的样式
borderSide: const BorderSide(
///设置边框的颜色
color: Color(0xffB2B2B2),
///设置边框的粗细
width: 1,
),
),
),
),
),
Container(height: 40.h),
SubmitBtn(
btnName: '发送'.tr,
fontSize: 28.sp,
borderRadius: 20.w,
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () {
logic.keyNoticeSubmitRequest();
}),
],
),
),
);
}
// 底部选择pickerView
void openBottomItemSheet(BuildContext context) {
final List nameList = state.emailTemplateList
.map((EmailNotificationItem item) => item.name!)
.toList();
Pickers.showSinglePicker(context,
data: nameList,
pickerStyle: DefaultPickerStyle(), onConfirm: (p, int position) {
state.currentNotifyItem.value = state.emailTemplateList[position];
state.emailController.text = state.emailTemplateList[position].template!;
});
}
}