From f657db89af8e9e27b34f47d5429ad6ba139e9576 Mon Sep 17 00:00:00 2001 From: poojapandeyx Date: Fri, 12 Jul 2024 11:56:27 +0530 Subject: [PATCH 1/2] register with mobile number change --- lib/features/register/presentation/bloc/register_bloc.dart | 3 ++- lib/features/register/presentation/bloc/register_event.dart | 4 +++- .../presentation/widgets/register_bottom_section.dart | 3 ++- lib/features/register/presentation/widgets/register_form.dart | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/features/register/presentation/bloc/register_bloc.dart b/lib/features/register/presentation/bloc/register_bloc.dart index 82f63bb..2dbd996 100644 --- a/lib/features/register/presentation/bloc/register_bloc.dart +++ b/lib/features/register/presentation/bloc/register_bloc.dart @@ -11,6 +11,7 @@ class RegisterBloc extends Bloc { final TextEditingController countrySelectionTextField = TextEditingController(); String isdcode=""; + String countryId=""; final TextEditingController phoneNumberTextField = TextEditingController(); GlobalKey getFormKey() { @@ -28,7 +29,7 @@ class RegisterBloc extends Bloc { emit(RegisterLoading()); try { Map requestdata={ - "isdCode":event.isdcode, + "countryId":event.id, "phoneNumber":event.phoneNumber }; ResponseData response = await OTPAPI().RequestOTP(requestdata); diff --git a/lib/features/register/presentation/bloc/register_event.dart b/lib/features/register/presentation/bloc/register_event.dart index a826600..3e2e506 100644 --- a/lib/features/register/presentation/bloc/register_event.dart +++ b/lib/features/register/presentation/bloc/register_event.dart @@ -11,11 +11,13 @@ class RegisterSubmitted extends RegisterEvent { final String phoneNumber; final String countryResidence; final String isdcode; + final String id; const RegisterSubmitted( this.phoneNumber, this.countryResidence, - this.isdcode + this.isdcode, + this.id ); @override diff --git a/lib/features/register/presentation/widgets/register_bottom_section.dart b/lib/features/register/presentation/widgets/register_bottom_section.dart index c88b474..c16f9b8 100644 --- a/lib/features/register/presentation/widgets/register_bottom_section.dart +++ b/lib/features/register/presentation/widgets/register_bottom_section.dart @@ -82,7 +82,8 @@ class RegisterBottomSection extends StatelessWidget { RegisterSubmitted( loginBloc.phoneNumberTextField.text, loginBloc.countrySelectionTextField.text, - loginBloc.isdcode + loginBloc.isdcode, + loginBloc.countryId ), ) : null; diff --git a/lib/features/register/presentation/widgets/register_form.dart b/lib/features/register/presentation/widgets/register_form.dart index 5af77bb..8775002 100644 --- a/lib/features/register/presentation/widgets/register_form.dart +++ b/lib/features/register/presentation/widgets/register_form.dart @@ -36,6 +36,7 @@ class RegisterForm extends StatelessWidget { loginBloc.phoneNumberTextField.text = "${countryState.countryModel.data![selectedCountry].isdCode}"; loginBloc.isdcode="${countryState.countryModel.data![selectedCountry].isdCode}"; + loginBloc.countryId="${countryState.countryModel.data![selectedCountry].id}"; flag = "${ApiEndpoints.base}${countryState.countryModel.data![selectedCountry].flagIcon}"; Globalconst.phonenumber=loginBloc.phoneNumberTextField.text; From c60ca32d82c6a0116116381100aef7e0252e99cf Mon Sep 17 00:00:00 2001 From: poojapandeyx Date: Fri, 12 Jul 2024 19:46:59 +0530 Subject: [PATCH 2/2] api integrated --- lib/Globalconst.dart | 1 + lib/core/routes/routes.dart | 4 ++ .../bloc/GetCountry/get_country_bloc.dart | 2 +- .../repositories/get_country_api.dart | 6 +-- lib/features/login/Repository/LoginAPI.dart | 11 ++++ .../login/presentation/bloc/login_bloc.dart | 22 ++++++-- .../login/presentation/bloc/login_event.dart | 6 +-- .../presentation/widgets/bottom_section.dart | 15 ++---- .../presentation/widgets/login_form.dart | 28 ++++++++-- .../register/Repository/RegisterApi.dart | 18 +++++++ .../presentation/bloc/register_user_bloc.dart | 24 ++++++++- .../bloc/register_user_event.dart | 2 + .../widgets/register_user_bottom_section.dart | 53 +++++++++---------- .../securePin/Repository/PinAPIServices.dart | 17 ++++++ .../securePin/presentation/bloc/pin_bloc.dart | 53 ++++++++++++++++--- .../presentation/bloc/pin_event.dart | 9 ++-- .../widgets/confirm_pin_keypad_section.dart | 2 +- .../widgets/pin_keypad_section.dart | 15 +++++- .../presentation/widgets/pin_top_section.dart | 2 +- lib/shared/api/api_endpoints.dart | 5 ++ lib/shared/components/permission_dialog.dart | 24 ++++++++- 21 files changed, 249 insertions(+), 70 deletions(-) rename lib/features/countrySelection/{domain => }/repositories/get_country_api.dart (58%) create mode 100644 lib/features/login/Repository/LoginAPI.dart create mode 100644 lib/features/register/Repository/RegisterApi.dart create mode 100644 lib/features/securePin/Repository/PinAPIServices.dart diff --git a/lib/Globalconst.dart b/lib/Globalconst.dart index 6a8a72d..10f03d4 100644 --- a/lib/Globalconst.dart +++ b/lib/Globalconst.dart @@ -3,4 +3,5 @@ class Globalconst { static String name = ""; static String phonenumber = ""; static String isdcode = ""; + static String createdpin=""; } diff --git a/lib/core/routes/routes.dart b/lib/core/routes/routes.dart index 3b439e2..23f32f9 100644 --- a/lib/core/routes/routes.dart +++ b/lib/core/routes/routes.dart @@ -1,5 +1,6 @@ // router.dart +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:tanami_app/core/routes/route_name.dart'; import 'package:tanami_app/features/MainScreens/Academy/presentation/pages/academy_details_screen.dart'; @@ -32,6 +33,8 @@ import 'package:tanami_app/features/welcome/presentation/pages/weclome_screen.da import 'package:tanami_app/shared/components/no_internet.dart'; import '../../features/MainScreens/main_screen.dart'; +import '../../features/countrySelection/bloc/GetCountry/get_country_bloc.dart'; +import '../../features/countrySelection/bloc/GetCountry/get_country_event.dart'; import '../../features/forgotPassword/presentation/pages/restore_password_phone_verification_screen.dart'; import '../../features/login/presentation/pages/login_screen.dart'; import '../../features/register/presentation/pages/register_user_details_screen.dart'; @@ -51,6 +54,7 @@ final goRouter = GoRouter( name: "splash", path: RouteName.splashScreen, builder: (context, state) { + context.read().add(GetCountry()); return const SplashScreen(); }, routes: [ diff --git a/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart b/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart index cb671fd..a3bf90e 100644 --- a/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart +++ b/lib/features/countrySelection/bloc/GetCountry/get_country_bloc.dart @@ -3,7 +3,7 @@ import 'package:tanami_app/features/countrySelection/bloc/GetCountry/get_country import '../../../../Api_Helper/base_manager.dart'; import '../../domain/model/get_country_model.dart'; -import '../../domain/repositories/get_country_api.dart'; +import '../../repositories/get_country_api.dart'; import 'get_country_state.dart'; class GetCountryBlock extends Bloc { diff --git a/lib/features/countrySelection/domain/repositories/get_country_api.dart b/lib/features/countrySelection/repositories/get_country_api.dart similarity index 58% rename from lib/features/countrySelection/domain/repositories/get_country_api.dart rename to lib/features/countrySelection/repositories/get_country_api.dart index bf736bf..82010a1 100644 --- a/lib/features/countrySelection/domain/repositories/get_country_api.dart +++ b/lib/features/countrySelection/repositories/get_country_api.dart @@ -1,7 +1,7 @@ -import '../../../../Api_Helper/base_manager.dart'; -import '../../../../shared/api/api_endpoints.dart'; -import '../../../../shared/api/network_api_services.dart'; +import '../../../Api_Helper/base_manager.dart'; +import '../../../shared/api/api_endpoints.dart'; +import '../../../shared/api/network_api_services.dart'; class GetCountryAPI { GetCountryAPI(); diff --git a/lib/features/login/Repository/LoginAPI.dart b/lib/features/login/Repository/LoginAPI.dart new file mode 100644 index 0000000..71de319 --- /dev/null +++ b/lib/features/login/Repository/LoginAPI.dart @@ -0,0 +1,11 @@ +import '../../../Api_Helper/base_manager.dart'; +import '../../../shared/api/api_endpoints.dart'; +import '../../../shared/api/network_api_services.dart'; + +class LoginAPI { + LoginAPI(); + Future LoginRequest(Map data) async { + String url = ApiEndpoints.loginapi; + final response = await NetworkApiService().post(url, data); + return response; + }} \ No newline at end of file diff --git a/lib/features/login/presentation/bloc/login_bloc.dart b/lib/features/login/presentation/bloc/login_bloc.dart index a124603..fe34394 100644 --- a/lib/features/login/presentation/bloc/login_bloc.dart +++ b/lib/features/login/presentation/bloc/login_bloc.dart @@ -1,5 +1,7 @@ import 'package:bloc/bloc.dart'; import 'package:flutter/material.dart'; +import 'package:tanami_app/Api_Helper/base_manager.dart'; +import 'package:tanami_app/features/login/Repository/LoginAPI.dart'; import 'login_event.dart'; import 'login_state.dart'; @@ -10,7 +12,7 @@ class LoginBloc extends Bloc { TextEditingController(); final TextEditingController phoneNumberTextField = TextEditingController(); final TextEditingController passwordTextField = TextEditingController(); - + String countryId = ""; GlobalKey getFormKey() { return formKey; } @@ -29,16 +31,28 @@ class LoginBloc extends Bloc { emit(LoginLoading()); try { // Simulate API call - await Future.delayed(const Duration(seconds: 2)); + //await Future.delayed(const Duration(seconds: 2)); + Map logindata = { + "countryId": event.countryId, + "phoneNumber": event.phoneNumber, + "passwordHash": event.password + }; + ResponseData response = await LoginAPI().LoginRequest(logindata); + if (response.status == ResponseStatus.SUCCESS) { + emit(LoginSuccess()); + } else { + emit(const LoginFailure( + "Login failed. Please check your credentials.")); + } // Replace the next line with actual API call - final isSuccess = await _mockLoginApi( + /* final isSuccess = await _mockLoginApi( event.phoneNumber, event.password, event.countryResidence); if (isSuccess) { emit(LoginSuccess()); } else { emit(const LoginFailure( "Login failed. Please check your credentials.")); - } + } */ } catch (e) { emit(LoginFailure(e.toString())); } diff --git a/lib/features/login/presentation/bloc/login_event.dart b/lib/features/login/presentation/bloc/login_event.dart index 232ec43..6524059 100644 --- a/lib/features/login/presentation/bloc/login_event.dart +++ b/lib/features/login/presentation/bloc/login_event.dart @@ -11,12 +11,10 @@ class LoginSubmitted extends LoginEvent { final String phoneNumber; final String password; final String countryResidence; + final String countryId; const LoginSubmitted( - this.phoneNumber, - this.password, - this.countryResidence, - ); + this.phoneNumber, this.password, this.countryResidence, this.countryId); @override List get props => [phoneNumber, password, countryResidence]; diff --git a/lib/features/login/presentation/widgets/bottom_section.dart b/lib/features/login/presentation/widgets/bottom_section.dart index 3c943df..e7d36eb 100644 --- a/lib/features/login/presentation/widgets/bottom_section.dart +++ b/lib/features/login/presentation/widgets/bottom_section.dart @@ -30,6 +30,7 @@ class BottomSection extends StatelessWidget { var localizations = AppLocalizations.of(context); SecureStorageService secureStorageService = SecureStorageService(); final radioBloc = context.read(); + var loginbloc = context.read(); return Column( children: [ const Gap(12), @@ -87,17 +88,9 @@ class BottomSection extends StatelessWidget { : AppColor.inactiveBtnTxtColor, function: () { isButtonEnabled - ? context.read().add( - LoginSubmitted( - context - .read() - .phoneNumberTextField - .text, - context - .read() - .passwordTextField - .text, - ""), + ? loginbloc.add( + LoginSubmitted(loginbloc.phoneNumberTextField.text, + loginbloc.passwordTextField.text, "",loginbloc.countryId), ) : null; }, diff --git a/lib/features/login/presentation/widgets/login_form.dart b/lib/features/login/presentation/widgets/login_form.dart index 6c29693..2ede852 100644 --- a/lib/features/login/presentation/widgets/login_form.dart +++ b/lib/features/login/presentation/widgets/login_form.dart @@ -4,9 +4,13 @@ import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_text.dart'; import 'package:tanami_app/core/utils/constant/country_flag_data.dart'; +import '../../../../Globalconst.dart'; import '../../../../core/utils/language/localizations_delegate.dart'; +import '../../../../shared/api/api_endpoints.dart'; import '../../../../shared/components/bloc/password_field/password_visibility_bloc.dart'; import '../../../../shared/components/form_label_textfield.dart'; +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/login_bloc.dart'; @@ -18,6 +22,9 @@ class LoginForm extends StatelessWidget { Widget build(BuildContext context) { var localizations = AppLocalizations.of(context); final loginBloc = context.read(); + final countrydata = context.read(); + + String flag = ""; // Reset fields when the screen is built loginBloc.resetFields(); @@ -26,9 +33,24 @@ class LoginForm extends StatelessWidget { int selectedCountry = -1; if (state is RadioSelectionChanged) { selectedCountry = state.selectedIndex; - loginBloc.countrySelectionTextField.text = countryName[selectedCountry]; - loginBloc.phoneNumberTextField.text = - "${isoCountryCode[selectedCountry]} "; + final countryState = countrydata.state; + if (countryState is CountryLoaded) { + loginBloc.countrySelectionTextField.text = countryState + .countryModel.data![selectedCountry].countryName + .toString(); + loginBloc.phoneNumberTextField.text = + "${countryState.countryModel.data![selectedCountry].isdCode}"; + loginBloc.countryId="${countryState.countryModel.data![selectedCountry].id}"; + flag = + "${ApiEndpoints.base}${countryState.countryModel.data![selectedCountry].flagIcon}"; + Globalconst.phonenumber = loginBloc.phoneNumberTextField.text; + + Globalconst.name = countryState + .countryModel.data![selectedCountry].countryName + .toString(); + Globalconst.isdcode = + "${countryState.countryModel.data![selectedCountry].isdCode}"; + } } }, builder: (context, state) { int selectedCountry = -1; diff --git a/lib/features/register/Repository/RegisterApi.dart b/lib/features/register/Repository/RegisterApi.dart new file mode 100644 index 0000000..f9335af --- /dev/null +++ b/lib/features/register/Repository/RegisterApi.dart @@ -0,0 +1,18 @@ +import '../../../Api_Helper/base_manager.dart'; +import '../../../shared/api/api_endpoints.dart'; +import '../../../shared/api/network_api_services.dart'; + +class RegisterAPIService { + RegisterAPIService(); + Future RegisterRequest(Map data) async { + String url = ApiEndpoints.registerrequestapi; + final response = await NetworkApiService().post(url, data); + return response; + } + + Future BiometricUpdate(Map data) async { + String url = ApiEndpoints.biometricUpdateapi; + final response = await NetworkApiService().post(url, data); + return response; + } + } \ No newline at end of file diff --git a/lib/features/register/presentation/bloc/register_user_bloc.dart b/lib/features/register/presentation/bloc/register_user_bloc.dart index 937a3a2..ad4c507 100644 --- a/lib/features/register/presentation/bloc/register_user_bloc.dart +++ b/lib/features/register/presentation/bloc/register_user_bloc.dart @@ -1,5 +1,8 @@ import 'package:bloc/bloc.dart'; import 'package:flutter/material.dart'; +import 'package:tanami_app/Api_Helper/base_manager.dart'; +import 'package:tanami_app/Globalconst.dart'; +import 'package:tanami_app/features/register/Repository/RegisterApi.dart'; import 'register_user_event.dart'; import 'register_user_state.dart'; @@ -30,10 +33,27 @@ class RegisterUserBloc extends Bloc { } emit(RegisterUserLoading()); try { + Map registerdata = { + "token": event.token, + "firstName": event.firstName, + "lastName": event.lastName, + "emailAddress": event.email, + "passwordHash": event.password + }; + ResponseData response = + await RegisterAPIService().RegisterRequest(registerdata); + if (response.status == ResponseStatus.SUCCESS) { + var data=response.data["data"]; + Globalconst.token=data["token"].toString(); + emit(RegisterUserSuccess()); + } 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( + /* final isSuccess = await _mockLoginApi( event.firstName, event.password, event.lastName, @@ -45,7 +65,7 @@ class RegisterUserBloc extends Bloc { } else { emit(const RegisterUserFailure( "Register failed. Please check your credentials.")); - } + } */ } catch (e) { emit(RegisterUserFailure(e.toString())); } diff --git a/lib/features/register/presentation/bloc/register_user_event.dart b/lib/features/register/presentation/bloc/register_user_event.dart index b48da92..6f2b355 100644 --- a/lib/features/register/presentation/bloc/register_user_event.dart +++ b/lib/features/register/presentation/bloc/register_user_event.dart @@ -13,6 +13,7 @@ class RegisterUserSubmitted extends RegisterUserEvent { final String email; final String password; final String confirmPassword; + final String token; const RegisterUserSubmitted( this.firstName, @@ -20,6 +21,7 @@ class RegisterUserSubmitted extends RegisterUserEvent { this.lastName, this.confirmPassword, this.email, + this.token ); @override diff --git a/lib/features/register/presentation/widgets/register_user_bottom_section.dart b/lib/features/register/presentation/widgets/register_user_bottom_section.dart index 233fe3f..eb9e775 100644 --- a/lib/features/register/presentation/widgets/register_user_bottom_section.dart +++ b/lib/features/register/presentation/widgets/register_user_bottom_section.dart @@ -8,6 +8,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:tanami_app/Globalconst.dart'; import 'package:tanami_app/core/styles/app_images.dart'; import 'package:tanami_app/shared/components/checkbox_widget.dart'; import 'package:tanami_app/shared/components/loader.dart'; @@ -31,6 +32,7 @@ class RegisterUserBottomSection extends StatelessWidget { @override Widget build(BuildContext context) { var localizations = AppLocalizations.of(context); + var registerbloc = context.read(); return Column( children: [ const Gap(40), @@ -97,7 +99,7 @@ class RegisterUserBottomSection extends StatelessWidget { Loader.loader(context); } else if (state is RegisterUserSuccess) { goRouter.pop(); - permissionDialog(context); + permissionDialog(context,); } else if (state is RegisterUserFailure) { goRouter.pop(); errorToastMessage( @@ -128,32 +130,29 @@ class RegisterUserBottomSection extends StatelessWidget { ? AppColor.plainWhite : AppColor.inactiveBtnTxtColor, function: () { - isButtonEnabled - ? context.read().add( - RegisterUserSubmitted( - context - .read() - .firstNameTextField - .text, - context - .read() - .passwordTextField - .text, - context - .read() - .lastNameTextField - .text, - context - .read() - .repeatPasswordTextField - .text, - context - .read() - .emailTextField - .text, - ), - ) - : null; + + if(isButtonEnabled==true){ + if (registerbloc.passwordTextField.text != + registerbloc.repeatPasswordTextField.text) { + errorToastMessage( + context, + "Password and Repeat Password does not match.", + ); + }else{ + registerbloc.add( + RegisterUserSubmitted( + registerbloc.firstNameTextField.text, + registerbloc.passwordTextField.text, + registerbloc.lastNameTextField.text, + registerbloc.repeatPasswordTextField.text, + registerbloc.emailTextField.text, + Globalconst.token + ), + ); + } + + } + }, text: localizations.translate(AppText.nextText), clr: isButtonEnabled diff --git a/lib/features/securePin/Repository/PinAPIServices.dart b/lib/features/securePin/Repository/PinAPIServices.dart new file mode 100644 index 0000000..faae0e0 --- /dev/null +++ b/lib/features/securePin/Repository/PinAPIServices.dart @@ -0,0 +1,17 @@ +import '../../../Api_Helper/base_manager.dart'; +import '../../../shared/api/api_endpoints.dart'; +import '../../../shared/api/network_api_services.dart'; + +class PinAPIServices { + PinAPIServices(); + Future ConfirmPin(Map data) async { + String url = ApiEndpoints.confirmpinapi; + final response = await NetworkApiService().post(url, data); + return response; + } + Future Verifypin(Map data) async { + String url = ApiEndpoints.confirmpinapi; + final response = await NetworkApiService().post(url, data); + return response; + } +} diff --git a/lib/features/securePin/presentation/bloc/pin_bloc.dart b/lib/features/securePin/presentation/bloc/pin_bloc.dart index d3fa3a6..b0c3562 100644 --- a/lib/features/securePin/presentation/bloc/pin_bloc.dart +++ b/lib/features/securePin/presentation/bloc/pin_bloc.dart @@ -1,7 +1,10 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:tanami_app/Api_Helper/base_manager.dart'; +import 'package:tanami_app/Globalconst.dart'; import 'package:tanami_app/core/styles/app_text.dart'; import '../../../../core/utils/secure/secure_storage_service.dart'; +import '../../Repository/PinAPIServices.dart'; part 'pin_event.dart'; part 'pin_state.dart'; @@ -16,18 +19,48 @@ class PinBloc extends Bloc { isVerified: false, error: '', verifiedOnce: false)) { - on((event, emit) { + on((event, emit) async { final newPin = state.pin + event.number; if (newPin.length <= 6) { - emit(state.copyWith( + + + if (newPin.length == 6) { + if (event.fromscreen == "login") { + Map verifypindata = { + "token": Globalconst.token, + "masterPin": newPin + }; + ResponseData response = + await PinAPIServices().Verifypin(verifypindata); + if (response.status == ResponseStatus.SUCCESS) { + var data = response.data["user"]; + String accesstoken = data["accessToken"]; + String refreshtoken = data["refreshToken"]; + await secureStorageService.write('accesstoken', accesstoken); + await secureStorageService.write('refreshtoken', refreshtoken); + + emit(state.copyWith( + isVerified: false, + error: AppText.incorrectPinCode, + verifiedOnce: true, + )); + } else { + emit(state.copyWith( + pin: newPin, + pinComplete: newPin.length == 6, + error: 'has error', + isVerified: false, + verifiedOnce: false)); + } + } else { + emit(state.copyWith( pin: newPin, pinComplete: newPin.length == 6, error: '', verifiedOnce: false)); - - if (newPin.length == 6) { - add(VerifyPinPressed(newPin)); + add(VerifyPinPressed(newPin, event.fromscreen)); + } } } }); @@ -49,8 +82,16 @@ class PinBloc extends Bloc { on((event, emit) async { final storedPin = await secureStorageService.read('pin_code'); - + Map pindata = { + "token": Globalconst.token, + "masterPin": event.pin + }; if (storedPin == event.pin) { + ResponseData response = await PinAPIServices().ConfirmPin(pindata); + if (response.status == ResponseStatus.SUCCESS) { + await secureStorageService.write('userMPIN', storedPin.toString()); + } + emit(state.copyWith(isVerified: true, error: '', verifiedOnce: true)); } else { emit(state.copyWith( diff --git a/lib/features/securePin/presentation/bloc/pin_event.dart b/lib/features/securePin/presentation/bloc/pin_event.dart index ba3bc49..c3bb79e 100644 --- a/lib/features/securePin/presentation/bloc/pin_event.dart +++ b/lib/features/securePin/presentation/bloc/pin_event.dart @@ -9,8 +9,9 @@ abstract class PinEvent extends Equatable { class NumberPressed extends PinEvent { final String number; + final String fromscreen; - const NumberPressed(this.number); + const NumberPressed(this.number,this.fromscreen); @override List get props => [number]; @@ -22,9 +23,9 @@ class SavePinPressed extends PinEvent {} class VerifyPinPressed extends PinEvent { final String pin; - - const VerifyPinPressed(this.pin); + final String fromscreen; + const VerifyPinPressed(this.pin,this.fromscreen); @override - List get props => [pin]; + List get props => [pin,fromscreen]; } diff --git a/lib/features/securePin/presentation/widgets/confirm_pin_keypad_section.dart b/lib/features/securePin/presentation/widgets/confirm_pin_keypad_section.dart index 622ce16..698ee3e 100644 --- a/lib/features/securePin/presentation/widgets/confirm_pin_keypad_section.dart +++ b/lib/features/securePin/presentation/widgets/confirm_pin_keypad_section.dart @@ -91,7 +91,7 @@ class ConfirmPinKey extends StatelessWidget { final number = index == 10 ? '0' : '${index + 1}'; return GestureDetector( onTap: () { - context.read().add(NumberPressed(number)); + context.read().add(NumberPressed(number,"confirmpin")); }, child: Container( margin: const EdgeInsets.all(12), diff --git a/lib/features/securePin/presentation/widgets/pin_keypad_section.dart b/lib/features/securePin/presentation/widgets/pin_keypad_section.dart index df792de..daff1fe 100644 --- a/lib/features/securePin/presentation/widgets/pin_keypad_section.dart +++ b/lib/features/securePin/presentation/widgets/pin_keypad_section.dart @@ -23,6 +23,7 @@ class PinKey extends StatelessWidget { @override Widget build(BuildContext context) { + print(fromScreen); var localizations = AppLocalizations.of(context); return Column( crossAxisAlignment: CrossAxisAlignment.end, @@ -34,10 +35,13 @@ class PinKey extends StatelessWidget { state.error.isEmpty && !state.verifiedOnce) { if (fromScreen == "login" || fromScreen == "LoginedInUser") { + print("login true"); successToastMessage(context, localizations.translate(AppText.pinVerifiedSucess)); goRouter.pushNamed(RouteName.mainScreen); } else if (fromScreen == "reset-pin") { + print("reset true"); + log("Running this"); successToastMessage( context, localizations.translate(AppText.pinUpdatedSucess)); @@ -46,6 +50,13 @@ class PinKey extends StatelessWidget { context.read().add(SavePinPressed()); goRouter.pushNamed(RouteName.confirmPinScreen); } + } else { + if (state.pinComplete) { + errorToastMessage( + context, + state.error, + ); + } } }, builder: (context, state) { @@ -124,7 +135,9 @@ class PinKey extends StatelessWidget { final number = index == 10 ? '0' : '${index + 1}'; return GestureDetector( onTap: () { - context.read().add(NumberPressed(number)); + context + .read() + .add(NumberPressed(number, fromScreen)); }, child: Container( margin: const EdgeInsets.all(12), diff --git a/lib/features/securePin/presentation/widgets/pin_top_section.dart b/lib/features/securePin/presentation/widgets/pin_top_section.dart index 24f5195..f122423 100644 --- a/lib/features/securePin/presentation/widgets/pin_top_section.dart +++ b/lib/features/securePin/presentation/widgets/pin_top_section.dart @@ -39,7 +39,7 @@ class PinTopSection extends StatelessWidget { localizations.translate(AppText.welcomeBackText), clr: AppColor.smokeGrayColor), TextWidget() - .text14W700(", Jayesh", clr: AppColor.plainBlack), + .text14W700(", Pooja", clr: AppColor.plainBlack), ], ), TextWidget().text14W500( diff --git a/lib/shared/api/api_endpoints.dart b/lib/shared/api/api_endpoints.dart index 8b00684..966612e 100644 --- a/lib/shared/api/api_endpoints.dart +++ b/lib/shared/api/api_endpoints.dart @@ -7,4 +7,9 @@ class ApiEndpoints { static const requestotpapi = "${baseurl}auth/public/register"; static const requestresendotp = "${baseurl}auth/public/resend-otp"; static const verifyotp = "${baseurl}auth/public/verify-otp"; + static const registerrequestapi = "${baseurl}auth/public/email-register"; + static const biometricUpdateapi = "${baseurl}auth/public/biometric-update"; + static const confirmpinapi="${baseurl}auth/public/masterPin"; + static const loginapi="${baseurl}auth/public/login"; + static const verifypinapi="${baseurl}auth/public/verify-materPin"; } diff --git a/lib/shared/components/permission_dialog.dart b/lib/shared/components/permission_dialog.dart index 3bebdf7..2b76cc6 100644 --- a/lib/shared/components/permission_dialog.dart +++ b/lib/shared/components/permission_dialog.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; +import 'package:tanami_app/Api_Helper/base_manager.dart'; +import 'package:tanami_app/Globalconst.dart'; import 'package:tanami_app/core/styles/app_color.dart'; import '../../core/routes/route_name.dart'; @@ -8,6 +10,7 @@ import '../../core/routes/routes.dart'; import '../../core/styles/app_text.dart'; import '../../core/utils/language/localizations_delegate.dart'; import '../../core/utils/secure/secure_storage_service.dart'; +import '../../features/register/Repository/RegisterApi.dart'; import 'text_widget.dart'; import 'toast_message.dart'; @@ -82,7 +85,15 @@ permissionDialog( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ GestureDetector( - onTap: () { + onTap: () async { + Map biometricdata = { + "token": Globalconst.token, + "is_2FA_on": false + }; + + await RegisterAPIService() + .BiometricUpdate(biometricdata); + successToastMessage(context, "successful !"); goRouter.pop(); @@ -108,7 +119,16 @@ permissionDialog( ), GestureDetector( onTap: () async { - await secureStorageService.write("biometric", 'on'); + Map biometricdata = { + "token": Globalconst.token, + "is_2FA_on": true + }; + + ResponseData response = await RegisterAPIService() + .BiometricUpdate(biometricdata); + if (response.status == ResponseStatus.SUCCESS) { + await secureStorageService.write("biometric", 'on'); + } successToastMessage( context, "Biometric/Face Id Enabled Sucessfully !"); // successToastMessage(context, "successful !");