@@ -5,4 +5,5 @@ class Globalconst {
|
||||
static String isdcode = "";
|
||||
static String createdpin = "";
|
||||
static String firstName = "";
|
||||
static String languageSelected = "en";
|
||||
}
|
||||
|
||||
@@ -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<BiometricEvent, BiometricState> {
|
||||
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<BiometricEvent, BiometricState> {
|
||||
);
|
||||
} 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<BiometricEvent, BiometricState> {
|
||||
'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()));
|
||||
@@ -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});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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<GetCountryEvent, GetCountryState> {
|
||||
emit(CountryLoaded(countryModel));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(CountryError("Oops Something went wrong"));
|
||||
emit(CountryError(Globalconst.languageSelected == "en"
|
||||
? 'Oops Something went wrong'
|
||||
: "تبا شيء ما حدث بشكل خاطئ"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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<LocalizationBloc>().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();
|
||||
},
|
||||
|
||||
@@ -29,8 +29,9 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
|
||||
on<LoginSubmitted>((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<LoginEvent, LoginState> {
|
||||
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()));
|
||||
|
||||
@@ -16,6 +16,7 @@ class LoginScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final SecureStorageService secureStorageService = SecureStorageService();
|
||||
final radioBloc = context.read<RadioBloc>();
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
if (fromScreen == "welcome" ||
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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<OTPEvent, OTPState> {
|
||||
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"
|
||||
? "تبا شيء ما حدث بشكل خاطئ"
|
||||
: ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TimerEvent, TimerState> {
|
||||
}
|
||||
|
||||
void _onStartTimer(StartTimer event, Emitter<TimerState> emit) {
|
||||
const int duration = 300; // 5 minutes in seconds
|
||||
const int duration = 30; // 5 minutes in seconds
|
||||
emit(const TimerRunInProgress(duration));
|
||||
_startTicker(duration);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<TimerBloc>().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,
|
||||
|
||||
@@ -59,8 +59,7 @@ class RegisterBloc extends Bloc<RegisterEvent, RegisterState> {
|
||||
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) {
|
||||
|
||||
@@ -51,22 +51,6 @@ class RegisterUserBloc extends Bloc<RegisterUserEvent, RegisterUserState> {
|
||||
} 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()));
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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<PinEvent, PinState> {
|
||||
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<PinEvent, PinState> {
|
||||
pinComplete: true,
|
||||
pin: state.pin,
|
||||
isVerified: false,
|
||||
error: "Incorrect Pin Code",
|
||||
error: Globalconst.languageSelected == "en"
|
||||
? "Incorrect Pin Code"
|
||||
: "رمز التعريف الشخصي غير صحيح",
|
||||
verifiedOnce: true,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<MyApp> with WidgetsBindingObserver {
|
||||
context
|
||||
.read<LocalizationBloc>()
|
||||
.add(const ChangeLanguage(Locale('en')));
|
||||
Globalconst.languageSelected = "en";
|
||||
} else if (languageSelected == "en") {
|
||||
context
|
||||
.read<LocalizationBloc>()
|
||||
.add(const ChangeLanguage(Locale('en')));
|
||||
Globalconst.languageSelected = "en";
|
||||
} else {
|
||||
context
|
||||
.read<LocalizationBloc>()
|
||||
.add(const ChangeLanguage(Locale('ar')));
|
||||
Globalconst.languageSelected = "ar";
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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<dynamic>("success", ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 500) {
|
||||
return ResponseData<dynamic>(
|
||||
"Internal server error", ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 400) {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else {
|
||||
try {
|
||||
return ResponseData<dynamic>(
|
||||
@@ -80,6 +88,10 @@ class NetworkApiService {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['error']['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 500) {
|
||||
return ResponseData<dynamic>(
|
||||
"Internal server error", ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else {
|
||||
try {
|
||||
return ResponseData<dynamic>(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<LocalizationBloc>()
|
||||
.add(const ChangeLanguage(Locale('ar')));
|
||||
|
||||
Globalconst.languageSelected = "ar";
|
||||
await secureStorageService.write(
|
||||
'languageSelected', "ar");
|
||||
goRouter.pop();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user