albums and genre pages: save/reload search context

This commit is contained in:
Drew Weymouth
2023-02-05 16:38:49 -08:00
parent 56715c5598
commit a6a4444524
4 changed files with 73 additions and 46 deletions
+10 -13
View File
@@ -8,8 +8,7 @@ import (
type SearchEntry struct {
widget.Entry
height float32
OnTextChanged func(string)
height float32
}
func NewSearchEntry() *SearchEntry {
@@ -23,20 +22,18 @@ func NewSearchEntry() *SearchEntry {
sf.SetText("")
}
sf.ActionItem = c
sf.OnChanged = func(s string) {
if s == "" {
c.Resource = theme.SearchIcon()
} else {
c.Resource = theme.ContentClearIcon()
}
c.Refresh()
if sf.OnTextChanged != nil {
sf.OnTextChanged(s)
}
}
return sf
}
func (s *SearchEntry) Refresh() {
if s.Text == "" {
s.ActionItem.(*clearTextButton).Resource = theme.SearchIcon()
} else {
s.ActionItem.(*clearTextButton).Resource = theme.ContentClearIcon()
}
s.Entry.Refresh()
}
func (s *SearchEntry) MinSize() fyne.Size {
return fyne.NewSize(200, s.height)
}
+1 -1
View File
@@ -18,7 +18,7 @@ func NewSearcher() *Searcher {
s := &Searcher{
Entry: NewSearchEntry(),
}
s.Entry.OnTextChanged = s.onSearchTextChanged
s.Entry.OnChanged = s.onSearchTextChanged
return s
}