showSubZeroFullScreenSearch function

Future<String?> showSubZeroFullScreenSearch({
  1. required BuildContext context,
  2. String hintText = 'Search here',
  3. List<String> recentSearches = const [],
  4. Future<List<SubZeroSearchSuggestion>> onSearch(
    1. String query
    )?,
  5. bool showMicrophone = true,
  6. VoidCallback? onMicrophoneTap,
})

Shows a full-screen search modal following SubZero 2.0 Design System.

Provides a focused search experience with recent searches and results.

Example usage:

final result = await showSubZeroFullScreenSearch(
  context: context,
  recentSearches: ['iPhone', 'MacBook', 'AirPods'],
  onSearch: (query) async => await searchProducts(query),
);
if (result != null) {
  navigateToProduct(result);
}

Implementation

Future<String?> showSubZeroFullScreenSearch({
  required BuildContext context,
  String hintText = 'Search here',
  List<String> recentSearches = const [],
  Future<List<SubZeroSearchSuggestion>> Function(String query)? onSearch,
  bool showMicrophone = true,
  VoidCallback? onMicrophoneTap,
}) {
  return Navigator.of(context).push<String>(
    PageRouteBuilder(
      opaque: false,
      pageBuilder: (context, animation, secondaryAnimation) =>
          _FullScreenSearchModal(
        hintText: hintText,
        recentSearches: recentSearches,
        onSearch: onSearch,
        showMicrophone: showMicrophone,
        onMicrophoneTap: onMicrophoneTap,
      ),
      transitionsBuilder: (context, animation, secondaryAnimation, child) {
        return FadeTransition(
          opacity: animation,
          child: SlideTransition(
            position: Tween<Offset>(
              begin: const Offset(0, -0.02),
              end: Offset.zero,
            ).animate(CurvedAnimation(
              parent: animation,
              curve: Curves.easeOut,
            )),
            child: child,
          ),
        );
      },
      transitionDuration: const Duration(milliseconds: 200),
      reverseTransitionDuration: const Duration(milliseconds: 150),
    ),
  );
}