Skip to content

feat(files): add a collapsible category view for course files - #1810

Draft
lyrenius wants to merge 2 commits into
robertying:mainfrom
lyrenius:feat/course-file-categories
Draft

lyrenius wants to merge 2 commits into
robertying:mainfrom
lyrenius:feat/course-file-categories

Conversation

@lyrenius

Copy link
Copy Markdown
Contributor

Closes #1801

Add a By Category option to the course Files tab so students can find related files using the categories teachers set in Web Learning. By Time is the default.

Categories appear as vertical sections, with Uncategorized last. Every section starts expanded, and selecting its heading toggles it independently. The app remembers which sections are collapsed for each course on the device and
restores them after relaunch.

Testing

  • Jest covers file grouping, independent section toggles, and restoring saved choices.
  • iOS and Android release JS bundle checks passed.
  • Manually Electron verification passed. The other 3,620 Jest tests also passed.

@lyrenius
lyrenius marked this pull request as draft November 23, 2026 08:46

@robertying robertying left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Grouping by the teacher's categories is a good fit for the Files tab. The grouping helper is pure and well tested, keying categories by id so a rename keeps a section collapsed is a nice touch, and adding collapsedFileCategories needs no store version bump since mergeUserData fills in missing keys.

I ran it on an iPhone and an Android phone with the mock account. The design needs another pass before this goes in:

Design

  1. Remember the view choice. By Time / By Category is component state, so every course opens on By Time again, while the collapsed sections (which only exist in By Category) are saved. Please save the choice too, either once for the app or per course next to the collapsed sections.
  2. Avoid a second segmented control. The new control sits right under Notices / Assignments / Files, looks almost the same, and scrolls away with the list. A view menu in the header (ToggleMenu, as Search uses for its options) would keep the screen lighter.
  3. Match the app's other section headings. Search's section headers are a good reference:
    • Line the heading up with the file titles under it. It starts further left now, on both platforms.
    • Use the same text style and color as other section headings (primary on Android).
    • Give it accessibilityRole="header" as well, so screen readers can jump between categories.
    • Show how many files a section holds, at least when it's collapsed.
  4. Don't repeat the category on each card in By Category. The heading already says it.
  5. Category order. Sorting by each category's latest upload moves a section to the top whenever a file is added to it. Web Learning's FileCategory has a creationTime; ordering by it would match the website and keep sections where students expect them. What was the intent here?

Tests

The helper, the store and the screen's main paths are covered. Please add:

  • Tests for the Android and Electron versions in src/screens/__tests__/android and src/screens/__tests__/web. They render their own segmented control and the new chevron icons.
  • A category with two or more files in the screen test, so it checks that files in a section still have dividers between them and the last one before the next heading doesn't.
  • Pull to refresh in By Category, and the file list changing while a section is collapsed (a new upload, or a file moving to another category).
  • A test that the view choice is still set after the course is reopened, once it's saved.
  • Mock data: give a few mock courses' files categories, including one course with both categorized and uncategorized files, so the view can be tried with the mock login and a Maestro step can cover it (.maestro/04-tabs.yaml already opens a mock course).

This branch has not been deployed

No deployments
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.

[Feature Request] 课程文件按分类显示

2 participants