-
-
Notifications
You must be signed in to change notification settings - Fork 368
fix: Move Hunger Games to a real view instead of overlay (#4681) #6555
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
base: develop
Are you sure you want to change the base?
fix: Move Hunger Games to a real view instead of overlay (#4681) #6555
Conversation
Hi @LorenzoMascia! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @LorenzoMascia!
Of course the first thing is to fix the formatting, but please read my other comments.
builder: (context) => QuestionsPage( ), | ||
), | ||
).then((questionsAnswered) { | ||
// Gestisci il risultato se necessario |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per favore, niente in italiano.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, no more Italian
@@ -77,20 +77,24 @@ class _ProductQuestionsWidgetState extends State<ProductQuestionsWidget> | |||
Future<void> _openQuestions() async { | |||
_trackEvent(AnalyticsEvent.questionClicked); | |||
|
|||
final int? answeredQuestions = await openQuestionPage( | |||
Navigator.push( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No await
? Then please make it explicit and use unawait(
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
_QuestionPageState._numberQuestionsNext, | ||
? AppLocalizations.of(context).robotoff_next_n_questions(10 | ||
|
||
// QuestionPageState._numberQuestionsNext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No useless comments, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the comment and replaced the 10 with the variable numberQuestionsNext
@@ -367,7 +281,7 @@ class _LoadingQuestionsView extends StatelessWidget { | |||
child: Center( | |||
child: DefaultTextStyle( | |||
textAlign: TextAlign.center, | |||
style: const TextStyle(), | |||
style: TextStyle(color: colorScheme.onBackground), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what makes you use explicit colors.
Anyway, if you select onBackground
as a background color, shouldn't you use background
as a front color?
Shouldn't you rather use primary
and onPrimary
?
Or no color at all, just using the app and the device's default values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used primary, and I had to specify the color because with the light theme the lettering was not visible
|
||
void _incrementQuestionsAnswered() { | ||
setState(() { | ||
_questionsAnswered++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how setState
works but ++_questionsAnswered
would be more appropriate.
@@ -62,7 +62,7 @@ class QuestionCard extends StatelessWidget { | |||
mainAxisSize: MainAxisSize.min, | |||
children: <Widget>[ | |||
SizedBox( | |||
height: screenSize.height / 6, | |||
height: screenSize.height / 4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would an Expanded
give us more flexibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
); | ||
_currentQuestionIndex = 0; | ||
} catch (e) { | ||
debugPrint('Error loading next questions: $e'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No debugPrint
, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugPrint
removed
); | ||
_currentQuestionIndex = 0; | ||
try { | ||
setState(() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking, you're supposed to test if(mounted)
before calling setState
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
} | ||
} | ||
|
||
void _incrementQuestionsAnswered() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot see the added value of moving the code here.
It was more relevant to put that in _saveAnswer
, wasn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function removed
.toList(growable: false), | ||
), | ||
), | ||
).then((questionsAnswered) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use that much the then
syntax. Harder to read.
Please stick to the int? value = await myMethod(); if (value ...
syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the construct
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6555 +/- ##
==========================================
- Coverage 9.54% 5.84% -3.70%
==========================================
Files 325 499 +174
Lines 16411 29817 +13406
==========================================
+ Hits 1567 1744 +177
- Misses 14844 28073 +13229 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @LorenzoMascia, and thank you for your changes!
I like the Expanded
version, though the image size isn't correctly computed (the bottom of the big image isn't visible). That needs to be fixed (maybe removing the SizedBox
and letting the system compute by itself, I don't know).
Please read my other comments.
@@ -77,16 +77,20 @@ class _ProductQuestionsWidgetState extends State<ProductQuestionsWidget> | |||
Future<void> _openQuestions() async { | |||
_trackEvent(AnalyticsEvent.questionClicked); | |||
|
|||
final int? answeredQuestions = await openQuestionPage( | |||
final int? questionsAnswered = await Navigator.push<int>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, don't change the naming of the variables unless the change is very relevant.
It was probably not the case here, and the reviewer still has to check every change...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
@@ -308,7 +308,13 @@ class UserPreferencesContribute extends AbstractUserPreferences { | |||
AnalyticsHelper.trackEvent( | |||
AnalyticsEvent.hungerGameOpened, | |||
); | |||
await openQuestionPage(context); | |||
|
|||
Navigator.push( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the simpler await
syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
], | ||
return Expanded( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, // <--- CAMBIATO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per favore...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted, sorry
BuildContext context, | ||
Widget child, | ||
ImageChunkEvent? loadingProgress, | ||
) { | ||
if (loadingProgress == null) { | ||
// TODO(monsieurtanuki): remove this when the image is not null anymore | ||
return child; | ||
} | ||
return const Center( | ||
child: CircularProgressIndicator.adaptive()); | ||
}, | ||
), | ||
); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, what's the point of changing the parameter names and the coding style, except annoying the reviewer?
You literally changed nothing here, except adding an unexpected TODO
with my name...
Please revert that part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
Widget build(BuildContext context) { | ||
return Container( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of changing the coding style? Please revert that part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
width: constraints.maxWidth, | ||
height: constraints.maxHeight, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please try with double.infinity
for width and height?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
const _QuestionPage({ | ||
class QuestionsPage extends StatefulWidget { | ||
const QuestionsPage({ | ||
super.key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need key
, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't. Deleted.
); | ||
_currentQuestionIndex = 0; | ||
try { | ||
setState(() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
setState(() { | ||
_state = const _RobotoffQuestionLoadingState(); | ||
}); | ||
_loadQuestions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add unawaited(
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -367,7 +274,7 @@ class _LoadingQuestionsView extends StatelessWidget { | |||
child: Center( | |||
child: DefaultTextStyle( | |||
textAlign: TextAlign.center, | |||
style: const TextStyle(), | |||
style: TextStyle(color: colorScheme.onSurface), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please
- make a screenshot
- remove all your color and style changes, and then make a screenshot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, the screenshots are exactly the same.
…verlay Committer: Lorenzo Mascia <[email protected]> Changes : modified: packages/smooth_app/lib/pages/hunger_games/question_card.dart modified: packages/smooth_app/lib/pages/hunger_games/question_page.dart modified: packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart modified: packages/smooth_app/lib/pages/product/product_questions_widget.dart
Committer: Lorenzo Mascia <[email protected]> Changes: modified: packages/smooth_app/lib/pages/hunger_games/question_card.dart modified: packages/smooth_app/lib/pages/hunger_games/question_image_thumbnail.dart modified: packages/smooth_app/lib/pages/hunger_games/question_page.dart modified: packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart modified: packages/smooth_app/lib/pages/product/product_questions_widget.dart
Committer: Lorenzo Mascia <[email protected]> Changes: modified: packages/smooth_app/lib/pages/hunger_games/question_image_thumbnail.dart modified: packages/smooth_app/lib/pages/hunger_games/question_page.dart modified: packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart modified: packages/smooth_app/lib/pages/product/product_questions_widget.dart
81ca678
to
3992c5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @LorenzoMascia!
If you have 10 minutes, please have a look at my comments. If you already know that you won't have time for that in a near future, please tell me.
I'm still surprised that you had to change the styles and colors, but that's another story.
progress == null | ||
? child | ||
: const CircularProgressIndicator.adaptive(), | ||
child: LayoutBuilder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we don't need a LayoutBuilder
anymore, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's no longer needed. I had used the builder to get the BoxConstraints during some trials, but in the end I didn’t use them.
onAnswer: onAnswer, | ||
), | ||
], | ||
return Expanded( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if that Expanded
is relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it works in the same way returning directly the Column without the Expanded
@LorenzoMascia And congratulations for your first PR here! |
Co-authored-by: monsieurtanuki <[email protected]>
Committer: Lorenzo Mascia <[email protected]> Changes: modified: lib/pages/hunger_games/question_image_thumbnail.dart modified: lib/pages/hunger_games/question_page.dart
Hi @LorenzoMascia! |
Committer: Lorenzo Mascia [email protected]
Changes :
modified: packages/smooth_app/lib/pages/hunger_games/question_card.dart
modified: packages/smooth_app/lib/pages/hunger_games/question_page.dart
modified: packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart
modified: packages/smooth_app/lib/pages/product/product_questions_widget.dart
What
Scaffold
, as described in the issue.fix: Move Hunger Games to real view instead of overlay
Screenshot
Fixes bug(s)