Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Transportation Component Icon and title color is not compatible #1494

Merged
merged 16 commits into from
Apr 9, 2022
Merged
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ class KnowledgePanelTitleCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final ColorScheme colorScheme = themeData.colorScheme;
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
Color? colorFromEvaluation;
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
if (evaluation != null &&
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
(knowledgePanelTitleElement.iconColorFromEvaluation ?? false)) {
colorFromEvaluation = _getColorFromEvaluation(evaluation!);
if (themeData.brightness == Brightness.dark) {
colorFromEvaluation = _getColorFromEvaluationDarkMode(evaluation!);
} else {
colorFromEvaluation = _getColorFromEvaluation(evaluation!);
}
}
if (evaluation != null &&
_getColorFromEvaluation(evaluation!) == null &&
themeData.brightness == Brightness.dark) {
colorFromEvaluation = Colors.white;
colorFromEvaluation = colorScheme.onBackground;
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
}
List<Widget> iconWidget;
if (knowledgePanelTitleElement.iconUrl != null) {
Expand Down Expand Up @@ -83,6 +88,21 @@ class KnowledgePanelTitleCard extends StatelessWidget {
}

Color? _getColorFromEvaluation(Evaluation evaluation) {
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
switch (evaluation) {
case Evaluation.BAD:
return RED_COLOR;
case Evaluation.NEUTRAL:
return PRIMARY_GREY_COLOR;
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
case Evaluation.AVERAGE:
return LIGHT_ORANGE_COLOR;
case Evaluation.GOOD:
return LIGHT_GREEN_COLOR;
case Evaluation.UNKNOWN:
return null;
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Color? _getColorFromEvaluationDarkMode(Evaluation evaluation) {
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
switch (evaluation) {
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
case Evaluation.BAD:
return RED_COLOR;
Expand Down