fix: 修复测试部门问题-发送钥匙各个类型下点击通讯录无法直接获取通讯录联系人手机号及姓名

This commit is contained in:
DaisyWu 2025-05-26 15:58:52 +08:00
parent 2ad72c27cf
commit 8c0ae4f349

View File

@ -163,8 +163,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 +174,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 +202,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 +217,48 @@ 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) {
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!;
}
// UI
logic.update();
}
},
),
),
Container(
color: AppColors.greyLineColor, //
height: 2.0.h, //
color: AppColors.greyLineColor,
height: 2.0.h,
)
],
),