app-starlock/star_lock/lib/login/login/starLock_login_page.dart
2024-03-08 10:08:16 +08:00

223 lines
8.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../appRouters.dart';
import '../../app_settings/app_colors.dart';
import '../../common/XSConstantMacro/XSConstantMacro.dart';
import '../../tools/tf_loginInput.dart';
import '../../tools/submitBtn.dart';
import '../../tools/titleAppBar.dart';
import '../../translations/trans_lib.dart';
import 'starLock_login_logic.dart';
class StarLockLoginPage extends StatefulWidget {
const StarLockLoginPage({Key? key}) : super(key: key);
@override
State<StarLockLoginPage> createState() => _StarLockLoginPageState();
}
class _StarLockLoginPageState extends State<StarLockLoginPage> {
final logic = Get.put(StarLockLoginLogic());
final state = Get.find<StarLockLoginLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xFFFFFFFF),
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.login!.tr,
haveBack: false,
backgroundColor: AppColors.mainColor,
actionsList: [
TextButton(
child: Text(
TranslationLoader.lanKeys!.register!.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {
Navigator.pushNamed(context, Routers.starLockRegisterPage);
},
),
],
),
body: ListView(
padding: EdgeInsets.only(top: 120.h, left: 40.w, right: 40.w),
children: [
Container(
padding: EdgeInsets.all(10.w),
child: Center(
child: Image.asset('images/icon_main_1024.png',
width: 110.w, height: 110.w))),
SizedBox(height: 50.w),
LoginInput(
controller: state.emailOrPhoneController,
onchangeAction: (v) {
logic.checkNext(state.emailOrPhoneController);
},
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w),
child: Image.asset(
'images/icon_login_account.png',
width: 36.w,
height: 36.w,
),
),
hintText:
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
keyboardType: TextInputType.number,
inputFormatters: [
// FilteringTextInputFormatter.allow(RegExp('[0-9]')),
LengthLimitingTextInputFormatter(30),
]),
SizedBox(height: 10.h),
LoginInput(
controller: state.pwdController,
onchangeAction: (v) {
logic.checkNext(state.pwdController);
},
isPwd: true,
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w),
child: Image.asset(
'images/icon_login_password.png',
width: 36.w,
height: 36.w,
),
),
hintText:
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}",
inputFormatters: [
LengthLimitingTextInputFormatter(20),
]),
SizedBox(height: 20.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Obx(() => GestureDetector(
onTap: () {
state.agree.value = !state.agree.value;
logic.changeAgreeState();
},
child: Image.asset(
state.agree.value
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 30.w,
height: 30.w,
))),
SizedBox(
width: 15.w,
),
Flexible(
child: RichText(
text: TextSpan(
text: TranslationLoader.lanKeys!.readAndAgree!.tr,
style: TextStyle(
color: const Color(0xff333333), fontSize: 20.sp),
children: [
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
child: Text(
'${TranslationLoader.lanKeys!.userAgreement!.tr}',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 20.sp)),
onTap: () {
Get.toNamed(Routers.webviewShowPage, arguments: {
"url": XSConstantMacro.userAgreementURL,
"title": '用户协议'
});
},
)),
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
child: Text(
'${TranslationLoader.lanKeys!.privacyPolicy!.tr}',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 20.sp)),
onTap: () {
Get.toNamed(Routers.webviewShowPage, arguments: {
"url": XSConstantMacro.privacyPolicyURL,
"title": '隐私政策'
});
},
)),
],
)),
)
],
),
SizedBox(height: 50.w),
Obx(() => SubmitBtn(
btnName: TranslationLoader.lanKeys!.login!.tr,
fontSize: 28.sp,
borderRadius: 20.w,
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
isDisabled: state.canNext.value,
onClick: state.canNext.value
? () {
if (state.agree.value == false) {
logic.showToast('请先同意用户协议及隐私政策');
return;
} else {
logic.login();
}
}
: null)),
SizedBox(height: 50.w),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
child: SizedBox(
// width: 150.w,
height: 50.h,
// color: Colors.red,
child: Center(
child: Text(
'${TranslationLoader.lanKeys!.forgetPassword!.tr}',
style: TextStyle(
fontSize: 22.sp, color: AppColors.mainColor)),
),
),
onTap: () {
Navigator.pushNamed(
context, Routers.starLockForgetPasswordPage);
},
),
Expanded(
child: SizedBox(
width: 10.sp,
)),
//提交Google暂时屏蔽
// GestureDetector(
// child: SizedBox(
// // width: 150.w,
// height: 50.h,
// // color: Colors.red,
// child: Center(
// child: Text('演示模式',
// style: TextStyle(
// fontSize: 22.sp, color: AppColors.mainColor)),
// ),
// ),
// onTap: () {
// Get.toNamed(Routers.demoModeLockDetailPage);
// },
// )
],
),
],
));
}
}