import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';

import '../app_style/app_color.dart';

class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final List<Widget>? actions;
  final double? bottomCorner;

  const CustomAppBar({required this.title, this.actions, this.bottomCorner, Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AppBar(
      automaticallyImplyLeading: false,
      titleSpacing: 16,
      title: Row(
        children: [
          const Icon(Icons.arrow_back_ios).onPress(() {
            Navigator.of(context).pop();
          }),
          Text(
            title ?? "",
            style: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
          ).expanded,
        ],
      ),
      actions: actions,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.vertical(
          bottom: Radius.circular(bottomCorner ?? 10),
        ),
      ),
    );
  }

  @override
  Size get preferredSize => Size.fromHeight(60.toScreenHeight);
}
