Skip to content

feat: Add showPRCard option and improve ScoreGPACard layout handling#191

Merged
abc873693 merged 3 commits into
abc873693:masterfrom
TWCkaijin:feat/rearrange-score-page
May 26, 2026
Merged

feat: Add showPRCard option and improve ScoreGPACard layout handling#191
abc873693 merged 3 commits into
abc873693:masterfrom
TWCkaijin:feat/rearrange-score-page

Conversation

@abcd1234davidchen
Copy link
Copy Markdown
Contributor

This pull request introduces several enhancements and fixes to the ScoreScaffold and 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:

  • Added a new showPRCard property to ScoreScaffold and related widgets, allowing consumers to control the visibility of the PR card in the analysis tab. The default is now true for backward compatibility. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Added semesterPickerUiConfig to ScoreScaffold for more customizable semester picker UI. [1] [2] [3]
  • Refactored the AppBar in ScoreScaffold to always left-align the title, simplify the widget tree, and consistently space actions and pickers. [1] [2]

Score Analysis and GPA Card robustness:

  • In 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.
  • The grade point column in the GPA card is widened and now shows a dash for invalid values instead of "0.0", improving readability and accuracy. [1] [2]

Code quality and consistency:

  • Cleaned up code formatting by removing unnecessary line breaks and simplifying boolean expressions for better readability. [1] [2] [3] [4]

These changes collectively make the score analysis UI more flexible for consumers, more robust in handling edge cases, and more visually consistent.

@abcd1234davidchen abcd1234davidchen changed the title Add showPRCard option and improve ScoreGPACard layout handling feat: Add showPRCard option and improve ScoreGPACard layout handling May 13, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +779 to +801
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,
),
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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) : '-',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
e.gradePoint > 0 ? e.gradePoint.toStringAsFixed(1) : '-',
e.grade != '-' ? e.gradePoint.toStringAsFixed(1) : '-',

Copy link
Copy Markdown
Owner

@abc873693 abc873693 left a comment

Choose a reason for hiding this comment

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

我有在想,如果選擇學期改成靠右,課表的是不是也可以改,讓視覺位置一致。
但因為有其他 icon 可能要評估一下,可以另外開 PR 處理。

@abc873693 abc873693 merged commit c46e147 into abc873693:master May 26, 2026
3 checks passed
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.

2 participants