Merge branch 'develop_address_book' into 'release'
Develop address book See merge request StarlockTeam/app-starlock!99
This commit is contained in:
commit
fa18888df9
@ -29,6 +29,9 @@
|
|||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||||
<!--允许读设备日志,用于问题排查-->
|
<!--允许读设备日志,用于问题排查-->
|
||||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||||
|
<!--联系人-->
|
||||||
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||||
|
|
||||||
<!--相机-->
|
<!--相机-->
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
|||||||
@ -257,15 +257,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
|||||||
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) {
|
setState(() {
|
||||||
logic.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) {
|
||||||
logic.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 = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -602,17 +629,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
final Contact? currentContact =
|
final Contact? currentContact =
|
||||||
await state.contactPicker.selectContact();
|
await state.contactPicker.selectContact();
|
||||||
setState(() {
|
if (currentContact != null) {
|
||||||
state.contact = currentContact!;
|
setState(() {
|
||||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
state.contact = currentContact;
|
||||||
state.emailOrPhoneController.text = currentContact
|
|
||||||
.phoneNumbers![0]
|
// 处理手机号
|
||||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
if (currentContact.phoneNumbers != null &&
|
||||||
}
|
currentContact.phoneNumbers!.isNotEmpty) {
|
||||||
if (currentContact.fullName!.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]'), '');
|
||||||
|
}
|
||||||
|
state.emailOrPhoneController.text = phoneNumber;
|
||||||
|
} else {
|
||||||
|
state.emailOrPhoneController.text = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理姓名
|
||||||
|
if (currentContact.fullName != null &&
|
||||||
|
currentContact.fullName!.isNotEmpty) {
|
||||||
|
state.keyNameController.text = currentContact.fullName!;
|
||||||
|
} else {
|
||||||
|
state.keyNameController.text = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
|||||||
import 'package:star_lock/tools/regularExpression.dart';
|
import 'package:star_lock/tools/regularExpression.dart';
|
||||||
import 'package:star_lock/tools/showTipView.dart';
|
import 'package:star_lock/tools/showTipView.dart';
|
||||||
import 'package:star_lock/tools/submitBtn.dart';
|
import 'package:star_lock/tools/submitBtn.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
||||||
class SendElectronicKeyView extends StatefulWidget {
|
class SendElectronicKeyView extends StatefulWidget {
|
||||||
SendElectronicKeyView({required this.type, Key? key}) : super(key: key);
|
SendElectronicKeyView({required this.type, Key? key}) : super(key: key);
|
||||||
@ -31,6 +32,14 @@ class SendElectronicKeyView extends StatefulWidget {
|
|||||||
|
|
||||||
class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
|
late FlutterContactPicker _contactPicker;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_contactPicker = FlutterContactPicker();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@ -163,8 +172,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 +183,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 +211,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,
|
||||||
@ -220,24 +224,88 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final Contact? currentContact =
|
try {
|
||||||
await logic.state.contactPicker.selectContact();
|
final PermissionStatus status =
|
||||||
logic.state.contact = currentContact!;
|
await Permission.contacts.request();
|
||||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
if (status.isGranted) {
|
||||||
logic.state.emailOrPhoneController.text = currentContact
|
// 保存当前路由
|
||||||
.phoneNumbers![0]
|
final currentRoute = ModalRoute.of(context);
|
||||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
|
||||||
}
|
final Contact? currentContact =
|
||||||
if (currentContact.fullName!.isNotEmpty) {
|
await _contactPicker.selectContact();
|
||||||
logic.state.keyNameController.text =
|
|
||||||
currentContact.fullName!;
|
// 检查路由是否仍然存在且组件是否挂载
|
||||||
|
if (currentRoute?.isCurrent == true && mounted) {
|
||||||
|
// 检查 GetX 控制器是否仍然存在
|
||||||
|
if (Get.isRegistered<SendElectronicKeyViewLogic>(
|
||||||
|
tag: widget.type)) {
|
||||||
|
final logic = Get.find<SendElectronicKeyViewLogic>(
|
||||||
|
tag: widget.type);
|
||||||
|
|
||||||
|
if (currentContact != null) {
|
||||||
|
// 处理手机号
|
||||||
|
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;
|
||||||
|
logic.state.emailOrPhone.value = phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理姓名
|
||||||
|
if (currentContact.fullName != null &&
|
||||||
|
currentContact.fullName!.isNotEmpty) {
|
||||||
|
logic.state.keyNameController.text =
|
||||||
|
currentContact.fullName!;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新UI
|
||||||
|
logic.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 权限被拒绝,显示提示
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('需要通讯录权限才能选择联系人'.tr),
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Error selecting contact: $e');
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('获取通讯录失败,请检查权限设置'.tr),
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: AppColors.greyLineColor, // 设置边框颜色
|
color: AppColors.greyLineColor,
|
||||||
height: 2.0.h, //
|
height: 2.0.h,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -616,17 +684,65 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final Contact? currentContact =
|
try {
|
||||||
await logic.state.contactPicker.selectContact();
|
final PermissionStatus status =
|
||||||
logic.state.contact = currentContact!;
|
await Permission.contacts.request();
|
||||||
if (currentContact.phoneNumbers!.isNotEmpty) {
|
if (status.isGranted) {
|
||||||
logic.state.emailOrPhoneController.text = currentContact
|
final Contact? currentContact =
|
||||||
.phoneNumbers![0]
|
await _contactPicker.selectContact();
|
||||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
if (currentContact != null && mounted) {
|
||||||
}
|
// 处理手机号
|
||||||
if (currentContact.fullName!.isNotEmpty) {
|
if (currentContact.phoneNumbers != null &&
|
||||||
logic.state.keyNameController.text =
|
currentContact.phoneNumbers!.isNotEmpty) {
|
||||||
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;
|
||||||
|
logic.state.emailOrPhone.value = phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理姓名
|
||||||
|
if (currentContact.fullName != null &&
|
||||||
|
currentContact.fullName!.isNotEmpty) {
|
||||||
|
logic.state.keyNameController.text =
|
||||||
|
currentContact.fullName!;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新UI
|
||||||
|
logic.update();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 权限被拒绝,显示提示
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('需要通讯录权限才能选择联系人'.tr),
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Error selecting contact: $e');
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('获取通讯录失败,请检查权限设置'.tr),
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -736,7 +852,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
child: Text(
|
child: Text(
|
||||||
'取消'.tr,
|
'取消'.tr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
|
color: Colors.black, fontSize: 24.sp),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@ -779,7 +895,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
|
|||||||
Text(
|
Text(
|
||||||
titleStr,
|
titleStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: ScreenUtil().setSp(20), color: Colors.black),
|
fontSize: 20.sp, color: Colors.black),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -15,8 +15,8 @@ class SendElectronicKeyViewState {
|
|||||||
TextEditingController realNameController = TextEditingController(); //真实姓名输入框
|
TextEditingController realNameController = TextEditingController(); //真实姓名输入框
|
||||||
TextEditingController idCardController = TextEditingController(); //身份证号输入框
|
TextEditingController idCardController = TextEditingController(); //身份证号输入框
|
||||||
|
|
||||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
// final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||||
late Contact contact;
|
// late Contact contact;
|
||||||
|
|
||||||
RxBool isRemoteUnlock = false.obs; //是否允许远程开锁
|
RxBool isRemoteUnlock = false.obs; //是否允许远程开锁
|
||||||
RxBool isAuthentication = false.obs; //是否可以实名认证
|
RxBool isAuthentication = false.obs; //是否可以实名认证
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import 'package:star_lock/talk/starChart/constant/talk_status.dart';
|
|||||||
|
|
||||||
class StartChartTalkStatus {
|
class StartChartTalkStatus {
|
||||||
// 私有字段,用于存储当前状态
|
// 私有字段,用于存储当前状态
|
||||||
TalkStatus _status = TalkStatus.uninitialized;
|
TalkStatus _status = TalkStatus.none;
|
||||||
|
|
||||||
// 私有化默认构造函数,防止外部创建实例
|
// 私有化默认构造函数,防止外部创建实例
|
||||||
StartChartTalkStatus._();
|
StartChartTalkStatus._();
|
||||||
|
|||||||
@ -155,7 +155,7 @@ dependencies:
|
|||||||
# 选择日期时间
|
# 选择日期时间
|
||||||
flutter_cupertino_datetime_picker: ^3.0.0
|
flutter_cupertino_datetime_picker: ^3.0.0
|
||||||
# 选择原生通讯录
|
# 选择原生通讯录
|
||||||
flutter_native_contact_picker: ^0.0.4
|
flutter_native_contact_picker: 0.0.7
|
||||||
#底部弹出选择器
|
#底部弹出选择器
|
||||||
flutter_picker: ^2.1.0
|
flutter_picker: ^2.1.0
|
||||||
#生成二维码
|
#生成二维码
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user