fix:增加添加锁后判断是否wifi锁,如果是wifi锁则直接进入配网页面
This commit is contained in:
parent
ca48b7e9c3
commit
b59dafc37c
@ -8,6 +8,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:network_info_plus/network_info_plus.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/blue/io_gateway/io_gateway_configuringWifi.dart';
|
||||
import 'package:star_lock/blue/io_gateway/io_gateway_getStatus.dart';
|
||||
@ -68,7 +69,12 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
secretKey: secretKey,
|
||||
peerId: peerId,
|
||||
);
|
||||
Get.close(2);
|
||||
|
||||
if (state.pageName.value == 'lockSet') {
|
||||
Get.close(2);
|
||||
} else {
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,8 @@ class _ConfiguringWifiPageState extends State<ConfiguringWifiPage>
|
||||
SubmitBtn(
|
||||
btnName: '确定'.tr,
|
||||
onClick: () {
|
||||
logic.senderConfiguringWifiAction();
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
logic.senderConfiguringWifiAction();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -9,6 +9,7 @@ class ConfiguringWifiState{
|
||||
ConfiguringWifiState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map['lockSetInfoData'];
|
||||
pageName.value = map['pageName'];
|
||||
lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!;
|
||||
if (map['wifiName'] != null) {
|
||||
wifiName.value = map['wifiName'];
|
||||
@ -20,6 +21,7 @@ class ConfiguringWifiState{
|
||||
Rx<LockBasicInfo> lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
RxString wifiName = ''.obs;
|
||||
RxString pageName = ''.obs;
|
||||
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
RxInt sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
|
||||
@ -24,11 +24,18 @@ class _WifiListPageState extends State<WifiListPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
if (state.pageName.value == 'lockSet') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: 'WIFI列表'.tr,
|
||||
haveBack: true,
|
||||
haveBack: state.pageName.value == 'lockSet',
|
||||
actionsList: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
@ -38,45 +45,50 @@ class _WifiListPageState extends State<WifiListPage> {
|
||||
onPressed: logic.senderGetWifiListWifiAction,
|
||||
),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Obx(() => state.wifiNameDataList.value.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: state.wifiNameDataList.value.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
Map wifiNameStr = state.wifiNameDataList.value[index];
|
||||
return _messageListItem(
|
||||
wifiNameStr['wifiName'], wifiNameStr['rssi'], () {
|
||||
Get.toNamed(Routers.configuringWifiPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value,
|
||||
'wifiName': wifiNameStr['wifiName'],
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Obx(() => state.wifiNameDataList.value.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: state.wifiNameDataList.value.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
Map wifiNameStr = state.wifiNameDataList.value[index];
|
||||
return _messageListItem(
|
||||
wifiNameStr['wifiName'], wifiNameStr['rssi'], () {
|
||||
Get.toNamed(Routers.configuringWifiPage,
|
||||
arguments: {
|
||||
'lockSetInfoData':
|
||||
state.lockSetInfoData.value,
|
||||
'wifiName': wifiNameStr['wifiName'],
|
||||
'pageName': state.pageName.value,
|
||||
});
|
||||
});
|
||||
})
|
||||
: NoData(
|
||||
noDataHeight: 1.sh -
|
||||
ScreenUtil().statusBarHeight -
|
||||
ScreenUtil().bottomBarHeight -
|
||||
64.h)),
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '手动配网'.tr,
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
Get.toNamed(Routers.configuringWifiPage,
|
||||
arguments: <String, LockSetInfoData>{
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
})
|
||||
: NoData(
|
||||
noDataHeight: 1.sh -
|
||||
ScreenUtil().statusBarHeight -
|
||||
ScreenUtil().bottomBarHeight -
|
||||
64.h)),
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '手动配网'.tr,
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
Get.toNamed(Routers.configuringWifiPage,
|
||||
arguments: <String, LockSetInfoData>{
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
}),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
));
|
||||
}),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _messageListItem(String wifiName, String rssi, Function() action) {
|
||||
|
||||
@ -1,18 +1,22 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class WifiListState{// 0普通状态(可用) 1连接中(不可用)
|
||||
class WifiListState {
|
||||
// 0普通状态(可用) 1连接中(不可用)
|
||||
WifiListState() {
|
||||
final map = Get.arguments;
|
||||
lockSetInfoData.value = map['lockSetInfoData'];
|
||||
pageName.value = map['pageName'];
|
||||
lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!;
|
||||
}
|
||||
final RxList<Map<String, String>> wifiNameDataList = <Map<String, String>>[].obs;
|
||||
|
||||
final RxList<Map<String, String>> wifiNameDataList =
|
||||
<Map<String, String>>[].obs;
|
||||
Rx<LockSetInfoData> lockSetInfoData = LockSetInfoData().obs;
|
||||
Rx<LockBasicInfo> lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
RxInt sureBtnState = 0.obs;
|
||||
}
|
||||
RxString pageName = ''.obs;
|
||||
}
|
||||
|
||||
@ -595,10 +595,10 @@ class _LockSetPageState extends State<LockSetPage>
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.wifiListPage,
|
||||
arguments: <String, LockSetInfoData>{
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
Get.toNamed(Routers.wifiListPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value,
|
||||
'pageName': 'lockSet'
|
||||
});
|
||||
// Get.toNamed(Routers.configuringWifiPage, arguments: {
|
||||
// 'lockSetInfoData': state.lockSetInfoData.value
|
||||
// });
|
||||
|
||||
@ -345,6 +345,8 @@ class LockFeature {
|
||||
this.isSupportCatEye,
|
||||
this.isSupportBackupBattery,
|
||||
this.isNoSupportedBlueBroadcast,
|
||||
this.wifiLockType,
|
||||
this.wifi,
|
||||
});
|
||||
|
||||
LockFeature.fromJson(Map<String, dynamic> json) {
|
||||
@ -360,6 +362,8 @@ class LockFeature {
|
||||
isSupportCatEye = json['isSupportCatEye'];
|
||||
isSupportBackupBattery = json['isSupportBackupBattery'];
|
||||
isNoSupportedBlueBroadcast = json['isNoSupportedBlueBroadcast'];
|
||||
wifiLockType = json['wifiLockType'];
|
||||
wifi = json['wifi'];
|
||||
}
|
||||
|
||||
int? password;
|
||||
@ -374,6 +378,8 @@ class LockFeature {
|
||||
int? isSupportCatEye;
|
||||
int? isSupportBackupBattery;
|
||||
int? isNoSupportedBlueBroadcast;
|
||||
int? wifiLockType;
|
||||
int? wifi;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
@ -389,6 +395,8 @@ class LockFeature {
|
||||
data['isSupportCatEye'] = isSupportCatEye;
|
||||
data['isSupportBackupBattery'] = isSupportBackupBattery;
|
||||
data['isNoSupportedBlueBroadcast'] = isNoSupportedBlueBroadcast;
|
||||
data['wifiLockType'] = wifiLockType;
|
||||
data['wifi'] = wifi;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/apm/apm_helper.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||
import 'package:star_lock/mine/addLock/saveLock/entity/SaveLockEntity.dart';
|
||||
|
||||
import '../../../app_settings/app_settings.dart';
|
||||
@ -408,10 +409,11 @@ class SaveLockLogic extends BaseGetXController {
|
||||
|
||||
final String getMobile = (await Storage.getMobile())!;
|
||||
ApmHelper.instance.trackEvent('save_lock_result', {
|
||||
'lock_name':BlueManage().connectDeviceName,
|
||||
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
||||
'date':DateTool().getNowDateWithType(1),
|
||||
'save_lock_result':'成功',
|
||||
'lock_name': BlueManage().connectDeviceName,
|
||||
'account':
|
||||
getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
||||
'date': DateTool().getNowDateWithType(1),
|
||||
'save_lock_result': '成功',
|
||||
});
|
||||
backAction();
|
||||
// await senderCustomPasswords();
|
||||
@ -424,10 +426,11 @@ class SaveLockLogic extends BaseGetXController {
|
||||
|
||||
final String getMobile = (await Storage.getMobile())!;
|
||||
ApmHelper.instance.trackEvent('save_lock_result', {
|
||||
'lock_name':BlueManage().connectDeviceName,
|
||||
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
||||
'date':DateTool().getNowDateWithType(1),
|
||||
'save_lock_result':'${entity.errorCode}--${entity.errorMsg}',
|
||||
'lock_name': BlueManage().connectDeviceName,
|
||||
'account':
|
||||
getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
||||
'date': DateTool().getNowDateWithType(1),
|
||||
'save_lock_result': '${entity.errorCode}--${entity.errorMsg}',
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -482,20 +485,52 @@ class SaveLockLogic extends BaseGetXController {
|
||||
// );
|
||||
// }
|
||||
|
||||
void backAction() {
|
||||
void backAction() async {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent(clearScanDevices: true));
|
||||
BlueManage().disconnect();
|
||||
Future<void>.delayed(const Duration(seconds: 1), () {
|
||||
Get.close(state.isFromMap == 1 ? (CommonDataManage().seletLockType == 0 ? 4 : 5) : (CommonDataManage().seletLockType == 0 ? 5 : 6));
|
||||
});
|
||||
//刚刚配对完,需要对开锁页锁死 2 秒
|
||||
Future<void>.delayed(const Duration(milliseconds: 200), () {
|
||||
if (Get.isRegistered<LockDetailLogic>()) {
|
||||
Get.find<LockDetailLogic>()
|
||||
.functionBlocker
|
||||
.countdownProhibited(duration: const Duration(seconds: 2));
|
||||
|
||||
// 查询锁设置信息
|
||||
final LockSetInfoEntity entity =
|
||||
await ApiRepository.to.getLockSettingInfoDataIsNotLoadingIcon(
|
||||
lockId: state.lockId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.lockSetInfoData.value = entity.data!;
|
||||
if (state.lockSetInfoData.value.lockFeature?.wifi == 1) {
|
||||
// await Future<void>.delayed(const Duration(seconds: 1), () {c
|
||||
// Get.close(state.isFromMap == 1
|
||||
// ? (CommonDataManage().seletLockType == 0 ? 4 : 5)
|
||||
// : (CommonDataManage().seletLockType == 0 ? 5 : 6));
|
||||
// });
|
||||
// //刚刚配对完,需要对开锁页锁死 2 秒
|
||||
// await Future<void>.delayed(const Duration(milliseconds: 200), () {
|
||||
// if (Get.isRegistered<LockDetailLogic>()) {
|
||||
// Get.find<LockDetailLogic>()
|
||||
// .functionBlocker
|
||||
// .countdownProhibited(duration: const Duration(seconds: 2));
|
||||
// }
|
||||
// });
|
||||
// 如果是wifi锁,需要配置WIFI
|
||||
Get.toNamed(Routers.wifiListPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value,
|
||||
'pageName': 'saveLock'
|
||||
});
|
||||
} else {
|
||||
Future<void>.delayed(const Duration(seconds: 1), () {
|
||||
Get.close(state.isFromMap == 1
|
||||
? (CommonDataManage().seletLockType == 0 ? 4 : 5)
|
||||
: (CommonDataManage().seletLockType == 0 ? 5 : 6));
|
||||
});
|
||||
//刚刚配对完,需要对开锁页锁死 2 秒
|
||||
Future<void>.delayed(const Duration(milliseconds: 200), () {
|
||||
if (Get.isRegistered<LockDetailLogic>()) {
|
||||
Get.find<LockDetailLogic>()
|
||||
.functionBlocker
|
||||
.countdownProhibited(duration: const Duration(seconds: 2));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -3,6 +3,7 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
|
||||
@ -25,7 +26,7 @@ class SaveLockState {
|
||||
RxString aliName = ''.obs;
|
||||
RxInt pwdTimestamp = 0.obs;
|
||||
RxMap addressInfo = {}.obs;
|
||||
|
||||
final Rx<LockSetInfoData> lockSetInfoData = LockSetInfoData().obs;
|
||||
TextEditingController aliNameController = TextEditingController();
|
||||
FocusNode focusNode = FocusNode();
|
||||
|
||||
|
||||
@ -423,6 +423,15 @@ class ApiProvider extends BaseProvider {
|
||||
'lockId': lockId,
|
||||
}));
|
||||
|
||||
// 获取所有锁设置信息
|
||||
Future<Response> getLockSettingInfoDataIsNotLoadingIcon(String lockId) =>
|
||||
post(
|
||||
getLockSettingURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
}),
|
||||
isUnShowLoading: true);
|
||||
|
||||
// 删除锁
|
||||
Future<Response> deletLockInfo(int lockId) => post(
|
||||
deletLockURL.toUrl,
|
||||
|
||||
@ -486,6 +486,12 @@ class ApiRepository {
|
||||
final res = await apiProvider.getLockSettingInfoData(lockId);
|
||||
return LockSetInfoEntity.fromJson(res.body);
|
||||
}
|
||||
// 获取所有锁设置信息(不显示加载框)
|
||||
Future<LockSetInfoEntity> getLockSettingInfoDataIsNotLoadingIcon(
|
||||
{required String lockId}) async {
|
||||
final res = await apiProvider.getLockSettingInfoDataIsNotLoadingIcon(lockId);
|
||||
return LockSetInfoEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 删除锁
|
||||
Future<LockListInfoEntity> deletOwnerLockData({required int lockId}) async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user