refactor: extract duplicated code into shared utilities#3
Closed
devin-ai-integration[bot] wants to merge 1 commit into
Closed
refactor: extract duplicated code into shared utilities#3devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- 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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/_EmptyCardinattendance_screen,score_screen,exam_score_screen,home_screen.ScoreLabel— two-line label+value column, previously duplicated as_ScoreLabelin bothscore_screenandexam_score_screen.TimetableHeaderCell/TimetablePeriodCell— styled table cells for timetable grids, previously duplicated as_headerCell/_periodCellmethods in bothcurriculum_screenandfollowing_screen(SharedCurriculumScreen).AsyncContentBuilder— encapsulates theisLoading → 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:)andForumMessage.copyWithLikes(userID, liked:)— the optimistic like-toggle helper was duplicated verbatim as_toggledLike/_withPostLike/_withMessageLikeacrossforum_screenandforum_post_detail_screen. Now callers just usepost.copyWithLikes(userID, liked: !liked).Link to Devin session: https://app.devin.ai/sessions/b4c9125db11b4c978f2d1e6bf30c4f96
Requested by: @HansHans135