341 lines
13 KiB
Dart
Executable File
341 lines
13 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:star_lock/flavors.dart';
|
||
import 'package:star_lock/tools/customer_tool.dart';
|
||
|
||
import '../../appRouters.dart';
|
||
import '../../app_settings/app_colors.dart';
|
||
import '../../common/XSConstantMacro/XSConstantMacro.dart';
|
||
import '../../tools/commonItem.dart';
|
||
import '../../tools/tf_loginInput.dart';
|
||
import '../../tools/submitBtn.dart';
|
||
import '../../tools/titleAppBar.dart';
|
||
import '../../translations/trans_lib.dart';
|
||
import 'starLock_login_logic.dart';
|
||
|
||
class StarLockLoginPage extends StatefulWidget {
|
||
const StarLockLoginPage({Key? key}) : super(key: key);
|
||
|
||
@override
|
||
State<StarLockLoginPage> createState() => _StarLockLoginPageState();
|
||
}
|
||
|
||
class _StarLockLoginPageState extends State<StarLockLoginPage> {
|
||
final logic = Get.put(StarLockLoginLogic());
|
||
final state = Get.find<StarLockLoginLogic>().state;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
resizeToAvoidBottomInset: false,
|
||
backgroundColor: const Color(0xFFFFFFFF),
|
||
appBar: TitleAppBar(
|
||
barTitle: TranslationLoader.lanKeys!.login!.tr,
|
||
haveBack: false,
|
||
backgroundColor: AppColors.mainColor,
|
||
actionsList: [
|
||
const IconButton(
|
||
onPressed: CustomerTool.openCustomerService,
|
||
icon: Icon(
|
||
Icons.support_agent,
|
||
color: Colors.white,
|
||
)),
|
||
TextButton(
|
||
child: Text(
|
||
TranslationLoader.lanKeys!.register!.tr,
|
||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||
),
|
||
onPressed: () async {
|
||
var data = await Get.toNamed(Routers.starLockRegisterPage);
|
||
if (data != null) {
|
||
state.emailOrPhoneController.text = data['phoneOrEmailStr'];
|
||
logic.checkNext(state.emailOrPhoneController);
|
||
state.pwdController.text = data['pwd'];
|
||
logic.checkNext(state.pwdController);
|
||
setState(() {});
|
||
}
|
||
},
|
||
),
|
||
],
|
||
),
|
||
body: ListView(
|
||
padding: EdgeInsets.only(top: 120.h, left: 40.w, right: 40.w),
|
||
children: [
|
||
Container(
|
||
padding: EdgeInsets.all(10.w),
|
||
child: Center(
|
||
child: Image.asset('images/icon_main_1024.png',
|
||
width: 110.w, height: 110.w))),
|
||
SizedBox(height: 50.w),
|
||
Obx(() => CommonItem(
|
||
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'];
|
||
}
|
||
},
|
||
)),
|
||
LoginInput(
|
||
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:
|
||
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
|
||
// keyboardType: TextInputType.number,
|
||
inputFormatters: [
|
||
// FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
||
LengthLimitingTextInputFormatter(30),
|
||
]),
|
||
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:
|
||
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}",
|
||
inputFormatters: [
|
||
LengthLimitingTextInputFormatter(20),
|
||
]),
|
||
// SizedBox(height: 15.h),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.start,
|
||
children: [
|
||
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: TranslationLoader.lanKeys!.readAndAgree!.tr,
|
||
style: TextStyle(
|
||
color: const Color(0xff333333), fontSize: 20.sp),
|
||
children: [
|
||
WidgetSpan(
|
||
alignment: PlaceholderAlignment.middle,
|
||
child: GestureDetector(
|
||
child: Text(
|
||
'《${TranslationLoader.lanKeys!.userAgreement!.tr}》',
|
||
style: TextStyle(
|
||
color: AppColors.mainColor,
|
||
fontSize: 20.sp)),
|
||
onTap: () {
|
||
Get.toNamed(Routers.webviewShowPage, arguments: {
|
||
"url": XSConstantMacro.userAgreementURL,
|
||
"title": '用户协议'.tr
|
||
});
|
||
},
|
||
)),
|
||
WidgetSpan(
|
||
alignment: PlaceholderAlignment.middle,
|
||
child: GestureDetector(
|
||
child: Text(
|
||
'《${TranslationLoader.lanKeys!.privacyPolicy!.tr}》',
|
||
style: TextStyle(
|
||
color: AppColors.mainColor,
|
||
fontSize: 20.sp)),
|
||
onTap: () {
|
||
Get.toNamed(Routers.webviewShowPage, arguments: {
|
||
"url": XSConstantMacro.privacyPolicyURL,
|
||
"title": '隐私政策'.tr
|
||
});
|
||
},
|
||
)),
|
||
],
|
||
)),
|
||
)
|
||
],
|
||
),
|
||
SizedBox(height: 50.w),
|
||
Obx(() => SubmitBtn(
|
||
btnName: TranslationLoader.lanKeys!.login!.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: 50.w),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
GestureDetector(
|
||
child: SizedBox(
|
||
// width: 150.w,
|
||
height: 50.h,
|
||
// color: Colors.red,
|
||
child: Center(
|
||
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,
|
||
)),
|
||
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);
|
||
},
|
||
)
|
||
],
|
||
),
|
||
],
|
||
));
|
||
}
|
||
|
||
Widget loginInput(
|
||
{TextEditingController? controller,
|
||
List<TextInputFormatter>? inputFormatters,
|
||
String? hintText,
|
||
bool? isHaveLeftWidget,
|
||
Widget? leftWidget,
|
||
String? label,
|
||
bool? isPwd,
|
||
BlockStrCallback? onchangeAction}) {
|
||
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,
|
||
),
|
||
),
|
||
SizedBox(
|
||
width: 40.w,
|
||
),
|
||
Expanded(
|
||
child: TextField(
|
||
//输入框一行
|
||
maxLines: 1,
|
||
controller: controller,
|
||
onChanged: onchangeAction,
|
||
// autofocus: false,
|
||
inputFormatters: inputFormatters,
|
||
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,
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|