reportFor method

List<IntentNote> reportFor(
  1. ThemeFamily family
)

The hints family cannot honour (empty when it honours them all), at the newest engine version. Static: no theme is generated.

Implementation

List<IntentNote> reportFor(ThemeFamily family) {
  final notes = <IntentNote>[];
  if (!steerableFamilies.contains(family)) {
    const reason = 'family not steerable yet';
    if (brightness != null) {
      notes.add(IntentNote('brightness', brightness!.name, reason));
    }
    for (final c in colors) {
      notes.add(IntentNote('colors', c.word, reason));
    }
    if (chroma != null) notes.add(IntentNote('chroma', chroma!.word, reason));
    if (harmony != null) {
      notes.add(IntentNote('harmony', harmonyWords[harmony]!, reason));
    }
    if (hueRange != null) {
      notes.add(
        IntentNote('hueRange', '${hueRange!.$1}–${hueRange!.$2}', reason),
      );
    }
    return notes;
  }
  final def = family.definition;
  final want = effectiveBrightness;
  if (want != null && !brightnessAllowed(def, want)) {
    notes.add(
      IntentNote(
        'brightness',
        want.name,
        want == ThemeBrightness.light
            ? 'dark-only family'
            : 'light-only family',
      ),
    );
  }
  final h = harmony;
  final honoursHarmony = _harmonyFamilies.contains(family);
  if (h != null) {
    if (!honoursHarmony) {
      notes.add(
        IntentNote(
          'harmony',
          harmonyWords[h]!,
          'family uses its own colour schemes',
        ),
      );
    } else if (!def.schemes.any((w) => w.value == h && w.weight > 0)) {
      notes.add(
        IntentNote('harmony', harmonyWords[h]!, 'not used by this family'),
      );
    }
  }
  if (family == ThemeFamily.bauhaus &&
      colors.length >= 2 &&
      !colors[0].neutral &&
      !colors[1].neutral &&
      h == null) {
    int mid(IntentColor c) =>
        (c.loTenths + ((c.hiTenths - c.loTenths) % 3600) ~/ 2) % 3600;
    final d = (mid(colors[0]) - mid(colors[1])).abs() % 3600;
    if ((d > 1800 ? 3600 - d : d) < bauhausSteeredEqualsApartTenths) {
      notes.add(
        IntentNote(
          'colors',
          colors[1].word,
          'too close to ${colors[0].word} for a second Bauhaus accent',
        ),
      );
    }
  }
  if (family == ThemeFamily.bauhaus) {
    final level = effectiveChroma;
    final grey = colors.isNotEmpty && colors.first.neutral;
    if (level == IntentChroma.muted || grey) {
      notes.add(
        IntentNote(
          grey ? 'colors' : 'chroma',
          grey ? colors.first.word : level!.word,
          'Bauhaus accents stay strong',
        ),
      );
    }
  }
  for (final c in colors.skip(1)) {
    if (c.neutral) {
      notes.add(
        IntentNote('colors', c.word, 'neutrals only quiet the base colour'),
      );
    } else if (h != null && honoursHarmony) {
      notes.add(
        IntentNote('colors', c.word, 'harmony picks the accent colours'),
      );
    }
  }
  return notes;
}