Skip to content

Commit

Permalink
fix: 3291 Question "Continue" button doesn't work (#3314)
Browse files Browse the repository at this point in the history
* Added a Flag to decide whether to display Continue button in [CongratsWidget]

* Code refactor for  fix: 3291 Question "Continue" button doesn't work

* Merge branch 'remove_continue_button_for_normal_questions_page' of https://github.com/omkarChend1kar/smooth-app into remove_continue_button_for_normal_questions_page

* Resolved formatting issue for fix: 3291 Question "Continue" button doesn't work

Co-authored-by: monsieurtanuki <fabrice_fontaine@hotmail.com>
  • Loading branch information
omkarChend1kar and monsieurtanuki authored Nov 12, 2022
1 parent 4553468 commit 8614a3f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
13 changes: 9 additions & 4 deletions packages/smooth_app/lib/pages/hunger_games/congrats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import 'package:smooth_app/pages/user_management/login_page.dart';

class CongratsWidget extends StatelessWidget {
const CongratsWidget({
required this.shouldDisplayContinueButton,
required this.anonymousAnnotationList,
this.onContinue,
super.key,
});

final bool shouldDisplayContinueButton;
final VoidCallback? onContinue;
final Map<String, InsightAnnotation> anonymousAnnotationList;

Expand Down Expand Up @@ -56,10 +58,13 @@ class CongratsWidget extends StatelessWidget {
return _buildSignInButton(context, appLocalizations);
}
}),
SmoothSimpleButton(
onPressed: onContinue,
child: Text(appLocalizations.robotoff_continue),
),
if (shouldDisplayContinueButton)
SmoothSimpleButton(
onPressed: onContinue,
child: Text(appLocalizations.robotoff_continue),
)
else
EMPTY_WIDGET,
TextButton(
child: Text(appLocalizations.close),
onPressed: () => Navigator.maybePop<Widget>(context),
Expand Down
2 changes: 2 additions & 0 deletions packages/smooth_app/lib/pages/hunger_games/question_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class QuestionPage extends StatefulWidget {
final Product? product;
final List<RobotoffQuestion>? questions;
final Function()? updateProductUponAnswers;
bool get shouldDisplayContinueButton => product == null;

@override
State<QuestionPage> createState() => _QuestionPageState();
Expand Down Expand Up @@ -162,6 +163,7 @@ class _QuestionPageState extends State<QuestionPage>
}) {
if (questions.length == questionIndex) {
return CongratsWidget(
shouldDisplayContinueButton: widget.shouldDisplayContinueButton,
anonymousAnnotationList: _anonymousAnnotationList,
onContinue: _reloadQuestions,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,11 @@ class UserPreferencesContribute extends AbstractUserPreferences {
);

Future<void> _hungerGames() async => Navigator.push(
context,
MaterialPageRoute<QuestionPage>(
builder: (_) => const QuestionPage(),
));
context,
MaterialPageRoute<QuestionPage>(
builder: (_) => const QuestionPage(),
),
);

Widget _getListTile(
final String title,
Expand Down

0 comments on commit 8614a3f

Please sign in to comment.