feature: curated subject colors with quick-pick in the timetable color dialog - #549
Conversation
…r dialog
Applied from an external patch (subject-colors.patch), with two fixes
made before applying:
- Hardcoded German 'Vorschläge' label replaced with
AppLocalizations.of(context).timetableColorSuggestions (DE+EN arb
keys added) -- the rest of this dialog already goes through
AppLocalizations, this string didn't and would have broken for
English users.
- SubjectColors' doc comment claimed normalize("Bio (GK)") resolves
to the same key as "bio" -- traced through the actual algorithm and
that's false (it produces "biogk", which matches nothing). Doc
comment rewritten to describe the real behavior (exact match after
stripping punctuation/case, no token extraction) and to note the
practical mitigating factor: TimetableSubject.name from liblanis is
normally the bare portal-parsed abbreviation, with course/group
qualifiers already split into a separate `badge` field upstream, so
the common case is expected to match -- schools whose Stundenplan
display settings embed course info directly into the subject name
may see more hash-color fallbacks.
Behavior: getColorForLesson() now tries, in order, (1) the user's own
saved per-lesson color, (2) a curated color from
assets/subject_colors.json matched by normalized subject-name alias,
(3) the existing hash-based RandomColor fallback. The color-picker
dialog gets a row of quick-pick swatches (primary + alternatives) for
the matched subject, still allowing the free-form picker below it.
SubjectColors.ensureLoaded() awaited once at startup in main.dart so
lookups are synchronous afterwards; falls back to an empty table
(never throws) if the asset can't be loaded/parsed.
|
Hi, Color schemes are highly debated among all students and setting a default scheme all agree on is hard and would most likely require a democratic decision. (Also like what the heck blue is math in your world!? Blue is obviously the german class. Red is for math! Always has been...) Some other feedback on the implementation: Although probably not actually noticeable on the startup the parsing process of this file does slow the startup time a bit and could be invoked after the first network request to save on startup time. |
getColorForLesson() now tries, in order:
The color picker dialog now shows a row of quick-pick swatches (primary + alternatives) for the matched subject, alongside the existing free-form picker below.
lib/utils/subject_colors.dart is partially AI-generated but was manually tested