feat: Add FAQ screen and navigation, implement authentication-gated access for home screen features, and dynamically render header menu options based on authentication status.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
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';
|
||||
@@ -10,14 +12,14 @@ import 'package:real_estate_mobile/features/home/presentation/widgets/testimonia
|
||||
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 StatefulWidget {
|
||||
class HomeScreen extends ConsumerStatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
|
||||
@override
|
||||
State<HomeScreen> createState() => _HomeScreenState();
|
||||
ConsumerState<HomeScreen> createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
class _HomeScreenState extends ConsumerState<HomeScreen> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
@override
|
||||
@@ -148,6 +150,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
context.push('/agents/search');
|
||||
return;
|
||||
}
|
||||
if (index == 2 || index == 3) {
|
||||
final authState = ref.read(authProvider);
|
||||
if (authState.status != AuthStatus.authenticated) {
|
||||
context.push('/login');
|
||||
return;
|
||||
}
|
||||
}
|
||||
setState(() => _selectedIndex = index);
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
|
||||
@@ -154,7 +154,10 @@ class _MenuDrawer extends ConsumerWidget {
|
||||
context,
|
||||
icon: Icons.help_outline,
|
||||
label: "FAQ's",
|
||||
onTap: () => Navigator.pop(context),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
context.push('/faq');
|
||||
},
|
||||
),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
@@ -165,55 +168,128 @@ class _MenuDrawer extends ConsumerWidget {
|
||||
const SizedBox(height: 16),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
const SizedBox(height: 16),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.person_outline,
|
||||
label: 'Account Settings',
|
||||
onTap: () => Navigator.pop(context),
|
||||
),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.notifications_outlined,
|
||||
label: 'Notification Settings',
|
||||
onTap: () => Navigator.pop(context),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
const SizedBox(height: 24),
|
||||
// Log Out button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
ref.read(authProvider.notifier).logout();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.logout,
|
||||
color: AppColors.accentOrange,
|
||||
size: 20,
|
||||
),
|
||||
label: const Text(
|
||||
'Log Out',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
if (ref.watch(authProvider).status ==
|
||||
AuthStatus.authenticated) ...[
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.person_outline,
|
||||
label: 'Account Settings',
|
||||
onTap: () => Navigator.pop(context),
|
||||
),
|
||||
_buildMenuItem(
|
||||
context,
|
||||
icon: Icons.notifications_outlined,
|
||||
label: 'Notification Settings',
|
||||
onTap: () => Navigator.pop(context),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(color: AppColors.divider, height: 1),
|
||||
const SizedBox(height: 24),
|
||||
// Log Out button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
ref.read(authProvider.notifier).logout();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.logout,
|
||||
color: AppColors.accentOrange,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
side: const BorderSide(
|
||||
color: AppColors.accentOrange,
|
||||
width: 1.5,
|
||||
label: const Text(
|
||||
'Log Out',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
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,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.accentOrange,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 16),
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user