“DaisyWu” 7f1642b09f 1,修复星锁点分享界面少了发送密码到、分享
2,修复星锁类型选择的文字,少了句号。系统短信多了那字,是软件里。
3,修复接收者少了通讯录的头像。及选择通讯录相关逻辑操作
4,修复建议限制50位。接收者如是汉字或位数不够,英文弹框,通通锁提示操作失败。
5,星星锁电子钥匙、密码模块发送成功后,发送短信、邮箱接入最新API,解决发送不成功问题
2024-07-08 18:18:20 +08:00

121 lines
4.3 KiB
Dart
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 'dart:async';
import 'package:flutter/material.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_entity.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_state.dart';
import 'package:star_lock/tools/regularExpression.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
class CustomSMSTemplateListLogic extends BaseGetXController {
CustomSMSTemplateListState state = CustomSMSTemplateListState();
// 获取短信模板列表
Future<void> getSMSTemplateListRequest({required bool isRefresh}) async {
if (isRefresh) {
state.smsTemplateList.clear();
pageNo = 1;
}
final CustomSMSTemplateListEntity entity = await ApiRepository.to
.getSMSTemplateList(
channelType: state.type.value,
pageNo: pageNo,
pageSize: int.parse(pageSize));
if (entity.errorCode!.codeIsSuccessful) {
state.smsTemplateList.value =
entity.data?.list ?? <CustomSMSTemplateItem>[];
state.smsTemplateList.refresh();
}
}
// 删除短信模板
Future<void> deleteSMSTemplateRequest({required int id}) async {
final LoginEntity entity =
await ApiRepository.to.deleteTemplateInfo(id: id);
if (entity.errorCode!.codeIsSuccessful) {
getSMSTemplateListRequest(isRefresh: true);
}
}
List<TextSpan> buildElectronicKeySpan(
{required CustomSMSTemplateItem templateData}) {
final List<TextSpan> textSpans = [];
_addTextSpan(textSpans, '${templateData.regards}\n', state.defaultStyle);
_buildTextSpansFromTemplate(
textSpans, templateData.template, state.defaultStyle, state.highStyle);
_addTextSpan(textSpans, '\n${templateData.tips}', state.defaultStyle);
return textSpans;
}
List<TextSpan> buildPasswordSpan(
{required CustomSMSTemplateItem templateData}) {
final List<TextSpan> textSpans = [];
_addTextSpan(textSpans, '${templateData.regards}\n', state.defaultStyle);
_buildPasswordTextSpans(
textSpans, templateData.template, state.defaultStyle, state.highStyle);
_addTextSpan(textSpans, '\n${templateData.tips}', state.defaultStyle);
return textSpans;
}
void _buildTextSpansFromTemplate(List<TextSpan> textSpans, String? template,
TextStyle defaultStyle, TextStyle highStyle) {
final List<String> textFragments =
template?.split(RegularExpression.urlRegExp) ?? [];
for (int i = 0; i < textFragments.length; i++) {
_addTextSpan(textSpans, textFragments[i], defaultStyle);
if (i < textFragments.length - 1) {
_addTextSpan(textSpans, '\n', defaultStyle);
_addTextSpan(
textSpans,
RegularExpression.urlRegExp.stringMatch(template!) ?? '',
highStyle);
}
}
}
void _buildPasswordTextSpans(List<TextSpan> textSpans, String? template,
TextStyle defaultStyle, TextStyle highStyle) {
final RegExp variableRegExp = RegExp(r'\$\{([^}]+)\}');
final String text = template ?? '';
int startIndex = 0;
for (final Match match in variableRegExp.allMatches(text)) {
_addTextSpan(
textSpans,
text
.substring(startIndex, match.start)
.replaceAllMapped(RegExp(r'|。'), (Match match) {
return '${match.group(0)}\n';
}),
defaultStyle);
_addTextSpan(textSpans, match.group(0) ?? '', highStyle);
startIndex = match.end;
}
_addTextSpan(
textSpans,
text.substring(startIndex).replaceAllMapped(RegExp(r'|。'),
(Match match) {
return '${match.group(0)}\n';
}),
defaultStyle);
}
void _addTextSpan(List<TextSpan> textSpans, String text, TextStyle style) {
textSpans.add(TextSpan(text: text, style: style));
}
Future<void> getVipStatus() async {
final bool? isVip = await Storage.getBool(saveIsVip);
state.isVip.value = isVip ?? false;
state.isVip.refresh();
}
@override
Future<void> onReady() async {
super.onReady();
}
}