import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hmg_flutter_template/classes/colors.dart';
import 'package:hmg_flutter_template/config/routes.dart';
import 'package:hmg_flutter_template/extensions/int_extensions.dart';
import 'package:hmg_flutter_template/extensions/string_extensions.dart';
import 'package:hmg_flutter_template/extensions/widget_extensions.dart';

AppBar AppBarWidget(
  BuildContext context, {
  required String title,
  String? image,
  bool isNeedLeading = true,
  List<Widget>? actions,
}) {
  return AppBar(
    leadingWidth: 0,
    // leading: GestureDetector(
    //   behavior: HitTestBehavior.opaque,
    //   onTap: Feedback.wrapForTap(() => Navigator.maybePop(context), context),
    //   child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor),
    // ),
    //titleSpacing: -1.44,
    title: Row(
      children: [
        if (isNeedLeading)
          GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: Feedback.wrapForTap(() => Navigator.maybePop(context), context),
            child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor),
          ),
        4.width,
        if (image != null)
          SvgPicture.asset(
            image,
            height: 40,
            width: 40,
          ),
        if (image != null) 14.width,
        title.toText16(color: MyColors.darkTextColor, isBold: true).expanded,
      ],
    ),
    centerTitle: false,
    elevation: 0,
    backgroundColor: Colors.white,
    actions: actions,
  );
}
