content: import 'package:flutter/material.dart';
  import 'package:get/get.dart';
  
  import '../constants/colors.dart';
  import '../controller/note_controller.dart';
  import 'note_detail_page.dart';
  
  class Search extends SearchDelegate {
    final NoteController controller = Get.find<NoteController>();
  
    @override
    List<Widget> buildActions(BuildContext context) {
      return [
        IconButton(
            onPressed: () {
              query = "";
            },
            icon: const Icon(Icons.clear, color: Colors.black))
      ];
    }
  
    @override
    String get searchFieldLabel => 'Search Notes'; // Set the hint text here
  
    @override
    Widget buildLeading(BuildContext context) {
      return IconButton(
          onPressed: () {
            Get.back();
          },
          icon: AnimatedIcon(
            icon: AnimatedIcons.menu_arrow,
            progress: transitionAnimation,
            color: Colors.black,
          ));
    }
  
    @override
    Widget buildSuggestions(BuildContext context) {
      final suggestionList = query.isEmpty
          ? controller.notes
          : controller.notes.where(
              (p) {
                return p.title!.toLowerCase().contains(query.toLowerCase()) ||
                    p.content!.toLowerCase().contains(query.toLowerCase());
              },
            ).toList();
      return Container(
        padding: const EdgeInsets.only(
          top: 10,
          right: 10,
          left: 10,
        ),
        child: ListView.builder(
          shrinkWrap: true,
          itemCount: suggestionList.length,
          itemBuilder: (context, index) {
            return GestureDetector(
                onTap: () {
                  Get.to(
                    NoteDetailPage(),
                    arguments: index,
                  );
                },
                child: Padding(
                  padding: const EdgeInsets.symmetric(vertical: 5),
                  child: Container(
                    decoration: BoxDecoration(
                      color: AppColor.grayColor,
                      borderRadius: BorderRadius.circular(10),
                    ),
                    padding: const EdgeInsets.all(15),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          controller.notes[index].title!,
                          style: const TextStyle(
                              fontSize: 21,
                              fontWeight: FontWeight.bold,
                              color: AppColor.textColor),
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                        ),
                        const SizedBox(
                          height: 10,
                        ),
                        Text(
                          suggestionList[index].content!,
                          style: const TextStyle(
                              fontSize: 18, color: AppColor.textColor),
                          overflow: TextOverflow.ellipsis,
                          maxLines: 2,
                        ),
                        const SizedBox(
                          height: 10,
                        ),
                        Text(
                          controller.notes[index].dateTimeEdited!,
                        ),
                      ],
                    ),
                  ),
                ));
          },
        ),
      );
    }
  
    @override
    Widget buildResults(BuildContext context) {
      // TODO: implement buildResults
      throw UnimplementedError();
    }
  }
  