mirrored_repositories/Pretty-Ui/Eden/lib/core/common
import 'package:eden/core/utils/app_typography.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../utils/app_colors.dart';

class PriceTag extends StatelessWidget {
  const PriceTag({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 80.w,
      child: CustomPaint(
        painter: PriceTagPaint(),
        child: Padding(
          padding: EdgeInsets.symmetric(vertical: 5.h),
          child: Center(
            child: Text(
              'Free',
              style: AppTypography.kBold16.copyWith(color: AppColors.kPrimary),
            ),
          ),
        ),
      ),
    );
  }
}

class PriceTagPaint extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint paint = Paint()
      ..color = AppColors.kPrimary.withOpacity(0.15)
      ..strokeCap = StrokeCap.round
      ..style = PaintingStyle.fill;

    Path path = Path();

    path
      ..moveTo(0, size.height * .5)
      ..lineTo(size.width * .13, 0)
      ..lineTo(size.width, 0)
      ..lineTo(size.width, size.height)
      ..lineTo(size.width * .13, size.height)
      ..lineTo(0, size.height * .5)
      ..close();
    canvas.drawPath(path, paint);

    // Circle.
    canvas.drawCircle(
      Offset(size.width * .17, size.height * .5),
      size.height * .15,
      paint..color = Colors.white,
    );
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
