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

Adds "< " to "Back" menu items #420

Merged
merged 6 commits into from
Jul 18, 2024

Conversation

jdlcdl
Copy link
Collaborator

@jdlcdl jdlcdl commented Jul 16, 2024

Description

Perhaps with another "arrow" glyph, this will look nicer, but "< Back" is still very identifiable as a special menu item.

Also changed some tuples' 2nd item to the more standard "lambda: MENU_EXIT" instead of "lambda: None"

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (develop@9eb1bcb). Learn more about missing BASE report.
Report is 14 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #420   +/-   ##
==========================================
  Coverage           ?   94.63%           
==========================================
  Files              ?       57           
  Lines              ?     7078           
  Branches           ?        0           
==========================================
  Hits               ?     6698           
  Misses             ?      380           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@odudex
Copy link
Member

odudex commented Jul 16, 2024

The lambda: MENU_EXIT didn't change behaviors, right?

@tadeubas
Copy link
Contributor

Hi @jdlcdl ! Can we create a constant for Back and reuse it everywhere?

@@ -109,7 +109,7 @@ def load_method(self):
t("Load from SD card"),
None if not self.has_sd_card() else lambda: None,
),
(t("Back"), lambda: None),
("< " + t("Back"), lambda: MENU_EXIT),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd item should return None to express that it's ignored.

@@ -904,7 +904,7 @@ def choose_len_mnemonic(ctx):
[
(t("12 words"), lambda: MENU_EXIT),
(t("24 words"), lambda: MENU_EXIT),
(t("Back"), lambda: MENU_EXIT),
("< " + t("Back"), lambda: MENU_EXIT),
Copy link
Collaborator Author

@jdlcdl jdlcdl Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all 2nd items should return None to express that they're ignored, or they could return num words (or None) if they're not ignored.

@@ -228,7 +228,7 @@ def _sign_menu(self):
t("Sign to SD card"),
None if not self.has_sd_card() else lambda: None,
),
(t("Back"), lambda: None),
("< " + t("Back"), lambda: MENU_EXIT),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd item should be None to express that it's ignored.

@@ -199,7 +199,7 @@ def sign_message(self):
t("Sign to SD card"),
None if not self.has_sd_card() else lambda: None,
),
(t("Back"), lambda: None),
("< " + t("Back"), lambda: MENU_EXIT),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd item should be None to express that it's ignored.

@jdlcdl
Copy link
Collaborator Author

jdlcdl commented Jul 16, 2024

The lambda: MENU_EXIT didn't change behaviors, right?

I was trying to standardize exiting menus with this MENU_EXIT status, but often it is ignored and doesn't matter. I wasn't intending to alter behavior. I'll move these back to the way they were because I'm not sure if they're inspected elsewhere.

@jdlcdl jdlcdl marked this pull request as draft July 16, 2024 15:11
@odudex
Copy link
Member

odudex commented Jul 16, 2024

The lambda: MENU_EXIT didn't change behaviors, right?

I was trying to standardize exiting menus with this MENU_EXIT status, but often it is ignored and doesn't matter. I wasn't intending to alter behavior. I'll move these back to the way they were because I'm not sure if they're inspected elsewhere.

I was just asking because I didn't know too, but if you tested it's ok!

@jdlcdl
Copy link
Collaborator Author

jdlcdl commented Jul 17, 2024

Hi @jdlcdl ! Can we create a constant for Back and reuse it everywhere?

Still not ready, but working in that direction.

latest commit tries to implement a cta_back() reusable in pages/init.py but to pass tests, couldn't use it in one place, and to pass i18n checks, had to feed it i18n food at least once. Still a work in progress, and have not tested it on device (only limited testing in simulator so far). It's leading me to believe that "Menu" class might take an optional cta_back param and set this up by default so that every menu doesn't always need it; then it would be easier to move from Menu item to Page later.

@jdlcdl
Copy link
Collaborator Author

jdlcdl commented Jul 18, 2024

Altering to ready-for-review.

  • i18n food kluge was fixed above, ty to tadeubas.

  • assert_has_calls() was failing because cta_back() was returning a callable that returned MENU_EXIT, optionally could pass in a different status and it would return a callable that returns it) but this is not always the case, in the settings menu, we need to pass a callable to cta_back() which will be returned (instead of a callable that returns that callable).

@jdlcdl jdlcdl marked this pull request as ready for review July 18, 2024 11:57
@odudex odudex merged commit 5c42590 into selfcustody:develop Jul 18, 2024
7 checks passed
@odudex
Copy link
Member

odudex commented Jul 18, 2024

Reviewed, tested and merged. Thank you!

@jdlcdl jdlcdl deleted the menu_item_back_arrow branch July 21, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants