feat: Implement agent network management and refactor app navigation with a new AppShell component.
This commit is contained in:
@@ -68,6 +68,10 @@ class _MenuDrawer extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final authState = ref.watch(authProvider);
|
||||
final isAuthenticated = authState.status == AuthStatus.authenticated;
|
||||
final user = authState.user;
|
||||
|
||||
return DraggableScrollableSheet(
|
||||
initialChildSize: 0.85,
|
||||
minChildSize: 0.5,
|
||||
@@ -76,7 +80,7 @@ class _MenuDrawer extends ConsumerWidget {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(15)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -90,220 +94,284 @@ class _MenuDrawer extends ConsumerWidget {
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Header with logo and close
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Header bar with logo and close button
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/icons/logo.png',
|
||||
width: 109,
|
||||
height: 29,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.inputFill,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 23, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF648188),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/icons/logo.png',
|
||||
width: 109,
|
||||
height: 29,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
color: AppColors.primaryDark,
|
||||
size: 20,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Profile section (when authenticated)
|
||||
if (isAuthenticated && user != null) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
// Avatar
|
||||
Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: AppColors.inputFill,
|
||||
border: Border.all(
|
||||
color: AppColors.divider,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: ClipOval(
|
||||
child: user.avatar != null
|
||||
? Image.network(
|
||||
user.avatar!,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
const Icon(
|
||||
Icons.person,
|
||||
size: 36,
|
||||
color: AppColors.hintText,
|
||||
),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.person,
|
||||
size: 36,
|
||||
color: AppColors.hintText,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// Name and welcome text
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Welcome Back,',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: user.firstName ?? '',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
' ${user.lastName ?? ''}',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
|
||||
// Menu items
|
||||
Expanded(
|
||||
child: ListView(
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.home_outlined,
|
||||
label: 'Home',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.go('/home');
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.school_outlined,
|
||||
icon: Icons.school_rounded,
|
||||
label: 'Education',
|
||||
onTap: () => Navigator.pop(context),
|
||||
),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.info_outline,
|
||||
icon: Icons.help_rounded,
|
||||
label: "Faq's",
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/faq');
|
||||
},
|
||||
),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.info_rounded,
|
||||
label: 'About Us',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/about');
|
||||
},
|
||||
),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.help_outline,
|
||||
label: "FAQ's",
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/faq');
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.mail_outline,
|
||||
label: 'Contact',
|
||||
icon: Icons.call_rounded,
|
||||
label: 'Call Us',
|
||||
showChevron: false,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/contact');
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
const SizedBox(height: 16),
|
||||
if (ref.watch(authProvider).status ==
|
||||
AuthStatus.authenticated) ...[
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.person_outline,
|
||||
label: 'Account Settings',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/profile');
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.notifications_outlined,
|
||||
label: 'Notification Settings',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/profile');
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
const SizedBox(height: 24),
|
||||
// Log Out button
|
||||
SizedBox(
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Bottom section: Log Out or Login buttons
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
|
||||
child: isAuthenticated
|
||||
? // Log Out button - filled orange
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
height: 54,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
ref.read(authProvider.notifier).logout();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.logout,
|
||||
color: AppColors.accentOrange,
|
||||
size: 20,
|
||||
Icons.logout_rounded,
|
||||
color: AppColors.primaryDark,
|
||||
size: 24,
|
||||
),
|
||||
label: const Text(
|
||||
'Log Out',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 16),
|
||||
side: const BorderSide(
|
||||
color: AppColors.accentOrange,
|
||||
width: 1.5,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
// Login button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/login');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.login,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
label: const Text(
|
||||
'Log In',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.accentOrange,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 16),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: // Login / Sign Up buttons
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 54,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/login');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.login,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
label: const Text(
|
||||
'Log In',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.accentOrange,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 54,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/signup');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.person_add_outlined,
|
||||
color: AppColors.accentOrange,
|
||||
size: 20,
|
||||
),
|
||||
label: const Text(
|
||||
'Sign Up',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(
|
||||
color: AppColors.accentOrange,
|
||||
width: 1.5,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// Sign Up button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/signup');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.person_add_outlined,
|
||||
color: AppColors.accentOrange,
|
||||
size: 20,
|
||||
),
|
||||
label: const Text(
|
||||
'Sign Up',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 16),
|
||||
side: const BorderSide(
|
||||
color: AppColors.accentOrange,
|
||||
width: 1.5,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -317,31 +385,32 @@ class _MenuDrawer extends ConsumerWidget {
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
bool showChevron = true,
|
||||
}) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 18),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: AppColors.primaryDark, size: 24),
|
||||
const SizedBox(width: 16),
|
||||
Icon(icon, color: AppColors.accentOrange, size: 30),
|
||||
const SizedBox(width: 20),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
color: AppColors.hintText,
|
||||
size: 22,
|
||||
),
|
||||
if (showChevron)
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
color: AppColors.hintText,
|
||||
size: 22,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user