Fix password visibility icon state
This commit is contained in:
@@ -7320,12 +7320,7 @@ func (u *ui) passwordLine(label, value string) layout.Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *ui) inlinePasswordToggle(gtx layout.Context, click *widget.Clickable, showing bool) layout.Dimensions {
|
func (u *ui) inlinePasswordToggle(gtx layout.Context, click *widget.Clickable, showing bool) layout.Dimensions {
|
||||||
icon := u.eyeIcon
|
icon, desc := u.passwordTogglePresentation(showing)
|
||||||
desc := "Show password"
|
|
||||||
if showing {
|
|
||||||
icon = u.eyeOffIcon
|
|
||||||
desc = "Hide password"
|
|
||||||
}
|
|
||||||
btn := material.IconButton(u.theme, click, icon, desc)
|
btn := material.IconButton(u.theme, click, icon, desc)
|
||||||
btn.Background = color.NRGBA{R: 239, G: 236, B: 229, A: 255}
|
btn.Background = color.NRGBA{R: 239, G: 236, B: 229, A: 255}
|
||||||
btn.Color = accentColor
|
btn.Color = accentColor
|
||||||
@@ -7334,6 +7329,13 @@ func (u *ui) inlinePasswordToggle(gtx layout.Context, click *widget.Clickable, s
|
|||||||
return btn.Layout(gtx)
|
return btn.Layout(gtx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *ui) passwordTogglePresentation(showing bool) (*widget.Icon, string) {
|
||||||
|
if showing {
|
||||||
|
return u.eyeIcon, "Hide password"
|
||||||
|
}
|
||||||
|
return u.eyeOffIcon, "Show password"
|
||||||
|
}
|
||||||
|
|
||||||
func (u *ui) detailPasswordValue() string {
|
func (u *ui) detailPasswordValue() string {
|
||||||
item, ok := u.selectedEntry()
|
item, ok := u.selectedEntry()
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -8399,6 +8399,28 @@ func TestUIPasswordRevealTogglesDisplayedPasswordAndLockResetsIt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUIPasswordTogglePresentationMatchesVisibility(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
u := newUIWithModel("desktop", vault.Model{})
|
||||||
|
|
||||||
|
icon, desc := u.passwordTogglePresentation(false)
|
||||||
|
if icon != u.eyeOffIcon {
|
||||||
|
t.Fatal("passwordTogglePresentation(false) should use slashed eye icon")
|
||||||
|
}
|
||||||
|
if desc != "Show password" {
|
||||||
|
t.Fatalf("passwordTogglePresentation(false) desc = %q, want %q", desc, "Show password")
|
||||||
|
}
|
||||||
|
|
||||||
|
icon, desc = u.passwordTogglePresentation(true)
|
||||||
|
if icon != u.eyeIcon {
|
||||||
|
t.Fatal("passwordTogglePresentation(true) should use unslashed eye icon")
|
||||||
|
}
|
||||||
|
if desc != "Hide password" {
|
||||||
|
t.Fatalf("passwordTogglePresentation(true) desc = %q, want %q", desc, "Hide password")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type memoryClipboardWriter struct {
|
type memoryClipboardWriter struct {
|
||||||
content string
|
content string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user