2026-02-25 06:55:05 +05:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
2026-03-14 14:53:46 +05:30
|
|
|
import 'package:shimmer/shimmer.dart';
|
2026-02-25 06:55:05 +05:30
|
|
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
2026-03-07 22:19:17 +05:30
|
|
|
import 'package:real_estate_mobile/core/widgets/s3_image.dart';
|
2026-03-14 23:33:32 +05:30
|
|
|
import 'package:real_estate_mobile/features/home/data/models/landing_page_content.dart';
|
|
|
|
|
import 'package:real_estate_mobile/features/home/presentation/providers/home_provider.dart';
|
2026-02-25 06:55:05 +05:30
|
|
|
|
|
|
|
|
/// Featured professionals carousel shown above the agents/lenders tab section.
|
2026-03-14 23:33:32 +05:30
|
|
|
/// Uses CMS data from the admin panel (Top Professionals section).
|
2026-02-25 06:55:05 +05:30
|
|
|
class FeaturedProfessionalsSection extends ConsumerStatefulWidget {
|
|
|
|
|
const FeaturedProfessionalsSection({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
ConsumerState<FeaturedProfessionalsSection> createState() =>
|
|
|
|
|
_FeaturedProfessionalsSectionState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _FeaturedProfessionalsSectionState
|
|
|
|
|
extends ConsumerState<FeaturedProfessionalsSection> {
|
|
|
|
|
int _currentPage = 0;
|
2026-03-07 10:25:53 +05:30
|
|
|
late ScrollController _scrollController;
|
2026-02-25 06:55:05 +05:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2026-03-07 10:25:53 +05:30
|
|
|
_scrollController = ScrollController();
|
|
|
|
|
_scrollController.addListener(_onScroll);
|
2026-02-25 06:55:05 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
2026-03-07 10:25:53 +05:30
|
|
|
_scrollController.removeListener(_onScroll);
|
|
|
|
|
_scrollController.dispose();
|
2026-02-25 06:55:05 +05:30
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 10:25:53 +05:30
|
|
|
void _onScroll() {
|
|
|
|
|
if (!_scrollController.hasClients) return;
|
|
|
|
|
final cardWidth = MediaQuery.of(context).size.width - 80;
|
|
|
|
|
if (cardWidth <= 0) return;
|
|
|
|
|
final page = (_scrollController.offset / cardWidth).round();
|
|
|
|
|
if (page != _currentPage) {
|
|
|
|
|
setState(() => _currentPage = page);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 06:55:05 +05:30
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-14 23:33:32 +05:30
|
|
|
final homeState = ref.watch(homeProvider);
|
2026-03-30 15:12:09 +05:30
|
|
|
final featuresContent = homeState.content?.features;
|
2026-02-25 06:55:05 +05:30
|
|
|
|
2026-03-30 15:12:09 +05:30
|
|
|
// Use CMS featuredAgents from features section (matches web)
|
|
|
|
|
final professionals = featuresContent?.featuredAgents ?? [];
|
2026-03-14 23:33:32 +05:30
|
|
|
|
|
|
|
|
if (homeState.isLoading) {
|
2026-03-14 14:53:46 +05:30
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 40),
|
|
|
|
|
child: Shimmer.fromColors(
|
|
|
|
|
baseColor: const Color(0xFFE0E0E0),
|
|
|
|
|
highlightColor: const Color(0xFFF5F5F5),
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 370,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
height: 192,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
2026-03-14 20:59:47 +05:30
|
|
|
borderRadius: BorderRadius.vertical(
|
|
|
|
|
top: Radius.circular(15),
|
|
|
|
|
),
|
2026-03-14 14:53:46 +05:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Container(height: 16, width: 160, color: Colors.white),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Container(height: 12, width: 100, color: Colors.white),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
Container(height: 14, width: 180, color: Colors.white),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
Container(height: 12, width: 140, color: Colors.white),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2026-03-07 10:25:53 +05:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (professionals.isEmpty) {
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
}
|
2026-02-25 06:55:05 +05:30
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 40),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
// Card carousel
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 370,
|
2026-03-07 10:25:53 +05:30
|
|
|
child: ListView.builder(
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
physics: const BouncingScrollPhysics(),
|
2026-02-25 06:55:05 +05:30
|
|
|
itemCount: professionals.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
2026-03-07 10:25:53 +05:30
|
|
|
final cardWidth = MediaQuery.of(context).size.width - 80;
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: cardWidth,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
left: index == 0 ? 0 : 8,
|
|
|
|
|
right: index == professionals.length - 1 ? 0 : 8,
|
|
|
|
|
),
|
2026-03-14 21:30:37 +05:30
|
|
|
child: _buildFeaturedCard(professionals[index], index),
|
2026-03-07 10:25:53 +05:30
|
|
|
),
|
|
|
|
|
);
|
2026-02-25 06:55:05 +05:30
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
|
|
|
|
// Dot indicators
|
|
|
|
|
_buildDotIndicators(professionals.length),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 15:12:09 +05:30
|
|
|
Widget _buildFeaturedCard(FeaturedAgentItem item, int index) {
|
2026-02-25 06:55:05 +05:30
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
|
border: Border.all(color: AppColors.primaryDark, width: 0.1),
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2026-03-07 10:25:53 +05:30
|
|
|
mainAxisSize: MainAxisSize.min,
|
2026-02-25 06:55:05 +05:30
|
|
|
children: [
|
|
|
|
|
// Image
|
|
|
|
|
ClipRRect(
|
2026-03-14 20:59:47 +05:30
|
|
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(15)),
|
2026-03-14 23:33:32 +05:30
|
|
|
child: item.imageUrl.isNotEmpty
|
|
|
|
|
? S3Image(
|
|
|
|
|
imageUrl: item.imageUrl,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 192,
|
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
|
placeholder: (_) => _buildImagePlaceholder(index),
|
|
|
|
|
errorWidget: (_) => _buildImagePlaceholder(index),
|
|
|
|
|
)
|
|
|
|
|
: _buildImagePlaceholder(index),
|
2026-02-25 06:55:05 +05:30
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// Content
|
2026-03-07 10:25:53 +05:30
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 14),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// Name
|
|
|
|
|
Text(
|
2026-03-14 23:33:32 +05:30
|
|
|
item.name,
|
2026-03-07 10:25:53 +05:30
|
|
|
style: const TextStyle(
|
|
|
|
|
fontFamily: 'Fractul',
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
color: AppColors.primaryDark,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 2),
|
|
|
|
|
|
2026-03-30 15:12:09 +05:30
|
|
|
// Role
|
|
|
|
|
if (item.role.isNotEmpty)
|
2026-02-25 06:55:05 +05:30
|
|
|
Text(
|
2026-03-30 15:12:09 +05:30
|
|
|
item.role,
|
2026-02-25 06:55:05 +05:30
|
|
|
style: const TextStyle(
|
|
|
|
|
fontFamily: 'Fractul',
|
2026-03-07 10:25:53 +05:30
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
2026-02-25 06:55:05 +05:30
|
|
|
color: AppColors.primaryDark,
|
|
|
|
|
),
|
2026-03-07 10:25:53 +05:30
|
|
|
maxLines: 1,
|
2026-02-25 06:55:05 +05:30
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
2026-03-07 10:25:53 +05:30
|
|
|
const SizedBox(height: 6),
|
2026-02-25 06:55:05 +05:30
|
|
|
|
2026-03-30 15:12:09 +05:30
|
|
|
// Verified badge + Rating
|
2026-03-07 10:25:53 +05:30
|
|
|
Row(
|
|
|
|
|
children: [
|
2026-03-14 23:33:32 +05:30
|
|
|
SvgPicture.asset(
|
|
|
|
|
'assets/icons/verified_badge_icon.svg',
|
|
|
|
|
width: 16,
|
|
|
|
|
height: 16,
|
|
|
|
|
placeholderBuilder: (_) => const Icon(
|
|
|
|
|
Icons.verified,
|
|
|
|
|
color: Color(0xFF638559),
|
|
|
|
|
size: 16,
|
2026-02-25 06:55:05 +05:30
|
|
|
),
|
2026-03-14 23:33:32 +05:30
|
|
|
),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
const Text(
|
|
|
|
|
'Verified Agent',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontFamily: 'SourceSerif4',
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
color: Color(0xFF638559),
|
2026-02-25 06:55:05 +05:30
|
|
|
),
|
2026-03-14 23:33:32 +05:30
|
|
|
),
|
2026-03-30 15:12:09 +05:30
|
|
|
if (item.rating.isNotEmpty) ...[
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
const Icon(Icons.star, size: 16, color: Color(0xFFFFDE21)),
|
|
|
|
|
const SizedBox(width: 2),
|
|
|
|
|
Text(
|
|
|
|
|
'Rating',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontFamily: 'SourceSerif4',
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
color: AppColors.primaryDark,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-03-07 10:25:53 +05:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
|
|
|
|
// Location row
|
2026-03-14 23:33:32 +05:30
|
|
|
if (item.location.isNotEmpty)
|
2026-03-07 10:25:53 +05:30
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
SvgPicture.asset(
|
2026-03-14 23:33:32 +05:30
|
|
|
'assets/icons/location_orange_icon.svg',
|
2026-03-14 20:59:47 +05:30
|
|
|
width: 16,
|
|
|
|
|
height: 16,
|
2026-03-14 23:33:32 +05:30
|
|
|
placeholderBuilder: (_) => const Icon(
|
|
|
|
|
Icons.location_on,
|
|
|
|
|
color: AppColors.accentOrange,
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
2026-03-07 10:25:53 +05:30
|
|
|
),
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
2026-03-14 23:33:32 +05:30
|
|
|
item.location,
|
2026-03-07 10:25:53 +05:30
|
|
|
style: const TextStyle(
|
|
|
|
|
fontFamily: 'SourceSerif4',
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
color: AppColors.primaryDark,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-02-25 06:55:05 +05:30
|
|
|
),
|
2026-03-07 10:25:53 +05:30
|
|
|
const SizedBox(height: 8),
|
2026-02-25 06:55:05 +05:30
|
|
|
|
2026-03-07 10:25:53 +05:30
|
|
|
// Experience
|
2026-03-14 23:33:32 +05:30
|
|
|
if (item.experience.isNotEmpty)
|
2026-03-07 10:25:53 +05:30
|
|
|
RichText(
|
|
|
|
|
text: TextSpan(
|
2026-02-25 06:55:05 +05:30
|
|
|
children: [
|
2026-03-07 10:25:53 +05:30
|
|
|
const TextSpan(
|
|
|
|
|
text: 'Experience: ',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontFamily: 'SourceSerif4',
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
color: AppColors.primaryDark,
|
2026-02-25 06:55:05 +05:30
|
|
|
),
|
|
|
|
|
),
|
2026-03-07 10:25:53 +05:30
|
|
|
TextSpan(
|
2026-03-14 23:33:32 +05:30
|
|
|
text: item.experience,
|
2026-03-07 10:25:53 +05:30
|
|
|
style: const TextStyle(
|
|
|
|
|
fontFamily: 'SourceSerif4',
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
|
color: AppColors.primaryDark,
|
2026-02-25 06:55:05 +05:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2026-03-07 10:25:53 +05:30
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-02-25 06:55:05 +05:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildImagePlaceholder(int index) {
|
2026-03-14 21:30:37 +05:30
|
|
|
const colors = [
|
|
|
|
|
Color(0xFFC4D9D4),
|
|
|
|
|
Color(0xFFD4C9B8),
|
|
|
|
|
Color(0xFFB8C4D4),
|
|
|
|
|
];
|
|
|
|
|
return Container(
|
2026-02-25 06:55:05 +05:30
|
|
|
width: double.infinity,
|
|
|
|
|
height: 192,
|
2026-03-14 21:30:37 +05:30
|
|
|
color: colors[index % colors.length],
|
|
|
|
|
child: const Icon(Icons.person, size: 80, color: AppColors.primaryDark),
|
2026-02-25 06:55:05 +05:30
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildDotIndicators(int count) {
|
|
|
|
|
return Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: List.generate(count, (index) {
|
|
|
|
|
final isActive = index == _currentPage;
|
|
|
|
|
return Container(
|
|
|
|
|
width: isActive ? 10 : 8,
|
|
|
|
|
height: isActive ? 10 : 8,
|
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
color: isActive
|
|
|
|
|
? AppColors.primaryDark
|
|
|
|
|
: AppColors.primaryDark.withValues(alpha: 0.3),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|