diff --git a/lib/Globalconst.dart b/lib/Globalconst.dart index 1e452fb..68c7ff8 100644 --- a/lib/Globalconst.dart +++ b/lib/Globalconst.dart @@ -5,4 +5,5 @@ class Globalconst { static String isdcode = ""; static String createdpin = ""; static String firstName = ""; + static String languageSelected = "en"; } diff --git a/lib/features/biometric/presentation/bloc/biometric_bloc.dart b/lib/features/biometric/bloc/biometric_bloc.dart similarity index 74% rename from lib/features/biometric/presentation/bloc/biometric_bloc.dart rename to lib/features/biometric/bloc/biometric_bloc.dart index 10f9fab..dc5c046 100644 --- a/lib/features/biometric/presentation/bloc/biometric_bloc.dart +++ b/lib/features/biometric/bloc/biometric_bloc.dart @@ -2,10 +2,11 @@ import 'dart:io'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:local_auth/local_auth.dart'; +import 'package:tanami_app/Globalconst.dart'; import 'package:tanami_app/core/utils/secure/secure_storage_service.dart'; import 'package:tanami_app/features/biometric/domain/repository/biometric_api.dart'; -import '../../../../Api_Helper/base_manager.dart'; +import '../../../Api_Helper/base_manager.dart'; import 'biometric_event.dart'; import 'biometric_state.dart'; @@ -33,7 +34,9 @@ class BiometricBloc extends Bloc { bool authenticated = false; if (Platform.isIOS) { authenticated = await localAuthentication.authenticate( - localizedReason: 'Please authenticate to access the app', + localizedReason: Globalconst.languageSelected == "en" + ? 'Please authenticate to access the app' + : 'يرجى المصادقة للوصول إلى التطبيق', options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, @@ -42,7 +45,9 @@ class BiometricBloc extends Bloc { ); } else if (Platform.isAndroid) { authenticated = await localAuthentication.authenticate( - localizedReason: 'Please authenticate to access the app', + localizedReason: Globalconst.languageSelected == "en" + ? 'Please authenticate to access the app' + : 'يرجى المصادقة للوصول إلى التطبيق', options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, @@ -64,10 +69,18 @@ class BiometricBloc extends Bloc { 'refreshtoken', response.data["data"]["refreshToken"]); emit(BiometricAuthenticated()); } else { - emit(BiometricFailed('Authentication failed')); + if (Globalconst.languageSelected == "en") { + emit(BiometricFailed('Authentication failed')); + } else { + emit(BiometricFailed('المصادقة فشلت')); + } } } else { - emit(BiometricFailed('Authentication failed')); + if (Globalconst.languageSelected == "en") { + emit(BiometricFailed('Authentication failed')); + } else { + emit(BiometricFailed('المصادقة فشلت')); + } } } catch (e) { emit(BiometricFailed(e.toString())); diff --git a/lib/features/biometric/presentation/bloc/biometric_event.dart b/lib/features/biometric/bloc/biometric_event.dart similarity index 100% rename from lib/features/biometric/presentation/bloc/biometric_event.dart rename to lib/features/biometric/bloc/biometric_event.dart diff --git a/lib/features/biometric/presentation/bloc/biometric_state.dart b/lib/features/biometric/bloc/biometric_state.dart similarity index 100% rename from lib/features/biometric/presentation/bloc/biometric_state.dart rename to lib/features/biometric/bloc/biometric_state.dart diff --git a/lib/features/biometric/presentation/pages/biometric_layout.dart b/lib/features/biometric/presentation/pages/biometric_layout.dart index f882ada..bc623ee 100644 --- a/lib/features/biometric/presentation/pages/biometric_layout.dart +++ b/lib/features/biometric/presentation/pages/biometric_layout.dart @@ -10,9 +10,9 @@ import '../../../../core/routes/route_name.dart'; import '../../../../core/routes/routes.dart'; import '../../../../core/styles/app_images.dart'; import '../../../../shared/components/device_locked_dialog.dart'; -import '../bloc/biometric_bloc.dart'; -import '../bloc/biometric_event.dart'; -import '../bloc/biometric_state.dart'; +import '../../bloc/biometric_bloc.dart'; +import '../../bloc/biometric_event.dart'; +import '../../bloc/biometric_state.dart'; class BiometricLayout extends StatelessWidget { const BiometricLayout({super.key}); diff --git a/lib/features/changePassword/presentation/bloc/change_password_bloc.dart b/lib/features/changePassword/bloc/change_password_bloc.dart similarity index 100% rename from lib/features/changePassword/presentation/bloc/change_password_bloc.dart rename to lib/features/changePassword/bloc/change_password_bloc.dart diff --git a/lib/features/changePassword/presentation/bloc/change_password_event.dart b/lib/features/changePassword/bloc/change_password_event.dart similarity index 100% rename from lib/features/changePassword/presentation/bloc/change_password_event.dart rename to lib/features/changePassword/bloc/change_password_event.dart diff --git a/lib/features/changePassword/presentation/bloc/change_password_state.dart b/lib/features/changePassword/bloc/change_password_state.dart similarity index 100% rename from lib/features/changePassword/presentation/bloc/change_password_state.dart rename to lib/features/changePassword/bloc/change_password_state.dart diff --git a/lib/features/changePassword/presentation/pages/change_password_screen.dart b/lib/features/changePassword/presentation/pages/change_password_screen.dart index b84852d..ba65ad3 100644 --- a/lib/features/changePassword/presentation/pages/change_password_screen.dart +++ b/lib/features/changePassword/presentation/pages/change_password_screen.dart @@ -6,7 +6,7 @@ import 'package:google_fonts/google_fonts.dart'; import '../../../../core/styles/app_color.dart'; import '../../../../core/styles/app_text.dart'; import '../../../../core/utils/language/localizations_delegate.dart'; -import '../bloc/change_password_bloc.dart'; +import '../../bloc/change_password_bloc.dart'; import 'change_password_layout.dart'; class ChangePasswordScreen extends StatelessWidget { diff --git a/lib/features/changePassword/presentation/widgets/change_password_bottom_section.dart b/lib/features/changePassword/presentation/widgets/change_password_bottom_section.dart index b20bf0c..e88ccd9 100644 --- a/lib/features/changePassword/presentation/widgets/change_password_bottom_section.dart +++ b/lib/features/changePassword/presentation/widgets/change_password_bottom_section.dart @@ -10,9 +10,9 @@ import '../../../../core/styles/app_color.dart'; import '../../../../core/styles/app_text.dart'; import '../../../../core/utils/language/localizations_delegate.dart'; import '../../../../shared/components/button_widget.dart'; -import '../bloc/change_password_bloc.dart'; -import '../bloc/change_password_event.dart'; -import '../bloc/change_password_state.dart'; +import '../../bloc/change_password_bloc.dart'; +import '../../bloc/change_password_event.dart'; +import '../../bloc/change_password_state.dart'; class RestorePasswordBottomSection extends StatelessWidget { const RestorePasswordBottomSection({ diff --git a/lib/features/changePassword/presentation/widgets/change_password_form.dart b/lib/features/changePassword/presentation/widgets/change_password_form.dart index 012be1a..39e6947 100644 --- a/lib/features/changePassword/presentation/widgets/change_password_form.dart +++ b/lib/features/changePassword/presentation/widgets/change_password_form.dart @@ -11,7 +11,7 @@ import '../../../../shared/components/bloc/password_field/password_visibility_bl import '../../../../shared/components/button_widget.dart'; import '../../../../shared/components/form_label_textfield.dart'; import '../../../../shared/components/text_widget.dart'; -import '../bloc/change_password_bloc.dart'; +import '../../bloc/change_password_bloc.dart'; class RestorePasswordForm extends StatelessWidget { const RestorePasswordForm({super.key}); diff --git a/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart b/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart index ee6d510..2ef555b 100644 --- a/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart +++ b/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart @@ -2,6 +2,7 @@ import 'package:bloc/bloc.dart'; import 'package:tanami_app/features/countrySelection/bloc/GetCountry/get_country_event.dart'; import '../../../../Api_Helper/base_manager.dart'; +import '../../../../Globalconst.dart'; import '../../domain/model/get_country_model.dart'; import '../../repositories/get_country_api.dart'; import 'get_country_state.dart'; @@ -20,7 +21,9 @@ class GetCountryBlock extends Bloc { emit(CountryLoaded(countryModel)); } } catch (e) { - emit(CountryError("Oops Something went wrong")); + emit(CountryError(Globalconst.languageSelected == "en" + ? 'Oops Something went wrong' + : "تبا شيء ما حدث بشكل خاطئ")); } } } diff --git a/lib/features/forgotPassword/presentation/bloc/restore_password_bloc.dart b/lib/features/forgotPassword/bloc/restore_password_bloc.dart similarity index 95% rename from lib/features/forgotPassword/presentation/bloc/restore_password_bloc.dart rename to lib/features/forgotPassword/bloc/restore_password_bloc.dart index fb2d5ea..e7b5263 100644 --- a/lib/features/forgotPassword/presentation/bloc/restore_password_bloc.dart +++ b/lib/features/forgotPassword/bloc/restore_password_bloc.dart @@ -4,8 +4,8 @@ import 'package:bloc/bloc.dart'; import 'package:flutter/material.dart'; import 'package:tanami_app/Globalconst.dart'; -import '../../../../Api_Helper/base_manager.dart'; -import '../../domain/repository/forgot_password_api.dart'; +import '../../../Api_Helper/base_manager.dart'; +import '../domain/repository/forgot_password_api.dart'; import 'restore_password_event.dart'; import 'restore_password_state.dart'; diff --git a/lib/features/forgotPassword/presentation/bloc/restore_password_event.dart b/lib/features/forgotPassword/bloc/restore_password_event.dart similarity index 100% rename from lib/features/forgotPassword/presentation/bloc/restore_password_event.dart rename to lib/features/forgotPassword/bloc/restore_password_event.dart diff --git a/lib/features/forgotPassword/presentation/bloc/restore_password_phone_verification_bloc.dart b/lib/features/forgotPassword/bloc/restore_password_phone_verification_bloc.dart similarity index 93% rename from lib/features/forgotPassword/presentation/bloc/restore_password_phone_verification_bloc.dart rename to lib/features/forgotPassword/bloc/restore_password_phone_verification_bloc.dart index f26425b..1a5bba6 100644 --- a/lib/features/forgotPassword/presentation/bloc/restore_password_phone_verification_bloc.dart +++ b/lib/features/forgotPassword/bloc/restore_password_phone_verification_bloc.dart @@ -2,9 +2,9 @@ import 'package:bloc/bloc.dart'; import 'package:flutter/material.dart'; import 'package:tanami_app/Globalconst.dart'; -import '../../../../Api_Helper/base_manager.dart'; -import '../../../../core/utils/secure/secure_storage_service.dart'; -import '../../domain/repository/forgot_password_api.dart'; +import '../../../Api_Helper/base_manager.dart'; +import '../../../core/utils/secure/secure_storage_service.dart'; +import '../domain/repository/forgot_password_api.dart'; import 'restore_password_phone_verification_event.dart'; import 'restore_password_phone_verification_state.dart'; diff --git a/lib/features/forgotPassword/presentation/bloc/restore_password_phone_verification_event.dart b/lib/features/forgotPassword/bloc/restore_password_phone_verification_event.dart similarity index 100% rename from lib/features/forgotPassword/presentation/bloc/restore_password_phone_verification_event.dart rename to lib/features/forgotPassword/bloc/restore_password_phone_verification_event.dart diff --git a/lib/features/forgotPassword/presentation/bloc/restore_password_phone_verification_state.dart b/lib/features/forgotPassword/bloc/restore_password_phone_verification_state.dart similarity index 100% rename from lib/features/forgotPassword/presentation/bloc/restore_password_phone_verification_state.dart rename to lib/features/forgotPassword/bloc/restore_password_phone_verification_state.dart diff --git a/lib/features/forgotPassword/presentation/bloc/restore_password_state.dart b/lib/features/forgotPassword/bloc/restore_password_state.dart similarity index 100% rename from lib/features/forgotPassword/presentation/bloc/restore_password_state.dart rename to lib/features/forgotPassword/bloc/restore_password_state.dart diff --git a/lib/features/forgotPassword/presentation/pages/restore_password_phone_verification_screen.dart b/lib/features/forgotPassword/presentation/pages/restore_password_phone_verification_screen.dart index ceac93f..4860a09 100644 --- a/lib/features/forgotPassword/presentation/pages/restore_password_phone_verification_screen.dart +++ b/lib/features/forgotPassword/presentation/pages/restore_password_phone_verification_screen.dart @@ -5,7 +5,7 @@ import 'package:tanami_app/features/forgotPassword/presentation/pages/restore_pa import '../../../../core/styles/app_color.dart'; import '../../../countrySelection/bloc/choose_country_bloc.dart'; -import '../bloc/restore_password_phone_verification_bloc.dart'; +import '../../bloc/restore_password_phone_verification_bloc.dart'; class RestorePasswordPhoneVerificationScreen extends StatelessWidget { const RestorePasswordPhoneVerificationScreen({super.key}); diff --git a/lib/features/forgotPassword/presentation/pages/restore_password_screen.dart b/lib/features/forgotPassword/presentation/pages/restore_password_screen.dart index 079b42d..29d1c8f 100644 --- a/lib/features/forgotPassword/presentation/pages/restore_password_screen.dart +++ b/lib/features/forgotPassword/presentation/pages/restore_password_screen.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../core/styles/app_color.dart'; -import '../bloc/restore_password_bloc.dart'; +import '../../bloc/restore_password_bloc.dart'; import 'restore_password_layout.dart'; class RestorePasswordScreen extends StatelessWidget { diff --git a/lib/features/forgotPassword/presentation/widgets/restore_password_bottom_section.dart b/lib/features/forgotPassword/presentation/widgets/restore_password_bottom_section.dart index c0423b7..1b64c3d 100644 --- a/lib/features/forgotPassword/presentation/widgets/restore_password_bottom_section.dart +++ b/lib/features/forgotPassword/presentation/widgets/restore_password_bottom_section.dart @@ -13,9 +13,9 @@ import '../../../../core/utils/language/localizations_delegate.dart'; import '../../../../shared/components/button_widget.dart'; import '../../../../shared/components/text_widget.dart'; import '../../../countrySelection/bloc/choose_country_bloc.dart'; -import '../bloc/restore_password_bloc.dart'; -import '../bloc/restore_password_event.dart'; -import '../bloc/restore_password_state.dart'; +import '../../bloc/restore_password_bloc.dart'; +import '../../bloc/restore_password_event.dart'; +import '../../bloc/restore_password_state.dart'; class RestorePasswordBottomSection extends StatelessWidget { const RestorePasswordBottomSection({ diff --git a/lib/features/forgotPassword/presentation/widgets/restore_password_form.dart b/lib/features/forgotPassword/presentation/widgets/restore_password_form.dart index d6cbe3c..95359c9 100644 --- a/lib/features/forgotPassword/presentation/widgets/restore_password_form.dart +++ b/lib/features/forgotPassword/presentation/widgets/restore_password_form.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_text.dart'; -import 'package:tanami_app/features/forgotPassword/presentation/bloc/restore_password_bloc.dart'; +import 'package:tanami_app/features/forgotPassword/bloc/restore_password_bloc.dart'; import '../../../../core/utils/language/localizations_delegate.dart'; import '../../../../shared/components/bloc/password_field/password_visibility_bloc.dart'; diff --git a/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_bottom_section.dart b/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_bottom_section.dart index ba1f62d..53dfc42 100644 --- a/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_bottom_section.dart +++ b/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_bottom_section.dart @@ -13,9 +13,9 @@ import '../../../../core/utils/language/localizations_delegate.dart'; import '../../../../shared/components/button_widget.dart'; import '../../../../shared/components/text_widget.dart'; import '../../../countrySelection/bloc/choose_country_bloc.dart'; -import '../bloc/restore_password_phone_verification_bloc.dart'; -import '../bloc/restore_password_phone_verification_event.dart'; -import '../bloc/restore_password_phone_verification_state.dart'; +import '../../bloc/restore_password_phone_verification_bloc.dart'; +import '../../bloc/restore_password_phone_verification_event.dart'; +import '../../bloc/restore_password_phone_verification_state.dart'; class RestorePasswordPhoneVerificationBottomSection extends StatelessWidget { const RestorePasswordPhoneVerificationBottomSection({ diff --git a/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_form.dart b/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_form.dart index 55531bf..5eb4034 100644 --- a/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_form.dart +++ b/lib/features/forgotPassword/presentation/widgets/restore_password_phone_verification_form.dart @@ -15,7 +15,7 @@ import '../../../countrySelection/bloc/GetCountry/get_country_bloc.dart'; import '../../../countrySelection/bloc/GetCountry/get_country_state.dart'; import '../../../countrySelection/bloc/choose_country_bloc.dart'; import '../../../countrySelection/bloc/choose_country_state.dart'; -import '../bloc/restore_password_phone_verification_bloc.dart'; +import '../../bloc/restore_password_phone_verification_bloc.dart'; class RestorePasswordPhoneVerificationForm extends StatelessWidget { const RestorePasswordPhoneVerificationForm({super.key}); diff --git a/lib/features/languageChange/presentation/widgets/bottom_section.dart b/lib/features/languageChange/presentation/widgets/bottom_section.dart index 4be6407..b1de861 100644 --- a/lib/features/languageChange/presentation/widgets/bottom_section.dart +++ b/lib/features/languageChange/presentation/widgets/bottom_section.dart @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; +import '../../../../Globalconst.dart'; import '../../../../core/routes/routes.dart'; import '../../../../core/styles/app_color.dart'; import '../../../../core/styles/app_text.dart'; @@ -37,8 +38,10 @@ Widget bottomSection(BuildContext context) { context.read().add(ChangeLanguage(newLocale)); if (radioBloc.selectedCountry == 1) { await secureStorageService.write('languageSelected', "ar"); + Globalconst.languageSelected = "ar"; } else { await secureStorageService.write('languageSelected', "en"); + Globalconst.languageSelected = "en"; } goRouter.pop(); }, diff --git a/lib/features/login/presentation/bloc/login_bloc.dart b/lib/features/login/presentation/bloc/login_bloc.dart index 2829012..7a18a06 100644 --- a/lib/features/login/presentation/bloc/login_bloc.dart +++ b/lib/features/login/presentation/bloc/login_bloc.dart @@ -29,8 +29,9 @@ class LoginBloc extends Bloc { on((event, emit) async { if (!formKey.currentState!.validate()) { emit(LoginLoading()); - emit( - const LoginFailure("Login failed. Please check your credentials.")); + emit(LoginFailure(Globalconst.languageSelected == "en" + ? "Login failed. Please check your credentials." + : "فشل تسجيل الدخول. يرجى التحقق من بيانات الاعتماد الخاصة بك.")); return; } emit(LoginLoading()); @@ -58,8 +59,7 @@ class LoginBloc extends Bloc { emit(LoginFailure(response.message.toString())); } } else { - emit(const LoginFailure( - "Login failed. Please check your credentials.")); + emit(LoginFailure(response.message.toString())); } } catch (e) { emit(LoginFailure(e.toString())); diff --git a/lib/features/login/presentation/pages/login_screen.dart b/lib/features/login/presentation/pages/login_screen.dart index 3283009..381f5ad 100644 --- a/lib/features/login/presentation/pages/login_screen.dart +++ b/lib/features/login/presentation/pages/login_screen.dart @@ -16,6 +16,7 @@ class LoginScreen extends StatelessWidget { Widget build(BuildContext context) { final SecureStorageService secureStorageService = SecureStorageService(); final radioBloc = context.read(); + return WillPopScope( onWillPop: () async { if (fromScreen == "welcome" || diff --git a/lib/features/login/presentation/widgets/bottom_section.dart b/lib/features/login/presentation/widgets/bottom_section.dart index 7c405b9..ad324e2 100644 --- a/lib/features/login/presentation/widgets/bottom_section.dart +++ b/lib/features/login/presentation/widgets/bottom_section.dart @@ -59,6 +59,7 @@ class BottomSection extends StatelessWidget { successToastMessage(context, "login successful !"); goRouter.pop(); radioBloc.resetSelection(); + loginbloc.resetFields(); await secureStorageService.write('isLoginedIn', "true"); goRouter.pushNamed(RouteName.pinScreen, pathParameters: { "fromScreen": diff --git a/lib/features/login/presentation/widgets/login_form.dart b/lib/features/login/presentation/widgets/login_form.dart index 96c1092..e7b41fe 100644 --- a/lib/features/login/presentation/widgets/login_form.dart +++ b/lib/features/login/presentation/widgets/login_form.dart @@ -197,7 +197,7 @@ class LoginForm extends StatelessWidget { child: FormLabelTextField( hintText: localizations.translate(AppText.enterPassword), title: localizations.translate(AppText.password), - type: "password", + type: "login-password", textEditingController: loginBloc.passwordTextField, ), ), diff --git a/lib/features/otpVerification/bloc/otp_bloc.dart b/lib/features/otpVerification/bloc/otp_bloc.dart index 949c763..f9705d7 100644 --- a/lib/features/otpVerification/bloc/otp_bloc.dart +++ b/lib/features/otpVerification/bloc/otp_bloc.dart @@ -1,6 +1,7 @@ import 'package:bloc/bloc.dart'; import '../../../Api_Helper/base_manager.dart'; +import '../../../Globalconst.dart'; import '../domain/Repository/otp_api.dart'; import 'otp_event.dart'; import 'otp_state.dart'; @@ -19,10 +20,12 @@ class OTPBloc extends Bloc { if (response.status == ResponseStatus.SUCCESS) { emit(OTPLoaded()); } else { - emit(OTPFailed("Oops something went wrong")); + emit(OTPFailed(response.message.toString())); } } catch (e) { - emit(OTPError("Oops something went wrong")); + emit(OTPError(Globalconst.languageSelected == "en" + ? "تبا شيء ما حدث بشكل خاطئ" + : "")); } } } diff --git a/lib/features/otpVerification/presentation/bloc/timer/timer_bloc.dart b/lib/features/otpVerification/presentation/bloc/timer/timer_bloc.dart index acbe5a3..2efe8f9 100644 --- a/lib/features/otpVerification/presentation/bloc/timer/timer_bloc.dart +++ b/lib/features/otpVerification/presentation/bloc/timer/timer_bloc.dart @@ -1,6 +1,7 @@ -// timer_bloc.dart import 'dart:async'; + import 'package:bloc/bloc.dart'; + import 'timer_event.dart'; import 'timer_state.dart'; @@ -13,7 +14,7 @@ class TimerBloc extends Bloc { } void _onStartTimer(StartTimer event, Emitter emit) { - const int duration = 300; // 5 minutes in seconds + const int duration = 30; // 5 minutes in seconds emit(const TimerRunInProgress(duration)); _startTicker(duration); } diff --git a/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart b/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart index 02c4e43..460ea0d 100644 --- a/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart +++ b/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:sms_autofill/sms_autofill.dart'; @@ -63,6 +64,8 @@ class OtpFillSection extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ PinFieldAutoFill( + keyboardType: TextInputType.number, + inputFormatters: [FilteringTextInputFormatter.digitsOnly], controller: otpBloc.otpController, currentCode: otpBloc.otpController.text, decoration: BoxLooseDecoration( diff --git a/lib/features/otpVerification/presentation/widgets/resend_otp_section.dart b/lib/features/otpVerification/presentation/widgets/resend_otp_section.dart index 07f921a..33deb12 100644 --- a/lib/features/otpVerification/presentation/widgets/resend_otp_section.dart +++ b/lib/features/otpVerification/presentation/widgets/resend_otp_section.dart @@ -14,6 +14,7 @@ import '../../../register/presentation/bloc/register_bloc.dart'; import '../../../register/presentation/bloc/register_event.dart'; import '../../../register/presentation/bloc/register_state.dart'; import '../bloc/timer/timer_bloc.dart'; +import '../bloc/timer/timer_event.dart'; import '../bloc/timer/timer_state.dart'; class ResendOtpSection extends StatelessWidget { @@ -49,6 +50,7 @@ class ResendOtpSection extends StatelessWidget { if (state is RegisterLoading) { Loader.loader(context); } else if (state is RegisterSuccess) { + context.read().add(StartTimer()); // Reset timer successToastMessage(context, "OTP Resend Sucessfully !"); goRouter.pop(); } else if (state is RegisterFailure) { @@ -75,13 +77,13 @@ class ResendOtpSection extends StatelessWidget { Resendotp(token), ); } else { - errorToastMessage(context, - "Please wait ${timerState.formattedDuration} Minutes before resending OTP"); + // errorToastMessage(context, + // "Please wait ${timerState.formattedDuration} Seconds before resending OTP"); } }, child: TextWidget().text14W500( localizations.translate(AppText.resendSms), - clr: isButtonEnabled + clr: timerState is TimerRunComplete ? AppColor.plainBlack : AppColor.indicatorInactiveColor, textDecoration: TextDecoration.underline, diff --git a/lib/features/register/presentation/bloc/register_bloc.dart b/lib/features/register/presentation/bloc/register_bloc.dart index 221f04d..8a626ec 100644 --- a/lib/features/register/presentation/bloc/register_bloc.dart +++ b/lib/features/register/presentation/bloc/register_bloc.dart @@ -59,8 +59,7 @@ class RegisterBloc extends Bloc { if (response.status == ResponseStatus.SUCCESS) { emit(RegisterSuccess(event.token)); //emit(OTPLoaded()); } else { - emit(const RegisterFailure( - "Register failed. Please check your credentials.")); + emit(RegisterFailure(response.message.toString())); //emit(OTPFailed("Oops something went wrong")); } } catch (e) { diff --git a/lib/features/register/presentation/bloc/register_user_bloc.dart b/lib/features/register/presentation/bloc/register_user_bloc.dart index 858089b..467872b 100644 --- a/lib/features/register/presentation/bloc/register_user_bloc.dart +++ b/lib/features/register/presentation/bloc/register_user_bloc.dart @@ -51,22 +51,6 @@ class RegisterUserBloc extends Bloc { } else { emit(RegisterUserFailure(response.message)); } - // Simulate API call - await Future.delayed(const Duration(seconds: 2)); - // Replace the next line with actual API call - /* final isSuccess = await _mockLoginApi( - event.firstName, - event.password, - event.lastName, - event.confirmPassword, - event.email, - ); - if (isSuccess) { - emit(RegisterUserSuccess()); - } else { - emit(const RegisterUserFailure( - "Register failed. Please check your credentials.")); - } */ } catch (e) { emit(RegisterUserFailure(e.toString())); } diff --git a/lib/features/register/presentation/widgets/register_user_form.dart b/lib/features/register/presentation/widgets/register_user_form.dart index f9fc805..66e3141 100644 --- a/lib/features/register/presentation/widgets/register_user_form.dart +++ b/lib/features/register/presentation/widgets/register_user_form.dart @@ -31,14 +31,14 @@ class RegisterUserForm extends StatelessWidget { FormLabelTextField( hintText: localizations.translate(AppText.enterFirstName), title: localizations.translate(AppText.firstNameText), - type: localizations.translate(AppText.firstNameText), + type: "first name", textEditingController: registerUserBloc.firstNameTextField, ), const Gap(12), FormLabelTextField( hintText: localizations.translate(AppText.enterLastName), title: localizations.translate(AppText.lastNameText), - type: AppText.lastNameText, + type: "first name", textEditingController: registerUserBloc.lastNameTextField, ), const Gap(12), diff --git a/lib/features/securePin/presentation/bloc/pin_bloc.dart b/lib/features/securePin/presentation/bloc/pin_bloc.dart index bb50deb..60f43fc 100644 --- a/lib/features/securePin/presentation/bloc/pin_bloc.dart +++ b/lib/features/securePin/presentation/bloc/pin_bloc.dart @@ -3,6 +3,7 @@ import 'package:equatable/equatable.dart'; import 'package:tanami_app/Api_Helper/base_manager.dart'; import 'package:tanami_app/core/styles/app_text.dart'; +import '../../../../Globalconst.dart'; import '../../../../core/routes/routes.dart'; import '../../../../core/utils/secure/secure_storage_service.dart'; import '../../Repository/PinAPIServices.dart'; @@ -109,9 +110,9 @@ class PinBloc extends Bloc { ResponseData response = await PinAPIServices().Verifypin(pindata); if (response.status == ResponseStatus.SUCCESS) { await secureStorageService.write( - 'accesstoken', response.data["data"]["accessToken"]); + 'accesstoken', response.data["user"]["accessToken"]); await secureStorageService.write( - 'refreshtoken', response.data["data"]["refreshToken"]); + 'refreshtoken', response.data["user"]["refreshToken"]); emit(state.copyWith( pinComplete: true, pin: state.pin, @@ -124,7 +125,9 @@ class PinBloc extends Bloc { pinComplete: true, pin: state.pin, isVerified: false, - error: "Incorrect Pin Code", + error: Globalconst.languageSelected == "en" + ? "Incorrect Pin Code" + : "رمز التعريف الشخصي غير صحيح", verifiedOnce: true, )); } diff --git a/lib/features/securePin/presentation/widgets/pin_keypad_section.dart b/lib/features/securePin/presentation/widgets/pin_keypad_section.dart index 5798bc3..1b480ab 100644 --- a/lib/features/securePin/presentation/widgets/pin_keypad_section.dart +++ b/lib/features/securePin/presentation/widgets/pin_keypad_section.dart @@ -89,10 +89,12 @@ class PinKey extends StatelessWidget { ); }, ), - (fromScreen == "login" || fromScreen == "forgot-pin") + (fromScreen == "login" || + fromScreen == "forgot-pin" || + fromScreen == "LoginedInUser") ? const Gap(20) : const Gap(0), - (fromScreen == "login") + (fromScreen == "login" || fromScreen == "LoginedInUser") ? GestureDetector( onTap: () { forgotPinDialog(context); diff --git a/lib/main.dart b/lib/main.dart index 1639670..d477641 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,17 +4,18 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:local_auth/local_auth.dart'; +import 'package:tanami_app/Globalconst.dart'; import 'package:tanami_app/features/login/presentation/bloc/login_bloc.dart'; import 'core/routes/routes.dart'; import 'core/utils/connectivity/network_connectivity.dart'; import 'core/utils/language/localizations_delegate.dart'; import 'core/utils/secure/secure_storage_service.dart'; -import 'features/biometric/presentation/bloc/biometric_bloc.dart'; -import 'features/biometric/presentation/bloc/biometric_event.dart'; +import 'features/biometric/bloc/biometric_bloc.dart'; +import 'features/biometric/bloc/biometric_event.dart'; import 'features/countrySelection/bloc/GetCountry/get_country_bloc.dart'; import 'features/countrySelection/bloc/choose_country_bloc.dart'; -import 'features/forgotPassword/presentation/bloc/restore_password_phone_verification_bloc.dart'; +import 'features/forgotPassword/bloc/restore_password_phone_verification_bloc.dart'; import 'features/otpVerification/bloc/otp_bloc.dart'; import 'features/register/presentation/bloc/register_bloc.dart'; import 'shared/components/bloc/bottom_nav_bar/bottom_navigation_bloc.dart'; @@ -136,14 +137,17 @@ class _MyAppState extends State with WidgetsBindingObserver { context .read() .add(const ChangeLanguage(Locale('en'))); + Globalconst.languageSelected = "en"; } else if (languageSelected == "en") { context .read() .add(const ChangeLanguage(Locale('en'))); + Globalconst.languageSelected = "en"; } else { context .read() .add(const ChangeLanguage(Locale('ar'))); + Globalconst.languageSelected = "ar"; } }, ); diff --git a/lib/shared/api/network_api_services.dart b/lib/shared/api/network_api_services.dart index 2d1423b..d01e1fe 100644 --- a/lib/shared/api/network_api_services.dart +++ b/lib/shared/api/network_api_services.dart @@ -9,7 +9,7 @@ class NetworkApiService { final Dio _dio = Dio(BaseOptions( validateStatus: (status) { return status != null && - status < 500; // Allow any status code less than 500 + status <= 500; // Allow any status code less than 500 }, )); @@ -25,6 +25,14 @@ class NetworkApiService { if (response.statusCode == 201 || response.statusCode == 200) { return ResponseData("success", ResponseStatus.SUCCESS, data: response.data); + } else if (response.statusCode == 500) { + return ResponseData( + "Internal server error", ResponseStatus.PRIVATE, + data: response.data); + } else if (response.statusCode == 400) { + return ResponseData( + response.data['message'], ResponseStatus.PRIVATE, + data: response.data); } else { try { return ResponseData( @@ -80,6 +88,10 @@ class NetworkApiService { return ResponseData( response.data['error']['message'], ResponseStatus.PRIVATE, data: response.data); + } else if (response.statusCode == 500) { + return ResponseData( + "Internal server error", ResponseStatus.PRIVATE, + data: response.data); } else { try { return ResponseData( diff --git a/lib/shared/components/device_locked_dialog.dart b/lib/shared/components/device_locked_dialog.dart index 63de4b5..9e4bdfc 100644 --- a/lib/shared/components/device_locked_dialog.dart +++ b/lib/shared/components/device_locked_dialog.dart @@ -6,13 +6,13 @@ import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_color.dart'; import 'package:tanami_app/core/styles/app_text.dart'; import 'package:tanami_app/core/utils/secure/secure_storage_service.dart'; -import 'package:tanami_app/features/biometric/presentation/bloc/biometric_bloc.dart'; +import 'package:tanami_app/features/biometric/bloc/biometric_bloc.dart'; import '../../Globalconst.dart'; import '../../core/routes/route_name.dart'; import '../../core/routes/routes.dart'; import '../../core/utils/language/localizations_delegate.dart'; -import '../../features/biometric/presentation/bloc/biometric_state.dart'; +import '../../features/biometric/bloc/biometric_state.dart'; import 'text_widget.dart'; deviceLockedDialog( diff --git a/lib/shared/components/form_label_textfield.dart b/lib/shared/components/form_label_textfield.dart index 593cacc..81ed595 100644 --- a/lib/shared/components/form_label_textfield.dart +++ b/lib/shared/components/form_label_textfield.dart @@ -11,7 +11,7 @@ import 'package:tanami_app/shared/components/text_widget.dart'; import '../../core/routes/route_name.dart'; import '../../core/routes/routes.dart'; import '../../core/utils/language/localizations_delegate.dart'; -import '../../features/forgotPassword/presentation/bloc/restore_password_phone_verification_bloc.dart'; +import '../../features/forgotPassword/bloc/restore_password_phone_verification_bloc.dart'; import '../../features/register/presentation/bloc/register_bloc.dart'; import 'text_from_field_widget.dart'; @@ -60,11 +60,14 @@ class FormLabelTextField extends StatelessWidget { txtAlign: type == "description" ? TextAlign.start : TextAlign.center, ), const Gap(10), - (type == "password" || type == "repeat-password") + (type == "password" || + type == "repeat-password" || + type == "login-password") ? PasswordField( controller: textEditingController, hintText: hintText, originalPasswordController: originalPasswordController, + type: type, ) : textFormField( onInput: onChangeFun, @@ -139,25 +142,29 @@ class FormLabelTextField extends StatelessWidget { return null; } }, - inputFormatters: (type == "phone number") - ? registerBloc.isdcode.isNotEmpty - ? [ - LengthLimitingTextInputFormatter( - countryPhoneLengths[registerBloc.isdcode]), - ] - : restorePasswordBloc.isdcode.isNotEmpty + inputFormatters: (type == "first name") + ? [ + LengthLimitingTextInputFormatter(35), + ] + : (type == "phone number") + ? registerBloc.isdcode.isNotEmpty ? [ LengthLimitingTextInputFormatter( - countryPhoneLengths[ - restorePasswordBloc.isdcode]), + countryPhoneLengths[registerBloc.isdcode]), ] - : [ - LengthLimitingTextInputFormatter( - countryPhoneLengths[loginBloc.isdcode]), - ] - : [ - LengthLimitingTextInputFormatter(350), - ], + : restorePasswordBloc.isdcode.isNotEmpty + ? [ + LengthLimitingTextInputFormatter( + countryPhoneLengths[ + restorePasswordBloc.isdcode]), + ] + : [ + LengthLimitingTextInputFormatter( + countryPhoneLengths[loginBloc.isdcode]), + ] + : [ + LengthLimitingTextInputFormatter(350), + ], maxlines: type == "description" ? 6 : 1, texttype: type == "phone number" ? TextInputType.phone diff --git a/lib/shared/components/language_change_bottom_sheet.dart b/lib/shared/components/language_change_bottom_sheet.dart index c8d464d..990b262 100644 --- a/lib/shared/components/language_change_bottom_sheet.dart +++ b/lib/shared/components/language_change_bottom_sheet.dart @@ -8,6 +8,7 @@ import 'package:tanami_app/core/utils/secure/secure_storage_service.dart'; import 'package:tanami_app/features/welcome/presentation/pages/weclome_screen.dart'; import 'package:tanami_app/shared/components/text_widget.dart'; +import '../../Globalconst.dart'; import 'bloc/language/lng_bloc.dart'; import 'bloc/language/lng_event.dart'; @@ -49,6 +50,7 @@ void showLanguageBottomSheet(BuildContext context) { await secureStorageService.write( 'languageSelected', "en"); goRouter.pop(); + Globalconst.languageSelected = "en"; Navigator.of(context).push(MaterialPageRoute( builder: (_) => const WelcomeScreen())); }, @@ -67,7 +69,7 @@ void showLanguageBottomSheet(BuildContext context) { context .read() .add(const ChangeLanguage(Locale('ar'))); - + Globalconst.languageSelected = "ar"; await secureStorageService.write( 'languageSelected', "ar"); goRouter.pop(); diff --git a/lib/shared/components/password_text_form_field.dart b/lib/shared/components/password_text_form_field.dart index 029f79b..f17914b 100644 --- a/lib/shared/components/password_text_form_field.dart +++ b/lib/shared/components/password_text_form_field.dart @@ -17,11 +17,13 @@ class PasswordField extends StatelessWidget { final TextEditingController controller; final String hintText; final TextEditingController? originalPasswordController; + final String? type; const PasswordField({ super.key, required this.controller, required this.hintText, this.originalPasswordController, + this.type, }); @override @@ -31,29 +33,36 @@ class PasswordField extends StatelessWidget { builder: (context, state) { return TextFormField( validator: (value) { - if (value == null || value.isEmpty) { - return localizations.translate(AppText.enterPassword); - } + if (type == "login-password") { + if (value == null || value.isEmpty) { + return localizations.translate(AppText.enterPassword); + } + } else { + if (value == null || value.isEmpty) { + return localizations.translate(AppText.enterPassword); + } - // Password validation rules - if (value.length < 8 || value.length > 20) { - return localizations.translate(AppText.passwordLength); - } - if (!RegExp(r'[a-z]').hasMatch(value)) { - return localizations.translate(AppText.passwordLowerCase); - } - if (!RegExp(r'[A-Z]').hasMatch(value)) { - return localizations.translate(AppText.passwordUpperCase); - } - if (!RegExp(r'\d').hasMatch(value)) { - return localizations.translate(AppText.passwordDigit); - } - if (!RegExp(r'[!@#$%&*()\-+=^]').hasMatch(value)) { - return localizations.translate(AppText.passwordSpecialCharacter); - } - if (originalPasswordController != null && - value != originalPasswordController!.text) { - return localizations.translate("Passwords do not match"); + // Password validation rules + if (value.length < 8 || value.length > 20) { + return localizations.translate(AppText.passwordLength); + } + if (!RegExp(r'[a-z]').hasMatch(value)) { + return localizations.translate(AppText.passwordLowerCase); + } + if (!RegExp(r'[A-Z]').hasMatch(value)) { + return localizations.translate(AppText.passwordUpperCase); + } + if (!RegExp(r'\d').hasMatch(value)) { + return localizations.translate(AppText.passwordDigit); + } + if (!RegExp(r'[!@#$%&*()\-+=^]').hasMatch(value)) { + return localizations + .translate(AppText.passwordSpecialCharacter); + } + if (originalPasswordController != null && + value != originalPasswordController!.text) { + return localizations.translate("Passwords do not match"); + } } return null;