diff --git a/lib/core/styles/app_text.dart b/lib/core/styles/app_text.dart index 579545d..9d3009e 100644 --- a/lib/core/styles/app_text.dart +++ b/lib/core/styles/app_text.dart @@ -158,7 +158,8 @@ class AppText { static const String withdrawAmt = 'Total Withdrawal amount:'; static const String depositAmt = 'Total Deposit amount:'; static const String info2 = 'Payment can include transfer fee from your bank'; - static const String info3 = 'To accomplish payment please use payment details and Reference ID in tour Bank'; + static const String info3 = + 'To accomplish payment please use payment details and Reference ID in tour Bank'; static const String next = 'Next'; static const String depositNoti = 'Create deposit notification'; static const String submit = 'Submit request'; @@ -194,6 +195,7 @@ class AppText { static const String noText = "No"; static const String yesText = "Yes"; static const String pinUpdatedSucess = "Pin updated Sucessfully !"; + static const String pinVerifiedSucess = "Pin verified Sucessfully !"; static const String passwordUpdatedSucess = "Password updated Sucessfully !"; static const String changePasswordText = "Change Password"; static const String newPasswordText = "New Password"; diff --git a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart index 99fd29b..b717f81 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart @@ -35,7 +35,7 @@ class InvestPayMethodSection extends StatelessWidget { }, child: Container( clipBehavior: Clip.antiAlias, - padding: const EdgeInsets.all(12), + // padding: const EdgeInsets.all(12), decoration: ShapeDecoration( color: Colors.white, shape: RoundedRectangleBorder( @@ -59,70 +59,81 @@ class InvestPayMethodSection extends StatelessWidget { ), child: Column( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Radio( - activeColor: AppColor.radioActiveColor, - value: 0, - groupValue: selectedIndex, - onChanged: (int? value) { - if (value != null) { - radioBloc.add(RadioSelected(value)); - } - }, - ), - const Gap(5), - SvgPicture.asset(AppImages.walletIcon), - const Gap(5), - TextWidget().text14W700(AppText.walletText, - clr: AppColor.textLabelColor), - ], - ), - Container( - decoration: const BoxDecoration( - border: Border( - bottom: - BorderSide(width: 1, color: Colors.grey))), - child: Row( + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: selectedIndex == 0 + ? const Color(0xFFE4F5E9) + : const Color(0xCCE2E2E2), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( children: [ - RichText( - text: TextSpan( - children: [ - TextSpan( - text: '${AppText.balanceText}: ', - style: GoogleFonts.dmSans( - color: Colors.grey, - fontSize: 12.0, - fontWeight: FontWeight.bold, - ), - ), - TextSpan( - text: 'SAR 178,000', - style: GoogleFonts.dmSans( - color: Colors.black, - fontSize: 14.0, - fontWeight: FontWeight.bold, - ), - ), - ], - ), + Radio( + activeColor: AppColor.radioActiveColor, + value: 0, + groupValue: selectedIndex, + onChanged: (int? value) { + if (value != null) { + radioBloc.add(RadioSelected(value)); + } + }, ), - const Icon( - Icons.arrow_forward, - color: Colors.grey, - size: 15, - ) + const Gap(5), + SvgPicture.asset(AppImages.walletIcon), + const Gap(5), + TextWidget().text14W700(AppText.walletText, + clr: AppColor.textLabelColor), ], ), - ), - ], + Container( + decoration: const BoxDecoration( + border: Border( + bottom: BorderSide( + width: 1, color: Colors.grey))), + child: Row( + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '${AppText.balanceText}: ', + style: GoogleFonts.dmSans( + color: Colors.grey, + fontSize: 12.0, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: 'SAR 178,000', + style: GoogleFonts.dmSans( + color: Colors.black, + fontSize: 14.0, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + const Icon( + Icons.arrow_forward, + color: Colors.grey, + size: 15, + ) + ], + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(12), + child: TextWidget().text14W500( + "condimentum ac, vestibulum eu nisl.torquent per conubia nostra, per inceptos himenaeos.", + clr: AppColor.textLabelColor), ), - TextWidget().text14W500( - "condimentum ac, vestibulum eu nisl.torquent per conubia nostra, per inceptos himenaeos.", - clr: AppColor.textLabelColor), const Gap(12), ], ), @@ -135,7 +146,7 @@ class InvestPayMethodSection extends StatelessWidget { }, child: Container( clipBehavior: Clip.antiAlias, - padding: const EdgeInsets.all(12), + // padding: const EdgeInsets.all(12), decoration: ShapeDecoration( color: Colors.white, shape: RoundedRectangleBorder( @@ -159,33 +170,44 @@ class InvestPayMethodSection extends StatelessWidget { ), child: Column( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Radio( - activeColor: AppColor.radioActiveColor, - value: 1, - groupValue: selectedIndex, - onChanged: (int? value) { - if (value != null) { - radioBloc.add(RadioSelected(value)); - } - }, - ), - const Gap(5), - SvgPicture.asset(AppImages.applePayIcon), - const Gap(5), - TextWidget().text14W700(AppText.applePayText, - clr: AppColor.textLabelColor), - ], - ), - ], + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: selectedIndex == 1 + ? const Color(0xFFE4F5E9) + : const Color(0xCCE2E2E2), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Radio( + activeColor: AppColor.radioActiveColor, + value: 1, + groupValue: selectedIndex, + onChanged: (int? value) { + if (value != null) { + radioBloc.add(RadioSelected(value)); + } + }, + ), + const Gap(5), + SvgPicture.asset(AppImages.applePayIcon), + const Gap(5), + TextWidget().text14W700(AppText.applePayText, + clr: AppColor.textLabelColor), + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(12.0), + child: TextWidget().text14W500( + AppText.instantTransferFundsApplePayText, + clr: AppColor.textLabelColor), ), - TextWidget().text14W500( - AppText.instantTransferFundsApplePayText, - clr: AppColor.textLabelColor), const Gap(12), ], ), diff --git a/lib/features/MainScreens/main_screen.dart b/lib/features/MainScreens/main_screen.dart index 028360d..95e53f3 100644 --- a/lib/features/MainScreens/main_screen.dart +++ b/lib/features/MainScreens/main_screen.dart @@ -8,6 +8,7 @@ import 'package:tanami_app/features/MainScreens/Wallet/presentation/pages/wallet import 'package:tanami_app/shared/components/common_bottom_navigation.dart'; import '../../shared/components/bloc/bottom_nav_bar/bottom_navigation_bloc.dart'; +import '../../shared/components/bloc/bottom_nav_bar/bottom_navigation_event.dart'; import '../../shared/components/bloc/bottom_nav_bar/bottom_navigation_state.dart'; import '../../shared/components/exit_app_dialog.dart'; @@ -26,6 +27,7 @@ class MainScreen extends StatelessWidget { const MainScreen({super.key}); @override Widget build(BuildContext context) { + final PageController pageController = PageController(); return BlocBuilder( builder: (context, state) { int selectedIndex = (state as TabState).selectedIndex; @@ -36,8 +38,22 @@ class MainScreen extends StatelessWidget { }, child: Scaffold( backgroundColor: Colors.white, - body: currentTab[selectedIndex], - bottomNavigationBar: bottomnavigationbar(context, selectedIndex), + body: PageView( + controller: pageController, + physics: const NeverScrollableScrollPhysics(), // Disable swipe + onPageChanged: (index) { + context.read().add(TabChanged(index)); + }, + children: const [ + WalletScreen(), + PortfolioScreen(), + InvestScreen(), + AcademyScreen(), + SettingsScreen(), + ], + ), + bottomNavigationBar: + bottomnavigationbar(context, selectedIndex, pageController), ), ); }, diff --git a/lib/features/login/presentation/widgets/bottom_section.dart b/lib/features/login/presentation/widgets/bottom_section.dart index c192af8..4087117 100644 --- a/lib/features/login/presentation/widgets/bottom_section.dart +++ b/lib/features/login/presentation/widgets/bottom_section.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; +import 'package:tanami_app/core/utils/secure/secure_storage_service.dart'; import 'package:tanami_app/shared/components/loader.dart'; import 'package:tanami_app/shared/components/toast_message.dart'; @@ -25,6 +26,7 @@ class BottomSection extends StatelessWidget { @override Widget build(BuildContext context) { + SecureStorageService secureStorageService = SecureStorageService(); final radioBloc = context.read(); return Column( children: [ @@ -42,7 +44,7 @@ class BottomSection extends StatelessWidget { ), const Gap(20), BlocConsumer( - listener: (context, state) { + listener: (context, state) async { if (state is LoginLoading) { Loader.loader(context); } else if (state is LoginSuccess) { @@ -50,6 +52,7 @@ class BottomSection extends StatelessWidget { successToastMessage(context, "login successful !"); goRouter.pop(); radioBloc.resetSelection(); + await secureStorageService.write('isLoginedIn', "true"); goRouter.pushNamed(RouteName.pinScreen, pathParameters: { "fromScreen": fromScreen == "forgot-pin" ? "forgot-pin" : "login", diff --git a/lib/features/securePin/presentation/pages/pin_screen.dart b/lib/features/securePin/presentation/pages/pin_screen.dart index 0505eec..725fc75 100644 --- a/lib/features/securePin/presentation/pages/pin_screen.dart +++ b/lib/features/securePin/presentation/pages/pin_screen.dart @@ -5,6 +5,7 @@ import '../../../../core/styles/app_color.dart'; import '../../../../core/styles/app_text.dart'; import '../../../../core/utils/secure/secure_storage_service.dart'; import '../../../../shared/components/appbar_widget.dart'; +import '../../../../shared/components/exit_app_dialog.dart'; import '../bloc/pin_bloc.dart'; import 'pin_layout.dart'; @@ -15,28 +16,38 @@ class PinScreen extends StatelessWidget { @override Widget build(BuildContext context) { final secureStorageService = SecureStorageService(); - return Scaffold( - backgroundColor: AppColor.plainWhite, - appBar: fromScreen == "register" || fromScreen == "reset-pin" - ? AppBarWidget( - height: 75, - titleTxt: fromScreen == "reset-pin" - ? AppText.changePinCode - : AppText.createPinCode, - showLeading: fromScreen == "reset-pin" ? true : false, - ) - : null, - resizeToAvoidBottomInset: true, - body: MultiBlocProvider( - providers: [ - BlocProvider( - // Create an instance of the OnboardingBloc - create: (context) => - PinBloc(secureStorageService: secureStorageService), + return WillPopScope( + onWillPop: () async { + if (fromScreen == "LoginedInUser") { + exitAppDialog(context); + return false; + } else { + return true; + } + }, + child: Scaffold( + backgroundColor: AppColor.plainWhite, + appBar: fromScreen == "register" || fromScreen == "reset-pin" + ? AppBarWidget( + height: 75, + titleTxt: fromScreen == "reset-pin" + ? AppText.changePinCode + : AppText.createPinCode, + showLeading: fromScreen == "reset-pin" ? true : false, + ) + : null, + resizeToAvoidBottomInset: true, + body: MultiBlocProvider( + providers: [ + BlocProvider( + // Create an instance of the OnboardingBloc + create: (context) => + PinBloc(secureStorageService: secureStorageService), + ), + ], + child: PinLayout( + fromScreen: fromScreen, ), - ], - child: PinLayout( - fromScreen: fromScreen, ), ), ); diff --git a/lib/features/securePin/presentation/widgets/pin_keypad_section.dart b/lib/features/securePin/presentation/widgets/pin_keypad_section.dart index caee038..0c8e02f 100644 --- a/lib/features/securePin/presentation/widgets/pin_keypad_section.dart +++ b/lib/features/securePin/presentation/widgets/pin_keypad_section.dart @@ -31,7 +31,8 @@ class PinKey extends StatelessWidget { if (state.pinComplete && state.error.isEmpty && !state.verifiedOnce) { - if (fromScreen == "login") { + if (fromScreen == "login" || fromScreen == "LoginedInUser") { + successToastMessage(context, AppText.pinVerifiedSucess); goRouter.pushNamed(RouteName.mainScreen); } else if (fromScreen == "reset-pin") { log("Running this"); diff --git a/lib/features/securePin/presentation/widgets/pin_top_section.dart b/lib/features/securePin/presentation/widgets/pin_top_section.dart index a1daf83..8adceb3 100644 --- a/lib/features/securePin/presentation/widgets/pin_top_section.dart +++ b/lib/features/securePin/presentation/widgets/pin_top_section.dart @@ -25,7 +25,7 @@ class PinTopSection extends StatelessWidget { ), ), const Gap(40), - fromScreen == "login" + (fromScreen == "login" || fromScreen == "LoginedInUser") ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/features/splash/presentation/pages/splash_screen.dart b/lib/features/splash/presentation/pages/splash_screen.dart index 6ba4c6c..d99aa0a 100644 --- a/lib/features/splash/presentation/pages/splash_screen.dart +++ b/lib/features/splash/presentation/pages/splash_screen.dart @@ -4,6 +4,7 @@ import 'package:tanami_app/core/routes/route_name.dart'; import 'package:tanami_app/core/routes/routes.dart'; import '../../../../core/styles/app_color.dart'; +import '../../../../core/utils/secure/secure_storage_service.dart'; import '../bloc/app_version/app_version_bloc.dart'; import '../bloc/app_version/app_version_event.dart'; import '../bloc/splash/splash_bloc.dart'; @@ -16,6 +17,7 @@ class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { + SecureStorageService secureStorageService = SecureStorageService(); return Scaffold( backgroundColor: AppColor.plainWhite, body: MultiBlocProvider( @@ -32,11 +34,21 @@ class SplashScreen extends StatelessWidget { // Set the child of the MultiBlocProvider to a BlocListener widget child: BlocListener( // Define the listener function for the BlocListener widget - listener: (context, state) { + listener: (context, state) async { // Check if the current state is SplashCompleted if (state is SplashCompleted) { - // Navigate to the WelcomeScreen using the goRouter - goRouter.goNamed(RouteName.welcomeScreen); + if (await secureStorageService.read('isLoginedIn') == null) { + goRouter.goNamed(RouteName.welcomeScreen); + } else { + if (await secureStorageService.read('isLoginedIn') == "false") { + // Navigate to the WelcomeScreen using the goRouter + goRouter.goNamed(RouteName.welcomeScreen); + } else { + goRouter.goNamed(RouteName.pinScreen, pathParameters: { + "fromScreen": "LoginedInUser", + }); + } + } } }, child: const SplashLayout(), diff --git a/lib/shared/components/common_bottom_navigation.dart b/lib/shared/components/common_bottom_navigation.dart index 6c0845a..fd916ed 100644 --- a/lib/shared/components/common_bottom_navigation.dart +++ b/lib/shared/components/common_bottom_navigation.dart @@ -7,7 +7,8 @@ import 'package:tanami_app/core/styles/app_color.dart'; import 'bloc/bottom_nav_bar/bottom_navigation_bloc.dart'; import 'bloc/bottom_nav_bar/bottom_navigation_event.dart'; -Widget bottomnavigationbar(BuildContext context, selectedIndex) { +Widget bottomnavigationbar( + BuildContext context, selectedIndex, PageController pageController) { return BottomNavigationBar( type: BottomNavigationBarType.fixed, showUnselectedLabels: true, @@ -25,6 +26,8 @@ Widget bottomnavigationbar(BuildContext context, selectedIndex) { ), currentIndex: selectedIndex, onTap: (index) { + pageController.jumpToPage(index); + context.read().add(TabChanged(index)); }, items: [ diff --git a/lib/shared/components/log_out_dialog.dart b/lib/shared/components/log_out_dialog.dart index 060914d..23cf883 100644 --- a/lib/shared/components/log_out_dialog.dart +++ b/lib/shared/components/log_out_dialog.dart @@ -6,9 +6,11 @@ import '../../core/routes/route_name.dart'; import '../../core/routes/routes.dart'; import '../../core/styles/app_color.dart'; import '../../core/styles/app_text.dart'; +import '../../core/utils/secure/secure_storage_service.dart'; import 'text_widget.dart'; buildprofilelogoutdialog(context) { + SecureStorageService secureStorageService = SecureStorageService(); return showDialog( context: context, builder: (context) => Column( @@ -79,7 +81,8 @@ buildprofilelogoutdialog(context) { ), Gap(28.w), InkWell( - onTap: () { + onTap: () async { + await secureStorageService.write('isLoginedIn', "false"); goRouter.goNamed(RouteName.loginScreen, pathParameters: { "fromScreen": "registerStep", });