import 'package:flutter/material.dart';

import 'guide_frame.dart';

/// Capture-only guide frame (no live detection boxes).
class GuideOverlay extends StatelessWidget {
  const GuideOverlay({super.key, required this.size});

  final Size size;

  @override
  Widget build(BuildContext context) {
    return CustomPaint(
      size: size,
      painter: _GuidePainter(),
    );
  }
}

class _GuidePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final rect = GuideFrame.inViewport(size);

    final dim = Paint()..color = Colors.black.withOpacity(0.45);
    final path = Path()
      ..addRect(Offset.zero & size)
      ..addRRect(RRect.fromRectAndRadius(rect, const Radius.circular(10)))
      ..fillType = PathFillType.evenOdd;
    canvas.drawPath(path, dim);

    final border = Paint()
      ..style = PaintingStyle.stroke
      ..strokeWidth = 1.5
      ..color = Colors.white70;
    canvas.drawRRect(
      RRect.fromRectAndRadius(rect, const Radius.circular(10)),
      border,
    );
  }

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