185 lines
6.1 KiB
Dart
Executable File
185 lines
6.1 KiB
Dart
Executable File
|
|
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 'package:star_lock/mine/addLock/saveLock/saveLock_state.dart';
|
|
|
|
import '../../../app_settings/app_colors.dart';
|
|
import '../../../tools/appRouteObserver.dart';
|
|
import '../../../tools/submitBtn.dart';
|
|
import '../../../tools/titleAppBar.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 SaveLockLogic logic = Get.put(SaveLockLogic());
|
|
final SaveLockState state = Get.find<SaveLockLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '添加锁'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Column(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
height: 80.h,
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 50.w, right: 50.w),
|
|
width: 1.sw,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Flexible(
|
|
child: Text(
|
|
'如需修改名字请重新命名,点击确定添加锁'.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(
|
|
maxLines: 1,
|
|
focusNode: state.focusNode,
|
|
autofocus: true,
|
|
controller: state.aliNameController,
|
|
onChanged: (String v) {
|
|
state.aliName.value = v;
|
|
},
|
|
textAlign: TextAlign.center,
|
|
inputFormatters: <TextInputFormatter>[
|
|
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,),
|
|
),
|
|
|
|
// focusedBorder: const OutlineInputBorder(
|
|
// borderSide:
|
|
// BorderSide(width: 0, color: Colors.transparent)),
|
|
disabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(50.h)),
|
|
borderSide: BorderSide(color: AppColors.mainColor, width: 1,),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(50.h)),
|
|
borderSide: BorderSide(color: AppColors.mainColor, width: 1)
|
|
),
|
|
// border: const OutlineInputBorder(
|
|
// borderSide:
|
|
// BorderSide(width: 0, color: Colors.transparent)),
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
|
)
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 120.h,
|
|
),
|
|
SubmitBtn(
|
|
btnName: '确定'.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() {
|
|
super.didChangeDependencies();
|
|
|
|
/// 路由订阅
|
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
/// 取消路由订阅
|
|
state.focusNode.unfocus();
|
|
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();
|
|
}
|
|
}
|