feat: Redesign home screen sections with updated testimonial card styles, refined trust stats layout, and spacing adjustments.
This commit is contained in:
@@ -47,15 +47,9 @@ class TrustStatsSection extends ConsumerWidget {
|
||||
final title = data.title.isNotEmpty ? data.title : _defaultContent.title;
|
||||
final subtitle =
|
||||
data.subtitle.isNotEmpty ? data.subtitle : _defaultContent.subtitle;
|
||||
final ratingInfo = data.ratingInfo.isNotEmpty
|
||||
? data.ratingInfo
|
||||
: _defaultContent.ratingInfo;
|
||||
final stats =
|
||||
data.stats.isNotEmpty ? data.stats : _defaultContent.stats;
|
||||
|
||||
// Extract rating number from ratingInfo string (e.g. "4.9" from "...4.9 out of 5...")
|
||||
final ratingValue = _extractRating(ratingInfo);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
@@ -81,40 +75,23 @@ class TrustStatsSection extends ConsumerWidget {
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
ratingInfo,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(color: AppColors.divider),
|
||||
const SizedBox(height: 16),
|
||||
// Stats row
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Dynamic stats from CMS
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: stats
|
||||
.map((stat) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _buildStatItem(stat),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
// Stats (group centered, content left-aligned)
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: IntrinsicWidth(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: stats
|
||||
.map((stat) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _buildStatItem(stat),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
// Rating visual
|
||||
const SizedBox(width: 16),
|
||||
_buildRatingVisual(ratingValue),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -127,32 +104,29 @@ class TrustStatsSection extends ConsumerWidget {
|
||||
final fallbackIcon = iconEntry?.$2 ?? Icons.info_outline;
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (svgPath != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8, top: 2),
|
||||
child: SvgPicture.asset(
|
||||
svgPath,
|
||||
width: 27,
|
||||
height: 27,
|
||||
placeholderBuilder: (_) => Icon(
|
||||
fallbackIcon,
|
||||
size: 27,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8, top: 2),
|
||||
child: Icon(
|
||||
fallbackIcon,
|
||||
size: 27,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10, top: 2),
|
||||
child: svgPath != null
|
||||
? SvgPicture.asset(
|
||||
svgPath,
|
||||
width: 27,
|
||||
height: 27,
|
||||
placeholderBuilder: (_) => Icon(
|
||||
fallbackIcon,
|
||||
size: 27,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
fallbackIcon,
|
||||
size: 27,
|
||||
color: AppColors.accentOrange,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
@@ -182,59 +156,4 @@ class TrustStatsSection extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRatingVisual(double rating) {
|
||||
final fullStars = rating.floor();
|
||||
final hasHalfStar = (rating - fullStars) >= 0.3;
|
||||
final totalStars = 5;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
rating.toStringAsFixed(1),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Fractul',
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.primaryDark,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: List.generate(
|
||||
totalStars,
|
||||
(index) {
|
||||
if (index < fullStars) {
|
||||
return const Icon(
|
||||
Icons.star,
|
||||
color: AppColors.accentOrange,
|
||||
size: 18,
|
||||
);
|
||||
} else if (index == fullStars && hasHalfStar) {
|
||||
return const Icon(
|
||||
Icons.star_half,
|
||||
color: AppColors.accentOrange,
|
||||
size: 18,
|
||||
);
|
||||
} else {
|
||||
return const Icon(
|
||||
Icons.star_border,
|
||||
color: AppColors.accentOrange,
|
||||
size: 18,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Extract numeric rating from ratingInfo string.
|
||||
/// e.g. "Clients rate our real estate services 4.9 out of 5..." → 4.9
|
||||
double _extractRating(String ratingInfo) {
|
||||
final match = RegExp(r'(\d+\.?\d*)\s*out\s*of\s*\d+').firstMatch(ratingInfo);
|
||||
if (match != null) {
|
||||
return double.tryParse(match.group(1)!) ?? 4.9;
|
||||
}
|
||||
return 4.9;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user