-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor score page (Only score parts) (#157)
* feat: rewrite score tile widget * feat: extract & rewrite the section of course score * feat: add i18n text for key of class and department * refactor: define highlight color for origin divider color * feat: add metrics title widget * feat: add grade metrics cell widget * feat: rewrite semester score section to new metrics style * feat: rewrite two rank sections to new metrics style * refactor: rename widget * fix: incorrect theme divider color use * feat: rewrite warning widget and extract from score page * refactor: use refactored widgets to tidy up the score page, and seperate appbar buttons to two * fix: i10n key typo * refactor: use getter to generate sub widgets while it is not depend on any params for building * refactor: seperate appbar action buttons into isolate widget and wrap buttons with tooltip
- Loading branch information
1 parent
9683d3d
commit 8f7cae4
Showing
18 changed files
with
655 additions
and
451 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_app/src/r.dart'; | ||
|
||
class ScorePageAppBarActionButtons extends StatelessWidget { | ||
const ScorePageAppBarActionButtons({ | ||
super.key, | ||
required VoidCallback onRefreshPressed, | ||
required VoidCallback onCalculateCreditPressed, | ||
}) : _onRefreshPressed = onRefreshPressed, | ||
_onCalculateCreditPressed = onCalculateCreditPressed; | ||
|
||
final VoidCallback _onRefreshPressed; | ||
final VoidCallback _onCalculateCreditPressed; | ||
|
||
Widget get _refreshButton => Tooltip( | ||
message: R.current.refresh, | ||
child: IconButton( | ||
icon: const Icon(Icons.refresh), | ||
onPressed: _onRefreshPressed, | ||
), | ||
); | ||
|
||
Widget get _calculateCreditButton => Tooltip( | ||
message: R.current.calculationCredit, | ||
child: IconButton( | ||
icon: const Icon(Icons.calculate), | ||
onPressed: _onCalculateCreditPressed, | ||
), | ||
); | ||
|
||
@override | ||
Widget build(BuildContext context) => Row( | ||
children: [ | ||
_refreshButton, | ||
_calculateCreditButton, | ||
], | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// ignore_for_file: import_of_legacy_library_into_null_safe | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_app/src/model/course/course_score_json.dart'; | ||
import 'package:flutter_app/src/r.dart'; | ||
import 'package:flutter_app/ui/pages/score/widgets/score_tile_widget.dart'; | ||
import 'package:flutter_app/ui/pages/score/widgets/metrics_title_widget.dart'; | ||
|
||
class CourseScoreSection extends StatelessWidget { | ||
const CourseScoreSection({ | ||
super.key, | ||
required List<CourseScoreInfoJson> scoreInfoList, | ||
}) : _scoreInfoList = scoreInfoList; | ||
|
||
final List<CourseScoreInfoJson> _scoreInfoList; | ||
|
||
void _onCategoryChanged(int? category) { | ||
// TODO(TU): implement this method in view model or controller. | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) => Column( | ||
children: [ | ||
MetricsTitle(title: R.current.resultsOfVariousSubjects), | ||
ListView.builder( | ||
shrinkWrap: true, | ||
itemCount: _scoreInfoList.length, | ||
physics: const NeverScrollableScrollPhysics(), | ||
itemBuilder: (_, index) { | ||
final scoreInfo = _scoreInfoList[index]; | ||
return Padding( | ||
padding: const EdgeInsets.only(bottom: 8.0), | ||
child: ScoreTile( | ||
courseName: scoreInfo.name, | ||
category: scoreInfo.category, | ||
scoreValue: scoreInfo.score, | ||
onCategoryChanged: _onCategoryChanged, | ||
), | ||
); | ||
}, | ||
), | ||
], | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// ignore_for_file: import_of_legacy_library_into_null_safe | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_app/src/model/course/course_score_json.dart'; | ||
import 'package:flutter_app/src/r.dart'; | ||
import 'package:flutter_app/ui/pages/score/widgets/grade_metrics_cell_widget.dart'; | ||
import 'package:flutter_app/ui/pages/score/widgets/metrics_title_widget.dart'; | ||
|
||
class RankGradeMetrics extends StatelessWidget { | ||
const RankGradeMetrics({ | ||
super.key, | ||
required String title, | ||
required RankJson rankInfo, | ||
}) : _title = title, | ||
_rankInfo = rankInfo; | ||
|
||
final String _title; | ||
final RankJson _rankInfo; | ||
|
||
Widget _buildSingleRankMetric(String categoryName, RankItemJson rankInfo) => Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 4.0), | ||
child: Text( | ||
'($categoryName)', | ||
textAlign: TextAlign.start, | ||
style: const TextStyle( | ||
fontSize: 10, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
GradeMetricsCell( | ||
name: R.current.rank, | ||
value: '${rankInfo.rank.toInt()} / ${rankInfo.total.toInt()}', | ||
), | ||
GradeMetricsCell( | ||
name: R.current.percentage, | ||
value: '${rankInfo.percentage.toStringAsFixed(1)}%', | ||
), | ||
], | ||
), | ||
], | ||
); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final classRankInfo = _rankInfo.course; | ||
final departmentRankInfo = _rankInfo.department; | ||
|
||
return Column( | ||
children: [ | ||
MetricsTitle(title: _title), | ||
_buildSingleRankMetric(R.current.kClass, classRankInfo), | ||
_buildSingleRankMetric(R.current.kDepartment, departmentRankInfo), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.