From 789e3435147ea95433b772da5f9dd30575975d3e Mon Sep 17 00:00:00 2001 From: Kamran <56407135+k5924@users.noreply.github.com> Date: Wed, 19 Jan 2022 18:46:51 +0000 Subject: [PATCH 1/5] Update App Version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 565244d..352acd3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 3.2.0+1 +version: 3.3.0+1 environment: sdk: ">=2.12.0 <3.0.0" From 536ff75cc12279f68428af58e7c9f225afb36503 Mon Sep 17 00:00:00 2001 From: Kamran <56407135+k5924@users.noreply.github.com> Date: Wed, 19 Jan 2022 18:47:16 +0000 Subject: [PATCH 2/5] get user type before login --- lib/src/providers/auth_provider.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/providers/auth_provider.dart b/lib/src/providers/auth_provider.dart index ba7ef14..475669d 100644 --- a/lib/src/providers/auth_provider.dart +++ b/lib/src/providers/auth_provider.dart @@ -176,4 +176,15 @@ class AuthProvider { return exceptionsFactory.exceptionCaught()!; } } + + Future getUserType() async { + try { + user = _auth.currentUser; + userModel = await DatabaseProvider(uid: user!.uid).getProfile(); + return userModel.userType; + } on FirebaseAuthException catch (e) { + exceptionsFactory = ExceptionsFactory(e.code); + return exceptionsFactory.exceptionCaught()!; + } + } } From 287402981aaf828367f096aa06e27679b4d8f8fe Mon Sep 17 00:00:00 2001 From: Kamran <56407135+k5924@users.noreply.github.com> Date: Wed, 19 Jan 2022 18:47:47 +0000 Subject: [PATCH 3/5] remove unnecessary page --- lib/src/screens/construction_page.dart | 29 -------------------------- 1 file changed, 29 deletions(-) delete mode 100644 lib/src/screens/construction_page.dart diff --git a/lib/src/screens/construction_page.dart b/lib/src/screens/construction_page.dart deleted file mode 100644 index 2bb0efd..0000000 --- a/lib/src/screens/construction_page.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter/material.dart'; - -class ConstructionPage extends StatefulWidget { - static const String kID = 'construction_page'; - - const ConstructionPage({Key? key}) : super(key: key); - - @override - _ConstructionPageState createState() => _ConstructionPageState(); -} - -class _ConstructionPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "This page is under construction", - style: Theme.of(context).textTheme.headline4, - ), - ], - ), - ), - ); - } -} From 0528639c38b5cb7f6774fcb356314bd9001a7be2 Mon Sep 17 00:00:00 2001 From: Kamran <56407135+k5924@users.noreply.github.com> Date: Wed, 19 Jan 2022 18:48:46 +0000 Subject: [PATCH 4/5] refactor splash screen --- lib/src/screens/splash_screen/export.dart | 1 + lib/src/screens/{ => splash_screen}/splash_screen.dart | 0 2 files changed, 1 insertion(+) create mode 100644 lib/src/screens/splash_screen/export.dart rename lib/src/screens/{ => splash_screen}/splash_screen.dart (100%) diff --git a/lib/src/screens/splash_screen/export.dart b/lib/src/screens/splash_screen/export.dart new file mode 100644 index 0000000..6c28074 --- /dev/null +++ b/lib/src/screens/splash_screen/export.dart @@ -0,0 +1 @@ +export 'splash_screen.dart'; diff --git a/lib/src/screens/splash_screen.dart b/lib/src/screens/splash_screen/splash_screen.dart similarity index 100% rename from lib/src/screens/splash_screen.dart rename to lib/src/screens/splash_screen/splash_screen.dart From c2ccbbf3002ac632c0e257b50d3e50cd91642dd9 Mon Sep 17 00:00:00 2001 From: Kamran <56407135+k5924@users.noreply.github.com> Date: Wed, 19 Jan 2022 18:49:30 +0000 Subject: [PATCH 5/5] Implemented HP-193, HP-104, HP-105 --- .../complete_end_user_profile.dart | 2 +- .../complete_financial_advisor_profile.dart | 2 +- .../complete_support_manager_profile.dart | 2 +- lib/src/screens/dashboard/export.dart | 2 - .../end_user_dashboard_screen.dart | 87 ++++++++++++ .../screens/end_user_dashboard/export.dart | 1 + lib/src/screens/export.dart | 9 +- .../financial_advisor_dashboard/export.dart | 1 + .../financial_advisor_dashboard.dart | 87 ++++++++++++ lib/src/screens/login/login_form.dart | 34 ++++- .../screens/settings_with_help/export.dart | 1 + .../settings_with_help_option.dart | 131 ++++++++++++++++++ .../settings_without_help_option/export.dart | 1 + .../settings_without_help_option.dart} | 9 +- .../support_manager_dashboard/export.dart | 1 + .../support_manager_dashboard_screen.dart} | 16 ++- .../utilities/constants/route_constants.dart | 5 +- 17 files changed, 365 insertions(+), 26 deletions(-) delete mode 100644 lib/src/screens/dashboard/export.dart create mode 100644 lib/src/screens/end_user_dashboard/end_user_dashboard_screen.dart create mode 100644 lib/src/screens/end_user_dashboard/export.dart create mode 100644 lib/src/screens/financial_advisor_dashboard/export.dart create mode 100644 lib/src/screens/financial_advisor_dashboard/financial_advisor_dashboard.dart create mode 100644 lib/src/screens/settings_with_help/export.dart create mode 100644 lib/src/screens/settings_with_help/settings_with_help_option.dart create mode 100644 lib/src/screens/settings_without_help_option/export.dart rename lib/src/screens/{dashboard/settings_screen.dart => settings_without_help_option/settings_without_help_option.dart} (92%) create mode 100644 lib/src/screens/support_manager_dashboard/export.dart rename lib/src/screens/{dashboard/dashboard_screen.dart => support_manager_dashboard/support_manager_dashboard_screen.dart} (80%) diff --git a/lib/src/screens/complete_profile/complete_end_user_profile.dart b/lib/src/screens/complete_profile/complete_end_user_profile.dart index 14bcf37..a30a458 100644 --- a/lib/src/screens/complete_profile/complete_end_user_profile.dart +++ b/lib/src/screens/complete_profile/complete_end_user_profile.dart @@ -76,7 +76,7 @@ class _CompleteEndUserProfileState extends State { } else { Navigator.pushReplacementNamed( context, - DashboardScreen.kID, + EndUserDashboardScreen.kID, ); EasyLoading.dismiss(); } diff --git a/lib/src/screens/complete_profile/complete_financial_advisor_profile.dart b/lib/src/screens/complete_profile/complete_financial_advisor_profile.dart index c76a36d..539a570 100644 --- a/lib/src/screens/complete_profile/complete_financial_advisor_profile.dart +++ b/lib/src/screens/complete_profile/complete_financial_advisor_profile.dart @@ -94,7 +94,7 @@ class _CompleteFinancialAdvisorProfileState } else { Navigator.pushReplacementNamed( context, - DashboardScreen.kID, + FinancialAdvisorDashboardScreen.kID, ); EasyLoading.dismiss(); } diff --git a/lib/src/screens/complete_profile/complete_support_manager_profile.dart b/lib/src/screens/complete_profile/complete_support_manager_profile.dart index 2fb7b30..8788571 100644 --- a/lib/src/screens/complete_profile/complete_support_manager_profile.dart +++ b/lib/src/screens/complete_profile/complete_support_manager_profile.dart @@ -78,7 +78,7 @@ class _CompleteSupportManagerProfileState } else { Navigator.pushReplacementNamed( context, - DashboardScreen.kID, + SupportManagerDashboardScreen.kID, ); EasyLoading.dismiss(); } diff --git a/lib/src/screens/dashboard/export.dart b/lib/src/screens/dashboard/export.dart deleted file mode 100644 index 2150d7d..0000000 --- a/lib/src/screens/dashboard/export.dart +++ /dev/null @@ -1,2 +0,0 @@ -export 'dashboard_screen.dart'; -export 'settings_screen.dart'; diff --git a/lib/src/screens/end_user_dashboard/end_user_dashboard_screen.dart b/lib/src/screens/end_user_dashboard/end_user_dashboard_screen.dart new file mode 100644 index 0000000..82d4c43 --- /dev/null +++ b/lib/src/screens/end_user_dashboard/end_user_dashboard_screen.dart @@ -0,0 +1,87 @@ +// ignore_for_file: use_build_context_synchronously + +import 'package:flutter/material.dart'; +import 'package:monerate/src/screens/export.dart'; +import 'package:monerate/src/screens/settings_with_help/export.dart'; + +class EndUserDashboardScreen extends StatefulWidget { + static const String kID = 'end_user_dashboard_screen'; + const EndUserDashboardScreen({Key? key}) : super(key: key); + + @override + _EndUserDashboardScreenState createState() => _EndUserDashboardScreenState(); +} + +class _EndUserDashboardScreenState extends State { + int _currentIndex = 0; + late PageController _pageController; + + @override + void initState() { + super.initState(); + _pageController = PageController(); + } + + @override + void dispose() { + // Clean up controllers when screen is disposed + _pageController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return WillPopScope( + onWillPop: () async => false, + child: Scaffold( + body: SizedBox.expand( + child: PageView( + controller: _pageController, + onPageChanged: (index) { + setState(() => _currentIndex = index); + }, + children: [ + Center( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(25), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + "End User HomePage", + ), + ], + ), + ), + ), + ), + const SettingsWithHelpOption(), + ], + ), + ), + bottomNavigationBar: BottomNavigationBar( + currentIndex: _currentIndex, + onTap: (value) { + _currentIndex = value; + _pageController.animateToPage( + value, + duration: const Duration(milliseconds: 100), + curve: Curves.linear, + ); + }, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: "Dashboard", + ), + BottomNavigationBarItem( + icon: Icon(Icons.settings), + label: "Settings", + ), + ], + ), + ), + ); + } +} diff --git a/lib/src/screens/end_user_dashboard/export.dart b/lib/src/screens/end_user_dashboard/export.dart new file mode 100644 index 0000000..2b086e8 --- /dev/null +++ b/lib/src/screens/end_user_dashboard/export.dart @@ -0,0 +1 @@ +export 'end_user_dashboard_screen.dart'; diff --git a/lib/src/screens/export.dart b/lib/src/screens/export.dart index 0d9afb6..693ce1b 100644 --- a/lib/src/screens/export.dart +++ b/lib/src/screens/export.dart @@ -1,10 +1,13 @@ export 'change_email/export.dart'; export 'change_password/export.dart'; export 'complete_profile/export.dart'; -export 'construction_page.dart'; -export 'dashboard/export.dart'; +export 'end_user_dashboard/export.dart'; +export 'financial_advisor_dashboard/export.dart'; export 'forgot_password/export.dart'; export 'login/export.dart'; export 'profile/export.dart'; +export 'settings_with_help/export.dart'; +export 'settings_without_help_option/export.dart'; export 'sign_up/export.dart'; -export 'splash_screen.dart'; +export 'splash_screen/export.dart'; +export 'support_manager_dashboard/export.dart'; diff --git a/lib/src/screens/financial_advisor_dashboard/export.dart b/lib/src/screens/financial_advisor_dashboard/export.dart new file mode 100644 index 0000000..ac383f5 --- /dev/null +++ b/lib/src/screens/financial_advisor_dashboard/export.dart @@ -0,0 +1 @@ +export 'financial_advisor_dashboard.dart'; \ No newline at end of file diff --git a/lib/src/screens/financial_advisor_dashboard/financial_advisor_dashboard.dart b/lib/src/screens/financial_advisor_dashboard/financial_advisor_dashboard.dart new file mode 100644 index 0000000..cd991d0 --- /dev/null +++ b/lib/src/screens/financial_advisor_dashboard/financial_advisor_dashboard.dart @@ -0,0 +1,87 @@ +// ignore_for_file: use_build_context_synchronously + +import 'package:flutter/material.dart'; +import 'package:monerate/src/screens/export.dart'; +import 'package:monerate/src/screens/settings_with_help/export.dart'; + +class FinancialAdvisorDashboardScreen extends StatefulWidget { + static const String kID = 'financial_advisor_dashboard_screen'; + const FinancialAdvisorDashboardScreen({Key? key}) : super(key: key); + + @override + _FinancialAdvisorDashboardScreenState createState() => _FinancialAdvisorDashboardScreenState(); +} + +class _FinancialAdvisorDashboardScreenState extends State { + int _currentIndex = 0; + late PageController _pageController; + + @override + void initState() { + super.initState(); + _pageController = PageController(); + } + + @override + void dispose() { + // Clean up controllers when screen is disposed + _pageController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return WillPopScope( + onWillPop: () async => false, + child: Scaffold( + body: SizedBox.expand( + child: PageView( + controller: _pageController, + onPageChanged: (index) { + setState(() => _currentIndex = index); + }, + children: [ + Center( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(25), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Text( + "Financial Advisor HomePage", + ), + ], + ), + ), + ), + ), + const SettingsWithHelpOption(), + ], + ), + ), + bottomNavigationBar: BottomNavigationBar( + currentIndex: _currentIndex, + onTap: (value) { + _currentIndex = value; + _pageController.animateToPage( + value, + duration: const Duration(milliseconds: 100), + curve: Curves.linear, + ); + }, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: "Dashboard", + ), + BottomNavigationBarItem( + icon: Icon(Icons.settings), + label: "Settings", + ), + ], + ), + ), + ); + } +} diff --git a/lib/src/screens/login/login_form.dart b/lib/src/screens/login/login_form.dart index 1faf0cf..bb67477 100644 --- a/lib/src/screens/login/login_form.dart +++ b/lib/src/screens/login/login_form.dart @@ -26,7 +26,6 @@ class _LoginFormState extends State { late String verified; late Object completeProfile; - @override void dispose() { // Clean up controllers when form is disposed @@ -42,6 +41,10 @@ class _LoginFormState extends State { ); } + Future _getUserType() async { + return authProvider.getUserType(); + } + Future _isProfileComplete() async { return authProvider.checkProfile(); } @@ -100,10 +103,31 @@ class _LoginFormState extends State { if (verified == "Email Verified") { completeProfile = await _isProfileComplete(); if (completeProfile == true) { - Navigator.pushNamed( - context, - DashboardScreen.kID, - ); + final userType = await _getUserType(); + if(userType == "End-User"){ + Navigator.pushReplacementNamed( + context, + EndUserDashboardScreen.kID, + ); + EasyLoading.dismiss(); + } + else if(userType == "Financial Advisor"){ + Navigator.pushReplacementNamed( + context, + FinancialAdvisorDashboardScreen.kID, + ); + EasyLoading.dismiss(); + } + else if(userType == "Support Manager"){ + Navigator.pushReplacementNamed( + context, + SupportManagerDashboardScreen.kID, + ); + EasyLoading.dismiss(); + } + else{ + EasyLoading.showError(userType.toString()); + } EasyLoading.dismiss(); } else if (completeProfile == false) { Navigator.pushNamed( diff --git a/lib/src/screens/settings_with_help/export.dart b/lib/src/screens/settings_with_help/export.dart new file mode 100644 index 0000000..fe64733 --- /dev/null +++ b/lib/src/screens/settings_with_help/export.dart @@ -0,0 +1 @@ +export 'settings_with_help_option.dart'; diff --git a/lib/src/screens/settings_with_help/settings_with_help_option.dart b/lib/src/screens/settings_with_help/settings_with_help_option.dart new file mode 100644 index 0000000..f525d5b --- /dev/null +++ b/lib/src/screens/settings_with_help/settings_with_help_option.dart @@ -0,0 +1,131 @@ +// ignore_for_file: use_build_context_synchronously + +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:monerate/src/providers/export.dart'; +import 'package:monerate/src/screens/export.dart'; + +class SettingsWithHelpOption extends StatefulWidget { + const SettingsWithHelpOption({Key? key}) : super(key: key); + + @override + _SettingsWithHelpOptionState createState() => _SettingsWithHelpOptionState(); +} + +class _SettingsWithHelpOptionState extends State { + final AuthProvider authProvider = AuthProvider(); + + Future? _signOut() async { + return authProvider.logout(); + } + + Future _viewPersonalDetails() async { + return authProvider.getProfile(); + } + + @override + Widget build(BuildContext context) { + return Center( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(25), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Settings", + style: Theme.of(context).textTheme.headline5, + ), + const SizedBox( + height: 20, + ), + Card( + elevation: 8, + child: ListTile( + leading: const Icon(Icons.person), + title: const Text("Personal Details"), + onTap: () async { + EasyLoading.show(status: 'loading...'); + final result = await _viewPersonalDetails(); + if (result.runtimeType == String) { + EasyLoading.showError(result.toString()); + } else { + Navigator.pushNamed( + context, + ViewProfileScreen.kID, + arguments: result, + ); + EasyLoading.dismiss(); + } + }, + ), + ), + const SizedBox( + height: 20, + ), + Card( + elevation: 8, + child: ListTile( + leading: const Icon(Icons.email), + title: const Text("Change Email"), + onTap: () => Navigator.pushNamed( + context, + ChangeEmailScreen.kID, + ), + ), + ), + const SizedBox( + height: 20, + ), + Card( + elevation: 8, + child: ListTile( + leading: const Icon(Icons.password), + title: const Text("Change Password"), + onTap: () => Navigator.pushNamed( + context, + ChangePasswordScreen.kID, + ), + ), + ), + const SizedBox( + height: 20, + ), + Card( + elevation: 8, + child: ListTile( + leading: const Icon(Icons.support), + title: const Text("Contact Support"), + onTap: () {}, + ), + ), + const SizedBox( + height: 20, + ), + Card( + elevation: 8, + child: ListTile( + leading: const Icon(Icons.logout), + title: const Text("Logout"), + onTap: () async { + EasyLoading.show(); + final result = await _signOut(); + if (result != null) { + EasyLoading.showError(result); + } else { + Navigator.pushReplacementNamed( + context, + LoginScreen.kID, + ); + EasyLoading.dismiss(); + } + }, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/src/screens/settings_without_help_option/export.dart b/lib/src/screens/settings_without_help_option/export.dart new file mode 100644 index 0000000..c99d838 --- /dev/null +++ b/lib/src/screens/settings_without_help_option/export.dart @@ -0,0 +1 @@ +export 'settings_without_help_option.dart'; diff --git a/lib/src/screens/dashboard/settings_screen.dart b/lib/src/screens/settings_without_help_option/settings_without_help_option.dart similarity index 92% rename from lib/src/screens/dashboard/settings_screen.dart rename to lib/src/screens/settings_without_help_option/settings_without_help_option.dart index 922eef3..7e23477 100644 --- a/lib/src/screens/dashboard/settings_screen.dart +++ b/lib/src/screens/settings_without_help_option/settings_without_help_option.dart @@ -5,14 +5,15 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:monerate/src/providers/export.dart'; import 'package:monerate/src/screens/export.dart'; -class SettingsScreen extends StatefulWidget { - const SettingsScreen({Key? key}) : super(key: key); +class SettingsWithoutHelpOption extends StatefulWidget { + const SettingsWithoutHelpOption({Key? key}) : super(key: key); @override - _SettingsScreenState createState() => _SettingsScreenState(); + _SettingsWithoutHelpOptionState createState() => + _SettingsWithoutHelpOptionState(); } -class _SettingsScreenState extends State { +class _SettingsWithoutHelpOptionState extends State { final AuthProvider authProvider = AuthProvider(); Future? _signOut() async { diff --git a/lib/src/screens/support_manager_dashboard/export.dart b/lib/src/screens/support_manager_dashboard/export.dart new file mode 100644 index 0000000..a250448 --- /dev/null +++ b/lib/src/screens/support_manager_dashboard/export.dart @@ -0,0 +1 @@ +export 'support_manager_dashboard_screen.dart'; diff --git a/lib/src/screens/dashboard/dashboard_screen.dart b/lib/src/screens/support_manager_dashboard/support_manager_dashboard_screen.dart similarity index 80% rename from lib/src/screens/dashboard/dashboard_screen.dart rename to lib/src/screens/support_manager_dashboard/support_manager_dashboard_screen.dart index 6fd33b7..1d8906a 100644 --- a/lib/src/screens/dashboard/dashboard_screen.dart +++ b/lib/src/screens/support_manager_dashboard/support_manager_dashboard_screen.dart @@ -3,15 +3,17 @@ import 'package:flutter/material.dart'; import 'package:monerate/src/screens/export.dart'; -class DashboardScreen extends StatefulWidget { - static const String kID = 'dashboard_screen'; - const DashboardScreen({Key? key}) : super(key: key); +class SupportManagerDashboardScreen extends StatefulWidget { + static const String kID = 'support_manager_dashboard_screen'; + const SupportManagerDashboardScreen({Key? key}) : super(key: key); @override - _DashboardScreenState createState() => _DashboardScreenState(); + _SupportManagerDashboardScreenState createState() => + _SupportManagerDashboardScreenState(); } -class _DashboardScreenState extends State { +class _SupportManagerDashboardScreenState + extends State { int _currentIndex = 0; late PageController _pageController; @@ -48,14 +50,14 @@ class _DashboardScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, children: const [ Text( - "HomePage", + "Support Manager HomePage", ), ], ), ), ), ), - const SettingsScreen(), + const SettingsWithoutHelpOption(), ], ), ), diff --git a/lib/src/utilities/constants/route_constants.dart b/lib/src/utilities/constants/route_constants.dart index b2999f5..4fca1e1 100644 --- a/lib/src/utilities/constants/route_constants.dart +++ b/lib/src/utilities/constants/route_constants.dart @@ -6,7 +6,6 @@ String kInitialRoute = SplashScreen.kID; Map kRoutes = { SplashScreen.kID: (context) => const SplashScreen(), LoginScreen.kID: (context) => const LoginScreen(), - ConstructionPage.kID: (context) => const ConstructionPage(), ForgotPasswordScreen.kID: (context) => const ForgotPasswordScreen(), SignUpScreen.kID: (context) => const SignUpScreen(), CompleteProfileScreen.kID: (context) => const CompleteProfileScreen(), @@ -15,8 +14,10 @@ Map kRoutes = { const CompleteFinancialAdvisorProfile(), CompleteSupportManagerProfile.kID: (context) => const CompleteSupportManagerProfile(), - DashboardScreen.kID: (context) => const DashboardScreen(), ViewProfileScreen.kID: (context) => const ViewProfileScreen(), ChangeEmailScreen.kID: (context) => const ChangeEmailScreen(), ChangePasswordScreen.kID: (context) => const ChangePasswordScreen(), + EndUserDashboardScreen.kID: (context) => const EndUserDashboardScreen(), + SupportManagerDashboardScreen.kID: (context) => const SupportManagerDashboardScreen(), + FinancialAdvisorDashboardScreen.kID: (context) => const FinancialAdvisorDashboardScreen(), };