diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 447da036..101e886b 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -867,5 +867,7 @@ "自定义短信模版":"Custom SMS template", "自定义邮件模版":"Custom email template", "名称":"Name", - "星星锁": "Star lock" + "星星锁": "Star lock", + "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "To receive important updates, please click 'OK' and enable notifications in the settings." + } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index 1f83013b..c8130c70 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -899,5 +899,7 @@ "自定义短信模版":"自定义短信模版", "自定义邮件模版":"自定义邮件模版", "名称":"名称", - "星星锁": "星星锁" + "星星锁": "星星锁", + "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。" + } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 3c3bedf6..193c6d36 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -867,5 +867,6 @@ "自定义短信模版":"自定义短信模版", "自定义邮件模版":"自定义邮件模版", "名称":"名称", - "星星锁": "星星锁" + "星星锁": "星星锁", + "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。" } diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 30e39212..6a26d88e 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -325,7 +325,8 @@ class BlueManage { mac != null) { scanSingleTimer?.cancel(); //兼容android 的低配手机 - await doNotSearchBLE(mac, connectStateCallBack); + await doNotSearchBLE(mac, connectStateCallBack, + isAddEquipment: isAddEquipment); scanSingleTimer = Timer(3.seconds, () { scanSingleTimer?.cancel(); startScanSingle(deviceName, 15, (List scanDevices) => null); @@ -384,6 +385,7 @@ class BlueManage { isAddEquipment == false) { connectStateCallBack(BluetoothConnectionState.disconnected); EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds); + scanDevices.clear(); return; } //尝试连接设备 @@ -392,7 +394,8 @@ class BlueManage { //直接给蓝牙设备写入 Future doNotSearchBLE( - String masAdds, ConnectStateCallBack connectStateCallBack) async { + String masAdds, ConnectStateCallBack connectStateCallBack, + {bool isAddEquipment = false}) async { await FlutterBluePlus.stopScan(); if (bluetoothConnectDevice == null || bluetoothConnectDevice?.remoteId.str != masAdds) { @@ -401,12 +404,14 @@ class BlueManage { _initListenConnectionState(); } //尝试连接设备 - await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack); + await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack, + isAddEquipment: isAddEquipment); } //设备连接 Future bluetoothDeviceConnect(BluetoothDevice bluetoothConnectDevice, - ConnectStateCallBack connectStateCallBack) async { + ConnectStateCallBack connectStateCallBack, + {bool isAddEquipment = false}) async { // 重连三次 const int maxAttempts = 3; int attempt = 0; @@ -430,23 +435,22 @@ class BlueManage { if (bluetoothConnectionState == BluetoothConnectionState.connected) { try { - bluetoothConnectDevice! - .discoverServices() - .then((List services) { - for (final BluetoothService service in services) { - if (service.uuid == _serviceIdConnect) { - for (final BluetoothCharacteristic characteristic - in service.characteristics) { - if (characteristic.characteristicUuid == - _characteristicIdSubscription) { - _subScribeToCharacteristic(characteristic); - bluetoothConnectionState = BluetoothConnectionState.connected; - connectStateCallBack(bluetoothConnectionState!); - } + final List services = + await bluetoothConnectDevice.discoverServices(); + //循环判断服务 + for (final BluetoothService service in services) { + if (service.uuid == _serviceIdConnect) { + for (final BluetoothCharacteristic characteristic + in service.characteristics) { + if (characteristic.characteristicUuid == + _characteristicIdSubscription) { + _subScribeToCharacteristic(characteristic); + bluetoothConnectionState = BluetoothConnectionState.connected; + connectStateCallBack(bluetoothConnectionState!); } } } - }); + } } on Exception catch (e) { bluetoothConnectionState = BluetoothConnectionState.disconnected; connectStateCallBack(bluetoothConnectionState!); diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index aac3c42e..f466f207 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -52,6 +52,7 @@ class _AuthorizedAdminListPageState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, + resizeToAvoidBottomInset: false, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr, haveBack: true, diff --git a/lib/main/lockDetail/card/cardList/cardList_page.dart b/lib/main/lockDetail/card/cardList/cardList_page.dart index 088d571b..e7e7a4c2 100755 --- a/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -54,6 +54,7 @@ class _CardListPageState extends State with RouteAware { Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, + resizeToAvoidBottomInset: false, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.card!.tr, haveBack: true, diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 153c3193..01e7c55b 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -51,6 +51,7 @@ class _ElectronicKeyListPageState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, + resizeToAvoidBottomInset: false, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.electronicKey!.tr, haveBack: true, diff --git a/lib/main/lockDetail/face/faceList/faceList_page.dart b/lib/main/lockDetail/face/faceList/faceList_page.dart index 28b9a109..e1a5c2ae 100755 --- a/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -51,6 +51,7 @@ class _FaceListPageState extends State with RouteAware { Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, + resizeToAvoidBottomInset: false, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.face!.tr, haveBack: true, diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 91865d3d..09c5759e 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -55,6 +55,7 @@ class _FingerprintListPageState extends State Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, + resizeToAvoidBottomInset: false, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.fingerprint!.tr, haveBack: true, diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart index 52c3d8cb..54f79b4c 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart @@ -4,21 +4,21 @@ import 'package:get/get.dart'; import 'fingerprintListData_entity.dart'; -class FingerprintListState{ - final lockId = 0.obs; - - // 因为删除跟添加指纹用的同一个协议 所以这里用做判断 - var isDeletAll = false; - var deletKeyID = "0"; - var deletFingerNo = 0; - - final fingerprintItemListData = [].obs; - final TextEditingController searchController = TextEditingController(); - - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 +class FingerprintListState{ // 是否是当前界面,用于判断是否需要针对当前界面进行展示 FingerprintListState() { Map map = Get.arguments; - lockId.value = map["lockId"]; + lockId.value = map['lockId']; } + final RxInt lockId = 0.obs; + + // 因为删除跟添加指纹用的同一个协议 所以这里用做判断 + bool isDeletAll = false; + String deletKeyID = '0'; + int deletFingerNo = 0; + + final RxList fingerprintItemListData = [].obs; + final TextEditingController searchController = TextEditingController(); + + RxBool ifCurrentScreen = true.obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 4ed1ff0a..b86e5fad 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -52,6 +52,7 @@ class _PasswordKeyListPageState extends State Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, + resizeToAvoidBottomInset: false, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.password!.tr, haveBack: true, diff --git a/lib/main/lockMian/lockMain/lockMain_logic.dart b/lib/main/lockMian/lockMain/lockMain_logic.dart index 50c0c767..7b006eb1 100755 --- a/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -1,7 +1,11 @@ import 'dart:async'; +import 'dart:io'; import 'package:connectivity_plus/connectivity_plus.dart'; +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:get/get.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/main/lockMian/lockList/lockList_logic.dart'; +import 'package:star_lock/tools/showTipView.dart'; import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; @@ -17,7 +21,8 @@ class LockMainLogic extends BaseGetXController { Future getStarLockInfo( {bool isUnShowLoading = false}) async { - LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo( + final LockListInfoEntity entity = + await ApiRepository.to.getStarLockListInfo( pageNo: pageNo, pageSize: 50, isUnShowLoading: isUnShowLoading, @@ -59,33 +64,35 @@ class LockMainLogic extends BaseGetXController { /// 获取联网类型 void getConnectType() async { - var connectResult = await (Connectivity().checkConnectivity()); + final ConnectivityResult connectResult = + await (Connectivity().checkConnectivity()); if (connectResult == ConnectivityResult.mobile) { // _netType = "4G"; state.networkConnectionStatus.value = 1; - AppLog.log("网络连接: 4G 4G 4G 4G 4G"); + AppLog.log('网络连接: 4G 4G 4G 4G 4G'); } else if (connectResult == ConnectivityResult.wifi) { // _netType = "wifi"; state.networkConnectionStatus.value = 1; - AppLog.log("网络连接: wifi wifi wifi wifi wifi"); + AppLog.log('网络连接: wifi wifi wifi wifi wifi'); } else { // _netType = "未连接"; state.networkConnectionStatus.value = 0; - AppLog.log("网络连接: 未连接 未连接 未连接 未连接 未连接"); + AppLog.log('网络连接: 未连接 未连接 未连接 未连接 未连接'); // showToast("网络访问失败,请检查网络是否正常"); } } /// 判断网络是否连接 Future isConnected() async { - var connectResult = await (Connectivity().checkConnectivity()); + final ConnectivityResult connectResult = + await Connectivity().checkConnectivity(); return connectResult != ConnectivityResult.none; } /// 设置网络切换监听 - connectListener() async { + Future connectListener() async { Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { - AppLog.log("设置网络切换监听:$result"); + AppLog.log('设置网络切换监听:$result'); if (state.networkConnectionStatus.value == 0 && result != ConnectivityResult.none) { // 从无网络到有网络 @@ -95,36 +102,52 @@ class LockMainLogic extends BaseGetXController { }); } + /// 检测推送是否开启 + Future checkWhetherPushIsEnabled() async { + bool notificationEnabled = false; + + if (Platform.isAndroid) { + notificationEnabled = await FlutterLocalNotificationsPlugin() + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin>() + ?.areNotificationsEnabled() ?? + false; + } else if (Platform.isIOS) { + notificationEnabled = await FlutterLocalNotificationsPlugin() + .resolvePlatformSpecificImplementation< + IOSFlutterLocalNotificationsPlugin>() + ?.requestPermissions( + alert: true, + badge: false, + sound: true, + ) ?? + false; + } + if (!notificationEnabled) { + //推送未开启 + ShowTipView().showIosTipWithContentDialog( + '为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。'.tr, () async { + openAppSettings(); + }); + } + } + @override void onReady() { - // TODO: implement onReady super.onReady(); - // 开启UDP UdpHelp().openUDP(); - BlueManage(); } @override void onInit() { - // TODO: implement onInit super.onInit(); - - // getLockInfo(); - // 设置网络变化监听 - // connectListener(); - // 获取网络连接状态 - // getConnectType(); + checkWhetherPushIsEnabled(); } @override void onClose() { - // TODO: implement onClose super.onClose(); - - // refreshController.dispose(); - // _teamEvent.cancel(); - // state.timer.cancel(); } } diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index 4400e484..b23b80c4 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -54,9 +54,6 @@ class _StarLockMainPageState extends State with BaseWidget { WidgetsBinding.instance.addPostFrameCallback((_) async { setState(() {}); }); - // if (mounted) { - // setState(() {}); - // } } @override diff --git a/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart b/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart index 80e9314b..6e2bc08f 100755 --- a/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart +++ b/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart @@ -8,50 +8,41 @@ class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{ final AppUnlockNeedMobileNetworkingLockState state = AppUnlockNeedMobileNetworkingLockState(); //请求锁列表 - Future> mockNetworkDataRequest() async { - SelectLockListEntity entity = await ApiRepository.to.selectLockList(); - List dataList = []; + Future mockNetworkDataRequest() async { + final SelectLockListEntity entity = await ApiRepository.to.selectLockList(searchStr: state.searchController.text); + List dataList = []; if (entity.errorCode!.codeIsSuccessful) { dataList = entity.data!.list!; state.lockItemList.value = dataList; for (int i = 0; i < dataList.length; i++) { - var itemData = dataList[i]; + final LockItemData itemData = dataList[i]; if (itemData.appUnlockOnline == 1) { state.selectLockIdList.add(itemData.lockId); } } } - return dataList; + return entity; } //APP开锁时需手机联网的锁 Future setAppUnlockMustOnlineRequest() async { - SelectLockListEntity entity = + final SelectLockListEntity entity = await ApiRepository.to.setAppUnlockMustOnline(state.selectLockIdList); if (entity.errorCode!.codeIsSuccessful) { - showToast("操作成功"); + showToast('操作成功'); } } @override void onReady() { - // TODO: implement onReady super.onReady(); - mockNetworkDataRequest(); + // mockNetworkDataRequest(); } @override void onInit() { - // TODO: implement onInit super.onInit(); } - - @override - void onClose() { - // TODO: implement onClose - - } - } \ No newline at end of file diff --git a/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart b/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart index 0be3ae30..a0ea8964 100755 --- a/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart +++ b/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart @@ -1,11 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_state.dart'; import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/commonItem.dart'; +import '../../../tools/keySearchWidget.dart'; import '../../../tools/noData.dart'; +import '../../../tools/storage.dart'; import '../../../tools/submitBtn.dart'; import '../../../tools/titleAppBar.dart'; import '../../../translations/trans_lib.dart'; @@ -20,19 +23,30 @@ class APPUnlockNeedMobileNetworkingLockPage extends StatefulWidget { } class _APPUnlockNeedMobileNetworkingLockPageState extends State { - final logic = Get.put(AppUnlockNeedMobileNetworkingLockLogic()); - final state = Get.find().state; + final AppUnlockNeedMobileNetworkingLockLogic logic = Get.put(AppUnlockNeedMobileNetworkingLockLogic()); + final AppUnlockNeedMobileNetworkingLockState state = Get.find().state; + + Future getHttpData() async { + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.mockNetworkDataRequest().then((SelectLockListEntity value) { + setState(() {}); + }); + } + } @override void initState() { super.initState(); + getHttpData(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, + resizeToAvoidBottomInset: false, appBar: TitleAppBar( barTitle: TranslationLoader .lanKeys!.appUnlockRequiresMobilePhoneAccessToTheLock!.tr, @@ -48,12 +62,19 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State state.lockItemList.value.isEmpty ? NoData() :Column( - children: [ + children: [ + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + state.lockItemList.value = []; + logic.mockNetworkDataRequest(); + }, + ), Container( - padding: EdgeInsets.all(30.w), + padding: EdgeInsets.all(15.w), child: Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( TranslationLoader.lanKeys! @@ -65,14 +86,14 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State Row( - children: [ + children: [ Image.asset( state.isCheckAll.value ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, @@ -97,8 +118,8 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State[ SizedBox( width: 15.w, ), @@ -166,10 +187,14 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State[].obs; - var selectLockIdList = []; - var isCheckAll = false.obs; + RxList lockItemList = [].obs; + List selectLockIdList = []; + RxBool isCheckAll = false.obs; + + final TextEditingController searchController = TextEditingController(); } \ No newline at end of file diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index e7b27134..71952895 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -595,8 +595,10 @@ class ApiProvider extends BaseProvider { 'lockIds': lockIds, })); - Future selectLockList() => - post(selectLockListURL.toUrl, jsonEncode({})); + Future selectLockList(String searchStr) => + post(selectLockListURL.toUrl, jsonEncode({ + 'searchStr': searchStr, + })); //APP开锁时需手机联网的锁 Future setAppUnlockMustOnline(List lockIdList) => post( diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 954aeaae..770372db 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -618,8 +618,8 @@ class ApiRepository { } //选择锁列表 - Future selectLockList() async { - final res = await apiProvider.selectLockList(); + Future selectLockList({String? searchStr}) async { + final res = await apiProvider.selectLockList(searchStr ?? ''); return SelectLockListEntity.fromJson(res.body); } diff --git a/test/widget_test.dart b/test/widget_test.dart index 1c7575bf..a9af1c20 100755 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -13,7 +13,7 @@ import 'package:star_lock/app.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); + await tester.pumpWidget(MyApp(isLogin: false)); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);