2024-04-30 14:46:06 +08:00

177 lines
5.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/blue/blue_manage.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/appRouteObserver.dart';
import '../../../tools/submitBtn.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart';
import 'saveLock_logic.dart';
class SaveLockPage extends StatefulWidget {
const SaveLockPage({Key? key}) : super(key: key);
@override
State<SaveLockPage> createState() => _SaveLockPageState();
}
class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
final logic = Get.put(SaveLockLogic());
final state = Get.find<SaveLockLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(barTitle: TranslationLoader.lanKeys!.addLock!.tr, haveBack:true, backgroundColor: AppColors.mainColor),
body: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 80.h,),
Container(
margin: EdgeInsets.only(left: 50.w, right: 50.w),
width: 1.sw,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text(TranslationLoader.lanKeys!.addSuccessfullyPleaseRename!.tr, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w500))
),
],
),
),
SizedBox(height: 80.h,),
Container(
height: 80.h,
// color: Colors.red,
padding: EdgeInsets.only(left: 50.w, right: 50.w),
child: TextField(
controller: state.aliNameController,
onChanged: (v){
state.aliName.value = v;
},
textAlign:TextAlign.center,
inputFormatters: [
LengthLimitingTextInputFormatter(32),
],
// style:TextStyle(height: 1.1, fontSize: 36.sp, fontWeight: FontWeight.w400, color:AppColors.mainColor),
decoration: InputDecoration(
hintText: '请填写信息'.tr,
hintStyle: TextStyle(
// height: 1.1,
fontSize: 24.sp,
fontWeight: FontWeight.w400,
color: const Color(0xFF999999)
),
border: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(50.h)),
///用来配置边框的样式
borderSide: BorderSide(
///设置边框的颜色
color: AppColors.mainColor,
///设置边框的粗细
width: 1,
),
),
///用来配置输入框获取焦点时的颜色
focusedBorder: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(50.h)),
///用来配置边框的样式
borderSide: BorderSide(
///设置边框的颜色
color: AppColors.mainColor,
///设置边框的粗细
width: 1,
),
),
)
),
),
SizedBox(height: 120.h,),
SubmitBtn(
btnName: TranslationLoader.lanKeys!.sure!.tr,
borderRadius: 20.w,
margin: EdgeInsets.only(
left: 50.w,
right: 50.w,
// top: 30.w,
// bottom: 30.w
),
padding: EdgeInsets.only(
top: 25.w,
bottom: 25.w
),
onClick: (){
logic.addUserConnectBlue();
}
),
],
)
);
}
@override
void didChangeDependencies() {
// TODO: implement didChangeDependencies
super.didChangeDependencies();
/// 路由订阅
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
}
@override
void dispose() {
// TODO: implement dispose
/// 取消路由订阅
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
BlueManage().stopScan();
}
/// 从上级界面进入 当前界面即将出现
@override
void didPush() {
super.didPush();
BlueManage().stopScan();
state.ifCurrentScreen.value = true;
}
/// 返回上一个界面 当前界面即将消失
@override
void didPop() {
super.didPop();
BlueManage().stopScan();
logic.dismissEasyLoading();
state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
}
/// 从下级返回 当前界面即将出现
@override
void didPopNext() {
super.didPopNext();
state.ifCurrentScreen.value = true;
}
/// 进入下级界面 当前界面即将消失
@override
void didPushNext() {
super.didPushNext();
state.sureBtnState.value = 0;
state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer();
}
}