feat: Implement initial filtering for agent search from the home screen, enable footer navigation, and add provider stability checks.
This commit is contained in:
@@ -11,8 +11,17 @@ import 'package:real_estate_mobile/features/agents/presentation/widgets/agent_fi
|
||||
|
||||
class AgentSearchScreen extends ConsumerStatefulWidget {
|
||||
final String? initialQuery;
|
||||
final String? initialAgentTypeId;
|
||||
final String? initialLocation;
|
||||
final String? initialCategory;
|
||||
|
||||
const AgentSearchScreen({super.key, this.initialQuery});
|
||||
const AgentSearchScreen({
|
||||
super.key,
|
||||
this.initialQuery,
|
||||
this.initialAgentTypeId,
|
||||
this.initialLocation,
|
||||
this.initialCategory,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<AgentSearchScreen> createState() => _AgentSearchScreenState();
|
||||
@@ -28,14 +37,31 @@ class _AgentSearchScreenState extends ConsumerState<AgentSearchScreen> {
|
||||
_searchController = TextEditingController(text: widget.initialQuery ?? '');
|
||||
_scrollController.addListener(_onScroll);
|
||||
|
||||
// Trigger initial search if query provided
|
||||
if (widget.initialQuery != null && widget.initialQuery!.isNotEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
ref
|
||||
.read(searchAgentsProvider.notifier)
|
||||
.search(widget.initialQuery!);
|
||||
});
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final notifier = ref.read(searchAgentsProvider.notifier);
|
||||
|
||||
// Apply initial agent type filter if provided
|
||||
if (widget.initialAgentTypeId != null) {
|
||||
notifier.filterByAgentType(widget.initialAgentTypeId);
|
||||
}
|
||||
|
||||
// Apply location and category filters if provided
|
||||
final initialFilters = <String, List<String>>{};
|
||||
if (widget.initialLocation != null) {
|
||||
initialFilters['state'] = [widget.initialLocation!];
|
||||
}
|
||||
if (widget.initialCategory != null) {
|
||||
initialFilters['specialization'] = [widget.initialCategory!];
|
||||
}
|
||||
if (initialFilters.isNotEmpty) {
|
||||
notifier.applyFilters(initialFilters);
|
||||
}
|
||||
|
||||
// Trigger initial search if query provided
|
||||
if (widget.initialQuery != null && widget.initialQuery!.isNotEmpty) {
|
||||
notifier.search(widget.initialQuery!);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -397,6 +423,7 @@ class _AgentCardState extends State<_AgentCard> {
|
||||
imageUrl: agent.avatarUrl,
|
||||
width: double.infinity,
|
||||
height: 265,
|
||||
alignment: Alignment.topCenter,
|
||||
errorWidget: (_) => Container(
|
||||
width: double.infinity,
|
||||
height: 265,
|
||||
|
||||
Reference in New Issue
Block a user