-
Notifications
You must be signed in to change notification settings - Fork 46
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 editor icons #677
Adds editor icons #677
Conversation
58edce0
to
3a292f8
Compare
3a292f8
to
2a308d3
Compare
ui/decredmaterial/editor.go
Outdated
@@ -2,6 +2,7 @@ | |||
|
|||
package decredmaterial | |||
|
|||
// |
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.
remove this line
ui/decredmaterial/editor.go
Outdated
@@ -43,10 +44,12 @@ type Editor struct { | |||
Bordered bool | |||
//IsPassword if true, displays the show and hide button. |
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.
All comments should start with a space after the slash, and should use the correct capitalization, here the 'i' in isPassword should be small letters, apply these changes for all other comments
//IsPassword if true, displays the show and hide button. | |
// isPassword if true, displays the show and hide button. |
ui/decredmaterial/editor.go
Outdated
@@ -73,6 +77,14 @@ func (t *Theme) RestoreEditor(editor *widget.Editor, hint string, title string) | |||
} | |||
} | |||
|
|||
//CREATES AN EDITOR WIDGET WITH ICON OF CHOICE. |
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.
- Comments should not be in all caps
- For exported functions, the comment should start with the exported function name
ui/decredmaterial/editor.go
Outdated
@@ -247,7 +267,7 @@ func (e Editor) editor(gtx layout.Context) layout.Dimensions { | |||
} | |||
|
|||
func (e Editor) handleEvents() { | |||
if e.showHidePassword.Button.Clicked() { | |||
if e.editorIconButton.Button.Clicked() { |
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.
ui/decredmaterial/editor.go
Outdated
// Bordered if true makes the adds a border around the editor. | ||
HasCustomButton bool | ||
CustomButton Button | ||
|
||
Bordered bool |
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.
// Bordered if true makes the adds a border around the editor. | |
HasCustomButton bool | |
CustomButton Button | |
Bordered bool | |
HasCustomButton bool | |
CustomButton Button | |
// Bordered if true makes the adds a border around the editor. | |
Bordered bool |
ui/decredmaterial/editor.go
Outdated
@@ -73,6 +79,15 @@ func (t *Theme) RestoreEditor(editor *widget.Editor, hint string, title string) | |||
} | |||
} | |||
|
|||
// IconEditor func creates an editor widget with icon of choice |
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.
// IconEditor func creates an editor widget with icon of choice | |
// IconEditor creates an editor widget with icon of choice |
ui/decredmaterial/editor.go
Outdated
@@ -73,6 +79,15 @@ func (t *Theme) RestoreEditor(editor *widget.Editor, hint string, title string) | |||
} | |||
} | |||
|
|||
// IconEditor func creates an editor widget with icon of choice | |||
func (t *Theme) IconEditor(editor *widget.Editor, hint string, editorIcon []byte, showEditorIcon bool, editorIconEvent func()) Editor { |
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 icons that shouldn't be clickable, trying to pass an empty event , e.g emptyEvent := func()
, crashes the app when the icon is clicked.
we can try passing a boolean argument to allow buttons to either be clickable or not
ui/decredmaterial/editor.go
Outdated
e := t.Editor(editor, hint) | ||
e.showEditorIcon = showEditorIcon | ||
e.isEditorButtonClickable = clickableIcon | ||
e.editorIcon = *NewIcon(MustIcon(widget.NewIcon(editorIcon))) |
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.
e.editorIcon = *NewIcon(MustIcon(widget.NewIcon(editorIcon))) | |
e.editorIcon.Icon = MustIcon(widget.NewIcon(editorIcon)) |
ui/decredmaterial/editor.go
Outdated
@@ -100,6 +123,17 @@ func (t *Theme) Editor(editor *widget.Editor, hint string) Editor { | |||
m2: unit.Dp(2), | |||
m5: unit.Dp(5), | |||
|
|||
editorIcon: *NewIcon(MustIcon(widget.NewIcon(icons.AVAVTimer))), |
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.
editorIcon: *NewIcon(MustIcon(widget.NewIcon(icons.AVAVTimer))), |
I don't see a use for this line
ui/decredmaterial/editor.go
Outdated
editorIcon: *NewIcon(MustIcon(widget.NewIcon(icons.AVAVTimer))), | ||
editorIconButton: IconButton{ | ||
material.IconButtonStyle{ | ||
Icon: MustIcon(widget.NewIcon(icons.ActionVisibilityOff)), |
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.
Icon: MustIcon(widget.NewIcon(icons.ActionVisibilityOff)), |
This doesn't need to be initialized here
ui/modal/create_password_modal.go
Outdated
//PLEASE UNCOMMENT TO SEE AN EXAMPLE OF THE ICONEDITOR FUNCTION USED ON THE WALLET NAME EDITOR | ||
showEditorIcon := true | ||
editorIcon := icons.AVArtTrack | ||
clickableIcon := false | ||
emptyfunc := func() {} | ||
cm.walletName = l.Theme.IconEditor(new(widget.Editor), "Wallet Name", editorIcon, showEditorIcon, clickableIcon, emptyfunc) | ||
cm.walletName.Editor.SingleLine, cm.walletName.Editor.Submit = true, true | ||
|
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 UNCOMMENT TO SEE AN EXAMPLE OF THE ICONEDITOR FUNCTION USED ON THE WALLET NAME EDITOR | |
showEditorIcon := true | |
editorIcon := icons.AVArtTrack | |
clickableIcon := false | |
emptyfunc := func() {} | |
cm.walletName = l.Theme.IconEditor(new(widget.Editor), "Wallet Name", editorIcon, showEditorIcon, clickableIcon, emptyfunc) | |
cm.walletName.Editor.SingleLine, cm.walletName.Editor.Submit = true, true |
This can be deleted
ui/modal/create_password_modal.go
Outdated
//PLEASE UNCOMMENT TO SEE AN EXAMPLE OF THE ICONEDITOR FUNCTION USED ON THE WALLET NAME EDITOR | ||
// func (cm *CreatePasswordModal) walletNameEvent() { | ||
// // info := NewInfoModal(cm.Load). | ||
// // Title("Set up startup password"). | ||
// // Body("Startup password helps protect your wallet from unauthorized access."). | ||
// // PositiveButton("Got it", func() {}) | ||
// // cm.ShowModal(info) | ||
// } | ||
|
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 UNCOMMENT TO SEE AN EXAMPLE OF THE ICONEDITOR FUNCTION USED ON THE WALLET NAME EDITOR | |
// func (cm *CreatePasswordModal) walletNameEvent() { | |
// // info := NewInfoModal(cm.Load). | |
// // Title("Set up startup password"). | |
// // Body("Startup password helps protect your wallet from unauthorized access."). | |
// // PositiveButton("Got it", func() {}) | |
// // cm.ShowModal(info) | |
// } |
This can be deleted
* Adds dynamic Icons to Editor Widget * fix lint * Adds support for editor widget Icon buttons * fix lint * Creates customizable click events for icons * Adds a boolean that selects between a clickable icon button and regular icon * fix lint * Cleans up unused code, comments and spaces
This draft PR creates a function that supports dynamic Icons when creating editor widgets.
A Test was done on the wallet name Editor to show how the function works. Screenshots attached.
Closes #673