Skip to content

refactor: extract duplicated code into shared utilities#3

Closed
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783059155-refactor-shared-utilities
Closed

refactor: extract duplicated code into shared utilities#3
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783059155-refactor-shared-utilities

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Consolidates 5 duplicated code patterns found across the codebase into shared utilities, removing ~65 lines net.

New shared widgets (lib/widgets/)

  • EmptyTile — the "no data" card with an info icon, previously copy-pasted as private _EmptyTile/_EmptyCard in attendance_screen, score_screen, exam_score_screen, home_screen.

  • ScoreLabel — two-line label+value column, previously duplicated as _ScoreLabel in both score_screen and exam_score_screen.

  • TimetableHeaderCell / TimetablePeriodCell — styled table cells for timetable grids, previously duplicated as _headerCell/_periodCell methods in both curriculum_screen and following_screen (SharedCurriculumScreen).

  • AsyncContentBuilder — encapsulates the isLoading → CircularProgressIndicator / isUnsupported → UnsupportedScreen / error → UnsupportedScreen(onRetry:) pattern used identically across 6 screens (attendance_screen, score_screen, exam_score_screen, home_screen, school_notice_screen).

Model-level dedup (lib/models/forum_models.dart)

  • ForumPost.copyWithLikes(userID, liked:) and ForumMessage.copyWithLikes(userID, liked:) — the optimistic like-toggle helper was duplicated verbatim as _toggledLike/_withPostLike/_withMessageLike across forum_screen and forum_post_detail_screen. Now callers just use post.copyWithLikes(userID, liked: !liked).

Link to Devin session: https://app.devin.ai/sessions/b4c9125db11b4c978f2d1e6bf30c4f96
Requested by: @HansHans135

- EmptyTile widget: extracted from attendance_screen, score_screen,
  exam_score_screen, and home_screen into lib/widgets/empty_tile.dart
- ScoreLabel widget: extracted from score_screen and exam_score_screen
  into lib/widgets/score_label.dart
- TimetableHeaderCell/TimetablePeriodCell: extracted from
  curriculum_screen and following_screen into lib/widgets/timetable_cells.dart
- AsyncContentBuilder: extracted loading/error/unsupported state pattern
  used across 6+ screens into lib/widgets/async_content_builder.dart
- ForumPost.copyWithLikes / ForumMessage.copyWithLikes: moved duplicated
  optimistic-update logic from forum_screen and forum_post_detail_screen
  into the model classes in lib/models/forum_models.dart

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@HansHans135 HansHans135 self-assigned this Jul 3, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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