From fae6703d8dddf31670630dee2849235ec1149589 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Sat, 2 Aug 2025 12:19:25 +0330 Subject: [PATCH] feat : new auth page --- .../presentation/widget/inputs/r_input.dart | 4 +- .../lib/presentation/pages/auth/logic.dart | 43 ++++-- .../lib/presentation/pages/auth/view.dart | 141 ++++++++++-------- .../pages/inspection_map/view.dart | 1 - .../inspection_map/widget/map/logic.dart | 2 +- .../lib/presentation/widget/captcha/view.dart | 4 + .../lib/presentation/widget/logo_widget.dart | 4 +- 7 files changed, 120 insertions(+), 79 deletions(-) diff --git a/packages/core/lib/presentation/widget/inputs/r_input.dart b/packages/core/lib/presentation/widget/inputs/r_input.dart index cc98965..81c2ff6 100644 --- a/packages/core/lib/presentation/widget/inputs/r_input.dart +++ b/packages/core/lib/presentation/widget/inputs/r_input.dart @@ -49,6 +49,7 @@ class RTextField extends StatefulWidget { final TextInputAction? textInputAction; final double? height; final Iterable? autofillHints; + final InputBorder? focusedBorder; const RTextField({ super.key, @@ -84,6 +85,7 @@ class RTextField extends StatefulWidget { this.hintStyle, this.labelStyle, this.errorStyle, + this.focusedBorder, // 🎨 Decorations this.suffixIcon, @@ -243,7 +245,7 @@ class _RTextFieldState extends State { counter: widget.showCounter ? null : const SizedBox(), hintStyle: widget.hintStyle, enabledBorder: widget._inputBorder, - focusedBorder: widget._inputBorder, + focusedBorder: widget.focusedBorder ?? widget._inputBorder, border: widget._inputBorder, ), ), diff --git a/packages/inspection/lib/presentation/pages/auth/logic.dart b/packages/inspection/lib/presentation/pages/auth/logic.dart index 0e157a2..3d3bc58 100644 --- a/packages/inspection/lib/presentation/pages/auth/logic.dart +++ b/packages/inspection/lib/presentation/pages/auth/logic.dart @@ -16,9 +16,13 @@ enum AuthStatus { init } enum OtpStatus { init, sent, verified, reSend } -class AuthLogic extends GetxController { +class AuthLogic extends GetxController with GetTickerProviderStateMixin { GlobalKey formKey = GlobalKey(); + late AnimationController _textAnimationController; + late Animation textAnimation; + RxBool showCard = false.obs; + Rx> formKeyOtp = GlobalKey().obs; Rx> formKeySentOtp = GlobalKey().obs; Rx usernameController = TextEditingController().obs; @@ -44,6 +48,31 @@ class AuthLogic extends GetxController { final Module _module = Get.arguments; + @override + void onInit() { + super.onInit(); + + _textAnimationController = + AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)) + ..repeat(reverse: true, count: 2).whenComplete(() { + showCard.value = true; + }); + + textAnimation = CurvedAnimation(parent: _textAnimationController, curve: Curves.easeInOut); + } + + @override + void onReady() { + super.onReady(); + //_textAnimationController.forward(); + } + + @override + void onClose() { + _timer?.cancel(); + super.onClose(); + } + void startTimer() { _timer?.cancel(); secondsRemaining.value = 120; @@ -67,18 +96,6 @@ class AuthLogic extends GetxController { return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; } - @override - void onReady() { - super.onReady(); - iLog('module selected : ${_module.toString()}'); - } - - @override - void onClose() { - _timer?.cancel(); - super.onClose(); - } - bool _isFormValid() { final isCaptchaValid = captchaController.formKey.currentState?.validate() ?? false; final isFormValid = formKey.currentState?.validate() ?? false; diff --git a/packages/inspection/lib/presentation/pages/auth/view.dart b/packages/inspection/lib/presentation/pages/auth/view.dart index 0c10507..054ba37 100644 --- a/packages/inspection/lib/presentation/pages/auth/view.dart +++ b/packages/inspection/lib/presentation/pages/auth/view.dart @@ -13,86 +13,97 @@ class AuthPage extends GetView { @override Widget build(BuildContext context) { return Scaffold( - body: SingleChildScrollView( - child: Column( - children: [ - SizedBox(height: 80), - LogoWidget(), - ObxValue((types) { - switch (types.value) { - case AuthType.otp: - //return otpForm(); - case AuthType.useAndPass: - return useAndPassFrom(); - } - }, controller.authType), + body: Stack( + alignment: Alignment.center, - SizedBox(height: 20), - RichText( - text: TextSpan( + children: [ + Assets.vec.bgAuthSvg.svg(fit: BoxFit.fill), + + Padding( + padding: EdgeInsets.symmetric(horizontal: 10.r), + child: FadeTransition( + opacity: controller.textAnimation, + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + spacing: 12, children: [ - TextSpan( - text: 'مطالعه بیانیه ', - style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDark), + Text( + 'به سامانه رصدیار خوش آمدید!', + textAlign: TextAlign.right, + style: AppFonts.yekan25Bold.copyWith(color: Colors.white), ), - TextSpan( - recognizer: TapGestureRecognizer() - ..onTap = () { - Get.bottomSheet( - privacyPolicyWidget(), - isScrollControlled: true, - enableDrag: true, - ignoreSafeArea: false, - ); - }, - text: 'حریم خصوصی', - style: AppFonts.yekan16.copyWith(color: AppColor.blueNormal), + Text( + 'سامانه رصد و پایش زنجیره تامین، تولید و توزیع کالا های اساسی', + textAlign: TextAlign.center, + style: AppFonts.yekan16.copyWith(color: Colors.white), ), ], ), ), - /* SizedBox(height: 18), + ), - ObxValue((types) { - return RichText( - text: TextSpan( + Obx(() { + final screenHeight = MediaQuery.of(context).size.height; + final targetTop = (screenHeight - 676) / 2; + + return AnimatedPositioned( + duration: const Duration(milliseconds: 1200), + curve: Curves.linear, + top: controller.showCard.value ? targetTop : screenHeight, + left: 10.r, + right: 10.r, + child: Container( + width: 381.w, + height: 676.h, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(40), + ), + child: Column( children: [ - TextSpan( - recognizer: - TapGestureRecognizer() - ..onTap = () { - if (controller.authType.value == AuthType.otp) { - controller.authType.value = AuthType.useAndPass; - if (controller.otpStatus.value != - OtpStatus.init) { - controller.otpStatus.value = OtpStatus.init; - } - } else { - controller.authType.value = AuthType.otp; - } - }, - text: - controller.authType.value == AuthType.otp - ? 'ورود با رمز ثابت' - : 'ورود با رمز یکبار مصرف', - - style: AppFonts.yekan14.copyWith( - color: AppColor.blueNormal, + SizedBox(height: 50.h), + LogoWidget(), + SizedBox(height: 20.h), + useAndPassFrom(), + SizedBox(height: 24.h), + RichText( + text: TextSpan( + children: [ + TextSpan( + text: 'مطالعه بیانیه ', + style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDark), + ), + TextSpan( + recognizer: TapGestureRecognizer() + ..onTap = () { + Get.bottomSheet( + privacyPolicyWidget(), + isScrollControlled: true, + enableDrag: true, + ignoreSafeArea: false, + ); + }, + text: 'حریم خصوصی', + style: AppFonts.yekan16.copyWith(color: AppColor.blueNormal), + ), + ], ), ), ], ), - ); - }, controller.authType),*/ - ], - ), + ), + ); + }), + ], ), ); } Widget useAndPassFrom() { return Padding( - padding: EdgeInsets.symmetric(horizontal: 30, vertical: 50), + padding: EdgeInsets.symmetric(horizontal: 30.r), child: Form( key: controller.formKey, child: AutofillGroup( @@ -106,6 +117,10 @@ class AuthPage extends GetView { keyboardType: TextInputType.number, initText: controller.usernameController.value.text, autofillHints: [AutofillHints.username], + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: AppColor.textColor, width: 1), + ), onChanged: (value) async { controller.usernameController.value.text = value; controller.usernameController.refresh(); @@ -144,6 +159,10 @@ class AuthPage extends GetView { label: 'رمز عبور', filled: false, obscure: true, + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: AppColor.textColor, width: 1), + ), controller: passwordController.value, autofillHints: [AutofillHints.password], variant: RTextFieldVariant.password, diff --git a/packages/inspection/lib/presentation/pages/inspection_map/view.dart b/packages/inspection/lib/presentation/pages/inspection_map/view.dart index 044bc48..433fdb9 100644 --- a/packages/inspection/lib/presentation/pages/inspection_map/view.dart +++ b/packages/inspection/lib/presentation/pages/inspection_map/view.dart @@ -177,7 +177,6 @@ class InspectionMapPage extends GetView { } /* - Widget selectedLocationWidget2({ required bool showHint, required SlidableController sliderController, diff --git a/packages/inspection/lib/presentation/pages/inspection_map/widget/map/logic.dart b/packages/inspection/lib/presentation/pages/inspection_map/widget/map/logic.dart index 07a483b..7612628 100644 --- a/packages/inspection/lib/presentation/pages/inspection_map/widget/map/logic.dart +++ b/packages/inspection/lib/presentation/pages/inspection_map/widget/map/logic.dart @@ -97,7 +97,7 @@ class MapLogic extends GetxController with GetTickerProviderStateMixin { isLoading.value = false; } -/* + /* void debouncedUpdateVisibleMarkers({required LatLng center, required double zoom}) { _debounceTimer?.cancel(); _debounceTimer = Timer(const Duration(milliseconds: 300), () { diff --git a/packages/inspection/lib/presentation/widget/captcha/view.dart b/packages/inspection/lib/presentation/widget/captcha/view.dart index 80278f9..1c727b7 100644 --- a/packages/inspection/lib/presentation/widget/captcha/view.dart +++ b/packages/inspection/lib/presentation/widget/captcha/view.dart @@ -50,6 +50,10 @@ class CaptchaWidget extends GetView { child: RTextField( label: 'کد امنیتی', controller: controller.textController, + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: AppColor.textColor, width: 1), + ), keyboardType: TextInputType.numberWithOptions(decimal: false, signed: false), maxLines: 1, maxLength: 6, diff --git a/packages/inspection/lib/presentation/widget/logo_widget.dart b/packages/inspection/lib/presentation/widget/logo_widget.dart index 4cf2a26..b8abdb1 100644 --- a/packages/inspection/lib/presentation/widget/logo_widget.dart +++ b/packages/inspection/lib/presentation/widget/logo_widget.dart @@ -10,8 +10,8 @@ class LogoWidget extends StatelessWidget { children: [ Row(), Assets.images.innerSplash.image( - width: 150, - height: 150, + width: 120.w, + height: 120.h, ), Text( 'سامانه رصدیار',