Skip to content

Commit

Permalink
Merge pull request #19 from k5924/separate-dashboards
Browse files Browse the repository at this point in the history
Separate-dashboards
  • Loading branch information
k5924 authored Jan 19, 2022
2 parents 1eaeba0 + c2ccbbf commit 04eb0e2
Show file tree
Hide file tree
Showing 22 changed files with 378 additions and 56 deletions.
11 changes: 11 additions & 0 deletions lib/src/providers/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,15 @@ class AuthProvider {
return exceptionsFactory.exceptionCaught()!;
}
}

Future<String?> 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()!;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class _CompleteEndUserProfileState extends State<CompleteEndUserProfile> {
} else {
Navigator.pushReplacementNamed(
context,
DashboardScreen.kID,
EndUserDashboardScreen.kID,
);
EasyLoading.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class _CompleteFinancialAdvisorProfileState
} else {
Navigator.pushReplacementNamed(
context,
DashboardScreen.kID,
FinancialAdvisorDashboardScreen.kID,
);
EasyLoading.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _CompleteSupportManagerProfileState
} else {
Navigator.pushReplacementNamed(
context,
DashboardScreen.kID,
SupportManagerDashboardScreen.kID,
);
EasyLoading.dismiss();
}
Expand Down
29 changes: 0 additions & 29 deletions lib/src/screens/construction_page.dart

This file was deleted.

2 changes: 0 additions & 2 deletions lib/src/screens/dashboard/export.dart

This file was deleted.

87 changes: 87 additions & 0 deletions lib/src/screens/end_user_dashboard/end_user_dashboard_screen.dart
Original file line number Diff line number Diff line change
@@ -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<EndUserDashboardScreen> {
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",
),
],
),
),
);
}
}
1 change: 1 addition & 0 deletions lib/src/screens/end_user_dashboard/export.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'end_user_dashboard_screen.dart';
9 changes: 6 additions & 3 deletions lib/src/screens/export.dart
Original file line number Diff line number Diff line change
@@ -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';
1 change: 1 addition & 0 deletions lib/src/screens/financial_advisor_dashboard/export.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'financial_advisor_dashboard.dart';
Original file line number Diff line number Diff line change
@@ -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<FinancialAdvisorDashboardScreen> {
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",
),
],
),
),
);
}
}
34 changes: 29 additions & 5 deletions lib/src/screens/login/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class _LoginFormState extends State<LoginForm> {
late String verified;
late Object completeProfile;


@override
void dispose() {
// Clean up controllers when form is disposed
Expand All @@ -42,6 +41,10 @@ class _LoginFormState extends State<LoginForm> {
);
}

Future<String?> _getUserType() async {
return authProvider.getUserType();
}

Future<Object> _isProfileComplete() async {
return authProvider.checkProfile();
}
Expand Down Expand Up @@ -100,10 +103,31 @@ class _LoginFormState extends State<LoginForm> {
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(
Expand Down
1 change: 1 addition & 0 deletions lib/src/screens/settings_with_help/export.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'settings_with_help_option.dart';
Loading

0 comments on commit 04eb0e2

Please sign in to comment.