fix:调整登录页面键盘无法收起的问题

This commit is contained in:
liyi 2025-08-18 18:18:02 +08:00
parent f48e7c8274
commit 335f66a0b5

View File

@ -80,231 +80,236 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
), ),
], ],
), ),
body: ListView( body: GestureDetector(
padding: EdgeInsets.only(top: 120.h, left: 40.w, right: 40.w), onTap: (){
children: <Widget>[ FocusScope.of(context).unfocus();
Container( },
padding: EdgeInsets.all(10.w), child: ListView(
child: Center( padding: EdgeInsets.only(top: 120.h, left: 40.w, right: 40.w),
child: Image.asset('images/icon_main_sky_1024.png', children: <Widget>[
width: 110.w, height: 110.w))), Container(
SizedBox(height: 50.w), padding: EdgeInsets.all(10.w),
Obx(() => CommonItem( child: Center(
leftTitel: '你所在的国家/地区'.tr, child: Image.asset('images/icon_main_sky_1024.png',
rightTitle: '', width: 110.w, height: 110.w))),
isHaveLine: true, SizedBox(height: 50.w),
isPadding: false, Obx(() => CommonItem(
isHaveRightWidget: true, leftTitel: '你所在的国家/地区'.tr,
isHaveDirection: true, rightTitle: '',
rightWidget: Text( isHaveLine: true,
'${state.countryName} +${state.countryCode.value}', isPadding: false,
textAlign: TextAlign.end, isHaveRightWidget: true,
style: TextStyle( isHaveDirection: true,
fontSize: 22.sp, color: AppColors.darkGrayTextColor), rightWidget: Text(
), '${state.countryName} +${state.countryCode.value}',
action: () async { textAlign: TextAlign.end,
final result = style: TextStyle(
await Get.toNamed(Routers.selectCountryRegionPage); fontSize: 22.sp, color: AppColors.darkGrayTextColor),
if (result != null) { ),
result as Map<String, dynamic>; action: () async {
state.countryCode.value = result['code']; final result =
state.countryKey.value = result['countryName']; await Get.toNamed(Routers.selectCountryRegionPage);
logic.checkIpAction(); if (result != null) {
} result as Map<String, dynamic>;
}, state.countryCode.value = result['code'];
)), state.countryKey.value = result['countryName'];
LoginInput( logic.checkIpAction();
focusNode: logic.state.emailOrPhoneFocusNode,
controller: state.emailOrPhoneController,
onchangeAction: (v) {
logic.checkNext(state.emailOrPhoneController);
},
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
child: Image.asset(
'images/icon_login_account.png',
width: 36.w,
height: 36.w,
),
),
hintText: '请输入手机号或者邮箱'.tr,
// keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
// FilteringTextInputFormatter.allow(RegExp('[0-9]')),
LengthLimitingTextInputFormatter(30),
FilteringTextInputFormatter.singleLineFormatter
]),
SizedBox(height: 10.h),
LoginInput(
focusNode: logic.state.pwdFocusNode,
controller: state.pwdController,
onchangeAction: (v) {
logic.checkNext(state.pwdController);
},
isPwd: true,
// isSuffixIcon: 2,
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
child: Image.asset(
'images/icon_login_password.png',
width: 36.w,
height: 36.w,
),
),
hintText: '请输入密码'.tr,
inputFormatters: <TextInputFormatter>[
LengthLimitingTextInputFormatter(20),
]),
// SizedBox(height: 15.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Obx(() => GestureDetector(
onTap: () {
state.agree.value = !state.agree.value;
logic.changeAgreeState();
},
child: Container(
// color: Colors.red,
padding: EdgeInsets.only(
left: 5.w, top: 20.w, right: 10.w, bottom: 20.h),
child: Image.asset(
state.agree.value
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 35.w,
height: 35.w,
),
))),
// SizedBox(
// width: 5.w,
// ),
Flexible(
child: RichText(
text: TextSpan(
text: '我已阅读并同意'.tr,
style: TextStyle(
color: const Color(0xff333333), fontSize: 20.sp),
children: <InlineSpan>[
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
child: Text('${'用户协议'.tr}',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 20.sp)),
onTap: () {
Get.toNamed(Routers.webviewShowPage,
arguments: <String, String>{
'url': XSConstantMacro.userAgreementURL,
'title': '用户协议'.tr
});
},
)),
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
child: Text('${'隐私政策'.tr}',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 20.sp)),
onTap: () {
Get.toNamed(Routers.webviewShowPage,
arguments: <String, String>{
'url': XSConstantMacro.privacyPolicyURL,
'title': '隐私政策'.tr
});
},
)),
],
)),
)
],
),
SizedBox(height: 50.w),
Obx(() => SubmitBtn(
btnName: '登录'.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('请先同意用户协议及隐私政策'.tr);
return;
} else {
logic.login();
}
} }
: null)), },
// SizedBox(height: 20.w), )),
// Obx(() => Visibility( LoginInput(
// visible: state.isCheckVerifyEnable.value, focusNode: logic.state.emailOrPhoneFocusNode,
// child: SubmitBtn( controller: state.emailOrPhoneController,
// btnName: '一键登录', onchangeAction: (v) {
// fontSize: 28.sp, logic.checkNext(state.emailOrPhoneController);
// borderRadius: 20.w, },
// padding: EdgeInsets.only(top: 25.w, bottom: 25.w), leftWidget: Padding(
// // isDisabled: state.canNext.value, padding: EdgeInsets.only(
// onClick: () { top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
// if (state.agree.value == false) { child: Image.asset(
// logic.showToast('请先同意用户协议及隐私政策'.tr); 'images/icon_login_account.png',
// return; width: 36.w,
// } else { height: 36.w,
// logic.oneClickLoginAction();
// }
// }),
// )),
SizedBox(height: 50.w),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
child: SizedBox(
// width: 150.w,
height: 50.h,
// color: Colors.red,
child: Center(
child: Text('${'忘记密码'.tr}',
style: TextStyle(
fontSize: 22.sp, color: AppColors.mainColor)),
), ),
), ),
onTap: () { hintText: '请输入手机号或者邮箱'.tr,
Navigator.pushNamed( // keyboardType: TextInputType.number,
context, Routers.starLockForgetPasswordPage); inputFormatters: <TextInputFormatter>[
// FilteringTextInputFormatter.allow(RegExp('[0-9]')),
LengthLimitingTextInputFormatter(30),
FilteringTextInputFormatter.singleLineFormatter
]),
SizedBox(height: 10.h),
LoginInput(
focusNode: logic.state.pwdFocusNode,
controller: state.pwdController,
onchangeAction: (v) {
logic.checkNext(state.pwdController);
}, },
), isPwd: true,
Expanded( // isSuffixIcon: 2,
child: SizedBox( leftWidget: Padding(
width: 10.sp, padding: EdgeInsets.only(
)), top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
Obx(() => Visibility( child: Image.asset(
visible: state.isCheckVerifyEnable.value && 'images/icon_login_password.png',
state.currentLanguage == 'zh_CN', width: 36.w,
child: GestureDetector( height: 36.w,
child: SizedBox( ),
// width: 150.w, ),
height: 50.h, hintText: '请输入密码'.tr,
// color: Colors.red, inputFormatters: <TextInputFormatter>[
child: Center( LengthLimitingTextInputFormatter(20),
child: Text('一键登录'.tr, ]),
style: TextStyle( // SizedBox(height: 15.h),
fontSize: 22.sp, Row(
color: AppColors.mainColor)), mainAxisAlignment: MainAxisAlignment.start,
), children: <Widget>[
Obx(() => GestureDetector(
onTap: () {
state.agree.value = !state.agree.value;
logic.changeAgreeState();
},
child: Container(
// color: Colors.red,
padding: EdgeInsets.only(
left: 5.w, top: 20.w, right: 10.w, bottom: 20.h),
child: Image.asset(
state.agree.value
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 35.w,
height: 35.w,
), ),
onTap: () { ))),
logic.oneClickLoginAction(context); // SizedBox(
}, // width: 5.w,
// ),
Flexible(
child: RichText(
text: TextSpan(
text: '我已阅读并同意'.tr,
style: TextStyle(
color: const Color(0xff333333), fontSize: 20.sp),
children: <InlineSpan>[
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
child: Text('${'用户协议'.tr}',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 20.sp)),
onTap: () {
Get.toNamed(Routers.webviewShowPage,
arguments: <String, String>{
'url': XSConstantMacro.userAgreementURL,
'title': '用户协议'.tr
});
},
)),
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
child: Text('${'隐私政策'.tr}',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 20.sp)),
onTap: () {
Get.toNamed(Routers.webviewShowPage,
arguments: <String, String>{
'url': XSConstantMacro.privacyPolicyURL,
'title': '隐私政策'.tr
});
},
)),
],
)),
)
],
),
SizedBox(height: 50.w),
Obx(() => SubmitBtn(
btnName: '登录'.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('请先同意用户协议及隐私政策'.tr);
return;
} else {
logic.login();
}
}
: null)),
// SizedBox(height: 20.w),
// Obx(() => Visibility(
// visible: state.isCheckVerifyEnable.value,
// child: SubmitBtn(
// btnName: '一键登录',
// fontSize: 28.sp,
// borderRadius: 20.w,
// padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
// // isDisabled: state.canNext.value,
// onClick: () {
// if (state.agree.value == false) {
// logic.showToast('请先同意用户协议及隐私政策'.tr);
// return;
// } else {
// logic.oneClickLoginAction();
// }
// }),
// )),
SizedBox(height: 50.w),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
child: SizedBox(
// width: 150.w,
height: 50.h,
// color: Colors.red,
child: Center(
child: Text('${'忘记密码'.tr}',
style: TextStyle(
fontSize: 22.sp, color: AppColors.mainColor)),
), ),
)) ),
], onTap: () {
), Navigator.pushNamed(
], context, Routers.starLockForgetPasswordPage);
},
),
Expanded(
child: SizedBox(
width: 10.sp,
)),
Obx(() => Visibility(
visible: state.isCheckVerifyEnable.value &&
state.currentLanguage == 'zh_CN',
child: GestureDetector(
child: SizedBox(
// width: 150.w,
height: 50.h,
// color: Colors.red,
child: Center(
child: Text('一键登录'.tr,
style: TextStyle(
fontSize: 22.sp,
color: AppColors.mainColor)),
),
),
onTap: () {
logic.oneClickLoginAction(context);
},
),
))
],
),
],
),
)); ));
} }