2023-07-21 19:31:01 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
2024-06-05 11:02:26 +08:00
|
|
|
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
2023-07-21 19:31:01 +08:00
|
|
|
|
import 'package:get/get.dart';
|
2024-06-04 18:09:38 +08:00
|
|
|
|
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_entity.dart';
|
2024-06-04 14:44:04 +08:00
|
|
|
|
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_entity.dart';
|
|
|
|
|
|
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_logic.dart';
|
|
|
|
|
|
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_state.dart';
|
2024-06-05 11:02:26 +08:00
|
|
|
|
import 'package:star_lock/tools/EasyRefreshTool.dart';
|
2024-06-04 14:44:04 +08:00
|
|
|
|
import 'package:star_lock/tools/noData.dart';
|
2024-06-05 11:02:26 +08:00
|
|
|
|
import 'package:star_lock/tools/showTipView.dart';
|
2023-07-21 19:31:01 +08:00
|
|
|
|
|
|
|
|
|
|
import '../../../../appRouters.dart';
|
|
|
|
|
|
import '../../../../app_settings/app_colors.dart';
|
|
|
|
|
|
import '../../../../tools/submitBtn.dart';
|
|
|
|
|
|
import '../../../../tools/titleAppBar.dart';
|
|
|
|
|
|
|
2024-06-04 14:44:04 +08:00
|
|
|
|
class CustomSMSTemplateListPage extends StatefulWidget {
|
|
|
|
|
|
const CustomSMSTemplateListPage({Key? key}) : super(key: key);
|
2023-07-21 19:31:01 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
2024-06-04 14:44:04 +08:00
|
|
|
|
State<CustomSMSTemplateListPage> createState() =>
|
|
|
|
|
|
_CustomSMSTemplateListPageState();
|
2023-07-21 19:31:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-04 14:44:04 +08:00
|
|
|
|
class _CustomSMSTemplateListPageState extends State<CustomSMSTemplateListPage> {
|
|
|
|
|
|
final CustomSMSTemplateListLogic logic =
|
|
|
|
|
|
Get.put(CustomSMSTemplateListLogic());
|
|
|
|
|
|
final CustomSMSTemplateListState state =
|
|
|
|
|
|
Get.find<CustomSMSTemplateListLogic>().state;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
super.initState();
|
2024-06-05 11:02:26 +08:00
|
|
|
|
logic.getSMSTemplateListRequest(isRefresh: true);
|
2024-06-13 18:07:00 +08:00
|
|
|
|
logic.getVipStatus();
|
2024-06-04 14:44:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-21 19:31:01 +08:00
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
2023-07-28 17:14:11 +08:00
|
|
|
|
appBar: TitleAppBar(
|
2024-07-09 16:04:56 +08:00
|
|
|
|
barTitle: state.channelType.value == 1 ? '自定义短信模版'.tr : '自定义邮件模版'.tr,
|
2023-07-28 17:14:11 +08:00
|
|
|
|
haveBack: true,
|
|
|
|
|
|
backgroundColor: AppColors.mainColor),
|
2024-06-05 11:02:26 +08:00
|
|
|
|
body: EasyRefreshTool(
|
|
|
|
|
|
onRefresh: () {
|
|
|
|
|
|
logic.getSMSTemplateListRequest(isRefresh: true);
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad: () {
|
|
|
|
|
|
logic.getSMSTemplateListRequest(isRefresh: false);
|
|
|
|
|
|
},
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Obx(() => Visibility(
|
|
|
|
|
|
child: _topTipWidget(),
|
|
|
|
|
|
visible: !state.isVip.value,
|
|
|
|
|
|
)),
|
|
|
|
|
|
Expanded(child: Obx(buildMainUI)),
|
|
|
|
|
|
SubmitBtn(
|
2024-08-02 13:52:37 +08:00
|
|
|
|
btnName: '新建模板'.tr,
|
2024-06-05 11:02:26 +08:00
|
|
|
|
borderRadius: 20.w,
|
|
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
|
|
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
|
|
|
|
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
|
|
|
|
|
onClick: () async {
|
2024-07-09 16:04:56 +08:00
|
|
|
|
final TemplateData templateData = TemplateData();
|
|
|
|
|
|
templateData.channelType = state.channelType.value;
|
2024-06-05 18:24:59 +08:00
|
|
|
|
templateData.isUpdate = false;
|
2024-07-09 16:04:56 +08:00
|
|
|
|
templateData.templateName =
|
2024-08-21 14:12:15 +08:00
|
|
|
|
templateData.templateType == 1 ? '电子钥匙'.tr : '密码'.tr;
|
2024-06-05 18:24:59 +08:00
|
|
|
|
final result = await Get.toNamed(Routers.newSMSTemplatePage,
|
2024-07-02 17:42:26 +08:00
|
|
|
|
arguments: {
|
|
|
|
|
|
'currentTemplate': templateData,
|
|
|
|
|
|
'isUpdate': false
|
2024-06-05 18:24:59 +08:00
|
|
|
|
});
|
2024-06-05 11:02:26 +08:00
|
|
|
|
if (result != null) {
|
|
|
|
|
|
logic.getSMSTemplateListRequest(isRefresh: true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 40.h,
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2023-07-21 19:31:01 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-28 17:14:11 +08:00
|
|
|
|
Widget _topTipWidget() {
|
2023-07-21 19:31:01 +08:00
|
|
|
|
return Container(
|
2023-07-28 17:14:11 +08:00
|
|
|
|
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 20.w),
|
|
|
|
|
|
padding:
|
|
|
|
|
|
EdgeInsets.only(top: 20.h, left: 20.w, right: 20.w, bottom: 20.h),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
|
|
|
|
|
child: Column(
|
2024-06-04 14:44:04 +08:00
|
|
|
|
children: <Widget>[
|
2023-07-28 17:14:11 +08:00
|
|
|
|
Text(
|
2024-08-02 13:52:37 +08:00
|
|
|
|
'你可以自己定义模版的内容,用于发送密码或电子钥匙信息给他人'.tr,
|
2023-07-28 17:14:11 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 22.sp,
|
|
|
|
|
|
color: AppColors.blackColor,
|
|
|
|
|
|
fontWeight: FontWeight.w600),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 15.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
|
top: 15.h, left: 15.w, right: 15.w, bottom: 15.h),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: const Color(0xFFFbF9EC),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(10.h)),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
2024-06-04 14:44:04 +08:00
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
SizedBox(
|
2023-07-28 17:14:11 +08:00
|
|
|
|
width: 1.sw - 15.w * 2 - 40.w * 2 - 140.w,
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2024-06-04 14:44:04 +08:00
|
|
|
|
children: <Widget>[
|
2023-07-28 17:14:11 +08:00
|
|
|
|
Text(
|
2024-08-01 18:54:32 +08:00
|
|
|
|
'${'当前状态'.tr}:${'试用中'.tr}',
|
2023-07-28 17:14:11 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 20.sp, fontWeight: FontWeight.w600),
|
|
|
|
|
|
),
|
2024-08-02 13:52:37 +08:00
|
|
|
|
Text('高级功能仅能用于你自己的锁'.tr,
|
2023-07-28 17:14:11 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 20.sp, fontWeight: FontWeight.w600))
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2023-07-21 19:31:01 +08:00
|
|
|
|
),
|
2023-07-28 17:14:11 +08:00
|
|
|
|
GestureDetector(
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.pushNamed(
|
|
|
|
|
|
context, Routers.valueAddedServicesHighFunctionPage);
|
|
|
|
|
|
},
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 100.w,
|
|
|
|
|
|
height: 50.h,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: const Color(0xFFCAB68D),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(35.h)),
|
|
|
|
|
|
child: Center(
|
|
|
|
|
|
child: Text(
|
2024-08-02 13:52:37 +08:00
|
|
|
|
'去开通'.tr,
|
2023-07-28 17:14:11 +08:00
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: Colors.white, fontSize: 20.sp)))),
|
2023-07-21 19:31:01 +08:00
|
|
|
|
),
|
2023-07-28 17:14:11 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
|
|
|
|
|
));
|
2023-07-21 19:31:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-04 14:44:04 +08:00
|
|
|
|
Widget buildMainUI() {
|
|
|
|
|
|
return state.smsTemplateList.isNotEmpty
|
2024-06-05 11:02:26 +08:00
|
|
|
|
? SlidableAutoCloseBehavior(
|
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
|
itemCount: state.smsTemplateList.length,
|
|
|
|
|
|
itemBuilder: (BuildContext c, int index) {
|
|
|
|
|
|
final CustomSMSTemplateItem itemData =
|
|
|
|
|
|
state.smsTemplateList[index];
|
|
|
|
|
|
return Slidable(
|
|
|
|
|
|
key: ValueKey(itemData.id),
|
|
|
|
|
|
endActionPane: ActionPane(
|
|
|
|
|
|
extentRatio: 0.2,
|
|
|
|
|
|
motion: const ScrollMotion(),
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
SlidableAction(
|
|
|
|
|
|
onPressed: (BuildContext context) {
|
|
|
|
|
|
ShowTipView()
|
|
|
|
|
|
.showIosTipWithContentDialog('是否删除?'.tr, () {
|
|
|
|
|
|
logic.deleteSMSTemplateRequest(
|
|
|
|
|
|
id: itemData.id ?? 0);
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
backgroundColor: Colors.red,
|
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
|
label: '删除'.tr,
|
|
|
|
|
|
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
child: _valueAddedServicesListSMSTemplateItem(itemData));
|
|
|
|
|
|
}),
|
|
|
|
|
|
)
|
2024-06-04 14:44:04 +08:00
|
|
|
|
: NoData();
|
2023-07-21 19:31:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-28 17:14:11 +08:00
|
|
|
|
Widget _valueAddedServicesListSMSTemplateItem(
|
2024-06-04 14:44:04 +08:00
|
|
|
|
CustomSMSTemplateItem itemData) {
|
2023-07-21 19:31:01 +08:00
|
|
|
|
return GestureDetector(
|
2024-06-04 18:09:38 +08:00
|
|
|
|
onTap: () async {
|
2024-07-09 16:04:56 +08:00
|
|
|
|
final TemplateData templateData = TemplateData();
|
2024-06-04 18:09:38 +08:00
|
|
|
|
templateData.name = itemData.name;
|
|
|
|
|
|
templateData.regards = itemData.regards;
|
|
|
|
|
|
templateData.tips = itemData.tips;
|
|
|
|
|
|
templateData.id = itemData.id;
|
|
|
|
|
|
templateData.template = itemData.template;
|
2024-07-09 16:04:56 +08:00
|
|
|
|
templateData.templateType = itemData.templateType;
|
2024-08-21 14:12:15 +08:00
|
|
|
|
templateData.templateName = templateData.templateName == 1 ? '电子钥匙'.tr : '密码'.tr;
|
2024-07-09 16:04:56 +08:00
|
|
|
|
templateData.channelType = itemData.channelType;
|
2024-06-05 18:24:59 +08:00
|
|
|
|
templateData.isUpdate = true;
|
2024-06-04 18:09:38 +08:00
|
|
|
|
final result = await Get.toNamed(Routers.newSMSTemplatePage,
|
2024-07-02 17:42:26 +08:00
|
|
|
|
arguments: {'currentTemplate': templateData, 'isUpdate': true});
|
2024-06-04 18:09:38 +08:00
|
|
|
|
if (result != null) {
|
2024-06-05 11:02:26 +08:00
|
|
|
|
logic.getSMSTemplateListRequest(isRefresh: true);
|
2024-06-04 18:09:38 +08:00
|
|
|
|
}
|
2024-06-04 14:44:04 +08:00
|
|
|
|
},
|
2023-07-21 19:31:01 +08:00
|
|
|
|
child: Container(
|
|
|
|
|
|
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
2023-07-28 17:14:11 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2023-07-21 19:31:01 +08:00
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(10.w),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2024-06-04 14:44:04 +08:00
|
|
|
|
children: <Widget>[
|
2023-07-21 19:31:01 +08:00
|
|
|
|
Padding(
|
2023-07-28 17:14:11 +08:00
|
|
|
|
padding: EdgeInsets.only(left: 30.h, top: 30.h, bottom: 20.h),
|
|
|
|
|
|
child: Text(
|
2024-06-04 14:44:04 +08:00
|
|
|
|
itemData.name ?? '',
|
2023-07-28 17:14:11 +08:00
|
|
|
|
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
|
|
|
|
|
),
|
2023-07-21 19:31:01 +08:00
|
|
|
|
),
|
|
|
|
|
|
Container(
|
2024-06-04 14:44:04 +08:00
|
|
|
|
width: 1.sw - 20.w * 2 - 30.w * 2,
|
2023-07-21 19:31:01 +08:00
|
|
|
|
margin: EdgeInsets.only(left: 25.w, right: 25.w, bottom: 25.h),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: const Color(0xFFF5F5F5),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(10.h),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Padding(
|
2024-06-04 14:44:04 +08:00
|
|
|
|
padding: EdgeInsets.only(left: 20.w, top: 20.h, bottom: 20.h),
|
|
|
|
|
|
child: RichText(
|
|
|
|
|
|
text: TextSpan(
|
2024-07-09 16:04:56 +08:00
|
|
|
|
children: itemData.templateType == 1
|
2024-06-04 14:44:04 +08:00
|
|
|
|
? logic.buildElectronicKeySpan(templateData: itemData)
|
|
|
|
|
|
: logic.buildPasswordSpan(templateData: itemData),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2023-07-21 19:31:01 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|