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: #3188 - colored button for "ignore" in hunger games #3195

Merged
merged 1 commit into from
Oct 23, 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 @@ -3,10 +3,13 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/model/Insight.dart';
import 'package:openfoodfacts/model/RobotoffQuestion.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/pages/hunger_games/question_card.dart';

const Color _yesBackground = Colors.lightGreen;
const Color _noBackground = Colors.redAccent;
const Color _maybeBackground = QuestionCard.robotoffBackground;
const Color _yesNoTextColor = Colors.white;
const Color _maybeTextColor = Colors.black;

/// Display of the typical Yes / No / Maybe options for Robotoff
class QuestionAnswersOptions extends StatelessWidget {
Expand Down Expand Up @@ -53,18 +56,14 @@ class QuestionAnswersOptions extends StatelessWidget {
),
],
),
const SizedBox(height: SMALL_SPACE),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildAnswerButton(
context,
insightAnnotation: InsightAnnotation.MAYBE,
backgroundColor: const Color(0xFFFFEFB7),
contentColor: Colors.black,
textButton: true,
),
],
SizedBox(
width: double.infinity,
child: _buildAnswerButton(
context,
insightAnnotation: InsightAnnotation.MAYBE,
backgroundColor: _maybeBackground,
contentColor: _maybeTextColor,
),
),
],
),
Expand All @@ -76,7 +75,6 @@ class QuestionAnswersOptions extends StatelessWidget {
required InsightAnnotation insightAnnotation,
required Color backgroundColor,
required Color contentColor,
bool textButton = false,
EdgeInsets padding = const EdgeInsets.all(VERY_SMALL_SPACE),
}) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
Expand All @@ -102,16 +100,14 @@ class QuestionAnswersOptions extends StatelessWidget {
padding: padding,
child: TextButton.icon(
onPressed: () => onAnswer(insightAnnotation),
style: textButton
? null
: ButtonStyle(
backgroundColor: MaterialStateProperty.all(backgroundColor),
shape: MaterialStateProperty.all(
const RoundedRectangleBorder(
borderRadius: ROUNDED_BORDER_RADIUS,
),
),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(backgroundColor),
shape: MaterialStateProperty.all(
const RoundedRectangleBorder(
borderRadius: ROUNDED_BORDER_RADIUS,
),
),
),
icon: Icon(
iconData,
color: contentColor,
Expand Down
6 changes: 4 additions & 2 deletions packages/smooth_app/lib/pages/hunger_games/question_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class QuestionCard extends StatelessWidget {

final RobotoffQuestion question;

static const Color robotoffBackground = Color(0xFFFFEFB7);

@override
Widget build(BuildContext context) {
final Future<Product> productFuture = OpenFoodAPIClient.getProduct(
Expand Down Expand Up @@ -64,7 +66,7 @@ class QuestionCard extends StatelessWidget {

Widget _buildQuestionText(BuildContext context, RobotoffQuestion question) {
return Container(
color: const Color(0xFFFFEFB7),
color: robotoffBackground,
padding: const EdgeInsets.all(SMALL_SPACE),
child: Column(
children: <Widget>[
Expand Down Expand Up @@ -99,7 +101,7 @@ class QuestionCard extends StatelessWidget {
}

Widget _buildQuestionShimmer() => Shimmer.fromColors(
baseColor: const Color(0xFFFFEFB7),
baseColor: robotoffBackground,
highlightColor: Colors.white,
child: Card(
elevation: 4,
Expand Down