386 lines
15 KiB
Dart
Executable File
386 lines
15 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'package:flutter/widgets.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:star_lock/flavors.dart';
|
||
import 'package:star_lock/login/login/starLock_login_state.dart';
|
||
import 'package:star_lock/tools/customer_tool.dart';
|
||
import 'package:url_launcher/url_launcher.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 StarLockLoginXHJPage extends StatefulWidget {
|
||
const StarLockLoginXHJPage({Key? key}) : super(key: key);
|
||
|
||
@override
|
||
State<StarLockLoginXHJPage> createState() => _StarLockLoginPageState();
|
||
}
|
||
|
||
class _StarLockLoginPageState extends State<StarLockLoginXHJPage> {
|
||
final StarLockLoginLogic logic = Get.put(StarLockLoginLogic());
|
||
final StarLockLoginState state = Get.find<StarLockLoginLogic>().state;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
resizeToAvoidBottomInset: false,
|
||
backgroundColor: const Color(0xFFFFFFFF),
|
||
body: ListView(
|
||
padding: EdgeInsets.only(
|
||
top: 110.h,
|
||
),
|
||
children: <Widget>[
|
||
Padding(
|
||
padding: EdgeInsets.symmetric(horizontal: 40.w),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: <Widget>[
|
||
Row(
|
||
children: [
|
||
Expanded(
|
||
child: Text(
|
||
'${"欢迎使用".tr}${F.title}',
|
||
style: TextStyle(
|
||
color: AppColors.darkGrayTextColor,
|
||
fontSize: 48.sp,
|
||
),
|
||
),
|
||
),
|
||
IconButton(
|
||
onPressed: CustomerTool.openCustomerService,
|
||
icon: Icon(
|
||
Icons.support_agent,
|
||
color: AppColors.mainColor,
|
||
)),
|
||
],
|
||
),
|
||
SizedBox(height: 30.h),
|
||
GestureDetector(
|
||
onTap: () async {
|
||
final result =
|
||
await Get.toNamed(Routers.selectCountryRegionPage);
|
||
if (result != null) {
|
||
result as Map<String, dynamic>;
|
||
state.countryCode.value = result['code'];
|
||
state.countryName.value = result['countryName'];
|
||
}
|
||
},
|
||
child: Container(
|
||
color: Colors.transparent,
|
||
child: Row(
|
||
children: <Widget>[
|
||
SizedBox(
|
||
width: 5.w,
|
||
),
|
||
Text(
|
||
TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||
style: TextStyle(
|
||
fontSize: 22.sp,
|
||
color: AppColors.darkGrayTextColor),
|
||
),
|
||
SizedBox(
|
||
width: 40.w,
|
||
),
|
||
Obx(() {
|
||
return Text(
|
||
'${state.countryName.value} +${state.countryCode.value}',
|
||
style: TextStyle(
|
||
fontSize: 22.sp, color: AppColors.mainColor),
|
||
);
|
||
})
|
||
],
|
||
),
|
||
),
|
||
),
|
||
LoginInput(
|
||
controller: state.emailOrPhoneController,
|
||
onchangeAction: (v) {
|
||
logic.checkNext(state.emailOrPhoneController);
|
||
},
|
||
leftWidget: Padding(
|
||
padding: EdgeInsets.only(
|
||
top: 30.w,
|
||
bottom: 20.w,
|
||
),
|
||
),
|
||
rightSlot: IconButton(
|
||
icon: const Icon(Icons.close),
|
||
onPressed: () {},
|
||
),
|
||
label: TranslationLoader
|
||
.lanKeys!.pleaseEnterNumberOrEmail!.tr,
|
||
// keyboardType: TextInputType.number,
|
||
inputFormatters: <TextInputFormatter>[
|
||
LengthLimitingTextInputFormatter(30),
|
||
]),
|
||
LoginInput(
|
||
controller: state.pwdController,
|
||
onchangeAction: (v) {
|
||
logic.checkNext(state.pwdController);
|
||
},
|
||
isPwd: true,
|
||
// isSuffixIcon: 2,
|
||
leftWidget: Padding(
|
||
padding: EdgeInsets.only(
|
||
top: 30.w,
|
||
bottom: 20.w,
|
||
),
|
||
),
|
||
label:
|
||
'${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}',
|
||
inputFormatters: <TextInputFormatter>[
|
||
LengthLimitingTextInputFormatter(20),
|
||
]),
|
||
SizedBox(height: 10.h),
|
||
],
|
||
),
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
state.agree.value = !state.agree.value;
|
||
logic.changeAgreeState();
|
||
},
|
||
child: Container(
|
||
color: Colors.transparent,
|
||
padding: EdgeInsets.symmetric(vertical: 30.h, horizontal: 40.w),
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.start,
|
||
children: <Widget>[
|
||
Obx(
|
||
() => Container(
|
||
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,
|
||
),
|
||
),
|
||
),
|
||
Flexible(
|
||
child: RichText(
|
||
text: TextSpan(
|
||
text: TranslationLoader.lanKeys!.readAndAgree!.tr,
|
||
style: TextStyle(
|
||
color: const Color(0xff333333), fontSize: 20.sp),
|
||
children: <InlineSpan>[
|
||
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: <String, String>{
|
||
'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: <String, String>{
|
||
'url': XSConstantMacro.privacyPolicyURL,
|
||
'title': '隐私政策'.tr
|
||
});
|
||
},
|
||
)),
|
||
],
|
||
)),
|
||
)
|
||
],
|
||
),
|
||
),
|
||
),
|
||
Padding(
|
||
padding: EdgeInsets.symmetric(horizontal: 40.w),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: <Widget>[
|
||
SizedBox(height: 5.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: 10.h),
|
||
SizedBox(
|
||
width: Get.width,
|
||
child: ElevatedButton(
|
||
onPressed: () async {
|
||
final dynamic 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(() {});
|
||
}
|
||
},
|
||
style: ElevatedButton.styleFrom(
|
||
backgroundColor: AppColors.mainColor),
|
||
child: Text(
|
||
TranslationLoader.lanKeys!.register!.tr,
|
||
style: TextStyle(fontSize: 22.sp, color: Colors.white),
|
||
),
|
||
),
|
||
),
|
||
SizedBox(height: 5.w),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: <Widget>[
|
||
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(
|
||
width: 1.sp,
|
||
color: Colors.transparent,
|
||
child: Column(
|
||
children: <Widget>[
|
||
Row(
|
||
children: <Widget>[
|
||
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,
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|