feat: Implement agent network management and refactor app navigation with a new AppShell component.
This commit is contained in:
@@ -1,68 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/featured_professionals_section.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/features_section.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/hero_section.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/home_header.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/testimonials_section.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/top_professionals_section.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/trust_stats_section.dart';
|
||||
|
||||
class HomeScreen extends ConsumerStatefulWidget {
|
||||
class HomeScreen extends ConsumerWidget {
|
||||
const HomeScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<HomeScreen> createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends ConsumerState<HomeScreen> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: _buildBody(),
|
||||
bottomNavigationBar: _buildBottomNavBar(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
// Only Home tab (index 0) has content for now
|
||||
switch (_selectedIndex) {
|
||||
case 0:
|
||||
return _buildHomeContent();
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
default:
|
||||
return Center(
|
||||
child: Text(
|
||||
['Home', 'Listings', 'Messages', 'Profile'][_selectedIndex],
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildHomeContent() {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
// Header
|
||||
SafeArea(
|
||||
bottom: false,
|
||||
child: const HomeHeader(),
|
||||
),
|
||||
|
||||
// Hero Section with Search
|
||||
const HeroSection(),
|
||||
const SizedBox(height: 40),
|
||||
@@ -94,102 +47,6 @@ class _HomeScreenState extends ConsumerState<HomeScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
// ── Bottom Navigation Bar (matches Figma node 49:6485) ──
|
||||
Widget _buildBottomNavBar() {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
top: BorderSide(color: Color(0xFFE8E8E8), width: 1),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildNavItem(
|
||||
index: 0,
|
||||
svgPath: 'assets/icons/nav_home_icon.svg',
|
||||
fallbackIcon: Icons.home,
|
||||
),
|
||||
_buildNavItem(
|
||||
index: 1,
|
||||
svgPath: 'assets/icons/nav_list_icon.svg',
|
||||
fallbackIcon: Icons.list,
|
||||
),
|
||||
_buildNavItem(
|
||||
index: 2,
|
||||
svgPath: 'assets/icons/nav_messages_icon.svg',
|
||||
fallbackIcon: Icons.chat_bubble,
|
||||
),
|
||||
_buildNavItem(
|
||||
index: 3,
|
||||
svgPath: 'assets/icons/nav_profile_icon.svg',
|
||||
fallbackIcon: Icons.person_outline,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNavItem({
|
||||
required int index,
|
||||
required String svgPath,
|
||||
required IconData fallbackIcon,
|
||||
}) {
|
||||
final isSelected = _selectedIndex == index;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (index == 1) {
|
||||
context.push('/agents/search');
|
||||
return;
|
||||
}
|
||||
if (index == 2) {
|
||||
final authState = ref.read(authProvider);
|
||||
if (authState.status != AuthStatus.authenticated) {
|
||||
context.push('/login');
|
||||
return;
|
||||
}
|
||||
context.push('/messages');
|
||||
return;
|
||||
}
|
||||
if (index == 3) {
|
||||
final authState = ref.read(authProvider);
|
||||
if (authState.status != AuthStatus.authenticated) {
|
||||
context.push('/login');
|
||||
return;
|
||||
}
|
||||
context.push('/profile');
|
||||
return;
|
||||
}
|
||||
setState(() => _selectedIndex = index);
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: SvgPicture.asset(
|
||||
svgPath,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: isSelected
|
||||
? const ColorFilter.mode(AppColors.primaryDark, BlendMode.srcIn)
|
||||
: const ColorFilter.mode(AppColors.accentOrange, BlendMode.srcIn),
|
||||
placeholderBuilder: (_) => Icon(
|
||||
fallbackIcon,
|
||||
size: 24,
|
||||
color: isSelected ? AppColors.primaryDark : AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFooter() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
|
||||
@@ -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