2023-07-10 17:50:31 +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-03-09 13:51:42 +08:00
|
|
|
|
import 'package:star_lock/flavors.dart';
|
2024-05-30 17:43:09 +08:00
|
|
|
|
import 'package:star_lock/tools/customer_tool.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
import '../../appRouters.dart';
|
|
|
|
|
|
import '../../app_settings/app_colors.dart';
|
2023-11-03 13:58:41 +08:00
|
|
|
|
import '../../common/XSConstantMacro/XSConstantMacro.dart';
|
2024-04-12 18:03:40 +08:00
|
|
|
|
import '../../tools/commonItem.dart';
|
2023-07-18 18:10:57 +08:00
|
|
|
|
import '../../tools/tf_loginInput.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
import '../../tools/submitBtn.dart';
|
|
|
|
|
|
import '../../tools/titleAppBar.dart';
|
|
|
|
|
|
import '../../translations/trans_lib.dart';
|
2023-08-02 09:22:39 +08:00
|
|
|
|
import 'starLock_login_logic.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
class StarLockLoginPage extends StatefulWidget {
|
2023-07-15 15:11:28 +08:00
|
|
|
|
const StarLockLoginPage({Key? key}) : super(key: key);
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<StarLockLoginPage> createState() => _StarLockLoginPageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _StarLockLoginPageState extends State<StarLockLoginPage> {
|
2023-08-02 09:22:39 +08:00
|
|
|
|
final logic = Get.put(StarLockLoginLogic());
|
|
|
|
|
|
final state = Get.find<StarLockLoginLogic>().state;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
2023-07-29 10:58:26 +08:00
|
|
|
|
resizeToAvoidBottomInset: false,
|
|
|
|
|
|
backgroundColor: const Color(0xFFFFFFFF),
|
|
|
|
|
|
appBar: TitleAppBar(
|
|
|
|
|
|
barTitle: TranslationLoader.lanKeys!.login!.tr,
|
2023-08-26 11:40:40 +08:00
|
|
|
|
haveBack: false,
|
2023-07-29 10:58:26 +08:00
|
|
|
|
backgroundColor: AppColors.mainColor,
|
|
|
|
|
|
actionsList: [
|
2024-05-30 18:12:15 +08:00
|
|
|
|
const IconButton(
|
2024-05-30 17:43:09 +08:00
|
|
|
|
onPressed: CustomerTool.openCustomerService,
|
|
|
|
|
|
icon: Icon(
|
|
|
|
|
|
Icons.support_agent,
|
2024-05-30 18:12:15 +08:00
|
|
|
|
color: Colors.white,
|
2024-05-30 17:43:09 +08:00
|
|
|
|
)),
|
2023-07-29 10:58:26 +08:00
|
|
|
|
TextButton(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
TranslationLoader.lanKeys!.register!.tr,
|
2023-08-02 09:22:39 +08:00
|
|
|
|
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
2023-07-10 17:50:31 +08:00
|
|
|
|
),
|
2024-03-28 13:46:35 +08:00
|
|
|
|
onPressed: () async {
|
|
|
|
|
|
var data = await Get.toNamed(Routers.starLockRegisterPage);
|
2024-05-03 18:30:45 +08:00
|
|
|
|
if (data != null) {
|
2024-03-28 13:46:35 +08:00
|
|
|
|
state.emailOrPhoneController.text = data['phoneOrEmailStr'];
|
|
|
|
|
|
logic.checkNext(state.emailOrPhoneController);
|
|
|
|
|
|
state.pwdController.text = data['pwd'];
|
|
|
|
|
|
logic.checkNext(state.pwdController);
|
2024-05-13 14:15:06 +08:00
|
|
|
|
setState(() {});
|
2024-03-28 13:46:35 +08:00
|
|
|
|
}
|
2023-07-29 10:58:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
body: ListView(
|
|
|
|
|
|
padding: EdgeInsets.only(top: 120.h, left: 40.w, right: 40.w),
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.all(10.w),
|
2024-03-05 15:54:51 +08:00
|
|
|
|
child: Center(
|
|
|
|
|
|
child: Image.asset('images/icon_main_1024.png',
|
|
|
|
|
|
width: 110.w, height: 110.w))),
|
2023-07-29 10:58:26 +08:00
|
|
|
|
SizedBox(height: 50.w),
|
2024-04-18 16:30:39 +08:00
|
|
|
|
Obx(() => CommonItem(
|
2024-05-03 18:30:45 +08:00
|
|
|
|
leftTitel:
|
|
|
|
|
|
"${"你所在的".tr}${TranslationLoader.lanKeys!.countryAndRegion!.tr}",
|
|
|
|
|
|
rightTitle: "",
|
|
|
|
|
|
isHaveLine: true,
|
|
|
|
|
|
isPadding: false,
|
|
|
|
|
|
isHaveRightWidget: true,
|
|
|
|
|
|
isHaveDirection: true,
|
|
|
|
|
|
rightWidget: Text(
|
|
|
|
|
|
'${state.countryName.value} +${state.countryCode.value}',
|
|
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
|
|
|
|
|
),
|
|
|
|
|
|
action: () async {
|
|
|
|
|
|
var result =
|
|
|
|
|
|
await Get.toNamed(Routers.selectCountryRegionPage);
|
|
|
|
|
|
if (result != null) {
|
|
|
|
|
|
result as Map<String, dynamic>;
|
|
|
|
|
|
state.countryCode.value = result['code'];
|
|
|
|
|
|
state.countryName.value = result['countryName'];
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
)),
|
2024-03-20 15:12:35 +08:00
|
|
|
|
LoginInput(
|
2024-05-03 18:30:45 +08:00
|
|
|
|
focusNode: logic.state.emailOrPhoneFocusNode,
|
2023-08-02 09:22:39 +08:00
|
|
|
|
controller: state.emailOrPhoneController,
|
2024-03-05 15:54:51 +08:00
|
|
|
|
onchangeAction: (v) {
|
2023-08-02 09:22:39 +08:00
|
|
|
|
logic.checkNext(state.emailOrPhoneController);
|
|
|
|
|
|
},
|
2024-03-20 15:12:35 +08:00
|
|
|
|
leftWidget: Padding(
|
|
|
|
|
|
padding: EdgeInsets.only(
|
2024-05-03 18:30:45 +08:00
|
|
|
|
top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
|
2024-03-20 15:12:35 +08:00
|
|
|
|
child: Image.asset(
|
|
|
|
|
|
'images/icon_login_account.png',
|
|
|
|
|
|
width: 36.w,
|
|
|
|
|
|
height: 36.w,
|
|
|
|
|
|
),
|
2023-07-10 17:50:31 +08:00
|
|
|
|
),
|
2024-03-05 15:54:51 +08:00
|
|
|
|
hintText:
|
|
|
|
|
|
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
|
2024-03-19 18:04:51 +08:00
|
|
|
|
// keyboardType: TextInputType.number,
|
2023-07-29 10:58:26 +08:00
|
|
|
|
inputFormatters: [
|
2024-01-23 18:37:03 +08:00
|
|
|
|
// FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
|
|
|
|
|
LengthLimitingTextInputFormatter(30),
|
2023-07-29 10:58:26 +08:00
|
|
|
|
]),
|
|
|
|
|
|
SizedBox(height: 10.h),
|
2024-03-20 15:12:35 +08:00
|
|
|
|
LoginInput(
|
2024-05-03 18:30:45 +08:00
|
|
|
|
focusNode: logic.state.pwdFocusNode,
|
2023-08-02 09:22:39 +08:00
|
|
|
|
controller: state.pwdController,
|
2024-03-05 15:54:51 +08:00
|
|
|
|
onchangeAction: (v) {
|
2023-08-02 09:22:39 +08:00
|
|
|
|
logic.checkNext(state.pwdController);
|
|
|
|
|
|
},
|
2023-07-29 10:58:26 +08:00
|
|
|
|
isPwd: true,
|
2024-05-04 18:14:23 +08:00
|
|
|
|
// isSuffixIcon: 2,
|
2024-03-20 15:12:35 +08:00
|
|
|
|
leftWidget: Padding(
|
|
|
|
|
|
padding: EdgeInsets.only(
|
2024-05-03 18:30:45 +08:00
|
|
|
|
top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
|
2024-03-20 15:12:35 +08:00
|
|
|
|
child: Image.asset(
|
|
|
|
|
|
'images/icon_login_password.png',
|
|
|
|
|
|
width: 36.w,
|
|
|
|
|
|
height: 36.w,
|
|
|
|
|
|
),
|
2023-07-10 17:50:31 +08:00
|
|
|
|
),
|
2024-03-05 15:54:51 +08:00
|
|
|
|
hintText:
|
|
|
|
|
|
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}",
|
2023-07-29 10:58:26 +08:00
|
|
|
|
inputFormatters: [
|
|
|
|
|
|
LengthLimitingTextInputFormatter(20),
|
|
|
|
|
|
]),
|
2024-04-16 17:44:38 +08:00
|
|
|
|
// SizedBox(height: 15.h),
|
2023-07-29 10:58:26 +08:00
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
|
children: [
|
2023-08-02 09:22:39 +08:00
|
|
|
|
Obx(() => GestureDetector(
|
2024-03-05 15:54:51 +08:00
|
|
|
|
onTap: () {
|
2023-08-02 09:22:39 +08:00
|
|
|
|
state.agree.value = !state.agree.value;
|
|
|
|
|
|
logic.changeAgreeState();
|
|
|
|
|
|
},
|
2024-04-16 17:44:38 +08:00
|
|
|
|
child: Container(
|
|
|
|
|
|
// color: Colors.red,
|
2024-05-03 18:30:45 +08:00
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
|
left: 5.w, top: 20.w, right: 10.w, bottom: 20.h),
|
2024-04-16 17:44:38 +08:00
|
|
|
|
child: Image.asset(
|
|
|
|
|
|
state.agree.value
|
|
|
|
|
|
? 'images/icon_round_select.png'
|
|
|
|
|
|
: 'images/icon_round_unSelect.png',
|
|
|
|
|
|
width: 35.w,
|
|
|
|
|
|
height: 35.w,
|
|
|
|
|
|
),
|
2024-03-05 15:54:51 +08:00
|
|
|
|
))),
|
2024-04-16 17:44:38 +08:00
|
|
|
|
// SizedBox(
|
|
|
|
|
|
// width: 5.w,
|
|
|
|
|
|
// ),
|
2023-07-29 10:58:26 +08:00
|
|
|
|
Flexible(
|
|
|
|
|
|
child: RichText(
|
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
|
text: TranslationLoader.lanKeys!.readAndAgree!.tr,
|
2024-03-05 15:54:51 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: const Color(0xff333333), fontSize: 20.sp),
|
2023-07-29 10:58:26 +08:00
|
|
|
|
children: [
|
|
|
|
|
|
WidgetSpan(
|
|
|
|
|
|
alignment: PlaceholderAlignment.middle,
|
|
|
|
|
|
child: GestureDetector(
|
2024-03-05 15:54:51 +08:00
|
|
|
|
child: Text(
|
|
|
|
|
|
'《${TranslationLoader.lanKeys!.userAgreement!.tr}》',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.mainColor,
|
|
|
|
|
|
fontSize: 20.sp)),
|
2023-11-03 13:58:41 +08:00
|
|
|
|
onTap: () {
|
2024-03-05 15:54:51 +08:00
|
|
|
|
Get.toNamed(Routers.webviewShowPage, arguments: {
|
|
|
|
|
|
"url": XSConstantMacro.userAgreementURL,
|
2024-04-07 14:03:59 +08:00
|
|
|
|
"title": '用户协议'.tr
|
2024-03-05 15:54:51 +08:00
|
|
|
|
});
|
2023-11-03 13:58:41 +08:00
|
|
|
|
},
|
2023-07-29 10:58:26 +08:00
|
|
|
|
)),
|
|
|
|
|
|
WidgetSpan(
|
|
|
|
|
|
alignment: PlaceholderAlignment.middle,
|
|
|
|
|
|
child: GestureDetector(
|
2024-03-05 15:54:51 +08:00
|
|
|
|
child: Text(
|
|
|
|
|
|
'《${TranslationLoader.lanKeys!.privacyPolicy!.tr}》',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.mainColor,
|
|
|
|
|
|
fontSize: 20.sp)),
|
2023-11-03 13:58:41 +08:00
|
|
|
|
onTap: () {
|
2024-03-05 15:54:51 +08:00
|
|
|
|
Get.toNamed(Routers.webviewShowPage, arguments: {
|
|
|
|
|
|
"url": XSConstantMacro.privacyPolicyURL,
|
2024-04-07 14:03:59 +08:00
|
|
|
|
"title": '隐私政策'.tr
|
2024-03-05 15:54:51 +08:00
|
|
|
|
});
|
2023-11-03 13:58:41 +08:00
|
|
|
|
},
|
2023-07-29 10:58:26 +08:00
|
|
|
|
)),
|
|
|
|
|
|
],
|
|
|
|
|
|
)),
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: 50.w),
|
2023-08-02 09:22:39 +08:00
|
|
|
|
Obx(() => SubmitBtn(
|
2023-07-29 10:58:26 +08:00
|
|
|
|
btnName: TranslationLoader.lanKeys!.login!.tr,
|
|
|
|
|
|
fontSize: 28.sp,
|
|
|
|
|
|
borderRadius: 20.w,
|
|
|
|
|
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
2023-08-02 09:22:39 +08:00
|
|
|
|
isDisabled: state.canNext.value,
|
2024-03-05 15:54:51 +08:00
|
|
|
|
onClick: state.canNext.value
|
|
|
|
|
|
? () {
|
2024-03-07 12:00:10 +08:00
|
|
|
|
if (state.agree.value == false) {
|
2024-04-07 14:03:59 +08:00
|
|
|
|
logic.showToast('请先同意用户协议及隐私政策'.tr);
|
2024-03-07 12:00:10 +08:00
|
|
|
|
return;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
logic.login();
|
|
|
|
|
|
}
|
2024-03-05 15:54:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
: null)),
|
2023-07-29 10:58:26 +08:00
|
|
|
|
SizedBox(height: 50.w),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
GestureDetector(
|
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
|
// width: 150.w,
|
|
|
|
|
|
height: 50.h,
|
|
|
|
|
|
// color: Colors.red,
|
|
|
|
|
|
child: Center(
|
2024-03-05 15:54:51 +08:00
|
|
|
|
child: Text(
|
|
|
|
|
|
'${TranslationLoader.lanKeys!.forgetPassword!.tr}?',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 22.sp, color: AppColors.mainColor)),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.pushNamed(
|
|
|
|
|
|
context, Routers.starLockForgetPasswordPage);
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
|
width: 10.sp,
|
|
|
|
|
|
)),
|
2024-05-30 17:43:09 +08:00
|
|
|
|
if (F.isLite)
|
|
|
|
|
|
Container()
|
|
|
|
|
|
else
|
|
|
|
|
|
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: () {
|
|
|
|
|
|
Get.toNamed(Routers.demoModeLockDetailPage);
|
|
|
|
|
|
},
|
|
|
|
|
|
)
|
2023-07-29 10:58:26 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
));
|
2023-07-10 17:50:31 +08:00
|
|
|
|
}
|
2024-03-20 15:12:35 +08:00
|
|
|
|
|
2024-05-03 18:30:45 +08:00
|
|
|
|
Widget loginInput(
|
|
|
|
|
|
{TextEditingController? controller,
|
|
|
|
|
|
List<TextInputFormatter>? inputFormatters,
|
|
|
|
|
|
String? hintText,
|
|
|
|
|
|
bool? isHaveLeftWidget,
|
|
|
|
|
|
Widget? leftWidget,
|
|
|
|
|
|
String? label,
|
|
|
|
|
|
bool? isPwd,
|
|
|
|
|
|
BlockStrCallback? onchangeAction}) {
|
2024-03-20 15:12:35 +08:00
|
|
|
|
return Container(
|
|
|
|
|
|
// color: Colors.red,
|
|
|
|
|
|
width: 1.sp,
|
|
|
|
|
|
// height: 200.h,
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Container(
|
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
|
'images/icon_login_password.png',
|
|
|
|
|
|
width: 36.w,
|
|
|
|
|
|
height: 36.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2024-05-03 18:30:45 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: 40.w,
|
|
|
|
|
|
),
|
2024-03-20 15:12:35 +08:00
|
|
|
|
Expanded(
|
|
|
|
|
|
child: TextField(
|
|
|
|
|
|
//输入框一行
|
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
|
controller: controller,
|
|
|
|
|
|
onChanged: onchangeAction,
|
|
|
|
|
|
// autofocus: false,
|
2024-05-03 18:30:45 +08:00
|
|
|
|
inputFormatters: inputFormatters,
|
2024-03-20 15:12:35 +08:00
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
|
//输入里面输入文字内边距设置
|
|
|
|
|
|
contentPadding: const EdgeInsets.only(
|
|
|
|
|
|
top: 8.0, left: -19.0, right: -15.0, bottom: 8.0),
|
|
|
|
|
|
labelText: label,
|
|
|
|
|
|
labelStyle: TextStyle(fontSize: 22.sp),
|
|
|
|
|
|
hintStyle: TextStyle(fontSize: 22.sp),
|
|
|
|
|
|
hintText: hintText,
|
|
|
|
|
|
//不需要输入框下划线
|
|
|
|
|
|
border: InputBorder.none,
|
|
|
|
|
|
//左边图标设置
|
|
|
|
|
|
// icon: isHaveLeftWidget == true
|
|
|
|
|
|
// ? leftWidget
|
|
|
|
|
|
// : SizedBox(
|
|
|
|
|
|
// width: 20.w,
|
|
|
|
|
|
// height: 40.w,
|
|
|
|
|
|
// ),
|
|
|
|
|
|
),
|
|
|
|
|
|
obscureText: isPwd ?? false,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
height: 0.5.h,
|
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
|
}
|