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 editor icons #677

Merged
merged 8 commits into from
Oct 29, 2021
Merged

Conversation

AdimekweEbuka
Copy link
Contributor

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.

Screenshot 2021-10-26 034645

Closes #673

@AdimekweEbuka AdimekweEbuka marked this pull request as ready for review October 26, 2021 20:45
@@ -2,6 +2,7 @@

package decredmaterial

//
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this line

@@ -43,10 +44,12 @@ type Editor struct {
Bordered bool
//IsPassword if true, displays the show and hide button.
Copy link
Collaborator

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

Suggested change
//IsPassword if true, displays the show and hide button.
// isPassword if true, displays the show and hide button.

@@ -73,6 +77,14 @@ func (t *Theme) RestoreEditor(editor *widget.Editor, hint string, title string)
}
}

//CREATES AN EDITOR WIDGET WITH ICON OF CHOICE.
Copy link
Collaborator

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

@@ -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() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Screenshot from 2021-10-27 12-44-09

Currently the icons all does the same thing when clicked, the click event should be customizable

Comment on lines 39 to 43
// Bordered if true makes the adds a border around the editor.
HasCustomButton bool
CustomButton Button

Bordered bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// 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

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// IconEditor func creates an editor widget with icon of choice
// IconEditor creates an editor widget with icon of choice

@@ -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 {
Copy link
Collaborator

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

e := t.Editor(editor, hint)
e.showEditorIcon = showEditorIcon
e.isEditorButtonClickable = clickableIcon
e.editorIcon = *NewIcon(MustIcon(widget.NewIcon(editorIcon)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
e.editorIcon = *NewIcon(MustIcon(widget.NewIcon(editorIcon)))
e.editorIcon.Icon = MustIcon(widget.NewIcon(editorIcon))

@@ -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))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
editorIcon: *NewIcon(MustIcon(widget.NewIcon(icons.AVAVTimer))),

I don't see a use for this line

editorIcon: *NewIcon(MustIcon(widget.NewIcon(icons.AVAVTimer))),
editorIconButton: IconButton{
material.IconButtonStyle{
Icon: MustIcon(widget.NewIcon(icons.ActionVisibilityOff)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Icon: MustIcon(widget.NewIcon(icons.ActionVisibilityOff)),

This doesn't need to be initialized here

Comment on lines 70 to 77
//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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
//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

Comment on lines 90 to 98
//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)
// }

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
//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

@dreacot dreacot merged commit e9c0753 into planetdecred:master Oct 29, 2021
song50119 pushed a commit to song50119/godcr that referenced this pull request Apr 24, 2022
* 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
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.

Editor Icon support
2 participants