import 'package:dotted_border/dotted_border.dart';
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 AppDashedButton extends StatelessWidget {
  final String title;
  final VoidCallback onPressed;
  double? height;
  Color? buttonColor;
  Widget? icon;

  AppDashedButton({required this.title, required this.onPressed, Key? key, this.height, this.icon, this.buttonColor}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: height,
      padding: EdgeInsets.symmetric(horizontal: 2.toScreenWidth),
      decoration: BoxDecoration(color: AppColor.background(context), borderRadius: BorderRadius.circular(10)),
      child: DottedBorder(
        strokeWidth: 1,
        padding: EdgeInsets.symmetric(vertical: 16.toScreenHeight, horizontal: 16.toScreenWidth),
        color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.black20,
        dashPattern: const [4, 3],
        radius: const Radius.circular(10),
        borderType: BorderType.RRect,
        child: icon != null
            ? Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  icon!,
                  7.width,
                  title.heading6(context).custom(color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.black10).center,
                ],
              )
            : title.heading6(context).custom(color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.primary10).center,
      ),
    ).onPress(onPressed);
  }
}
