fix: 修复我的--授权管理员的通讯录获取问题
This commit is contained in:
parent
600212aee5
commit
9a11a5b0f7
@ -286,20 +286,47 @@ class _VolumeAuthorizationLockPageState
|
|||||||
),
|
),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
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 &&
|
||||||
if (currentContact.fullName!.isNotEmpty) {
|
currentContact.phoneNumbers!.isNotEmpty) {
|
||||||
state.keyNameController.text = currentContact.fullName!;
|
// 获取第一个手机号并清理格式
|
||||||
}
|
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
|
else
|
||||||
|
|||||||
@ -270,16 +270,46 @@ class _AddAuthorizedAdministratorPageState
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
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]'), '');
|
||||||
|
}
|
||||||
|
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
|
else
|
||||||
|
|||||||
@ -146,14 +146,37 @@ 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(
|
||||||
'images/icon_addressBook.png',
|
'images/icon_addressBook.png',
|
||||||
width: 28.w,
|
width: 28.w,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user