330 lines
15 KiB
Dart
330 lines
15 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:school_asignment_app/common/const_text.dart';
|
|
import 'package:school_asignment_app/common/utils/utils.dart';
|
|
import 'package:school_asignment_app/page/global_widget/my_text.dart';
|
|
import 'package:school_asignment_app/routes/app_pages.dart';
|
|
|
|
import 'login_logic.dart';
|
|
|
|
class LoginPage extends StatefulWidget {
|
|
const LoginPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<LoginPage> createState() => _LoginPageState();
|
|
}
|
|
|
|
class _LoginPageState extends State<LoginPage> {
|
|
final logic = Get.find<LoginLogic>();
|
|
final state = Get.find<LoginLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
behavior: HitTestBehavior.translucent,
|
|
onTap: () {
|
|
Utils.hideKeyboard();
|
|
// FocusScope.of(context).requestFocus(state.theFocus);
|
|
},
|
|
child: AnnotatedRegion(
|
|
value: const SystemUiOverlayStyle(
|
|
statusBarColor: Colors.transparent,
|
|
systemNavigationBarIconBrightness: Brightness.light,
|
|
statusBarIconBrightness: Brightness.light,
|
|
statusBarBrightness: Brightness.dark,
|
|
),
|
|
child: Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
resizeToAvoidBottomInset: false,
|
|
body: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
alignment: Alignment.center,
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/images/login_bg.png'),
|
|
fit: BoxFit.fill, // 完全填充
|
|
),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
width: 86.w,
|
|
height: 86.w,
|
|
alignment: Alignment.center,
|
|
child: SizedBox(
|
|
height: 86.w,
|
|
width: 86.w,
|
|
child: Image.asset('assets/images/login_logo.png',
|
|
fit: BoxFit.cover),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(
|
|
horizontal: 32.w, vertical: 24.h),
|
|
padding: EdgeInsets.only(
|
|
top: 34.h, bottom: 16.h, left: 22.w, right: 22.w),
|
|
color: Colors.transparent,
|
|
/* decoration: BoxDecoration(
|
|
color: Colors.transparent,
|
|
border: Border.all(width: 1.w, color: Colors.white),
|
|
borderRadius: BorderRadius.all(Radius.circular(10.w)),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Color.fromRGBO(46, 91, 255, 0.1),
|
|
offset: Offset.zero, //阴影y轴偏移量
|
|
blurRadius: 100, //阴影模糊程度
|
|
spreadRadius: 100, //阴影扩散程度
|
|
)
|
|
],
|
|
),*/
|
|
child: Column(children: [
|
|
Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 10.r),
|
|
decoration: BoxDecoration(
|
|
color: Colors.transparent,
|
|
border: Border.all(width: 1.w, color: const Color(0xFFAECBFF)),
|
|
borderRadius: BorderRadius.all(Radius.circular(17.w)),
|
|
),
|
|
child: Center(
|
|
child: TextField(
|
|
controller: state.userNameController,
|
|
/* maxLines: 1,
|
|
maxLength: 20,*/
|
|
textInputAction: TextInputAction.next,
|
|
onEditingComplete: () {
|
|
Get.focusScope?.nextFocus();
|
|
// FocusScope.of(context).requestFocus(_pwdFocus);
|
|
},
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
hintText: "请输入账号",
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.white,),
|
|
// labelText: "账号",
|
|
labelStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.white,),
|
|
border: InputBorder.none,
|
|
prefixIcon:Image.asset('assets/images/login_account.png',width: 20.r,height: 20.r,),
|
|
/* suffixIcon: !state.hasNameVal
|
|
? null
|
|
: Transform.translate(
|
|
offset:
|
|
Offset(10, 10), // 根据原始组件的padding值来设置偏移量
|
|
child: IconButton(
|
|
alignment: Alignment.center,
|
|
padding: EdgeInsets.zero,
|
|
icon: Icon(
|
|
Icons.highlight_off_sharp,
|
|
color: Colors.grey,
|
|
size: 16.r,
|
|
),
|
|
onPressed: () {
|
|
state.userNameController
|
|
.clear(); // 清空文本框内容
|
|
state.passwordController.clear();
|
|
},
|
|
),
|
|
),*/
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 15.r,),
|
|
Obx(() {
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 10.r),
|
|
decoration: BoxDecoration(
|
|
color: Colors.transparent,
|
|
border: Border.all(width: 1.w, color: const Color(0xFFAECBFF)),
|
|
borderRadius: BorderRadius.all(Radius.circular(17.w)),
|
|
),
|
|
child: TextField(
|
|
focusNode: state.pwdFocus,
|
|
controller: state.passwordController,
|
|
keyboardType: TextInputType.number,
|
|
maxLines: 1,
|
|
obscureText: state.isShowPwd.value,
|
|
//隐藏密码显示
|
|
textInputAction: TextInputAction.go,
|
|
// onSubmitted: (val) => toLogin(),
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
decoration: InputDecoration(
|
|
hintText: "请输入密码",
|
|
/* suffix: GestureDetector(
|
|
onTap: logic.showPassword,
|
|
child: Icon(
|
|
Icons.remove_red_eye,
|
|
color: state.isShowPwd.value
|
|
? Theme.of(context).primaryColor
|
|
: Colors.grey,
|
|
),
|
|
),*/
|
|
prefixIcon: Image.asset('assets/images/login_pwd.png',width: 20.r,height: 20.r,),
|
|
hintStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.white,),
|
|
border: InputBorder.none,
|
|
// labelText: "密码",
|
|
isDense: true,
|
|
labelStyle: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.white,),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
SizedBox(
|
|
height: 22.h,
|
|
),
|
|
/* Row(
|
|
children: [
|
|
Container(
|
|
width: 30.w,
|
|
padding: EdgeInsets.only(right: 10.w),
|
|
child: Obx(() {
|
|
return Checkbox(
|
|
activeColor: Theme.of(context).primaryColor,
|
|
checkColor: Colors.white,
|
|
value: state.keepPwd.value,
|
|
onChanged: (value) {
|
|
Get.focusScope?.nextFocus();
|
|
*//* FocusScope.of(context).requestFocus(
|
|
state.pwdFocus);
|
|
FocusScope.of(context).requestFocus(
|
|
state.theFocus);*//*
|
|
state.keepPwd.value = value ?? false;
|
|
},
|
|
);
|
|
}),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Utils.hideKeyboard();
|
|
*//*Get.focusScope?.nextFocus();
|
|
Get.focusScope?.nextFocus();*//*
|
|
|
|
*//* FocusScope.of(context).requestFocus(
|
|
state.pwdFocus);
|
|
FocusScope.of(context).requestFocus(
|
|
state.theFocus);*//*
|
|
state.keepPwd.value = !state.keepPwd.value;
|
|
},
|
|
child: Text(
|
|
'记住密码',
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),*/
|
|
InkWell(
|
|
onTap: () {
|
|
logic.toLogin();
|
|
// Get.toNamed(Routes.home);
|
|
},
|
|
child: Obx(() {
|
|
return Container(
|
|
margin: EdgeInsets.symmetric(vertical: 10.h),
|
|
decoration: BoxDecoration(
|
|
color: state.canLogin.value
|
|
? const Color.fromRGBO(107, 104, 252, 1)
|
|
: const Color(0xFFdddddd),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color:
|
|
const Color.fromRGBO(46, 91, 255, 0.5),
|
|
offset: Offset(6.w, 10.h), //阴影y轴偏移量
|
|
blurRadius: 14, //阴影模糊程度
|
|
spreadRadius: 0.5, //阴影扩散程度
|
|
)
|
|
],
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(17.w),
|
|
),
|
|
),
|
|
alignment: Alignment.center,
|
|
width: double.infinity,
|
|
height: 50.h,
|
|
child: Text(
|
|
'登 录',
|
|
style: TextStyle(
|
|
fontSize: 16.sp, color: Colors.white),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 30.w,
|
|
padding: EdgeInsets.only(right: 10.w),
|
|
child: Obx(() {
|
|
return Checkbox(
|
|
activeColor: Theme.of(context).primaryColor,
|
|
checkColor: Colors.white,
|
|
value: state.readAgreement.value,
|
|
onChanged: (value) {
|
|
Utils.hideKeyboard();
|
|
/* FocusScope.of(context).requestFocus(
|
|
state.pwdFocus);
|
|
FocusScope.of(context).requestFocus(
|
|
state.theFocus);*/
|
|
state.readAgreement.value = value ?? false;
|
|
},
|
|
);
|
|
}),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Get.toNamed(Routes.agreementPage, arguments: {
|
|
"type": AGREEMENT_KEY.USER_AGREEMENT.name
|
|
});
|
|
},
|
|
child: quickText('请仔细阅读', size: 13.sp),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Get.toNamed(Routes.agreementPage, arguments: {
|
|
"type": AGREEMENT_KEY.USER_AGREEMENT.name
|
|
});
|
|
},
|
|
child: Text(
|
|
'《用户协议》',
|
|
style: TextStyle(
|
|
fontSize: 14.r,
|
|
color: Colors.deepOrangeAccent),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
]),
|
|
)
|
|
],
|
|
),
|
|
)),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
Get.delete<LoginLogic>();
|
|
super.dispose();
|
|
}
|
|
}
|