处理IOS密码不能输入非数字的内容

This commit is contained in:
豌杂 2025-12-18 13:57:19 +08:00
parent 7f3961c8ea
commit d125a2b470
1 changed files with 84 additions and 41 deletions

View File

@ -81,16 +81,19 @@ class _LoginPageState extends State<LoginPage> {
child: SizedBox( child: SizedBox(
height: 77.w, height: 77.w,
width: 77.w, width: 77.w,
child: Image.asset('assets/images/login_logo_icon.png', fit: BoxFit.cover), child: Image.asset('assets/images/login_logo_icon.png',
fit: BoxFit.cover),
), ),
), ),
Container( Container(
margin: EdgeInsets.only(top: 90.r), margin: EdgeInsets.only(top: 90.r),
padding: EdgeInsets.only(top: 50.h, bottom: 16.h, left: 40.w, right: 40.w), padding: EdgeInsets.only(
top: 50.h, bottom: 16.h, left: 40.w, right: 40.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: borderRadius: BorderRadius.only(
BorderRadius.only(topLeft: Radius.circular(30.r), topRight: Radius.circular(30.r)), topLeft: Radius.circular(30.r),
topRight: Radius.circular(30.r)),
/*boxShadow: const [ /*boxShadow: const [
BoxShadow( BoxShadow(
color: Color.fromRGBO(46, 91, 255, 0.1), color: Color.fromRGBO(46, 91, 255, 0.1),
@ -107,8 +110,10 @@ class _LoginPageState extends State<LoginPage> {
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.transparent, color: Colors.transparent,
border: Border.all(width: 1.w, color: const Color(0xFF434343)), border: Border.all(
borderRadius: BorderRadius.all(Radius.circular(17.w)), width: 1.w, color: const Color(0xFF434343)),
borderRadius:
BorderRadius.all(Radius.circular(17.w)),
), ),
child: TextField( child: TextField(
controller: state.userNameController, controller: state.userNameController,
@ -160,24 +165,29 @@ class _LoginPageState extends State<LoginPage> {
padding: EdgeInsets.symmetric(horizontal: 15.w), padding: EdgeInsets.symmetric(horizontal: 15.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.transparent, color: Colors.transparent,
border: Border.all(width: 1.w, color: const Color(0xFF434343)), border: Border.all(
borderRadius: BorderRadius.all(Radius.circular(17.w)), width: 1.w, color: const Color(0xFF434343)),
borderRadius:
BorderRadius.all(Radius.circular(17.w)),
), ),
child: TextField( child: TextField(
focusNode: state.pwdFocus, focusNode: state.pwdFocus,
controller: state.passwordController, controller: state.passwordController,
keyboardType: TextInputType.number, // keyboardType: TextInputType.number,
maxLines: 1, maxLines: 1,
obscureText: state.isShowPwd.value, obscureText: state.isShowPwd.value,
// //
// textInputAction: state.isShowPwd.value?TextInputAction.go:TextInputAction.next, // textInputAction: state.isShowPwd.value?TextInputAction.go:TextInputAction.next,
textInputAction: TextInputAction.send, textInputAction: TextInputAction.send,
enableInteractiveSelection: false, enableInteractiveSelection: false,
onSubmitted: (_) => easyThrottle('LOGIN_EASYTHROTTLE', () async { onSubmitted: (_) =>
easyThrottle('LOGIN_EASYTHROTTLE', () async {
Utils.hideKeyboard(); Utils.hideKeyboard();
await Future.delayed(const Duration(milliseconds: 300)); await Future.delayed(
WidgetsBinding.instance const Duration(milliseconds: 300));
.addPostFrameCallback((_) => logic.toLogin(context, upgradeLogic)); WidgetsBinding.instance.addPostFrameCallback(
(_) =>
logic.toLogin(context, upgradeLogic));
}), }),
style: TextStyle( style: TextStyle(
color: const Color(0xFF434343), color: const Color(0xFF434343),
@ -203,7 +213,8 @@ class _LoginPageState extends State<LoginPage> {
), ),
suffixIcon: InkWell( suffixIcon: InkWell(
onTap: () { onTap: () {
state.isShowPwd.value = !state.isShowPwd.value; state.isShowPwd.value =
!state.isShowPwd.value;
}, },
child: Padding( child: Padding(
padding: EdgeInsets.only(right: 5.r), padding: EdgeInsets.only(right: 5.r),
@ -246,24 +257,35 @@ class _LoginPageState extends State<LoginPage> {
child: Checkbox( child: Checkbox(
// activeColor: Colors.transparent, // // activeColor: Colors.transparent, //
activeColor: Theme.of(context).primaryColor, activeColor:
Theme.of(context).primaryColor,
// checkColor: Colors.white, // checkColor: Colors.white,
value: state.keepPwd.value, value: state.keepPwd.value,
onChanged: (value) { onChanged: (value) {
// Get.focusScope?.nextFocus(); // Get.focusScope?.nextFocus();
FocusScope.of(context).requestFocus(state.pwdFocus); FocusScope.of(context)
FocusScope.of(context).requestFocus(state.theFocus); .requestFocus(state.pwdFocus);
state.keepPwd.value = value ?? false; FocusScope.of(context)
.requestFocus(state.theFocus);
state.keepPwd.value =
value ?? false;
}, },
side: WidgetStateBorderSide.resolveWith( side: WidgetStateBorderSide
.resolveWith(
(Set<WidgetState> states) { (Set<WidgetState> states) {
if (states.contains(WidgetState.selected)) { if (states.contains(
WidgetState.selected)) {
// //
return BorderSide( return BorderSide(
width: 1.5.r, color: Theme.of(context).primaryColor); width: 1.5.r,
color: Theme.of(context)
.primaryColor);
} }
//绿 //绿
return BorderSide(width: 1.r, color: const Color(0xFF434343)); return BorderSide(
width: 1.r,
color: const Color(
0xFF434343));
}, },
)), )),
); );
@ -274,9 +296,12 @@ class _LoginPageState extends State<LoginPage> {
Utils.hideKeyboard(); Utils.hideKeyboard();
Get.focusScope?.nextFocus(); Get.focusScope?.nextFocus();
Get.focusScope?.nextFocus(); Get.focusScope?.nextFocus();
FocusScope.of(context).requestFocus(state.pwdFocus); FocusScope.of(context)
FocusScope.of(context).requestFocus(state.theFocus); .requestFocus(state.pwdFocus);
state.keepPwd.value = !state.keepPwd.value; FocusScope.of(context)
.requestFocus(state.theFocus);
state.keepPwd.value =
!state.keepPwd.value;
}, },
child: Text( child: Text(
'记住密码', '记住密码',
@ -291,21 +316,26 @@ class _LoginPageState extends State<LoginPage> {
), ),
InkWell( InkWell(
onTap: () => Get.toNamed(Routes.register), onTap: () => Get.toNamed(Routes.register),
child: quickText('账号注册', color: const Color(0xFF434343)), child: quickText('账号注册',
color: const Color(0xFF434343)),
) )
], ],
), ),
InkWell( InkWell(
onTap: () => easyThrottle('LOGIN_EASYTHROTTLE', () async { onTap: () =>
easyThrottle('LOGIN_EASYTHROTTLE', () async {
Utils.hideKeyboard(); Utils.hideKeyboard();
await Future.delayed(Duration.zero); await Future.delayed(Duration.zero);
WidgetsBinding.instance.addPostFrameCallback((_) => logic.toLogin(context, upgradeLogic)); WidgetsBinding.instance.addPostFrameCallback(
(_) => logic.toLogin(context, upgradeLogic));
}), }),
child: Obx(() { child: Obx(() {
return Container( return Container(
margin: EdgeInsets.symmetric(vertical: 10.h), margin: EdgeInsets.symmetric(vertical: 10.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: state.canLogin.value ? const Color(0xFF8C68FF) : const Color(0xFFdddddd), color: state.canLogin.value
? const Color(0xFF8C68FF)
: const Color(0xFFdddddd),
/*boxShadow: [ /*boxShadow: [
BoxShadow( BoxShadow(
color: color:
@ -322,7 +352,8 @@ class _LoginPageState extends State<LoginPage> {
alignment: Alignment.center, alignment: Alignment.center,
width: double.infinity, width: double.infinity,
height: 50.h, height: 50.h,
child: quickText('登 录', size: 18.sp, color: Colors.white)); child: quickText('登 录',
size: 18.sp, color: Colors.white));
}), }),
), ),
Row( Row(
@ -343,16 +374,23 @@ class _LoginPageState extends State<LoginPage> {
state.pwdFocus); state.pwdFocus);
FocusScope.of(context).requestFocus( FocusScope.of(context).requestFocus(
state.theFocus);*/ state.theFocus);*/
state.readAgreement.value = value ?? false; state.readAgreement.value =
value ?? false;
}, },
side: WidgetStateBorderSide.resolveWith( side: WidgetStateBorderSide.resolveWith(
(Set<WidgetState> states) { (Set<WidgetState> states) {
if (states.contains(WidgetState.selected)) { if (states
.contains(WidgetState.selected)) {
// //
return BorderSide(width: 1.5.r, color: Theme.of(context).primaryColor); return BorderSide(
width: 1.5.r,
color: Theme.of(context)
.primaryColor);
} }
//绿 //绿
return BorderSide(width: 1.r, color: const Color(0xFF434343)); return BorderSide(
width: 1.r,
color: const Color(0xFF434343));
}, },
), ),
), ),
@ -361,8 +399,9 @@ class _LoginPageState extends State<LoginPage> {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
Get.toNamed(Routes.agreementPage, Get.toNamed(Routes.agreementPage, arguments: {
arguments: {"type": AGREEMENT_KEY.USER_AGREEMENT.name}); "type": AGREEMENT_KEY.USER_AGREEMENT.name
});
}, },
child: quickText( child: quickText(
'请仔细阅读', '请仔细阅读',
@ -371,18 +410,22 @@ class _LoginPageState extends State<LoginPage> {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
Get.toNamed(Routes.agreementPage, Get.toNamed(Routes.agreementPage, arguments: {
arguments: {"type": AGREEMENT_KEY.USER_AGREEMENT.name}); "type": AGREEMENT_KEY.USER_AGREEMENT.name
});
}, },
child: Text( child: Text(
'《用户协议》', '《用户协议》',
style: TextStyle(fontSize: 12.r, color: Theme.of(context).primaryColor), style: TextStyle(
fontSize: 12.r,
color: Theme.of(context).primaryColor),
), ),
), ),
InkWell( InkWell(
onTap: () { onTap: () {
Get.toNamed(Routes.agreementPage, Get.toNamed(Routes.agreementPage, arguments: {
arguments: {"type": AGREEMENT_KEY.PRIVACY_GREEMENT.name}); "type": AGREEMENT_KEY.PRIVACY_GREEMENT.name
});
}, },
child: quickText( child: quickText(
'《隐私协议》', '《隐私协议》',