import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'app_colors.dart';

PreferredSizeWidget appbar(BuildContext context, title) {
  return AppBar(
    automaticallyImplyLeading: false,
    elevation: 2.0,
    title: SizedBox(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          InkResponse(
            onTap: () => Navigator.pop(context, true),
            child: SvgPicture.asset("assets/svg/app_bar_back.svg", height: 25),
          ),
          InkResponse(
            onTap: () => Navigator.pop(context,true),
            child: Text(
              title,
              style: TextStyle(
                fontSize: 16,
                height: 1.1,
                fontFamily: "JakartaSemiBold",
                color: AppColors.semi_black,
              ),
            ),
          ),
        ],
      ),
    ),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(
        bottom: Radius.circular(30), // Adjust the radius as needed
      ),
    ),
  );
}

PreferredSizeWidget appbar2(BuildContext context, title,widget) {
  return AppBar(
    automaticallyImplyLeading: false,
    elevation: 2.0,
    title: SizedBox(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          InkResponse(
            onTap: () => Navigator.pop(context, true),
            child: SvgPicture.asset("assets/svg/app_bar_back.svg", height: 25),
          ),
          Expanded(
            flex:4,
            child: InkResponse(
              onTap: () => Navigator.pop(context, true),
              child: Text(
                title,
                overflow: TextOverflow.ellipsis,
                maxLines: 1,
                style: TextStyle(
                  fontSize: 16,
                  height: 1.1,
                  fontFamily: "JakartaSemiBold",
                  color: AppColors.semi_black,
                ),
              ),
            ),
          ),
          Spacer(),
          widget
        ],
      ),
    ),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(
        bottom: Radius.circular(30), // Adjust the radius as needed
      ),
    ),
  );
}

Future<bool> onBackPressed(BuildContext context) async {
  Navigator.pop(context, true);
  return true;
}

Widget Emptywidget(BuildContext context){
  return SizedBox(
    height: MediaQuery.of(context).size.height*0.8,
    child: Center(
        child: Text("No Data Available")),
  );
}