feat: Implement agent network management and refactor app navigation with a new AppShell component.
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
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/core/widgets/s3_image.dart';
|
||||
import 'package:real_estate_mobile/features/agents/data/models/agent_profile.dart';
|
||||
import 'package:real_estate_mobile/features/agents/presentation/providers/agent_detail_provider.dart';
|
||||
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
||||
import 'package:real_estate_mobile/features/home/presentation/widgets/home_header.dart';
|
||||
import 'package:real_estate_mobile/features/profile/data/profile_repository.dart';
|
||||
|
||||
/// Provider that fetches the agent's own profile ID from /agents/profile/me
|
||||
@@ -30,51 +27,42 @@ class AgentHomeScreen extends ConsumerWidget {
|
||||
final myProfileAsync = ref.watch(_agentMyProfileProvider);
|
||||
|
||||
return myProfileAsync.when(
|
||||
loading: () => const Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.accentOrange,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.accentOrange,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
error: (_, __) => Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.error_outline,
|
||||
size: 48, color: AppColors.accentOrange),
|
||||
const SizedBox(height: 16),
|
||||
const Text('Failed to load profile',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.primaryDark)),
|
||||
const SizedBox(height: 12),
|
||||
TextButton(
|
||||
onPressed: () => ref.invalidate(_agentMyProfileProvider),
|
||||
child: const Text('Retry',
|
||||
style: TextStyle(color: AppColors.accentOrange)),
|
||||
),
|
||||
],
|
||||
),
|
||||
error: (_, __) => Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.error_outline,
|
||||
size: 48, color: AppColors.accentOrange),
|
||||
const SizedBox(height: 16),
|
||||
const Text('Failed to load profile',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.primaryDark)),
|
||||
const SizedBox(height: 12),
|
||||
TextButton(
|
||||
onPressed: () => ref.invalidate(_agentMyProfileProvider),
|
||||
child: const Text('Retry',
|
||||
style: TextStyle(color: AppColors.accentOrange)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
data: (agentProfileId) {
|
||||
if (agentProfileId == null) {
|
||||
return const Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: Text('No agent profile found',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
color: AppColors.primaryDark)),
|
||||
),
|
||||
return const Center(
|
||||
child: Text('No agent profile found',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 16,
|
||||
color: AppColors.primaryDark)),
|
||||
);
|
||||
}
|
||||
return _AgentHomeContent(agentProfileId: agentProfileId);
|
||||
@@ -97,16 +85,14 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
|
||||
Widget build(BuildContext context) {
|
||||
final state = ref.watch(agentDetailProvider(widget.agentProfileId));
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: state.isLoading
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(color: AppColors.accentOrange))
|
||||
: state.error != null
|
||||
? _buildError(state.error!)
|
||||
: _buildContent(state),
|
||||
bottomNavigationBar: _buildBottomNavBar(),
|
||||
);
|
||||
if (state.isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: AppColors.accentOrange));
|
||||
}
|
||||
if (state.error != null) {
|
||||
return _buildError(state.error!);
|
||||
}
|
||||
return _buildContent(state);
|
||||
}
|
||||
|
||||
Widget _buildError(String error) {
|
||||
@@ -140,8 +126,6 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
SafeArea(bottom: false, child: const HomeHeader()),
|
||||
const SizedBox(height: 12),
|
||||
_buildCoverAndAvatar(agent),
|
||||
const SizedBox(height: 16),
|
||||
_buildStatusSection(agent),
|
||||
@@ -968,97 +952,6 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
|
||||
);
|
||||
}
|
||||
|
||||
// ── Bottom Navigation Bar ──
|
||||
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(
|
||||
svgPath: 'assets/icons/nav_home_icon.svg',
|
||||
fallbackIcon: Icons.home,
|
||||
isSelected: true,
|
||||
onTap: () {},
|
||||
),
|
||||
_buildNavItem(
|
||||
svgPath: 'assets/icons/nav_list_icon.svg',
|
||||
fallbackIcon: Icons.list,
|
||||
isSelected: false,
|
||||
onTap: () => context.push('/agents/search'),
|
||||
),
|
||||
_buildNavItem(
|
||||
svgPath: 'assets/icons/nav_messages_icon.svg',
|
||||
fallbackIcon: Icons.chat_bubble,
|
||||
isSelected: false,
|
||||
onTap: () {
|
||||
final authState = ref.read(authProvider);
|
||||
if (authState.status != AuthStatus.authenticated) {
|
||||
context.push('/login');
|
||||
return;
|
||||
}
|
||||
context.push('/messages');
|
||||
},
|
||||
),
|
||||
_buildNavItem(
|
||||
svgPath: 'assets/icons/nav_profile_icon.svg',
|
||||
fallbackIcon: Icons.person_outline,
|
||||
isSelected: false,
|
||||
onTap: () {
|
||||
final authState = ref.read(authProvider);
|
||||
if (authState.status != AuthStatus.authenticated) {
|
||||
context.push('/login');
|
||||
return;
|
||||
}
|
||||
context.push('/profile');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNavItem({
|
||||
required String svgPath,
|
||||
required IconData fallbackIcon,
|
||||
required bool isSelected,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Testimonial Card (same as agent detail screen) ──
|
||||
|
||||
Reference in New Issue
Block a user