feat: Add showPRCard option and improve ScoreGPACard layout handling#191
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces UI enhancements to ScoreScaffold, including new configuration options for the semester picker and the ability to toggle the visibility of the PR card. The AppBar layout was refactored to move item and semester pickers into the actions menu. In ScoreGPACard, the logic was updated to include entries with missing score values as placeholders rather than skipping them. Review feedback suggests simplifying the _GradeEntry creation logic to reduce duplication and refining the grade point display condition to correctly handle valid 0.0 values instead of treating them as missing data.
| if (value == null) { | ||
| entries.add( | ||
| _GradeEntry( | ||
| title: score.title, | ||
| score: 0, | ||
| grade: '-', | ||
| gradePoint: ScoreAnalysis.scoreToGradePoint(-1.0), | ||
| credits: double.tryParse(score.units) ?? 0, | ||
| ), | ||
| ); | ||
| } else { | ||
| entries.add( | ||
| _GradeEntry( | ||
| title: score.title, | ||
| score: value, | ||
| grade: isGradePoint | ||
| ? (raw ?? '') | ||
| : ScoreAnalysis.scoreToGradeLetter(value), | ||
| gradePoint: ScoreAnalysis.scoreToGradePoint(value), | ||
| credits: double.tryParse(score.units) ?? 0, | ||
| ), | ||
| ); | ||
| } |
There was a problem hiding this comment.
The logic for adding entries to the GPA table can be simplified to reduce code duplication and improve maintainability. By calculating the field values upfront or using conditional expressions within the constructor, you can avoid repeating the _GradeEntry instantiation logic.
final bool isInvalid = value == null;
entries.add(
_GradeEntry(
title: score.title,
score: value ?? 0,
grade: isInvalid
? '-'
: (isGradePoint ? (raw ?? '') : ScoreAnalysis.scoreToGradeLetter(value!)),
gradePoint: isInvalid ? 0.0 : ScoreAnalysis.scoreToGradePoint(value!),
credits: double.tryParse(score.units) ?? 0,
),
);| width: 50, | ||
| child: Text( | ||
| e.gradePoint.toStringAsFixed(1), | ||
| e.gradePoint > 0 ? e.gradePoint.toStringAsFixed(1) : '-', |
There was a problem hiding this comment.
The current logic displays a dash (-) for any grade point that is not greater than zero. However, in many academic systems, 0.0 is a valid grade point (e.g., for a failing grade). This implementation incorrectly hides valid 0.0 grade points by treating them the same as invalid or missing data. It is better to check if the entry was specifically marked as invalid (e.g., by checking if the grade string is '-') to decide whether to show the dash.
| e.gradePoint > 0 ? e.gradePoint.toStringAsFixed(1) : '-', | |
| e.grade != '-' ? e.gradePoint.toStringAsFixed(1) : '-', |
abc873693
left a comment
There was a problem hiding this comment.
我有在想,如果選擇學期改成靠右,課表的是不是也可以改,讓視覺位置一致。
但因為有其他 icon 可能要評估一下,可以另外開 PR 處理。
This pull request introduces several enhancements and fixes to the
ScoreScaffoldand related score analysis widgets to improve flexibility and robustness, especially around the display of PR cards and semester picker configuration. It also fixes some UI and data handling edge cases for better user experience.ScoreScaffold and Score Analysis UI improvements:
showPRCardproperty toScoreScaffoldand related widgets, allowing consumers to control the visibility of the PR card in the analysis tab. The default is nowtruefor backward compatibility. [1] [2] [3] [4] [5] [6] [7] [8] [9]semesterPickerUiConfigtoScoreScaffoldfor more customizable semester picker UI. [1] [2] [3]AppBarinScoreScaffoldto always left-align the title, simplify the widget tree, and consistently space actions and pickers. [1] [2]Score Analysis and GPA Card robustness:
ScoreGPACard, scores that cannot be parsed now display a placeholder entry with a dash and zero values, preventing missing or broken rows in the GPA table.Code quality and consistency:
These changes collectively make the score analysis UI more flexible for consumers, more robust in handling edge cases, and more visually consistent.