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(
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'), '');
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]'), '');
}
if (currentContact.fullName!.isNotEmpty) {
state.keyNameController.text = currentContact.fullName!;
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

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

View File

@ -146,12 +146,35 @@ 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(