// lib/ui/branding/app_icon_painter.dart
import 'package:flutter/material.dart';

import '../widgets/tile_painter.dart';

/// Draws the Block Seasons brand mark: deep-navy field + a 2×2 grid of glossy
/// brand-color blocks. Shared by the launcher-icon and feature-graphic
/// generators so the brand stays identical everywhere.
class AppIconMark {
  static const navy = [Color(0xFF101736), Color(0xFF192555), Color(0xFF2C3168)];
  static const pink = Color(0xFFFF7EB3);
  static const yellow = Color(0xFFFFD166);
  static const cyan = Color(0xFF6FCDF5);
  static const green = Color(0xFF7EDB9C);

  /// Fills [rect] with the navy gradient.
  static void paintBackground(Canvas canvas, Rect rect) {
    final paint = Paint()
      ..shader = const LinearGradient(
        begin: Alignment.topLeft,
        end: Alignment.bottomRight,
        colors: navy,
      ).createShader(rect);
    canvas.drawRect(rect, paint);
  }

  /// Paints the 2×2 glossy blocks centered in a square of side [size], the
  /// block group occupying [groupFraction] of the side.
  static void paintBlocks(Canvas canvas, double size,
      {double groupFraction = 0.6}) {
    final group = size * groupFraction;
    final gap = size * 0.05;
    final block = (group - gap) / 2;
    final m = (size - group) / 2;
    final far = m + block + gap;
    void tile(double x, double y, Color c) => paintGlossyTile(
        canvas, Rect.fromLTWH(x, y, block, block), c, radiusFactor: 0.24);
    tile(m, m, pink);
    tile(far, m, yellow);
    tile(m, far, cyan);
    tile(far, far, green);
  }
}
