-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
UI tweaks for ETH contract flow #4346
Conversation
|
|
28d80a5
to
3374fa4
Compare
4ee434b
to
29da869
Compare
aff8fa9
to
962a2e7
Compare
3aef883
to
fc54ad1
Compare
962a2e7
to
dbaac78
Compare
f4bbfd8
to
ee1642a
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.
while we're at this, can you remove text_mono
and info
(and possibly even hold
) from confirm_blob
?
// we would need to account for that and we could not use a constant. | ||
let mut menu_choices = VerticalMenu::empty().danger( | ||
theme::ICON_CANCEL, | ||
verb_cancel.unwrap_or(TR::buttons__cancel.into()), |
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.
why not make verb_cancel
non-Optional and prefill this string at construction time?
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 is the benefit. It would just move the check / unwrap at a higher level, most probably in ConfirmBlobParams
- because that one can have it missing. Let's say I also set it to TR::buttons__cancel
in ConfirmBlobParams
, I would still need to make the check in new_confirm_action
. Unless I make it non-optional there too and set a default in uPy... Either way, the default would have to be somewhere, no?
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.
Well, yes, we kinda want to work with non-Options from as early as possible. If None
here doesn't have a special meaning, it should be unwrapped at the earliest convenient place, which, yes, would be new_confirm_action
.
No reason for a code tree this deep to be aware that the caller somewhere six stack frames out was too lazy to specify the value explicitly.
It may make sense to accept a None value from Python, because that's (a) an API boundary and (b) Python doesn't make it convenient to specify translated values as default arguments -- you can't say def confirm(verb: str = TR.some__verb)
because then it does not get updated when you change a translation.
But that's a property of the API, that it allows you to not specify a verb. Not a property of the implementation, where we always require a string to work with (unless we don't?), just that we have a default value for 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.
OK: fc0bb63
I think I understand your point, and it can be seen like this too, indeed.
I was seeing it from the other angle - as much as possible instantiate these "string bearing structs" like ConfirmBlobParams
and ConfirmActionMenuStrings
(maybe I should rename it to ConfirmActionMenuParams
while at it...) with no parameters, have everything default to None, and do with_XXX
only when "XXX" needs to be changed to something other than the default. Otherwise the struct would carry the None all the way to the very end, where the default would be used. I think @obrusvit 's recent changes also went in this direction - dropping as many parameters from ConfirmBlobParams::new
and moving them to .with_XXX
.
Of course, the two ways are not mutually exclusive, which is what I tried to do at fc0bb6 - not sure whether you guys like it - but basically ConfirmBlobParams::new
still means you want to go with defaults, but the default verb_cancel
is set to TR::buttons__cancel.into()
in the ctor rather than to None
- so this "params bearing struct" carries the concrete default around. Maybe if this is what you meant, then I should just replace the rest of the strings in ConfirmBlobParams
in the same way... I think I like it...
The disadvantage is of course that multiple instantiations of ConfirmBlobParams
around multiple API functions have to unwrap_or
if they want to do a .with_verb_cancel
(in order to let the uPy code customize the verb. OOOOR, I could make with_verb_cancel
accept an Option and have it set the default in case it received None
- but I don't know why, that looks less appealing to me (even though the opposite leads to duplication of the default value).
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.
Maybe if this is what you meant, then I should just replace the rest of the strings in
ConfirmBlobParams
in the same way... I think I like it...
yes, this is what I have in mind
multiple instantiations of ConfirmBlobParams around multiple API functions have to unwrap_or if they want to do a .with_verb_cancel (in order to let the uPy code customize the verb. OOOOR, I could make with_verb_cancel accept an Option and have it set the default in case it received None - but I don't know why, that looks less appealing to me (even though the opposite leads to duplication of the default value).
wondering about this .. would it make sense to construct ConfirmBlobParams
and friends by passing the micropython options -- gated by #[feature(micropython)]
of course?
wdyt @obrusvit
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 think @obrusvit 's recent changes also went in this direction - dropping as many parameters from ConfirmBlobParams::new and moving them to .with_XXX.
My motivation was not to drop as may params as possible from ConfirmBlobParams::new
but to keep only those which are used by all callers. There were 7 params and 4 calls were setting the last 4 to None
/False
Hence I reduced the new
params count to 3 and put the rest to with_xyz
builder methods.
wondering about this .. would it make sense to construct ConfirmBlobParams and friends by passing the micropython options -- gated by #[feature(micropython)] of course?
wdyt @obrusvit
Do you mean constructing ConfirmBlobParams
with (n_args, args, kwargs)
. Hmmm, I don't like it very much. IMO, ConfirmBlobParams
should be deeper in the UI code with rusty-types.
It's true that initially the trait UiFeaturesFirmware
(or whatever the name will be) will be riddled with micropython stuff, but mostly just Obj
, which should be replaced later on.
313f806
to
69d448f
Compare
b0a3a4a
to
fc0bb63
Compare
I'll do that in the next PR if you don't mind, together with cleanup of |
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 have some points to discuss.
// we would need to account for that and we could not use a constant. | ||
let mut menu_choices = VerticalMenu::empty().danger( | ||
theme::ICON_CANCEL, | ||
verb_cancel.unwrap_or(TR::buttons__cancel.into()), |
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 think @obrusvit 's recent changes also went in this direction - dropping as many parameters from ConfirmBlobParams::new and moving them to .with_XXX.
My motivation was not to drop as may params as possible from ConfirmBlobParams::new
but to keep only those which are used by all callers. There were 7 params and 4 calls were setting the last 4 to None
/False
Hence I reduced the new
params count to 3 and put the rest to with_xyz
builder methods.
wondering about this .. would it make sense to construct ConfirmBlobParams and friends by passing the micropython options -- gated by #[feature(micropython)] of course?
wdyt @obrusvit
Do you mean constructing ConfirmBlobParams
with (n_args, args, kwargs)
. Hmmm, I don't like it very much. IMO, ConfirmBlobParams
should be deeper in the UI code with rusty-types.
It's true that initially the trait UiFeaturesFirmware
(or whatever the name will be) will be riddled with micropython stuff, but mostly just Obj
, which should be replaced later on.
content_area = content_area.inset(Insets::top(theme::SPACING)); | ||
content_area = content_area | ||
.inset(Insets::top(theme::SPACING)) | ||
.inset(Insets::top(margin as i16)); |
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 makes the real margin now SPACING + margin
. It's quite confusing but probably 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.
Right. What could I do about it? Rename my parameter to extra_margin
? Would that make more sense?
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, it seems to be that the 2nd .inset
call could be elsewhere or you could not need to use SPACING
. Why does not margin
contain the spacing aswell?
BTW, I am centralizing these requests, and some more, here: #4386 |
7ab7bd7
to
c86d14d
Compare
core/.changelog.d/4302.added
Outdated
[T3T1] Add page counter to paginated blobs. | ||
[T3T1] Add cancel button to individual pages of a blob. | ||
[T3T1] Add margin to the first page of a blob. | ||
[T3B1] Add "continue" button after scrolling through the whole blob. |
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.
each of those needs its own file (4302.added
, 4302.added.1
, 4302.added.2
etc)
(check the output of ./CHANGELOG.unreleased
in core dir)
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 wonder why do we need such granularity in the changelog though. Does it mean anything for the customer?
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.
Yeah, we probably don't. I should have said that originally, i just got tripped by a "multi-line" changeset.
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'll change it do something like Improve paginated blob display. in the release branch if noone objects.
42804bf
to
73829d8
Compare
73829d8
to
cc48473
Compare
This commit adds a margin and footer description to the first page of the paginated blobs to be confirmed on Mercury. It also extracts the part of confirm_blob that deals with the first page to a separate function in order to keep confirm_blob simple.
[no changelog]
[no changelog]
[no changelog]
cc48473
to
5155f12
Compare
76bc58c
to
5c21566
Compare
QA OK tested on TS5, |
This is a continuation of #4343, addressing the UI side of #4302.