Merge branch 'master_hyx'

This commit is contained in:
anfe 2024-05-03 18:31:17 +08:00
commit 155ec4cf15
9 changed files with 203 additions and 100 deletions

View File

@ -94,7 +94,7 @@ class _StarLockForgetPasswordPageState
logic.checkNext(state.phoneController); logic.checkNext(state.phoneController);
}, },
leftWidget: Padding( leftWidget: Padding(
padding: EdgeInsets.only(top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), padding: EdgeInsets.only(top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
'images/icon_login_account.png', 'images/icon_login_account.png',
width: 36.w, width: 36.w,
@ -115,7 +115,7 @@ class _StarLockForgetPasswordPageState
isPwd: true, isPwd: true,
leftWidget: Padding( leftWidget: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
'images/icon_login_password.png', 'images/icon_login_password.png',
width: 36.w, width: 36.w,
@ -142,7 +142,7 @@ class _StarLockForgetPasswordPageState
isPwd: true, isPwd: true,
leftWidget: Padding( leftWidget: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
'images/icon_login_password.png', 'images/icon_login_password.png',
width: 36.w, width: 36.w,

View File

@ -15,6 +15,43 @@ import 'starLock_login_state.dart';
class StarLockLoginLogic extends BaseGetXController { class StarLockLoginLogic extends BaseGetXController {
final StarLockLoginState state = StarLockLoginState(); final StarLockLoginState state = StarLockLoginState();
final stateMyLogic = Get.put(StarLockMineLogic()).state; final stateMyLogic = Get.put(StarLockMineLogic()).state;
int indexFocusNode = noneFocusNode;
static int noneFocusNode = 0;
static int emailOrPhoneFocusNode = 1;
static int pwdFocusNode = 2;
@override
void onInit() {
super.onInit();
// state.emailOrPhoneFocusNode.addListener(() {
// if (state.emailOrPhoneFocusNode.hasFocus) {
// indexFocusNode = emailOrPhoneFocusNode;
// } else {
// changeInputFocusNode();
// }
// });
// state.pwdFocusNode.addListener(() {
// if (state.pwdFocusNode.hasFocus) {
// indexFocusNode = pwdFocusNode;
// } else {
// changeInputFocusNode();
// }
// });
}
//
void changeInputFocusNode() {
Future.delayed(Duration(milliseconds: 100), () {
if (indexFocusNode == noneFocusNode) {
return;
}
if (indexFocusNode == emailOrPhoneFocusNode) {
state.emailOrPhoneFocusNode.requestFocus();
} else if (indexFocusNode == pwdFocusNode) {
state.pwdFocusNode.requestFocus();
}
});
}
void login() async { void login() async {
var entity = await ApiRepository.to.login( var entity = await ApiRepository.to.login(

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/flavors.dart'; import 'package:star_lock/flavors.dart';
import 'package:star_lock/widget/star_input_formatter.dart';
import '../../appRouters.dart'; import '../../appRouters.dart';
import '../../app_settings/app_colors.dart'; import '../../app_settings/app_colors.dart';
@ -43,7 +43,7 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
), ),
onPressed: () async { onPressed: () async {
var data = await Get.toNamed(Routers.starLockRegisterPage); var data = await Get.toNamed(Routers.starLockRegisterPage);
if(data != null){ if (data != null) {
state.emailOrPhoneController.text = data['phoneOrEmailStr']; state.emailOrPhoneController.text = data['phoneOrEmailStr'];
logic.checkNext(state.emailOrPhoneController); logic.checkNext(state.emailOrPhoneController);
state.pwdController.text = data['pwd']; state.pwdController.text = data['pwd'];
@ -63,35 +63,38 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
width: 110.w, height: 110.w))), width: 110.w, height: 110.w))),
SizedBox(height: 50.w), SizedBox(height: 50.w),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: "${"你所在的".tr}${TranslationLoader.lanKeys!.countryAndRegion!.tr}", leftTitel:
rightTitle: "", "${"你所在的".tr}${TranslationLoader.lanKeys!.countryAndRegion!.tr}",
isHaveLine: true, rightTitle: "",
isPadding: false, isHaveLine: true,
isHaveRightWidget: true, isPadding: false,
isHaveDirection: true, isHaveRightWidget: true,
rightWidget: Text( isHaveDirection: true,
'${state.countryName.value} +${state.countryCode.value}', rightWidget: Text(
textAlign: TextAlign.end, '${state.countryName.value} +${state.countryCode.value}',
style: textAlign: TextAlign.end,
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), style: TextStyle(
), fontSize: 22.sp, color: AppColors.darkGrayTextColor),
action: () async { ),
var result = await Get.toNamed(Routers.selectCountryRegionPage); action: () async {
if (result != null) { var result =
result as Map<String, dynamic>; await Get.toNamed(Routers.selectCountryRegionPage);
state.countryCode.value = result['code']; if (result != null) {
state.countryName.value = result['countryName']; result as Map<String, dynamic>;
} state.countryCode.value = result['code'];
}, state.countryName.value = result['countryName'];
)), }
},
)),
LoginInput( LoginInput(
focusNode: logic.state.emailOrPhoneFocusNode,
controller: state.emailOrPhoneController, controller: state.emailOrPhoneController,
onchangeAction: (v) { onchangeAction: (v) {
logic.checkNext(state.emailOrPhoneController); logic.checkNext(state.emailOrPhoneController);
}, },
leftWidget: Padding( leftWidget: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
'images/icon_login_account.png', 'images/icon_login_account.png',
width: 36.w, width: 36.w,
@ -107,6 +110,7 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
]), ]),
SizedBox(height: 10.h), SizedBox(height: 10.h),
LoginInput( LoginInput(
focusNode: logic.state.pwdFocusNode,
controller: state.pwdController, controller: state.pwdController,
onchangeAction: (v) { onchangeAction: (v) {
logic.checkNext(state.pwdController); logic.checkNext(state.pwdController);
@ -114,7 +118,7 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
isPwd: true, isPwd: true,
leftWidget: Padding( leftWidget: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), top: 30.w, bottom: 20.w, right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
'images/icon_login_password.png', 'images/icon_login_password.png',
width: 36.w, width: 36.w,
@ -137,7 +141,8 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
}, },
child: Container( child: Container(
// color: Colors.red, // color: Colors.red,
padding: EdgeInsets.only(left: 5.w, top:20.w, right: 10.w, bottom:20.h), padding: EdgeInsets.only(
left: 5.w, top: 20.w, right: 10.w, bottom: 20.h),
child: Image.asset( child: Image.asset(
state.agree.value state.agree.value
? 'images/icon_round_select.png' ? 'images/icon_round_select.png'
@ -257,15 +262,15 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
)); ));
} }
Widget loginInput({ Widget loginInput(
TextEditingController? controller, {TextEditingController? controller,
List<TextInputFormatter>? inputFormatters, List<TextInputFormatter>? inputFormatters,
String? hintText, String? hintText,
bool? isHaveLeftWidget, bool? isHaveLeftWidget,
Widget? leftWidget, Widget? leftWidget,
String? label, String? label,
bool? isPwd, bool? isPwd,
BlockStrCallback? onchangeAction}) { BlockStrCallback? onchangeAction}) {
return Container( return Container(
// color: Colors.red, // color: Colors.red,
width: 1.sp, width: 1.sp,
@ -282,7 +287,9 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
height: 36.w, height: 36.w,
), ),
), ),
SizedBox(width: 40.w,), SizedBox(
width: 40.w,
),
Expanded( Expanded(
child: TextField( child: TextField(
// //
@ -290,7 +297,7 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
controller: controller, controller: controller,
onChanged: onchangeAction, onChanged: onchangeAction,
// autofocus: false, // autofocus: false,
inputFormatters:inputFormatters, inputFormatters: inputFormatters,
decoration: InputDecoration( decoration: InputDecoration(
// //
contentPadding: const EdgeInsets.only( contentPadding: const EdgeInsets.only(
@ -322,5 +329,4 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
), ),
); );
} }
} }

View File

@ -17,6 +17,9 @@ class StarLockLoginState {
TextEditingController emailOrPhoneController = TextEditingController(); TextEditingController emailOrPhoneController = TextEditingController();
TextEditingController pwdController = TextEditingController(); TextEditingController pwdController = TextEditingController();
FocusNode emailOrPhoneFocusNode = FocusNode();
FocusNode pwdFocusNode = FocusNode();
StarLockLoginState() { StarLockLoginState() {
// emailOrPhone.value = StoreService.to.getLastUserAccount() as String; // emailOrPhone.value = StoreService.to.getLastUserAccount() as String;
emailOrPhoneController.text = emailOrPhone.value; emailOrPhoneController.text = emailOrPhone.value;

View File

@ -203,7 +203,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
leftWidget: leftWidget:
// Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,), // Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,),
Padding( Padding(
padding: EdgeInsets.only(right: 10.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
state.isIphoneType.value state.isIphoneType.value
? 'images/icon_login_account.png' ? 'images/icon_login_account.png'
@ -227,7 +227,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
}, },
isPwd: true, isPwd: true,
leftWidget: Padding( leftWidget: Padding(
padding: EdgeInsets.only(right: 10.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
child: Image.asset( child: Image.asset(
'images/icon_login_password.png', 'images/icon_login_password.png',
width: 30.w, width: 30.w,

View File

@ -13,6 +13,8 @@ import 'package:get/get.dart';
// flavorizr.yaml // flavorizr.yaml
FutureOr<void> main() async { FutureOr<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await _setCommonServices(); await _setCommonServices();
// //

View File

@ -1,3 +1,4 @@
import 'package:extended_text_field/extended_text_field.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -11,11 +12,11 @@ import 'package:star_lock/app_settings/app_colors.dart';
typedef BlockStrCallback = void Function(dynamic textStr); typedef BlockStrCallback = void Function(dynamic textStr);
typedef BlockClickCallback = void Function(); typedef BlockClickCallback = void Function();
class LoginInput extends StatelessWidget { class LoginInput extends StatefulWidget {
TextEditingController? controller; TextEditingController? controller;
FocusNode? focusNode;
List<TextInputFormatter>? inputFormatters; List<TextInputFormatter>? inputFormatters;
TextInputType? keyboardType; TextInputType? keyboardType;
FocusNode? focusNode;
Color? background; Color? background;
String? hintText; String? hintText;
bool? isHaveLeftWidget; bool? isHaveLeftWidget;
@ -25,70 +26,110 @@ class LoginInput extends StatelessWidget {
bool? isSuffixIcon; bool? isSuffixIcon;
Widget? rightSlot; Widget? rightSlot;
BlockStrCallback? onchangeAction; BlockStrCallback? onchangeAction;
BlockStrCallback? onSubmitted;
BlockClickCallback? onTapAction; BlockClickCallback? onTapAction;
LoginInput( LoginInput({
{Key? key, Key? key,
required this.controller, required this.controller,
this.focusNode, this.rightSlot,
this.rightSlot, this.focusNode,
this.label, this.label,
this.isPwd, this.isPwd,
this.isSuffixIcon, this.isSuffixIcon,
this.inputFormatters, this.inputFormatters,
this.keyboardType, this.keyboardType,
this.background, this.background,
this.hintText, this.hintText,
this.isHaveLeftWidget = true, this.isHaveLeftWidget = true,
this.leftWidget, this.leftWidget,
this.onchangeAction, this.onchangeAction,
this.onTapAction, this.onTapAction,
}) this.onSubmitted,
: super(key: key); }) : super(key: key);
@override
State<LoginInput> createState() => _LoginInputState();
}
class _LoginInputState extends State<LoginInput> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isPwd = widget.isPwd ?? false;
String pwd = (widget.controller?.text ?? '').replaceAll(RegExp(r'.'), '*');
return Container( return Container(
child: Column( decoration: BoxDecoration(
border: Border(bottom: BorderSide(width: 0.5.h, color: Colors.grey)),
),
child: Row(
children: [ children: [
TextField( widget.isHaveLeftWidget == true
// ? widget.leftWidget ?? SizedBox()
maxLines: 1, : SizedBox(
controller: controller, width: 20.w,
focusNode: focusNode, height: 40.w,
onChanged: onchangeAction, ),
onTap: onTapAction, Expanded(
autofocus: false, child: Stack(
inputFormatters: inputFormatters, children: [
decoration: InputDecoration( TextField(
// //
contentPadding: const EdgeInsets.only( maxLines: 1,
top: 8.0, left: -19.0, right: -15.0, bottom: 8.0), controller: widget.controller,
labelText: label, focusNode: widget.focusNode,
labelStyle: TextStyle(fontSize: 22.sp,color: AppColors.darkGrayTextColor), onChanged: (String text) {
hintStyle: TextStyle(fontSize: 22.sp), if (widget.onchangeAction != null) {
hintText: hintText, widget.onchangeAction!(text);
//线 }
border: InputBorder.none, setState(() {});
suffixIcon: (isSuffixIcon ?? false) },
? IconButton( onTap: widget.onTapAction,
icon: const Icon(Icons.clear), autofocus: false,
onPressed: controller!.clear, inputFormatters: widget.inputFormatters,
) textInputAction: TextInputAction.next,
: null, keyboardType: isPwd ? TextInputType.emailAddress : null,
// style: isPwd
icon: isHaveLeftWidget == true ? TextStyle(
? leftWidget fontSize: 22.sp,
: SizedBox( color: Colors.transparent,
width: 20.w, letterSpacing: 2.5,
height: 40.w, fontFamily: 'Monospace',
)
: null,
decoration: InputDecoration(
//
contentPadding: const EdgeInsets.only(
top: 8.0, right: -10.0, bottom: 8.0),
labelText: widget.label,
labelStyle: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
hintStyle: TextStyle(fontSize: 22.sp),
hintText: widget.hintText,
//线
border: InputBorder.none,
suffixIcon: (widget.isSuffixIcon ?? false)
? IconButton(
icon: const Icon(Icons.clear),
onPressed: widget.controller!.clear,
)
: null,
),
),
if (isPwd)
Padding(
padding: EdgeInsets.only(top: 30.h),
child: Text(
pwd,
style: TextStyle(
fontSize: 22.sp,
color: AppColors.darkGrayTextColor,
letterSpacing: 2.0,
fontFamily: 'Monospace',
),
), ),
),
],
), ),
obscureText: isPwd ?? false,
),
Container(
height: 0.5.h,
color: Colors.grey,
), ),
], ],
), ),

View File

@ -0,0 +1,13 @@
import 'package:flutter/services.dart';
class StarInputFormatter extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue, TextEditingValue newValue) {
//
return TextEditingValue(
text: '*' * newValue.text.length,
selection: TextSelection.collapsed(offset: newValue.text.length),
);
}
}

View File

@ -170,6 +170,7 @@ dependencies:
expandable: ^5.0.1 expandable: ^5.0.1
colorfilter_generator: ^0.0.8 colorfilter_generator: ^0.0.8
file_picker: ^5.3.1 file_picker: ^5.3.1
extended_text_field: 13.1.0
dev_dependencies: dev_dependencies: