fix: 增加注册页面点击后收起键盘

This commit is contained in:
liyi 2025-09-10 09:17:38 +08:00
parent fac3c060e6
commit 393ee9d2bc

View File

@ -30,39 +30,41 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xFFFFFFFF), backgroundColor: const Color(0xFFFFFFFF),
appBar: TitleAppBar( appBar: TitleAppBar(barTitle: '注册'.tr, haveBack: true, backgroundColor: AppColors.mainColor),
barTitle: '注册'.tr, body: GestureDetector(
haveBack: true, onTap: () {
backgroundColor: AppColors.mainColor), FocusScope.of(context).unfocus();
body: ListView( },
padding: EdgeInsets.only(top: 40.h, left: 40.w, right: 40.w), child: ListView(
children: <Widget>[ padding: EdgeInsets.only(top: 40.h, left: 40.w, right: 40.w),
topSelectCountryAndRegionWidget(), children: <Widget>[
middleTFWidget(), topSelectCountryAndRegionWidget(),
Obx(() { middleTFWidget(),
return SubmitBtn( Obx(() {
btnName: '注册'.tr, return SubmitBtn(
// backgroundColorList: state.canSub.value ? [AppColors.mainColor] :[Colors.grey], btnName: '注册'.tr,
fontSize: 30.sp, // backgroundColorList: state.canSub.value ? [AppColors.mainColor] :[Colors.grey],
borderRadius: 20.w, fontSize: 30.sp,
padding: EdgeInsets.only(top: 25.w, bottom: 25.w), borderRadius: 20.w,
isDisabled: state.canSub.value, padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: state.canSub.value isDisabled: state.canSub.value,
? () { onClick: state.canSub.value
if (state.agree.value == false) { ? () {
logic.showToast('请先同意用户协议及隐私政策'.tr); if (state.agree.value == false) {
return; logic.showToast('请先同意用户协议及隐私政策'.tr);
} else { return;
logic.register(); } else {
logic.register();
}
} }
} : null);
: null); }),
}), SizedBox(
SizedBox( height: 20.h,
height: 20.h, ),
), _buildBottomAgreement()
_buildBottomAgreement() ],
], ),
)); ));
} }
@ -77,9 +79,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
width: 340.w, width: 340.w,
height: 60.h, height: 60.h,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(30.h)), borderRadius: BorderRadius.all(Radius.circular(30.h)), border: Border.all(width: 1.0, color: AppColors.greyLineColor)),
border:
Border.all(width: 1.0, color: AppColors.greyLineColor)),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
GestureDetector( GestureDetector(
@ -93,18 +93,13 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
decoration: state.isIphoneType.value decoration: state.isIphoneType.value
? BoxDecoration( ? BoxDecoration(
color: AppColors.mainColor, color: AppColors.mainColor,
borderRadius: borderRadius: BorderRadius.all(Radius.circular(30.h)),
BorderRadius.all(Radius.circular(30.h)), border: Border.all(width: 1.0, color: AppColors.greyLineColor))
border: Border.all(
width: 1.0, color: AppColors.greyLineColor))
: null, : null,
child: Center( child: Center(
child: Text( child: Text(
'手机'.tr, '手机'.tr,
style: TextStyle( style: TextStyle(color: state.isIphoneType.value ? Colors.white : Colors.black),
color: state.isIphoneType.value
? Colors.white
: Colors.black),
), ),
), ),
), ),
@ -121,19 +116,14 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
decoration: !state.isIphoneType.value decoration: !state.isIphoneType.value
? BoxDecoration( ? BoxDecoration(
color: AppColors.mainColor, color: AppColors.mainColor,
borderRadius: borderRadius: BorderRadius.all(Radius.circular(30.h)),
BorderRadius.all(Radius.circular(30.h)), border: Border.all(width: 1.0, color: AppColors.greyLineColor))
border: Border.all(
width: 1.0,
color: AppColors.greyLineColor))
: null, : null,
child: Center( child: Center(
child: Text( child: Text(
'邮箱'.tr, '邮箱'.tr,
style: TextStyle( style: TextStyle(
color: !state.isIphoneType.value color: !state.isIphoneType.value ? Colors.white : Colors.black,
? Colors.white
: Colors.black,
), ),
), ),
), ),
@ -163,21 +153,15 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
SizedBox(width: 5.w), SizedBox(width: 5.w),
Expanded( Expanded(child: Text('你所在的国家/地区'.tr, style: TextStyle(fontSize: 26.sp, color: AppColors.blackColor))),
child: Text('你所在的国家/地区'.tr,
style: TextStyle(
fontSize: 26.sp, color: AppColors.blackColor))),
SizedBox(width: 20.w), SizedBox(width: 20.w),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
Text( Text(
state.isIphoneType.value state.isIphoneType.value ? '${state.countryName.value} +${state.countryCode.value}' : state.countryName.value,
? '${state.countryName.value} +${state.countryCode.value}'
: state.countryName.value,
textAlign: TextAlign.end, textAlign: TextAlign.end,
style: TextStyle( style: TextStyle(fontSize: 26.sp, color: AppColors.blackColor),
fontSize: 26.sp, color: AppColors.blackColor),
) )
], ],
), ),
@ -212,9 +196,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
Padding( Padding(
padding: EdgeInsets.only(right: 5.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
state.isIphoneType.value state.isIphoneType.value ? 'images/icon_login_account.png' : 'images/icon_login_email.png',
? 'images/icon_login_account.png'
: 'images/icon_login_email.png',
width: 30.w, width: 30.w,
height: 30.w, height: 30.w,
), ),
@ -248,8 +230,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
SizedBox(height: 15.w), SizedBox(height: 15.w),
Text( Text(
'密码必须是8-20位至少包括数字/字母/符号中的2种'.tr, '密码必须是8-20位至少包括数字/字母/符号中的2种'.tr,
style: style: TextStyle(color: AppColors.placeholderTextColor, fontSize: 20.sp),
TextStyle(color: AppColors.placeholderTextColor, fontSize: 20.sp),
), ),
SizedBox(height: 10.w), SizedBox(height: 10.w),
LoginInput( LoginInput(
@ -299,14 +280,9 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
onTap: (state.canSendCode.value && state.canResend.value) onTap: (state.canSendCode.value && state.canResend.value)
? () async { ? () async {
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
final Object? result = await Navigator.pushNamed( final Object? result = await Navigator.pushNamed(context, Routers.safetyVerificationPage,
context, Routers.safetyVerificationPage, arguments: <String, Object>{'countryCode': state.countryCode, 'account': state.phoneOrEmailStr.value});
arguments: <String, Object>{ state.xWidth.value = (result! as Map<String, dynamic>)['xWidth'];
'countryCode': state.countryCode,
'account': state.phoneOrEmailStr.value
});
state.xWidth.value =
(result! as Map<String, dynamic>)['xWidth'];
logic.sendValidationCode(); logic.sendValidationCode();
} }
: null, : null,
@ -315,10 +291,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
// height: 60.h, // height: 60.h,
padding: EdgeInsets.all(10.h), padding: EdgeInsets.all(10.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: (state.canSendCode.value && state.canResend.value) ? AppColors.mainColor : Colors.grey,
(state.canSendCode.value && state.canResend.value)
? AppColors.mainColor
: Colors.grey,
borderRadius: BorderRadius.circular(5)), borderRadius: BorderRadius.circular(5)),
child: Center( child: Center(
child: Text(state.btnText.value, child: Text(state.btnText.value,
@ -347,9 +320,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
logic.changeAgreeState(); logic.changeAgreeState();
}, },
child: Image.asset( child: Image.asset(
state.agree.value state.agree.value ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png',
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 30.w, width: 30.w,
height: 30.w, height: 30.w,
))), ))),
@ -365,29 +336,17 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
WidgetSpan( WidgetSpan(
alignment: PlaceholderAlignment.middle, alignment: PlaceholderAlignment.middle,
child: GestureDetector( child: GestureDetector(
child: Text('${'用户协议'.tr}', child: Text('${'用户协议'.tr}', style: TextStyle(color: AppColors.mainColor, fontSize: 20.sp)),
style: TextStyle(
color: AppColors.mainColor, fontSize: 20.sp)),
onTap: () { onTap: () {
Get.toNamed(Routers.webviewShowPage, Get.toNamed(Routers.webviewShowPage, arguments: <String, String>{'url': XSConstantMacro.userAgreementURL, 'title': '用户协议'.tr});
arguments: <String, String>{
'url': XSConstantMacro.userAgreementURL,
'title': '用户协议'.tr
});
}, },
)), )),
WidgetSpan( WidgetSpan(
alignment: PlaceholderAlignment.middle, alignment: PlaceholderAlignment.middle,
child: GestureDetector( child: GestureDetector(
child: Text('${'隐私政策'.tr}', child: Text('${'隐私政策'.tr}', style: TextStyle(color: AppColors.mainColor, fontSize: 20.sp)),
style: TextStyle(
color: AppColors.mainColor, fontSize: 20.sp)),
onTap: () { onTap: () {
Get.toNamed(Routers.webviewShowPage, Get.toNamed(Routers.webviewShowPage, arguments: <String, String>{'url': XSConstantMacro.privacyPolicyURL, 'title': '隐私政策'.tr});
arguments: <String, String>{
'url': XSConstantMacro.privacyPolicyURL,
'title': '隐私政策'.tr
});
}, },
)), )),
], ],