Merge branch 'release' of gitee.com:starlock-cn/app-starlock into release

This commit is contained in:
Daisy 2024-06-06 13:58:35 +08:00
commit 4fa11a4a0a
19 changed files with 156 additions and 101 deletions

View File

@ -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."
}

View File

@ -899,5 +899,7 @@
"自定义短信模版":"自定义短信模版",
"自定义邮件模版":"自定义邮件模版",
"名称":"名称",
"星星锁": "星星锁"
"星星锁": "星星锁",
"为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。"
}

View File

@ -867,5 +867,6 @@
"自定义短信模版":"自定义短信模版",
"自定义邮件模版":"自定义邮件模版",
"名称":"名称",
"星星锁": "星星锁"
"星星锁": "星星锁",
"为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。": "为了让您及时收到重要通知和更新,我们需要获取通知权限。请点击“确定”按钮,然后在设置页面中启用通知权限。"
}

View File

@ -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<ScanResult> 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<void> 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<void> 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<BluetoothService> 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<BluetoothService> 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!);

View File

@ -52,6 +52,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr,
haveBack: true,

View File

@ -54,6 +54,7 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.card!.tr,
haveBack: true,

View File

@ -51,6 +51,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.electronicKey!.tr,
haveBack: true,

View File

@ -51,6 +51,7 @@ class _FaceListPageState extends State<FaceListPage> with RouteAware {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.face!.tr,
haveBack: true,

View File

@ -55,6 +55,7 @@ class _FingerprintListPageState extends State<FingerprintListPage>
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.fingerprint!.tr,
haveBack: true,

View File

@ -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 = <FingerprintItemData>[].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<FingerprintItemData> fingerprintItemListData = <FingerprintItemData>[].obs;
final TextEditingController searchController = TextEditingController();
RxBool ifCurrentScreen = true.obs;
}

View File

@ -52,6 +52,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.password!.tr,
haveBack: true,

View File

@ -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<LockListInfoEntity> 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<bool> isConnected() async {
var connectResult = await (Connectivity().checkConnectivity());
final ConnectivityResult connectResult =
await Connectivity().checkConnectivity();
return connectResult != ConnectivityResult.none;
}
///
connectListener() async {
Future<void> 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<void> 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();
}
}

View File

@ -54,9 +54,6 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
WidgetsBinding.instance.addPostFrameCallback((_) async {
setState(() {});
});
// if (mounted) {
// setState(() {});
// }
}
@override

View File

@ -8,50 +8,41 @@ class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{
final AppUnlockNeedMobileNetworkingLockState state = AppUnlockNeedMobileNetworkingLockState();
//
Future<List<LockItemData>> mockNetworkDataRequest() async {
SelectLockListEntity entity = await ApiRepository.to.selectLockList();
List<LockItemData> dataList = [];
Future<SelectLockListEntity> mockNetworkDataRequest() async {
final SelectLockListEntity entity = await ApiRepository.to.selectLockList(searchStr: state.searchController.text);
List<LockItemData> dataList = <LockItemData>[];
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<void> 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
}
}

View File

@ -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<APPUnlockNeedMobileNetworkingLockPage> {
final logic = Get.put(AppUnlockNeedMobileNetworkingLockLogic());
final state = Get.find<AppUnlockNeedMobileNetworkingLockLogic>().state;
final AppUnlockNeedMobileNetworkingLockLogic logic = Get.put(AppUnlockNeedMobileNetworkingLockLogic());
final AppUnlockNeedMobileNetworkingLockState state = Get.find<AppUnlockNeedMobileNetworkingLockLogic>().state;
Future<void> 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<APPUnlockNeedMob
// ],
backgroundColor: AppColors.mainColor),
body: Obx(() => state.lockItemList.value.isEmpty ? NoData() :Column(
children: [
children: <Widget>[
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: <Widget>[
Expanded(
child: Text(
TranslationLoader.lanKeys!
@ -65,14 +86,14 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.checkAll!.tr,
rightTitle: "",
rightTitle: '',
allHeight: 70.h,
isHaveLine: false,
isHaveRightWidget: true,
rightWidget: GestureDetector(
onTap: () {
state.isCheckAll.value = !state.isCheckAll.value;
for(LockItemData lockItemData in state.lockItemList.value){
for(final LockItemData lockItemData in state.lockItemList.value){
if(state.isCheckAll.value == true){
lockItemData.appUnlockOnline = 1;
state.selectLockIdList.add(lockItemData.lockId);
@ -84,7 +105,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
setState(() {});
},
child: Obx(() => Row(
children: [
children: <Widget>[
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<APPUnlockNeedMob
Expanded(
child: ListView.builder(
itemCount: state.lockItemList.value.length,
itemBuilder: (c, index) {
LockItemData itemData = state.lockItemList.value[index];
itemBuilder: (BuildContext c, int index) {
final LockItemData itemData = state.lockItemList.value[index];
// if(state.isCheckAll.value == true){
// itemData.isCheck = true;
// }else{
@ -113,7 +134,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
if (state.selectLockIdList.isNotEmpty) {
logic.setAppUnlockMustOnlineRequest();
} else {
logic.showToast("请选择需设置的锁");
logic.showToast('请选择需设置的锁');
}
}),
SizedBox(
@ -152,7 +173,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
borderRadius: BorderRadius.circular(10.w),
),
child: Row(
children: [
children: <Widget>[
SizedBox(
width: 15.w,
),
@ -166,10 +187,14 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
SizedBox(
width: 10.w,
),
Text(
itemData.lockAlias ?? "",
Expanded(child: Text(
itemData.lockAlias ?? '',
style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600),
)
)),
// Text(
// itemData.lockAlias ?? '',
// style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600),
// )
],
),
),

View File

@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'selectLockListEntity.dart';
class AppUnlockNeedMobileNetworkingLockState {
var lockItemList = <LockItemData>[].obs;
var selectLockIdList = [];
var isCheckAll = false.obs;
RxList<LockItemData> lockItemList = <LockItemData>[].obs;
List selectLockIdList = [];
RxBool isCheckAll = false.obs;
final TextEditingController searchController = TextEditingController();
}

View File

@ -595,8 +595,10 @@ class ApiProvider extends BaseProvider {
'lockIds': lockIds,
}));
Future<Response> selectLockList() =>
post(selectLockListURL.toUrl, jsonEncode({}));
Future<Response> selectLockList(String searchStr) =>
post(selectLockListURL.toUrl, jsonEncode({
'searchStr': searchStr,
}));
//APP开锁时需手机联网的锁
Future<Response> setAppUnlockMustOnline(List lockIdList) => post(

View File

@ -618,8 +618,8 @@ class ApiRepository {
}
//
Future<SelectLockListEntity> selectLockList() async {
final res = await apiProvider.selectLockList();
Future<SelectLockListEntity> selectLockList({String? searchStr}) async {
final res = await apiProvider.selectLockList(searchStr ?? '');
return SelectLockListEntity.fromJson(res.body);
}

View File

@ -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);