-
Notifications
You must be signed in to change notification settings - Fork 59
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
TwoStateToolbarAction #93
base: master
Are you sure you want to change the base?
Conversation
Displayed icon in widget alternates between 2 different icons. Simple demo app provided. More functionality will be added.
Give names that better describe what they are.
SetState0Icon sets or changes the icon that is displayed when state is TwoState0.
SetState1Icon sets the icon to display when the state is TwoState1.
toolbarAction description to README.md
Pull Request Test Coverage Report for Build 11555759619Details
💛 - Coveralls |
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.
Thanks for looking at this. What I am struggling with is the naming. For example OnActivated
is paired with a state parameter which doesn't really flow, would it not be OnChanged
or something else that matches with other Fyne callbacks referring to state change?
The other major tripping point is TwoState0
(and 1
) - this seems arbitrary and doesn't convey meaning. Confused more by the integer-like naming but boolean-like type.
I feel like this needs to review the intent / use-case so that the naming can match that expectation better.
And lastly... (sorry this is a tough one) - what does this add over and above a toolbar item where you call SetIcon
when it is tapped?
I have no problem making changes, or just using this on my own projects. I thought it would be of some use to others. Let's discuss further. |
I understand the naming of states to avoid a boolean - I did not mean to intend that a boolean alone was better. But you have named them as though they are integer - but they are boolean... To put it more technically this implementation looks like an N state check API where N=2. The implementation enforces there could never be any more states - but the naming implies there could. Coming from another angle the user has no hints at all that there are other states behind this icon. If it is an "on off" state then it is acceptable because it would be indicate on or off in some way. But with N states where N-1 are not currently visible could be confusing. Should all of this actually be a segmented button where each state is visible and the current is selected? |
TwoState0 and TwoState1 imply that there could be more than 2 states.
Matches offState and onState states.
Name the function args and method names to match OnState and OffState.
I have changed the state names to OffState and OnState, and the icons to offStateIcon and onStateIcon. I don't think displaying both buttons at the same time is appropriate, even with one of the buttons disabled. I feel that is more confusing that displaying a single button that implies an action that can be taken. |
Thanks for this, I think I understand now why two states was the way to go. |
In methods and functions, state replaced by a boolean called `on`.
Modify TwoStateToolbarAction description to correspond to boolean rather than state.
Change comment in example code. The user does not need to display the other icon as this is already done for the user.
Widget has been changed to use bool rather than enum to specify state. |
TwoStateToolbarAction is a toolbar action that maintains state and displays one of two icons based on the current state. Tapping the toolbar action changes the state and displays the other icon. The state is also passed to the
onActivate
function.This PR implements issue #92.