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
Show file tree
Hide file tree
Changes from all 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 @@ -18,14 +18,12 @@ class KnowledgePanelTitleCard extends StatelessWidget {
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
Color? colorFromEvaluation;
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
if (evaluation != null &&
(knowledgePanelTitleElement.iconColorFromEvaluation ?? false)) {
colorFromEvaluation = _getColorFromEvaluation(evaluation!);
}
if (evaluation != null &&
_getColorFromEvaluation(evaluation!) == null &&
themeData.brightness == Brightness.dark) {
colorFromEvaluation = Colors.white;
if (knowledgePanelTitleElement.iconColorFromEvaluation ?? false) {
if (themeData.brightness == Brightness.dark) {
colorFromEvaluation = _getColorFromEvaluationDarkMode(evaluation);
} else {
colorFromEvaluation = _getColorFromEvaluation(evaluation);
}
}
List<Widget> iconWidget;
if (knowledgePanelTitleElement.iconUrl != null) {
Expand Down Expand Up @@ -82,18 +80,33 @@ class KnowledgePanelTitleCard extends StatelessWidget {
);
}

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

Color _getColorFromEvaluationDarkMode(Evaluation? evaluation) {
switch (evaluation) {
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
case Evaluation.BAD:
return RED_COLOR;
case Evaluation.AVERAGE:
return LIGHT_ORANGE_COLOR;
case Evaluation.GOOD:
return LIGHT_GREEN_COLOR;
case null:
case Evaluation.NEUTRAL:
case Evaluation.UNKNOWN:
return null;
return LIGHT_GREY_COLOR;
}
}
}
1 change: 1 addition & 0 deletions packages/smooth_app/lib/generic_lib/design_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Color WHITE_COLOR = Color(0xFFFFFFFF);
const Color DARK_GREEN_COLOR = Color(0xFF219653);
const Color LIGHT_GREEN_COLOR = Color(0xFF60AC0E);
const Color LIGHT_YELLOW_COLOR = Color(0xFFF2C94C);
const Color LIGHT_GREY_COLOR = Color(0xFFBFBFBF);
const Color DARK_YELLOW_COLOR = Color(0xFFC88F01);
const Color LIGHT_ORANGE_COLOR = Color(0xFFF2994A);
const Color DARK_ORANGE_COLOR = Color(0xFFE07312);
Expand Down