fix: 授权管理员—各个类型下点击通讯录无法直接获取通讯录联系人手机号及姓名问题修复及自测

This commit is contained in:
DaisyWu 2025-05-26 16:11:54 +08:00
parent 8c0ae4f349
commit 4b3a74cc58

View File

@ -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 = '';
}
});
}
},
),
)