import "package:flutter/material.dart";
import "../theme/ensup_colors.dart";

/// Coins décoratifs de la charte ENSUP : un L coloré en haut-gauche et en
/// bas-droit, en surimpression et non cliquables (comme dans la maquette).
class BrandCorners extends StatelessWidget {
  const BrandCorners({super.key});

  @override
  Widget build(BuildContext context) {
    return IgnorePointer(
      child: Stack(
        children: [
          Positioned(
            top: 0,
            left: 0,
            child: CustomPaint(size: const Size(120, 120), painter: _TopLeftCornerPainter()),
          ),
          Positioned(
            bottom: 0,
            right: 0,
            child: CustomPaint(size: const Size(120, 120), painter: _BottomRightCornerPainter()),
          ),
        ],
      ),
    );
  }
}

const double _thickness = 22;

class _TopLeftCornerPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()..color = EnsupColors.red;
    // Barre verticale gauche (rouge) + segment haut rouge.
    canvas.drawRect(Rect.fromLTWH(0, 0, _thickness, size.height), paint);
    canvas.drawRect(const Rect.fromLTWH(0, 0, 28, _thickness), paint);
    // Segments colorés de la barre horizontale.
    paint.color = EnsupColors.purple;
    canvas.drawRect(const Rect.fromLTWH(28, 0, 22, _thickness), paint);
    paint.color = EnsupColors.teal;
    canvas.drawRect(const Rect.fromLTWH(50, 0, 22, _thickness), paint);
  }

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

class _BottomRightCornerPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()..color = EnsupColors.cyan;
    // Barre verticale droite (cyan) + segment bas cyan.
    canvas.drawRect(Rect.fromLTWH(size.width - _thickness, 0, _thickness, size.height), paint);
    canvas.drawRect(Rect.fromLTWH(size.width - 28, size.height - _thickness, 28, _thickness), paint);
    // Segments colorés de la barre horizontale.
    paint.color = EnsupColors.blue2;
    canvas.drawRect(Rect.fromLTWH(size.width - 50, size.height - _thickness, 22, _thickness), paint);
    paint.color = EnsupColors.blue3;
    canvas.drawRect(Rect.fromLTWH(size.width - 72, size.height - _thickness, 22, _thickness), paint);
  }

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