fix: 修复我的--授权管理员的通讯录获取问题

This commit is contained in:
DaisyWu 2025-05-28 14:44:06 +08:00
parent 600212aee5
commit 9a11a5b0f7
3 changed files with 111 additions and 31 deletions

View File

@ -288,17 +288,44 @@ class _VolumeAuthorizationLockPageState
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await state.contactPicker.selectContact(); await logic.state.contactPicker.selectContact();
// setState(() { if (currentContact != null) {
if (currentContact!.phoneNumbers!.isNotEmpty) { setState(() {
state.emailOrPhoneController.text = currentContact logic.state.contact = currentContact;
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); //
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]'), '');
} }
if (currentContact.fullName!.isNotEmpty) { logic.state.emailOrPhoneController.text = phoneNumber;
state.keyNameController.text = currentContact.fullName!; } else {
logic.state.emailOrPhoneController.text = '';
}
//
if (currentContact.fullName != null &&
currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
} else {
logic.state.keyNameController.text = '';
}
});
} }
// });
}, },
), ),
) )

View File

@ -271,14 +271,44 @@ class _AddAuthorizedAdministratorPageState
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await state.contactPicker.selectContact(); await logic.state.contactPicker.selectContact();
if (currentContact != null) {
setState(() { setState(() {
if (currentContact!.phoneNumbers!.isNotEmpty) { logic.state.contact = currentContact;
state.emailOrPhoneController.text = currentContact
.phoneNumbers![0] //
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); 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 = '';
} }
}); });
}
}, },
), ),
) )

View File

@ -146,12 +146,35 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
), ),
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
Contact? currentContact = await state.contactPicker.selectContact(); final Contact? currentContact =
state.contact = currentContact!; await logic.state.contactPicker.selectContact();
if (currentContact.phoneNumbers!.isNotEmpty) { if (currentContact != null) {
state.numberController.text = currentContact setState(() {
.phoneNumbers![0] logic.state.contact = currentContact;
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
//
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( child: Image.asset(