import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';

Future<void> showDateFilterMenu({
  required BuildContext context,
  Function()? aToZTap,
  Function()? zToaTap,
  String? isSelected,
}) async {
  final RenderBox overlay =
      Overlay.of(context).context.findRenderObject() as RenderBox;
  final RelativeRect position = RelativeRect.fromRect(
    Rect.fromLTRB(
      overlay.size.width / 3,
      240,
      0,
      overlay.size.height,
    ),
    Offset.zero & overlay.size,
  );

  await showMenu(
    context: context,
    position: position,
    color: ColorsManager.whiteColors,
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
        bottomRight: Radius.circular(10),
        bottomLeft: Radius.circular(10),
      ),
    ),
    items: <PopupMenuEntry>[
      PopupMenuItem(
        onTap: aToZTap,
        child: ListTile(
          leading: Image.asset(
            Assets.AtoZIcon,
            width: 25,
          ),
          title: Text(
            "Sort from newest to oldest",
            style: TextStyle(
                color: isSelected == "NewestToOldest"
                    ? Colors.black
                    : Colors.blueGrey),
          ),
        ),
      ),
      PopupMenuItem(
        onTap: zToaTap,
        child: ListTile(
          leading: Image.asset(
            Assets.ZtoAIcon,
            width: 25,
          ),
          title: Text(
            "Sort from oldest to newest",
            style: TextStyle(
                color: isSelected == "OldestToNewest"
                    ? Colors.black
                    : Colors.blueGrey),
          ),
        ),
      ),
    ],
  ).then((value) {});
}
