2024-04-26 11:39:41 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
import 'package:get/get.dart';
|
2024-07-26 09:21:22 +08:00
|
|
|
|
import 'package:star_lock/login/register/starLock_register_state.dart';
|
2024-04-26 11:39:41 +08:00
|
|
|
|
|
|
|
|
|
|
import '../../appRouters.dart';
|
|
|
|
|
|
import '../../app_settings/app_colors.dart';
|
|
|
|
|
|
import '../../common/XSConstantMacro/XSConstantMacro.dart';
|
|
|
|
|
|
import '../../tools/submitBtn.dart';
|
2024-07-25 14:40:02 +08:00
|
|
|
|
import '../../tools/tf_loginInput.dart';
|
2024-04-26 11:39:41 +08:00
|
|
|
|
import '../../tools/titleAppBar.dart';
|
|
|
|
|
|
import 'starLock_register_logic.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class StarLockRegisterXHJPage extends StatefulWidget {
|
|
|
|
|
|
const StarLockRegisterXHJPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<StarLockRegisterXHJPage> createState() => _StarLockRegisterPageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _StarLockRegisterPageState extends State<StarLockRegisterXHJPage> {
|
2024-07-26 09:21:22 +08:00
|
|
|
|
final StarLockRegisterLogic logic = Get.put(StarLockRegisterLogic());
|
|
|
|
|
|
final StarLockRegisterState state = Get.find<StarLockRegisterLogic>().state;
|
2024-04-26 11:39:41 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
resizeToAvoidBottomInset: false,
|
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
|
appBar: TitleAppBar(
|
2024-08-01 18:54:32 +08:00
|
|
|
|
barTitle: '注册'.tr,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
haveBack: true,
|
|
|
|
|
|
iconColor: AppColors.blackColor,
|
|
|
|
|
|
titleColor: AppColors.blackColor,
|
|
|
|
|
|
backgroundColor: Colors.white),
|
|
|
|
|
|
body: ListView(
|
|
|
|
|
|
padding: EdgeInsets.only(left: 40.w, right: 40.w),
|
2024-07-26 09:21:22 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
topSelectCountryAndRegionWidget(),
|
|
|
|
|
|
middleTFWidget(),
|
|
|
|
|
|
_buildBottomAgreement(),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 10.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
Obx(() {
|
|
|
|
|
|
return SubmitBtn(
|
2024-08-01 18:54:32 +08:00
|
|
|
|
btnName: '注册'.tr,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
// backgroundColorList: state.canSub.value ? [AppColors.mainColor] :[Colors.grey],
|
|
|
|
|
|
fontSize: 30.sp,
|
|
|
|
|
|
borderRadius: 20.w,
|
|
|
|
|
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
|
|
|
|
|
isDisabled: state.canSub.value,
|
|
|
|
|
|
onClick: state.canSub.value
|
|
|
|
|
|
? () {
|
|
|
|
|
|
if (state.agree.value == false) {
|
|
|
|
|
|
logic.showToast('请先同意用户协议及隐私政策'.tr);
|
|
|
|
|
|
return;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
logic.register();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
: null);
|
|
|
|
|
|
}),
|
|
|
|
|
|
],
|
|
|
|
|
|
));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget topSelectCountryAndRegionWidget() {
|
|
|
|
|
|
return Column(
|
2024-07-26 09:21:22 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
Container(
|
|
|
|
|
|
height: 80.h,
|
|
|
|
|
|
child: DefaultTabController(
|
|
|
|
|
|
length: 2,
|
2025-05-07 18:30:19 +08:00
|
|
|
|
initialIndex: state.isIphoneType.value ? 0 : 1,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
child: TabBar(
|
|
|
|
|
|
onTap: (int index) {
|
|
|
|
|
|
state.isIphoneType.value = index == 0;
|
|
|
|
|
|
},
|
2024-08-07 18:00:35 +08:00
|
|
|
|
overlayColor: MaterialStateProperty.resolveWith(
|
|
|
|
|
|
(Set<MaterialState> states) {
|
2024-04-26 11:39:41 +08:00
|
|
|
|
return Colors.transparent;
|
|
|
|
|
|
}),
|
|
|
|
|
|
dividerHeight: 0,
|
|
|
|
|
|
indicatorSize: TabBarIndicatorSize.tab,
|
2025-05-07 18:30:19 +08:00
|
|
|
|
tabs: <Widget>[Text('手机'.tr), Text('邮箱'.tr)],
|
2024-04-26 11:39:41 +08:00
|
|
|
|
indicatorColor: AppColors.mainColor,
|
|
|
|
|
|
labelStyle:
|
|
|
|
|
|
TextStyle(color: AppColors.mainColor, fontSize: 26.sp),
|
|
|
|
|
|
unselectedLabelStyle:
|
|
|
|
|
|
TextStyle(color: AppColors.blackColor, fontSize: 22.sp),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 15.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
GestureDetector(
|
|
|
|
|
|
onTap: () async {
|
2024-07-25 14:40:02 +08:00
|
|
|
|
final result = await Get.toNamed(Routers.selectCountryRegionPage);
|
2024-04-26 11:39:41 +08:00
|
|
|
|
if (result != null) {
|
|
|
|
|
|
result as Map<String, dynamic>;
|
|
|
|
|
|
state.countryCode.value = result['code'];
|
|
|
|
|
|
state.countryName.value = result['countryName'];
|
2024-06-07 10:53:24 +08:00
|
|
|
|
logic.checkIpAction();
|
2024-04-26 11:39:41 +08:00
|
|
|
|
}
|
2024-07-25 14:40:02 +08:00
|
|
|
|
// Get.log("路由返回值: $result, countryCode:${logic.state.countryCode}");
|
2024-04-26 11:39:41 +08:00
|
|
|
|
},
|
|
|
|
|
|
child: Obx(() => Container(
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
height: 70.h,
|
|
|
|
|
|
child: Row(
|
2024-07-26 09:21:22 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
SizedBox(width: 5.w),
|
2024-08-01 18:54:32 +08:00
|
|
|
|
Text('国家/地区'.tr,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 26.sp, color: AppColors.blackColor)),
|
|
|
|
|
|
SizedBox(width: 50.w),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
state.isIphoneType.value
|
|
|
|
|
|
? '${state.countryName.value} +${state.countryCode.value}'
|
|
|
|
|
|
: state.countryName.value,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 26.sp, color: AppColors.mainColor),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
)),
|
2024-08-07 18:00:35 +08:00
|
|
|
|
)
|
2024-04-26 11:39:41 +08:00
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget middleTFWidget() {
|
|
|
|
|
|
return Column(
|
2024-07-26 09:21:22 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
Obx(() => LoginInput(
|
|
|
|
|
|
controller: state.phoneOrEmailController,
|
|
|
|
|
|
onchangeAction: (v) {
|
|
|
|
|
|
logic.checkNext(state.phoneOrEmailController);
|
|
|
|
|
|
},
|
2024-05-04 09:57:08 +08:00
|
|
|
|
leftWidget: SizedBox(),
|
2025-05-07 18:30:19 +08:00
|
|
|
|
label: state.isIphoneType.value ? '请输入手机号'.tr : '请输入邮箱'.tr,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
keyboardType: TextInputType.number,
|
2024-07-26 09:21:22 +08:00
|
|
|
|
inputFormatters: <TextInputFormatter>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
LengthLimitingTextInputFormatter(30),
|
|
|
|
|
|
])),
|
|
|
|
|
|
LoginInput(
|
|
|
|
|
|
controller: state.pwdController,
|
|
|
|
|
|
onchangeAction: (v) {
|
|
|
|
|
|
logic.checkNext(state.pwdController);
|
|
|
|
|
|
},
|
|
|
|
|
|
isPwd: true,
|
2024-05-04 09:57:08 +08:00
|
|
|
|
leftWidget: SizedBox(),
|
2024-07-25 14:40:02 +08:00
|
|
|
|
label: '请输入密码'.tr,
|
2024-07-26 09:21:22 +08:00
|
|
|
|
inputFormatters: <TextInputFormatter>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
LengthLimitingTextInputFormatter(20),
|
|
|
|
|
|
]),
|
|
|
|
|
|
Text(
|
2024-08-01 18:54:32 +08:00
|
|
|
|
'密码必须是8-20位,至少包括数字/字母/符号中的2种'.tr,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
style:
|
2025-05-07 18:30:19 +08:00
|
|
|
|
TextStyle(color: AppColors.placeholderTextColor, fontSize: 20.sp),
|
2024-04-26 11:39:41 +08:00
|
|
|
|
),
|
|
|
|
|
|
LoginInput(
|
|
|
|
|
|
controller: state.sureController,
|
|
|
|
|
|
onchangeAction: (v) {
|
|
|
|
|
|
logic.checkNext(state.sureController);
|
|
|
|
|
|
},
|
|
|
|
|
|
isPwd: true,
|
2024-05-04 09:57:08 +08:00
|
|
|
|
leftWidget: SizedBox(),
|
2024-07-25 14:40:02 +08:00
|
|
|
|
label: '确认密码'.tr,
|
2024-07-26 09:21:22 +08:00
|
|
|
|
inputFormatters: <TextInputFormatter>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
LengthLimitingTextInputFormatter(20),
|
|
|
|
|
|
]),
|
|
|
|
|
|
Row(
|
2024-07-26 09:21:22 +08:00
|
|
|
|
children: <Widget>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
Expanded(
|
|
|
|
|
|
child: LoginInput(
|
|
|
|
|
|
controller: state.codeController,
|
|
|
|
|
|
onchangeAction: (v) {
|
|
|
|
|
|
logic.checkNext(state.codeController);
|
|
|
|
|
|
},
|
2024-05-04 09:57:08 +08:00
|
|
|
|
leftWidget: SizedBox(),
|
2024-07-26 09:21:22 +08:00
|
|
|
|
label: '请输入验证码'.tr,
|
|
|
|
|
|
inputFormatters: <TextInputFormatter>[
|
2024-04-26 11:39:41 +08:00
|
|
|
|
LengthLimitingTextInputFormatter(20),
|
|
|
|
|
|
]),
|
|
|
|
|
|
),
|
|
|
|
|
|
Obx(() => GestureDetector(
|
2024-09-23 15:45:39 +08:00
|
|
|
|
onTap: (state.canSendCode.value && state.canResend.value)
|
|
|
|
|
|
? () async {
|
|
|
|
|
|
// Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value});
|
|
|
|
|
|
final result = await Get.toNamed(
|
|
|
|
|
|
Routers.safetyVerificationPage,
|
|
|
|
|
|
arguments: <String, Object>{
|
|
|
|
|
|
'countryCode': state.countryCode,
|
|
|
|
|
|
'account': state.phoneOrEmailStr.value
|
|
|
|
|
|
});
|
|
|
|
|
|
state.xWidth.value =
|
|
|
|
|
|
(result as Map<String, dynamic>)['xWidth'];
|
|
|
|
|
|
logic.sendValidationCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
: null,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: EdgeInsets.all(10.h),
|
2024-09-13 14:50:36 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2024-09-23 15:45:39 +08:00
|
|
|
|
color:
|
|
|
|
|
|
(state.canSendCode.value && state.canResend.value)
|
|
|
|
|
|
? AppColors.mainColor
|
|
|
|
|
|
: AppColors.btnDisableColor,
|
2024-09-13 14:50:36 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(5)),
|
2024-04-26 11:39:41 +08:00
|
|
|
|
child: Center(
|
|
|
|
|
|
child: Text(state.btnText.value,
|
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
|
style: TextStyle(
|
2024-09-13 14:50:36 +08:00
|
|
|
|
color: Colors.white,
|
2024-04-26 11:39:41 +08:00
|
|
|
|
fontSize: 22.sp,
|
|
|
|
|
|
)),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
)),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: 20.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: 50.w),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildBottomAgreement() {
|
2024-08-27 11:08:44 +08:00
|
|
|
|
return Padding(
|
2025-05-07 18:30:19 +08:00
|
|
|
|
padding: EdgeInsets.only(bottom: 20.w),
|
2024-08-27 11:08:44 +08:00
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Obx(() => GestureDetector(
|
2025-05-07 18:30:19 +08:00
|
|
|
|
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,
|
|
|
|
|
|
),
|
|
|
|
|
|
))),
|
2024-08-27 11:08:44 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: 10.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
Flexible(
|
|
|
|
|
|
child: RichText(
|
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
|
text: '我已阅读并同意'.tr,
|
2025-05-07 18:30:19 +08:00
|
|
|
|
style: TextStyle(color: const Color(0xff333333), fontSize: 20.sp),
|
2024-08-27 11:08:44 +08:00
|
|
|
|
children: <InlineSpan>[
|
|
|
|
|
|
WidgetSpan(
|
|
|
|
|
|
alignment: PlaceholderAlignment.middle,
|
|
|
|
|
|
child: GestureDetector(
|
2025-05-07 18:30:19 +08:00
|
|
|
|
child: Text('《${'用户协议'.tr}》',
|
2024-08-27 11:08:44 +08:00
|
|
|
|
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(
|
2025-05-07 18:30:19 +08:00
|
|
|
|
child: Text('《${'隐私政策'.tr}》',
|
2024-08-27 11:08:44 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.mainColor, fontSize: 20.sp)),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Get.toNamed(Routers.webviewShowPage,
|
|
|
|
|
|
arguments: <String, String>{
|
|
|
|
|
|
'url': XSConstantMacro.privacyPolicyURL,
|
|
|
|
|
|
'title': '隐私政策'.tr
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
)),
|
|
|
|
|
|
],
|
|
|
|
|
|
)),
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
2024-04-26 11:39:41 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|