183 lines
5.8 KiB
Dart
183 lines
5.8 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../../appRouters.dart';
|
|
import '../../../../app_settings/app_colors.dart';
|
|
import '../../../../tools/appRouteObserver.dart';
|
|
import '../../../../tools/noData.dart';
|
|
import '../../../../tools/submitBtn.dart';
|
|
import '../../../../tools/titleAppBar.dart';
|
|
import 'gatewayGetWifiList_logic.dart';
|
|
import 'gatewayGetWifiList_state.dart';
|
|
|
|
class GatewayGetWifiListPage extends StatefulWidget {
|
|
const GatewayGetWifiListPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<GatewayGetWifiListPage> createState() => _GatewayGetWifiListPageState();
|
|
}
|
|
|
|
class _GatewayGetWifiListPageState extends State<GatewayGetWifiListPage> with RouteAware{
|
|
final GatewayGetWifiListLogic logic = Get.put(GatewayGetWifiListLogic());
|
|
final GatewayGetWifiListState state = Get.find<GatewayGetWifiListLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: TitleAppBar(
|
|
barTitle: 'WIFI列表'.tr,
|
|
haveBack: true,
|
|
actionsList: <Widget>[
|
|
TextButton(
|
|
child: Text(
|
|
'刷新'.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
|
),
|
|
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.gatewayConfigurationWifiPage, arguments: {
|
|
'wifiName': wifiNameStr['wifiName'],
|
|
'gatewayModel': state.gatewayModel
|
|
});
|
|
});
|
|
}) : 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.gatewayConfigurationWifiPage, arguments: {
|
|
'wifiName': '',
|
|
'gatewayModel': state.gatewayModel
|
|
});
|
|
}),
|
|
SizedBox(
|
|
height: 64.h,
|
|
)
|
|
],
|
|
)
|
|
);
|
|
}
|
|
|
|
Widget _messageListItem(String wifiName, String rssi, Function() action) {
|
|
return GestureDetector(
|
|
onTap: action,
|
|
child: Container(
|
|
height: 90.h,
|
|
width: 1.sw,
|
|
margin: EdgeInsets.only(bottom: 2.h),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(10.w),
|
|
),
|
|
child: Container(
|
|
width: 1.sw,
|
|
height: 80.h,
|
|
margin: EdgeInsets.only(left: 20.w, right: 40.w),
|
|
child: Column(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
height: 79.h,
|
|
width: 1.sw - 20.w*2,
|
|
child: Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: <Widget>[
|
|
Flexible(
|
|
child: Text(
|
|
'$wifiName(${rssi}db)',
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontSize: 22.sp, color: AppColors.blackColor),
|
|
),
|
|
),
|
|
// Text(
|
|
// rssi,
|
|
// maxLines: 1,
|
|
// overflow: TextOverflow.ellipsis,
|
|
// style: TextStyle(
|
|
// fontSize: 22.sp, color: AppColors.blackColor),
|
|
// )
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
height: 1.h,
|
|
color: AppColors.greyLineColor,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
|
|
/// 路由订阅
|
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
/// 取消路由订阅
|
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
|
super.dispose();
|
|
}
|
|
|
|
/// 从上级界面进入 当前界面即将出现
|
|
@override
|
|
void didPush() {
|
|
super.didPush();
|
|
state.ifCurrentScreen.value = true;
|
|
}
|
|
|
|
/// 返回上一个界面 当前界面即将消失
|
|
@override
|
|
void didPop() {
|
|
super.didPop();
|
|
logic.cancelBlueConnetctToastTimer();
|
|
if (EasyLoading.isShow) {
|
|
EasyLoading.dismiss(animation: true);
|
|
}
|
|
state.ifCurrentScreen.value = false;
|
|
state.sureBtnState.value = 0;
|
|
}
|
|
|
|
/// 从下级返回 当前界面即将出现
|
|
@override
|
|
void didPopNext() {
|
|
super.didPopNext();
|
|
state.ifCurrentScreen.value = true;
|
|
}
|
|
|
|
/// 进入下级界面 当前界面即将消失
|
|
@override
|
|
void didPushNext() {
|
|
super.didPushNext();
|
|
logic.cancelBlueConnetctToastTimer();
|
|
if (EasyLoading.isShow) {
|
|
EasyLoading.dismiss(animation: true);
|
|
}
|
|
state.ifCurrentScreen.value = false;
|
|
state.sureBtnState.value = 0;
|
|
}
|
|
}
|