fix: 修复测试部门问题-发送钥匙各个类型下点击通讯录无法直接获取通讯录联系人手机号及姓名
This commit is contained in:
parent
2ad72c27cf
commit
8c0ae4f349
@ -163,8 +163,8 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
color: AppColors.greyLineColor, // 设置边框颜色
|
color: AppColors.greyLineColor,
|
||||||
width: 2.0.h, // 设置边框宽度
|
width: 2.0.h,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -174,17 +174,14 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: logic.getCurrentController(1),
|
controller: logic.getCurrentController(1),
|
||||||
//输入框一行
|
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
inputFormatters: <TextInputFormatter>[
|
inputFormatters: <TextInputFormatter>[
|
||||||
FilteringTextInputFormatter.deny('\n'),
|
FilteringTextInputFormatter.deny('\n'),
|
||||||
LengthLimitingTextInputFormatter(30),
|
LengthLimitingTextInputFormatter(30),
|
||||||
],
|
],
|
||||||
// controller: _controller,
|
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
//输入里面输入文字内边距设置
|
|
||||||
hintText: rightTitle,
|
hintText: rightTitle,
|
||||||
hintStyle: TextStyle(fontSize: 22.sp),
|
hintStyle: TextStyle(fontSize: 22.sp),
|
||||||
focusedBorder: const OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
@ -205,9 +202,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(width: 10.w),
|
||||||
width: 10.w,
|
|
||||||
),
|
|
||||||
Container(
|
Container(
|
||||||
width: 32.w,
|
width: 32.w,
|
||||||
height: 32.w,
|
height: 32.w,
|
||||||
@ -222,22 +217,48 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
final Contact? currentContact =
|
final Contact? currentContact =
|
||||||
await logic.state.contactPicker.selectContact();
|
await logic.state.contactPicker.selectContact();
|
||||||
logic.state.contact = currentContact!;
|
if (currentContact != null) {
|
||||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
logic.state.contact = currentContact;
|
||||||
logic.state.emailOrPhoneController.text = currentContact
|
|
||||||
.phoneNumbers![0]
|
// 处理手机号
|
||||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
if (currentContact.phoneNumbers != null &&
|
||||||
}
|
currentContact.phoneNumbers!.isNotEmpty) {
|
||||||
if (currentContact.fullName!.isNotEmpty) {
|
// 获取第一个手机号并清理格式
|
||||||
logic.state.keyNameController.text =
|
String phoneNumber = currentContact.phoneNumbers![0];
|
||||||
currentContact.fullName!;
|
// 移除所有空格、括号、连字符等特殊字符
|
||||||
|
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(
|
Container(
|
||||||
color: AppColors.greyLineColor, // 设置边框颜色
|
color: AppColors.greyLineColor,
|
||||||
height: 2.0.h, //
|
height: 2.0.h,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user