-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add setting to automatically show submit button #200
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #200 +/- ##
=======================================
Coverage 75.96% 75.97%
=======================================
Files 79 79
Lines 8618 8633 +15
=======================================
+ Hits 6547 6559 +12
- Misses 2071 2074 +3 ☔ View full report in Codecov by Sentry. |
|
||
if (preferences.getBool(PrefKeys.autoSubmitButton) ?? false) { | ||
showSubmitButton = true; | ||
} | ||
else { | ||
showSubmitButton ??= ntConnection.getTopicFromName(topic)?.isPersistent; | ||
showSubmitButton ??= false; | ||
} |
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.
I don't think these lines are necessary, what was there previously should be fine
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.
One issue I found with this is that if showSubmitButton
is explicity set to false, it will be flipped back to true. Instead, it should be initialized to true only if there was no value present initially:
showSubmitButton ??= preferences.getBool(PrefKeys.autoSubmitButton);
showSubmitButton ??= ntConnection.getTopicFromName(topic)?.isPersistent;
showSubmitButton ??= false;
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.
But now, if the preferences.getBool(PrefKeys.autoSubmitButton)
setting is false, but the topic is persistent, showSubmitButton
is set to false but it really should be true.
I think these work (I could be wrong):
if (preferences.getBool(PrefKeys.autoSubmitButton) ?? false) {
showSubmitButton ??= true;
}
else {
showSubmitButton ??= ntConnection.getTopicFromName(topic)?.isPersistent;
showSubmitButton ??= false;
}
so if it has been explicitly set nothing changes, or (very ugly):
showSubmitButton ??= (
(preferences.getBool(PrefKeys.autoSubmitButton) ?? false) ||
(ntConnection.getTopicFromName(topic)?.isPersistent ?? false)
);
Thanks for making this PR! Could you add unit tests for these features? There should be one for the settings dialog (in test/widgets/settings_dialog_test.dart), and one for the text display (you'll have to set a mock initial value in shared preferences) I also think this button could be moved out of developer settings since I wouldn't say it's a very advanced feature, the appearance settings should work just fine for this |
Moved the setting under appearance settings; added unit tests for text display dialog and settings page. I tried to follow what the other tests did but I am not sure these are the kind you wanted. I also tested the new setting on a real robot and it works. I think the changes made earlier in |
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.
Amazing work on this! There's just a few issues with the unit tests, variable naming, and some minor async things, but the UI to this look good.
Also, the CI is failing since the formatting is incorrect, to fix this, run these 3 commands:
dart format .
dart run import_sorter:main
dart fix --apply
|
||
if (preferences.getBool(PrefKeys.autoSubmitButton) ?? false) { | ||
showSubmitButton = true; | ||
} | ||
else { | ||
showSubmitButton ??= ntConnection.getTopicFromName(topic)?.isPersistent; | ||
showSubmitButton ??= false; | ||
} |
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.
One issue I found with this is that if showSubmitButton
is explicity set to false, it will be flipped back to true. Instead, it should be initialized to true only if there was no value present initially:
showSubmitButton ??= preferences.getBool(PrefKeys.autoSubmitButton);
showSubmitButton ??= ntConnection.getTopicFromName(topic)?.isPersistent;
showSubmitButton ??= false;
Thanks for reviewing! I reverted to the old "true if topic is persistent" test without setting the preference, and added two tests for preference is true and preference is false. I do still have a question on what text_display.dart should actually be, I put my proposed new code in the commit but please see if there is anything wrong. |
I think the way it is now is good, I realize now the reason for it, which is the situation where the topic is persistent but the preference is set to false. |
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.
This looks great!
What I'd like to add for 2026 is the ability to set default settings for any widget. I'll have to think more about the implementation of it, but for the time being this will be a useful addition.
addresses Setting to automatically enable submit button #199