2026-02-24 03:19:55 +05:30
import ' package:flutter/material.dart ' ;
2026-02-25 07:48:02 +05:30
import ' package:flutter_riverpod/flutter_riverpod.dart ' ;
2026-02-24 03:19:55 +05:30
import ' package:flutter_svg/flutter_svg.dart ' ;
import ' package:real_estate_mobile/core/constants/app_colors.dart ' ;
2026-02-25 07:48:02 +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-24 03:19:55 +05:30
2026-02-25 07:48:02 +05:30
/// Default features content — matches web's hardcoded defaultContent fallback.
const _defaultFeatures = FeaturesContent (
title: ' Find Trusted Real Estate Professionals On Demand ' ,
subtitle:
' Quickly connect with the right agents exactly when you need them. ' ,
features: [
FeatureItem (
iconPath: ' hire_quickly ' ,
title: ' Hire Quickly ' ,
description:
' Connect with experienced local real estate agents who match your needs and preferences. Our simple process helps you get started quickly and move forward without delays or unnecessary complexity. ' ,
) ,
FeatureItem (
iconPath: ' verified ' ,
title: ' Verified Agents ' ,
description:
' All agents are carefully identity-verified and background-checked to ensure trust and safety. You can confidently work with professionals who meet quality and reliability standards. ' ,
) ,
FeatureItem (
iconPath: ' top_rated ' ,
title: ' Top Rated ' ,
description:
' Work with highly rated agents known for strong expertise and positive client feedback. Their consistent performance helps you make informed and confident property decisions. ' ,
) ,
FeatureItem (
iconPath: ' trusted ' ,
title: ' Trusted by Thousands ' ,
description:
' Thousands of buyers, sellers, and renters trust our platform to find reliable agents. Our professionals help people navigate property journeys with confidence and ease. ' ,
) ,
] ,
) ;
/// Map of feature icon keys to local SVG asset paths and Material fallback icons.
2026-03-14 21:30:37 +05:30
/// Supports both default slug keys and CMS web-style icon paths.
2026-02-25 07:48:02 +05:30
const _iconMap = {
2026-03-14 21:30:37 +05:30
// Default slug-based keys
2026-02-25 07:48:02 +05:30
' hire_quickly ' : ( ' assets/icons/hire_quickly_icon.svg ' , Icons . bolt ) ,
' verified ' : ( ' assets/icons/verified_icon.svg ' , Icons . verified_user_outlined ) ,
' top_rated ' : ( ' assets/icons/top_rated_icon.svg ' , Icons . star_outline ) ,
' trusted ' : ( ' assets/icons/trusted_icon.svg ' , Icons . people_outline ) ,
2026-03-14 21:30:37 +05:30
// CMS web-path keys (from CMS iconPath field)
' /assets/icons/hourglass-icon.svg ' : ( ' assets/icons/hire_quickly_icon.svg ' , Icons . bolt ) ,
' /assets/icons/verified-badge-icon.svg ' : ( ' assets/icons/verified_icon.svg ' , Icons . verified_user_outlined ) ,
' /assets/icons/star-orange-icon.svg ' : ( ' assets/icons/top_rated_icon.svg ' , Icons . star_outline ) ,
' /assets/icons/trusted-people-icon.svg ' : ( ' assets/icons/trusted_icon.svg ' , Icons . people_outline ) ,
2026-02-25 07:48:02 +05:30
} ;
class FeaturesSection extends ConsumerWidget {
2026-02-24 03:19:55 +05:30
const FeaturesSection ( { super . key } ) ;
@ override
2026-02-25 07:48:02 +05:30
Widget build ( BuildContext context , WidgetRef ref ) {
final homeState = ref . watch ( homeProvider ) ;
final cmsFeatures = homeState . content ? . features ;
// Use CMS data if available with non-empty features, otherwise fallback
final data = ( cmsFeatures ! = null & & cmsFeatures . features . isNotEmpty )
? cmsFeatures
: _defaultFeatures ;
final title = data . title . isNotEmpty ? data . title : _defaultFeatures . title ;
final subtitle =
data . subtitle . isNotEmpty ? data . subtitle : _defaultFeatures . subtitle ;
2026-02-24 03:19:55 +05:30
return Padding (
padding: const EdgeInsets . symmetric ( horizontal: 24 ) ,
child: Column (
children: [
2026-02-25 07:48:02 +05:30
Text (
title ,
2026-02-24 03:19:55 +05:30
textAlign: TextAlign . center ,
2026-02-25 07:48:02 +05:30
style: const TextStyle (
2026-02-24 03:19:55 +05:30
fontFamily: ' Fractul ' ,
fontSize: 25 ,
fontWeight: FontWeight . w700 ,
color: AppColors . primaryDark ,
) ,
) ,
const SizedBox ( height: 8 ) ,
2026-02-25 07:48:02 +05:30
Text (
subtitle ,
2026-02-24 03:19:55 +05:30
textAlign: TextAlign . center ,
2026-02-25 07:48:02 +05:30
style: const TextStyle (
2026-02-24 03:19:55 +05:30
fontFamily: ' SourceSerif4 ' ,
fontSize: 14 ,
fontWeight: FontWeight . w400 ,
color: AppColors . primaryDark ,
) ,
) ,
const SizedBox ( height: 24 ) ,
2026-02-25 07:48:02 +05:30
. . . data . features . map ( ( feature ) = > Padding (
padding: const EdgeInsets . only ( bottom: 12 ) ,
child: _buildFeatureCard ( feature ) ,
) ) ,
2026-02-24 03:19:55 +05:30
] ,
) ,
) ;
}
2026-02-25 07:48:02 +05:30
Widget _buildFeatureCard ( FeatureItem feature ) {
// Resolve icon: try icon map first, then default
final iconEntry = _iconMap [ feature . iconPath ] ;
final svgPath = iconEntry ? . $1 ? ? ' assets/icons/hire_quickly_icon.svg ' ;
final fallbackIcon = iconEntry ? . $2 ? ? Icons . bolt ;
2026-02-24 03:19:55 +05:30
return Container (
width: double . infinity ,
padding: const EdgeInsets . all ( 20 ) ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 15 ) ,
border: Border . all (
color: AppColors . primaryDark ,
width: 0.1 ,
) ,
) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Row (
children: [
SvgPicture . asset (
2026-02-25 07:48:02 +05:30
svgPath ,
2026-02-24 03:19:55 +05:30
width: 35 ,
height: 35 ,
placeholderBuilder: ( _ ) = > Icon (
fallbackIcon ,
size: 35 ,
color: AppColors . accentOrange ,
) ,
) ,
const SizedBox ( width: 12 ) ,
2026-02-25 07:48:02 +05:30
Expanded (
child: Text (
feature . title ,
style: const TextStyle (
fontFamily: ' Fractul ' ,
fontSize: 20 ,
fontWeight: FontWeight . w600 ,
color: AppColors . primaryDark ,
) ,
2026-02-24 03:19:55 +05:30
) ,
) ,
] ,
) ,
const SizedBox ( height: 12 ) ,
Text (
2026-02-25 07:48:02 +05:30
feature . description ,
2026-02-24 03:19:55 +05:30
style: const TextStyle (
fontFamily: ' SourceSerif4 ' ,
fontSize: 14 ,
fontWeight: FontWeight . w400 ,
color: AppColors . primaryDark ,
) ,
) ,
] ,
) ,
) ;
}
}