162 lines
5.2 KiB
Dart
Executable File
162 lines
5.2 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart';
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../blue/blue_manage.dart';
|
|
import '../../../../../tools/appRouteObserver.dart';
|
|
import '../../../../../tools/commonItem.dart';
|
|
import '../../../../../tools/submitBtn.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
import 'configuringWifi_logic.dart';
|
|
|
|
class ConfiguringWifiPage extends StatefulWidget {
|
|
const ConfiguringWifiPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<ConfiguringWifiPage> createState() => _ConfiguringWifiPageState();
|
|
}
|
|
|
|
class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> with RouteAware {
|
|
final ConfiguringWifiLogic logic = Get.put(ConfiguringWifiLogic());
|
|
final ConfiguringWifiState state = Get.find<ConfiguringWifiLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: TitleAppBar(
|
|
barTitle: '配置WiFi'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Column(
|
|
children: <Widget>[
|
|
configuringWifiTFWidget('WiFi名称'.tr, '请输入WiFi名字'.tr, state.wifiNameController),
|
|
Container(width: 1.sw, height: 1.h,color: AppColors.mainBackgroundColor),
|
|
configuringWifiTFWidget('WiFi密码'.tr, '请输入WiFi密码'.tr, state.wifiPWDController),
|
|
SizedBox(height: 50.h,),
|
|
SubmitBtn(btnName: '确定'.tr, onClick: () {
|
|
logic.senderConfiguringWifiAction();
|
|
}),
|
|
],
|
|
));
|
|
}
|
|
|
|
Widget configuringWifiTFWidget(
|
|
String titleStr, String rightTitle,TextEditingController controller) {
|
|
return Column(
|
|
children: <Widget>[
|
|
Container(height: 10.h),
|
|
CommonItem(
|
|
leftTitel: titleStr,
|
|
rightTitle: '',
|
|
isHaveRightWidget: true,
|
|
rightWidget: getTFWidget(rightTitle, controller)),
|
|
Container(height: 10.h),
|
|
],
|
|
);
|
|
}
|
|
|
|
// 接受者信息输入框
|
|
Widget getTFWidget(String tfStr, TextEditingController controller) {
|
|
return Container(
|
|
height: 65.h,
|
|
width: 300.w,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: TextField(
|
|
//输入框一行
|
|
maxLines: 1,
|
|
inputFormatters: <TextInputFormatter>[
|
|
FilteringTextInputFormatter.deny('\n'),
|
|
// LengthLimitingTextInputFormatter(30),
|
|
],
|
|
controller: controller,
|
|
autofocus: false,
|
|
textAlign: TextAlign.end,
|
|
decoration: InputDecoration(
|
|
//输入里面输入文字内边距设置
|
|
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
|
hintText: tfStr,
|
|
hintStyle: TextStyle(fontSize: 22.sp),
|
|
focusedBorder: const OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(width: 0, color: Colors.transparent)),
|
|
disabledBorder: const OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(width: 0, color: Colors.transparent)),
|
|
enabledBorder: const OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(width: 0, color: Colors.transparent)),
|
|
border: const OutlineInputBorder(
|
|
borderSide:
|
|
BorderSide(width: 0, color: Colors.transparent)),
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
|
),
|
|
style: TextStyle(
|
|
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@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;
|
|
}
|
|
}
|