Skip to content

feature: curated subject colors with quick-pick in the timetable color dialog - #549

Open
13732348243521734 wants to merge 1 commit into
lanis-mobile:mainfrom
13732348243521734:feature/timetable-subject-colors
Open

feature: curated subject colors with quick-pick in the timetable color dialog#549
13732348243521734 wants to merge 1 commit into
lanis-mobile:mainfrom
13732348243521734:feature/timetable-subject-colors

Conversation

@13732348243521734

Copy link
Copy Markdown

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
  3. falls back to the existing hash-based random color

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

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant