From 6af8d36184cdebc65c2f094fd8b8f357f0baadba Mon Sep 17 00:00:00 2001 From: DaisyWu <18682150237@163.com> Date: Wed, 7 May 2025 18:30:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20xhj=E3=80=81sky=20=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=89=8B=E6=9C=BA=E9=82=AE=E7=AE=B1=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=BF=AE=E6=94=B9=EF=BC=9A=E2=80=9C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AF=AD=E8=A8=80=E6=98=AF=E9=9D=9E=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E7=AE=80=E4=BD=93=EF=BC=8C=E9=BB=98=E8=AE=A4=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E6=B3=A8=E5=86=8C=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../register/starLock_register_page.dart | 27 +++----- .../register/starLock_register_state.dart | 25 +++++--- .../register/starLock_register_xhj_page.dart | 63 +++++++++---------- 3 files changed, 54 insertions(+), 61 deletions(-) diff --git a/lib/login/register/starLock_register_page.dart b/lib/login/register/starLock_register_page.dart index e9d599e9..a1d2c7ff 100755 --- a/lib/login/register/starLock_register_page.dart +++ b/lib/login/register/starLock_register_page.dart @@ -76,7 +76,6 @@ class _StarLockRegisterPageState extends State { Container( width: 340.w, height: 60.h, - // color: Colors.red, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(30.h)), border: @@ -119,28 +118,22 @@ class _StarLockRegisterPageState extends State { child: Obx( () => Container( height: 60.h, - // color: Colors.red, - decoration: state.isIphoneType.value - ? null - : BoxDecoration( + decoration: !state.isIphoneType.value + ? BoxDecoration( color: AppColors.mainColor, - borderRadius: BorderRadius.all( - Radius.circular( - 30.h, - ), - ), + borderRadius: + BorderRadius.all(Radius.circular(30.h)), border: Border.all( - width: 1.0, - color: AppColors.greyLineColor, - ), - ), + width: 1.0, + color: AppColors.greyLineColor)) + : null, child: Center( child: Text( '邮箱'.tr, style: TextStyle( - color: state.isIphoneType.value - ? Colors.black - : Colors.white, + color: !state.isIphoneType.value + ? Colors.white + : Colors.black, ), ), ), diff --git a/lib/login/register/starLock_register_state.dart b/lib/login/register/starLock_register_state.dart index 3555bd0c..6e6aa5e9 100755 --- a/lib/login/register/starLock_register_state.dart +++ b/lib/login/register/starLock_register_state.dart @@ -3,8 +3,11 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; class StarLockRegisterState { - StarLockRegisterState() { + // 根据系统语言设置默认选中的tab + final Locale? systemLocale = Get.deviceLocale; + isIphoneType.value = systemLocale?.languageCode == 'zh'; + resetResend(); } final TextEditingController phoneOrEmailController = TextEditingController(); @@ -22,16 +25,21 @@ class StarLockRegisterState { RxString verificationCode = ''.obs; RxString xWidth = ''.obs; // 滑动验证码滑动位置 RxBool isIphoneType = true.obs; - RxBool canSub = false.obs;// 是否能提交 + RxBool canSub = false.obs; // 是否能提交 RxBool agree = false.obs; - RxBool canSendCode = false.obs;// 是否能发送验证码 + RxBool canSendCode = false.obs; // 是否能发送验证码 // bool get isEmail => RegexUtil.isEmail(phoneOrEmailStr.value); // bool get isIphone => RegexUtil.isMobileSimple(phoneOrEmailStr.value); - bool get pwdIsOK => pwd.value.isNotEmpty && surePwd.value.isNotEmpty && pwd.value.length >= 8 && surePwd.value.length >= 8; - bool get codeIsOK => verificationCode.value.isNotEmpty && verificationCode.value.length >= 6 ; + bool get pwdIsOK => + pwd.value.isNotEmpty && + surePwd.value.isNotEmpty && + pwd.value.length >= 8 && + surePwd.value.length >= 8; + bool get codeIsOK => + verificationCode.value.isNotEmpty && verificationCode.value.length >= 6; - RxBool canResend = false.obs;// 是否能重新发送,就是验证码倒计时之后的重新发送 + RxBool canResend = false.obs; // 是否能重新发送,就是验证码倒计时之后的重新发送 RxString btnText = ''.obs; int totalSeconds = 120; int currentSecond = 120; @@ -39,9 +47,8 @@ class StarLockRegisterState { void resetResend() { canResend.value = totalSeconds == currentSecond; - btnText.value = !canResend.value - ? '$currentSecond s' - : btnText.value = '获取验证码'.tr; + btnText.value = + !canResend.value ? '$currentSecond s' : btnText.value = '获取验证码'.tr; } void onClose() { diff --git a/lib/login/register/starLock_register_xhj_page.dart b/lib/login/register/starLock_register_xhj_page.dart index de914623..038f85f6 100755 --- a/lib/login/register/starLock_register_xhj_page.dart +++ b/lib/login/register/starLock_register_xhj_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -74,6 +73,7 @@ class _StarLockRegisterPageState extends State { height: 80.h, child: DefaultTabController( length: 2, + initialIndex: state.isIphoneType.value ? 0 : 1, child: TabBar( onTap: (int index) { state.isIphoneType.value = index == 0; @@ -84,10 +84,7 @@ class _StarLockRegisterPageState extends State { }), dividerHeight: 0, indicatorSize: TabBarIndicatorSize.tab, - tabs: [ - Text('手机'.tr), - Text('邮箱'.tr) - ], + tabs: [Text('手机'.tr), Text('邮箱'.tr)], indicatorColor: AppColors.mainColor, labelStyle: TextStyle(color: AppColors.mainColor, fontSize: 26.sp), @@ -144,7 +141,7 @@ class _StarLockRegisterPageState extends State { logic.checkNext(state.phoneOrEmailController); }, leftWidget: SizedBox(), - label:state.isIphoneType.value ? '请输入手机号'.tr : '请输入邮箱'.tr, + label: state.isIphoneType.value ? '请输入手机号'.tr : '请输入邮箱'.tr, keyboardType: TextInputType.number, inputFormatters: [ LengthLimitingTextInputFormatter(30), @@ -163,7 +160,7 @@ class _StarLockRegisterPageState extends State { Text( '密码必须是8-20位,至少包括数字/字母/符号中的2种'.tr, style: - TextStyle(color: AppColors.placeholderTextColor, fontSize: 20.sp), + TextStyle(color: AppColors.placeholderTextColor, fontSize: 20.sp), ), LoginInput( controller: state.sureController, @@ -235,32 +232,31 @@ class _StarLockRegisterPageState extends State { Widget _buildBottomAgreement() { return Padding( - padding: EdgeInsets.only(bottom:20.w), + padding: EdgeInsets.only(bottom: 20.w), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Obx(() => GestureDetector( - onTap: () { - state.agree.value = !state.agree.value; - logic.changeAgreeState(); - }, - child: Container( - width: 40.w, - height: 40.w, - // color: Colors.red, - padding: EdgeInsets.only( - left: 5.w, - right: 10.w, - ), - child: Image.asset( - state.agree.value - ? 'images/icon_round_select.png' - : 'images/icon_round_unSelect.png', - width: 20.w, - height: 20.w, - ), - ) - )), + onTap: () { + state.agree.value = !state.agree.value; + logic.changeAgreeState(); + }, + child: Container( + width: 40.w, + height: 40.w, + // color: Colors.red, + padding: EdgeInsets.only( + left: 5.w, + right: 10.w, + ), + child: Image.asset( + state.agree.value + ? 'images/icon_round_select.png' + : 'images/icon_round_unSelect.png', + width: 20.w, + height: 20.w, + ), + ))), SizedBox( width: 10.w, ), @@ -268,14 +264,12 @@ class _StarLockRegisterPageState extends State { child: RichText( text: TextSpan( text: '我已阅读并同意'.tr, - style: - TextStyle(color: const Color(0xff333333), fontSize: 20.sp), + style: TextStyle(color: const Color(0xff333333), fontSize: 20.sp), children: [ WidgetSpan( alignment: PlaceholderAlignment.middle, child: GestureDetector( - child: Text( - '《${'用户协议'.tr}》', + child: Text('《${'用户协议'.tr}》', style: TextStyle( color: AppColors.mainColor, fontSize: 20.sp)), onTap: () { @@ -289,8 +283,7 @@ class _StarLockRegisterPageState extends State { WidgetSpan( alignment: PlaceholderAlignment.middle, child: GestureDetector( - child: Text( - '《${'隐私政策'.tr}》', + child: Text('《${'隐私政策'.tr}》', style: TextStyle( color: AppColors.mainColor, fontSize: 20.sp)), onTap: () {