Merge branch 'master_sky' into 'develop_sky'
# Conflicts: # lib/blue/blue_manage.dart
This commit is contained in:
commit
4c9422bc5b
@ -29,6 +29,8 @@
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<!--允许读设备日志,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
<!--联系人-->
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
||||
<!--相机-->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
@ -124,14 +124,18 @@ class BlueManage {
|
||||
.eventBus!
|
||||
.on<EventSendModel>()
|
||||
.listen((EventSendModel model) {
|
||||
AppLog.log('eventBus接收发送数据:${model}');
|
||||
if (model.sendChannel == DataChannel.ble) {
|
||||
FlutterBluePlus.isSupported.then((bool isAvailable) async {
|
||||
if (isAvailable) {
|
||||
if (_adapterState == BluetoothAdapterState.on) {
|
||||
// 蓝牙已开启,可以进行蓝牙操作
|
||||
AppLog.log('蓝牙已开启,开始收发送数据:${model.data}');
|
||||
writeCharacteristicWithResponse(model.data);
|
||||
} else {
|
||||
try {} catch (e) {
|
||||
try {
|
||||
AppLog.log('蓝牙已关闭,停止发送数据:${model.data}');
|
||||
} catch (e) {
|
||||
AppLog.log('蓝牙打开失败');
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,15 +257,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await logic.state.contactPicker.selectContact();
|
||||
logic.state.contact = currentContact!;
|
||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
||||
logic.state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
if (currentContact != null) {
|
||||
setState(() {
|
||||
logic.state.contact = currentContact;
|
||||
|
||||
// 处理手机号
|
||||
if (currentContact.phoneNumbers != null &&
|
||||
currentContact.phoneNumbers!.isNotEmpty) {
|
||||
// 获取第一个手机号并清理格式
|
||||
String phoneNumber = currentContact.phoneNumbers![0];
|
||||
// 移除所有空格、括号、连字符等特殊字符
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
|
||||
// 如果号码以+开头,保留+号
|
||||
if (phoneNumber.startsWith('+')) {
|
||||
phoneNumber = '+' +
|
||||
phoneNumber
|
||||
.substring(1)
|
||||
.replaceAll(RegExp(r'[^\d]'), '');
|
||||
} else {
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
|
||||
}
|
||||
logic.state.emailOrPhoneController.text = phoneNumber;
|
||||
} else {
|
||||
logic.state.emailOrPhoneController.text = '';
|
||||
}
|
||||
|
||||
// 处理姓名
|
||||
if (currentContact.fullName != null &&
|
||||
currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
} else {
|
||||
logic.state.keyNameController.text = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -602,17 +629,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await state.contactPicker.selectContact();
|
||||
setState(() {
|
||||
state.contact = currentContact!;
|
||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
||||
state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
state.keyNameController.text = currentContact.fullName!;
|
||||
}
|
||||
});
|
||||
if (currentContact != null) {
|
||||
setState(() {
|
||||
state.contact = currentContact;
|
||||
|
||||
// 处理手机号
|
||||
if (currentContact.phoneNumbers != null &&
|
||||
currentContact.phoneNumbers!.isNotEmpty) {
|
||||
// 获取第一个手机号并清理格式
|
||||
String phoneNumber = currentContact.phoneNumbers![0];
|
||||
// 移除所有空格、括号、连字符等特殊字符
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
|
||||
// 如果号码以+开头,保留+号
|
||||
if (phoneNumber.startsWith('+')) {
|
||||
phoneNumber = '+' +
|
||||
phoneNumber
|
||||
.substring(1)
|
||||
.replaceAll(RegExp(r'[^\d]'), '');
|
||||
} else {
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
|
||||
}
|
||||
state.emailOrPhoneController.text = phoneNumber;
|
||||
} else {
|
||||
state.emailOrPhoneController.text = '';
|
||||
}
|
||||
|
||||
// 处理姓名
|
||||
if (currentContact.fullName != null &&
|
||||
currentContact.fullName!.isNotEmpty) {
|
||||
state.keyNameController.text = currentContact.fullName!;
|
||||
} else {
|
||||
state.keyNameController.text = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
@ -286,20 +286,47 @@ class _VolumeAuthorizationLockPageState
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await state.contactPicker.selectContact();
|
||||
// setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
state.keyNameController.text = currentContact.fullName!;
|
||||
}
|
||||
// });
|
||||
},
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await logic.state.contactPicker.selectContact();
|
||||
if (currentContact != null) {
|
||||
setState(() {
|
||||
logic.state.contact = currentContact;
|
||||
|
||||
// 处理手机号
|
||||
if (currentContact.phoneNumbers != null &&
|
||||
currentContact.phoneNumbers!.isNotEmpty) {
|
||||
// 获取第一个手机号并清理格式
|
||||
String phoneNumber = currentContact.phoneNumbers![0];
|
||||
// 移除所有空格、括号、连字符等特殊字符
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
|
||||
// 如果号码以+开头,保留+号
|
||||
if (phoneNumber.startsWith('+')) {
|
||||
phoneNumber = '+' +
|
||||
phoneNumber
|
||||
.substring(1)
|
||||
.replaceAll(RegExp(r'[^\d]'), '');
|
||||
} else {
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
|
||||
}
|
||||
logic.state.emailOrPhoneController.text = phoneNumber;
|
||||
} else {
|
||||
logic.state.emailOrPhoneController.text = '';
|
||||
}
|
||||
|
||||
// 处理姓名
|
||||
if (currentContact.fullName != null &&
|
||||
currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
} else {
|
||||
logic.state.keyNameController.text = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
else
|
||||
|
||||
@ -20,6 +20,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
||||
import 'package:star_lock/tools/regularExpression.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class SendElectronicKeyView extends StatefulWidget {
|
||||
SendElectronicKeyView({required this.type, Key? key}) : super(key: key);
|
||||
@ -31,6 +32,8 @@ class SendElectronicKeyView extends StatefulWidget {
|
||||
|
||||
class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
@ -163,8 +166,8 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: AppColors.greyLineColor, // 设置边框颜色
|
||||
width: 2.0.h, // 设置边框宽度
|
||||
color: AppColors.greyLineColor,
|
||||
width: 2.0.h,
|
||||
),
|
||||
)),
|
||||
child: Row(
|
||||
@ -174,17 +177,14 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: logic.getCurrentController(1),
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.deny('\n'),
|
||||
LengthLimitingTextInputFormatter(30),
|
||||
],
|
||||
// controller: _controller,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
hintText: rightTitle,
|
||||
hintStyle: TextStyle(fontSize: 22.sp),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
@ -205,9 +205,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
SizedBox(width: 10.w),
|
||||
Container(
|
||||
width: 32.w,
|
||||
height: 32.w,
|
||||
@ -222,22 +220,49 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await logic.state.contactPicker.selectContact();
|
||||
logic.state.contact = currentContact!;
|
||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
||||
logic.state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
if (currentContact != null) {
|
||||
setState(() {
|
||||
logic.state.contact = currentContact;
|
||||
|
||||
// 处理手机号
|
||||
if (currentContact.phoneNumbers != null &&
|
||||
currentContact.phoneNumbers!.isNotEmpty) {
|
||||
// 获取第一个手机号并清理格式
|
||||
String phoneNumber = currentContact.phoneNumbers![0];
|
||||
// 移除所有空格、括号、连字符等特殊字符
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
|
||||
// 如果号码以+开头,保留+号
|
||||
if (phoneNumber.startsWith('+')) {
|
||||
phoneNumber = '+' +
|
||||
phoneNumber
|
||||
.substring(1)
|
||||
.replaceAll(RegExp(r'[^\d]'), '');
|
||||
} else {
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
|
||||
}
|
||||
logic.state.emailOrPhoneController.text = phoneNumber;
|
||||
} else {
|
||||
logic.state.emailOrPhoneController.text = '';
|
||||
}
|
||||
|
||||
// 处理姓名
|
||||
if (currentContact.fullName != null &&
|
||||
currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
} else {
|
||||
logic.state.keyNameController.text = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: AppColors.greyLineColor, // 设置边框颜色
|
||||
height: 2.0.h, //
|
||||
color: AppColors.greyLineColor,
|
||||
height: 2.0.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -616,19 +641,46 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await logic.state.contactPicker.selectContact();
|
||||
logic.state.contact = currentContact!;
|
||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
||||
logic.state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
}
|
||||
},
|
||||
final Contact? currentContact =
|
||||
await logic.state.contactPicker.selectContact();
|
||||
if (currentContact != null) {
|
||||
setState(() {
|
||||
logic.state.contact = currentContact;
|
||||
|
||||
// 处理手机号
|
||||
if (currentContact.phoneNumbers != null &&
|
||||
currentContact.phoneNumbers!.isNotEmpty) {
|
||||
// 获取第一个手机号并清理格式
|
||||
String phoneNumber = currentContact.phoneNumbers![0];
|
||||
// 移除所有空格、括号、连字符等特殊字符
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
|
||||
// 如果号码以+开头,保留+号
|
||||
if (phoneNumber.startsWith('+')) {
|
||||
phoneNumber = '+' +
|
||||
phoneNumber
|
||||
.substring(1)
|
||||
.replaceAll(RegExp(r'[^\d]'), '');
|
||||
} else {
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
|
||||
}
|
||||
logic.state.emailOrPhoneController.text = phoneNumber;
|
||||
} else {
|
||||
logic.state.emailOrPhoneController.text = '';
|
||||
}
|
||||
|
||||
// 处理姓名
|
||||
if (currentContact.fullName != null &&
|
||||
currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
} else {
|
||||
logic.state.keyNameController.text = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
else
|
||||
@ -736,7 +788,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
child: Text(
|
||||
'取消'.tr,
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
|
||||
color: Colors.black, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
@ -779,7 +831,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||
Text(
|
||||
titleStr,
|
||||
style: TextStyle(
|
||||
fontSize: ScreenUtil().setSp(20), color: Colors.black),
|
||||
fontSize: 20.sp, color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -61,7 +61,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 开完锁之后上传记录
|
||||
if (reply is SenderReferEventRecordTimeReply &&
|
||||
state.ifCurrentScreen.value == true) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
await _replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -118,7 +118,9 @@ class LockDetailLogic extends BaseGetXController {
|
||||
state.animationController!.stop();
|
||||
|
||||
//锁数据更新
|
||||
AppLog.log('开锁成功,开始同步所记录:getLockRecordLastUploadDataTime');
|
||||
getLockRecordLastUploadDataTime();
|
||||
AppLog.log('开锁成功,结束同步所记录:getLockRecordLastUploadDataTime');
|
||||
// 只有接听状态时才可以重发开门指令
|
||||
if (StartChartManage().talkStatus.status ==
|
||||
TalkStatus.answeredSuccessfully) {
|
||||
@ -340,6 +342,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
reply.data.removeRange(0, 7);
|
||||
// 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面
|
||||
if (reply.data.length < 17) {
|
||||
AppLog.log('数据长度不够17:${reply.data}');
|
||||
return;
|
||||
}
|
||||
final List<List<int>> getList = splitList(reply.data, 17);
|
||||
@ -380,12 +383,13 @@ class LockDetailLogic extends BaseGetXController {
|
||||
if (i == getList.length - 1) {
|
||||
//设置最后的时间戳
|
||||
|
||||
state.operateDate = operateDate;
|
||||
state.operateDate = time;
|
||||
}
|
||||
} catch (e) {
|
||||
AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。');
|
||||
}
|
||||
}
|
||||
AppLog.log('上传数据长度:${uploadList.length}');
|
||||
lockRecordUploadData(uploadList);
|
||||
|
||||
if (dataLength == state.logCountPage) {
|
||||
@ -512,6 +516,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
});
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
AppLog.log(
|
||||
'开始发送同步锁记录命令,蓝牙状态是否链接:${connectionState == BluetoothConnectionState.connected}');
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -526,6 +532,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
final List<int> getPublicKeyList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
AppLog.log(
|
||||
'发送同步锁记录命令:${BlueManage().connectDeviceName}');
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
@ -604,11 +612,14 @@ class LockDetailLogic extends BaseGetXController {
|
||||
final LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
AppLog.log('开始获取服务端所记录更新时间:${entity}');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
state.currentDate = entity.data!.currentDate! ~/ 1000;
|
||||
AppLog.log('发送同步所记录命令:---');
|
||||
senderReferEventRecordTime();
|
||||
}
|
||||
AppLog.log('结束获取服务端所记录更新时间:${entity}');
|
||||
}
|
||||
|
||||
// 操作记录上传
|
||||
|
||||
@ -4,7 +4,7 @@ import 'flavors.dart';
|
||||
import 'main.dart' as runner;
|
||||
|
||||
Future<void> main() async {
|
||||
F.appFlavor = Flavor.xhj;
|
||||
F.appFlavor = Flavor.xhj_pre;
|
||||
// AppLog.log('local调用了main函数');
|
||||
await runner.main();
|
||||
}
|
||||
|
||||
@ -270,16 +270,46 @@ class _AddAuthorizedAdministratorPageState
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await state.contactPicker.selectContact();
|
||||
setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
final Contact? currentContact =
|
||||
await logic.state.contactPicker.selectContact();
|
||||
if (currentContact != null) {
|
||||
setState(() {
|
||||
logic.state.contact = currentContact;
|
||||
|
||||
// 处理手机号
|
||||
if (currentContact.phoneNumbers != null &&
|
||||
currentContact.phoneNumbers!.isNotEmpty) {
|
||||
// 获取第一个手机号并清理格式
|
||||
String phoneNumber = currentContact.phoneNumbers![0];
|
||||
// 移除所有空格、括号、连字符等特殊字符
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
|
||||
// 如果号码以+开头,保留+号
|
||||
if (phoneNumber.startsWith('+')) {
|
||||
phoneNumber = '+' +
|
||||
phoneNumber
|
||||
.substring(1)
|
||||
.replaceAll(RegExp(r'[^\d]'), '');
|
||||
} else {
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
|
||||
}
|
||||
logic.state.emailOrPhoneController.text = phoneNumber;
|
||||
} else {
|
||||
logic.state.emailOrPhoneController.text = '';
|
||||
}
|
||||
|
||||
// 处理姓名
|
||||
if (currentContact.fullName != null &&
|
||||
currentContact.fullName!.isNotEmpty) {
|
||||
logic.state.keyNameController.text =
|
||||
currentContact.fullName!;
|
||||
} else {
|
||||
logic.state.keyNameController.text = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
),
|
||||
)
|
||||
else
|
||||
|
||||
@ -146,14 +146,37 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
Contact? currentContact = await state.contactPicker.selectContact();
|
||||
state.contact = currentContact!;
|
||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
||||
state.numberController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
},
|
||||
final Contact? currentContact =
|
||||
await logic.state.contactPicker.selectContact();
|
||||
if (currentContact != null) {
|
||||
setState(() {
|
||||
logic.state.contact = currentContact;
|
||||
|
||||
// 处理手机号
|
||||
if (currentContact.phoneNumbers != null &&
|
||||
currentContact.phoneNumbers!.isNotEmpty) {
|
||||
// 获取第一个手机号并清理格式
|
||||
String phoneNumber = currentContact.phoneNumbers![0];
|
||||
// 移除所有空格、括号、连字符等特殊字符
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
|
||||
// 如果号码以+开头,保留+号
|
||||
if (phoneNumber.startsWith('+')) {
|
||||
phoneNumber = '+' +
|
||||
phoneNumber
|
||||
.substring(1)
|
||||
.replaceAll(RegExp(r'[^\d]'), '');
|
||||
} else {
|
||||
phoneNumber =
|
||||
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
|
||||
}
|
||||
logic.state.numberController.text = phoneNumber;
|
||||
} else {
|
||||
logic.state.numberController.text = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Image.asset(
|
||||
'images/icon_addressBook.png',
|
||||
width: 28.w,
|
||||
|
||||
@ -4,7 +4,7 @@ import 'package:star_lock/talk/starChart/constant/talk_status.dart';
|
||||
|
||||
class StartChartTalkStatus {
|
||||
// 私有字段,用于存储当前状态
|
||||
TalkStatus _status = TalkStatus.uninitialized;
|
||||
TalkStatus _status = TalkStatus.none;
|
||||
|
||||
// 私有化默认构造函数,防止外部创建实例
|
||||
StartChartTalkStatus._();
|
||||
|
||||
@ -158,7 +158,7 @@ dependencies:
|
||||
# 选择日期时间
|
||||
flutter_cupertino_datetime_picker: ^3.0.0
|
||||
# 选择原生通讯录
|
||||
flutter_native_contact_picker: ^0.0.4
|
||||
flutter_native_contact_picker: 0.0.7
|
||||
#底部弹出选择器
|
||||
flutter_picker: ^2.1.0
|
||||
#生成二维码
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user