import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';

RAppBar chickenAppBar({
  bool hasBack = true,
  bool hasFilter = true,
  bool hasSearch = true,
  VoidCallback? onBackPressed,
  GestureTapCallback? onFilterTap,
  GestureTapCallback? onSearchTap,
}) {
  return RAppBar(
    hasBack: hasBack,
    onBackPressed: onBackPressed,
    leadingWidth: 155,
    leading: Row(
      mainAxisSize: MainAxisSize.min,
      spacing: 6,
      children: [
        Text('رصدطیور', style: AppFonts.yekan16Bold.copyWith(color: Colors.white)),
        Assets.vec.chickenSvg.svg(
          width: 24,
          height: 24,
          colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
        ),
      ],
    ),
    additionalActions: [
      if (hasFilter) filterWidget(onFilterTap),
      SizedBox(width: 8),
      if (hasSearch) searchWidget(onSearchTap),
      SizedBox(width: 8),
    ],
  );
}

GestureDetector searchWidget(GestureTapCallback? onSearchTap) {
  return GestureDetector(
    onTap: onSearchTap,
    child: Assets.vec.filterOutlineSvg.svg(
      width: 20,
      height: 20,
      colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
    ),
  );
}

GestureDetector filterWidget(GestureTapCallback? onFilterTap) {
  return GestureDetector(
    onTap: onFilterTap,
    child: Assets.vec.searchSvg.svg(
      width: 24,
      height: 24,
      colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
    ),
  );
}
