fix:调整WiFi配网时loading不连续的问题
This commit is contained in:
parent
d867cf870e
commit
bc48f573a1
@ -115,7 +115,7 @@ class CommandReciverManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parseData(oriDataList).then((Reply? value) async {
|
parseData(oriDataList).then((Reply? value) async {
|
||||||
EasyLoading.dismiss();
|
// EasyLoading.dismiss();
|
||||||
await EventBusManager().eventBusFir(value);
|
await EventBusManager().eventBusFir(value);
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
AppLog.log('APP解析数据时发生错误: ${error.toString()}');
|
AppLog.log('APP解析数据时发生错误: ${error.toString()}');
|
||||||
|
|||||||
@ -88,11 +88,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
Future<void> _replySenderConfiguringWifiResult(Reply reply) async {
|
Future<void> _replySenderConfiguringWifiResult(Reply reply) async {
|
||||||
final int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
state.isLoading.value = false;
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
dismissEasyLoading();
|
|
||||||
final int secretKeyJsonLength = (reply.data[4] << 8) + reply.data[3];
|
final int secretKeyJsonLength = (reply.data[4] << 8) + reply.data[3];
|
||||||
|
|
||||||
final List<int> secretKeyList =
|
final List<int> secretKeyList =
|
||||||
@ -110,7 +112,8 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
|
|
||||||
/// 配网成功后,赋值锁的peerId
|
/// 配网成功后,赋值锁的peerId
|
||||||
StartChartManage().lockPeerId = peerId ?? '';
|
StartChartManage().lockPeerId = peerId ?? '';
|
||||||
|
dismissEasyLoading();
|
||||||
|
state.isLoading.value = false;
|
||||||
// 保存到缓存
|
// 保存到缓存
|
||||||
await Storage.saveLockNetWorkInfo(jsonMap);
|
await Storage.saveLockNetWorkInfo(jsonMap);
|
||||||
// 上报服务器
|
// 上报服务器
|
||||||
@ -126,6 +129,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
showToast('配网失败'.tr);
|
showToast('配网失败'.tr);
|
||||||
|
state.isLoading.value = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,6 +142,10 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 点击配置wifi
|
// 点击配置wifi
|
||||||
Future<void> senderConfiguringWifiAction() async {
|
Future<void> senderConfiguringWifiAction() async {
|
||||||
|
if (state.isLoading.isTrue) {
|
||||||
|
AppLog.log('正在配网中请勿重复点击');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (state.wifiNameController.text.isEmpty) {
|
if (state.wifiNameController.text.isEmpty) {
|
||||||
showToast('请输入wifi名称'.tr);
|
showToast('请输入wifi名称'.tr);
|
||||||
return;
|
return;
|
||||||
@ -197,11 +205,14 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
password: state.wifiPWDController.text,
|
password: state.wifiPWDController.text,
|
||||||
gatewayConfigurationStr: state.getGatewayConfigurationStr,
|
gatewayConfigurationStr: state.getGatewayConfigurationStr,
|
||||||
);
|
);
|
||||||
EasyLoading.show();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isAddEquipment: true,
|
isAddEquipment: true,
|
||||||
);
|
);
|
||||||
|
// 显示加载指示器
|
||||||
|
showEasyLoading();
|
||||||
|
state.isLoading.value = true;
|
||||||
|
// 模拟异步请求
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取设备状态
|
// 获取设备状态
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
@ -21,7 +20,8 @@ class ConfiguringWifiPage extends StatefulWidget {
|
|||||||
State<ConfiguringWifiPage> createState() => _ConfiguringWifiPageState();
|
State<ConfiguringWifiPage> createState() => _ConfiguringWifiPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> with RouteAware {
|
class _ConfiguringWifiPageState extends State<ConfiguringWifiPage>
|
||||||
|
with RouteAware {
|
||||||
final ConfiguringWifiLogic logic = Get.put(ConfiguringWifiLogic());
|
final ConfiguringWifiLogic logic = Get.put(ConfiguringWifiLogic());
|
||||||
final ConfiguringWifiState state = Get.find<ConfiguringWifiLogic>().state;
|
final ConfiguringWifiState state = Get.find<ConfiguringWifiLogic>().state;
|
||||||
|
|
||||||
@ -30,24 +30,32 @@ class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> with RouteAwa
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
appBar: TitleAppBar(
|
appBar: TitleAppBar(
|
||||||
barTitle: '配置WiFi'.tr,
|
barTitle: '配置WiFi'.tr,
|
||||||
haveBack: true,
|
haveBack: true,
|
||||||
backgroundColor: AppColors.mainColor),
|
backgroundColor: AppColors.mainColor),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
configuringWifiTFWidget('WiFi名称'.tr, '请输入WiFi名字'.tr, state.wifiNameController),
|
configuringWifiTFWidget(
|
||||||
Container(width: 1.sw, height: 1.h,color: AppColors.mainBackgroundColor),
|
'WiFi名称'.tr, '请输入WiFi名字'.tr, state.wifiNameController),
|
||||||
configuringWifiTFWidget('WiFi密码'.tr, '请输入WiFi密码'.tr, state.wifiPWDController),
|
Container(
|
||||||
SizedBox(height: 50.h,),
|
width: 1.sw, height: 1.h, color: AppColors.mainBackgroundColor),
|
||||||
SubmitBtn(btnName: '确定'.tr, onClick: () {
|
configuringWifiTFWidget(
|
||||||
logic.senderConfiguringWifiAction();
|
'WiFi密码'.tr, '请输入WiFi密码'.tr, state.wifiPWDController),
|
||||||
}),
|
SizedBox(
|
||||||
|
height: 50.h,
|
||||||
|
),
|
||||||
|
SubmitBtn(
|
||||||
|
btnName: '确定'.tr,
|
||||||
|
onClick: () {
|
||||||
|
logic.senderConfiguringWifiAction();
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget configuringWifiTFWidget(
|
Widget configuringWifiTFWidget(
|
||||||
String titleStr, String rightTitle,TextEditingController controller) {
|
String titleStr, String rightTitle, TextEditingController controller) {
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(height: 10.h),
|
Container(height: 10.h),
|
||||||
@ -86,16 +94,16 @@ class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> with RouteAwa
|
|||||||
hintStyle: TextStyle(fontSize: 22.sp),
|
hintStyle: TextStyle(fontSize: 22.sp),
|
||||||
focusedBorder: const OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide:
|
||||||
BorderSide(width: 0, color: Colors.transparent)),
|
BorderSide(width: 0, color: Colors.transparent)),
|
||||||
disabledBorder: const OutlineInputBorder(
|
disabledBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide:
|
||||||
BorderSide(width: 0, color: Colors.transparent)),
|
BorderSide(width: 0, color: Colors.transparent)),
|
||||||
enabledBorder: const OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide:
|
||||||
BorderSide(width: 0, color: Colors.transparent)),
|
BorderSide(width: 0, color: Colors.transparent)),
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide:
|
||||||
BorderSide(width: 0, color: Colors.transparent)),
|
BorderSide(width: 0, color: Colors.transparent)),
|
||||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||||
),
|
),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
@ -26,4 +26,6 @@ class ConfiguringWifiState{
|
|||||||
TextEditingController wifiNameController = TextEditingController();
|
TextEditingController wifiNameController = TextEditingController();
|
||||||
TextEditingController wifiPWDController = TextEditingController();
|
TextEditingController wifiPWDController = TextEditingController();
|
||||||
String getGatewayConfigurationStr = '';
|
String getGatewayConfigurationStr = '';
|
||||||
|
|
||||||
|
RxBool isLoading=false.obs;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user