feat: Implement S3 image handling with a new resolver and widget, update agent display, and configure storage base URL.
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
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/config/app_config.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/agents_provider.dart';
|
||||
import 'package:real_estate_mobile/features/home/data/models/landing_page_content.dart';
|
||||
@@ -271,34 +270,15 @@ class _TopProfessionalsSectionState
|
||||
);
|
||||
}
|
||||
|
||||
/// Resolves an image URL: full URL as-is, relative prepend base URL.
|
||||
String? _resolveImageUrl(String? imageUrl) {
|
||||
if (imageUrl == null || imageUrl.isEmpty) return null;
|
||||
if (imageUrl.startsWith('http://') || imageUrl.startsWith('https://')) {
|
||||
return imageUrl;
|
||||
}
|
||||
final baseUrl = AppConfig.apiBaseUrl;
|
||||
if (baseUrl.isNotEmpty) {
|
||||
return '$baseUrl$imageUrl';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Builds the card image from AgentProfile avatar.
|
||||
/// Builds the card image from AgentProfile avatar using presigned URL.
|
||||
Widget _buildCardImage(AgentProfile agent, int index) {
|
||||
final resolvedUrl = _resolveImageUrl(agent.avatarUrl);
|
||||
|
||||
if (resolvedUrl != null) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: resolvedUrl,
|
||||
width: double.infinity,
|
||||
height: 192,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => _buildImagePlaceholder(index),
|
||||
errorWidget: (context, url, error) => _buildImagePlaceholder(index),
|
||||
);
|
||||
}
|
||||
return _buildImagePlaceholder(index);
|
||||
return S3Image(
|
||||
imageUrl: agent.avatarUrl,
|
||||
width: double.infinity,
|
||||
height: 192,
|
||||
placeholder: (_) => _buildImagePlaceholder(index),
|
||||
errorWidget: (_) => _buildImagePlaceholder(index),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImagePlaceholder(int index) {
|
||||
|
||||
Reference in New Issue
Block a user