customize placeholder text and fix update bug

This commit is contained in:
Drew Weymouth
2024-05-23 16:32:07 -07:00
parent b999d94e72
commit 44f7eebad1
2 changed files with 11 additions and 1 deletions
+10 -1
View File
@@ -24,6 +24,8 @@ import (
type SearchDialog struct { type SearchDialog struct {
widget.BaseWidget widget.BaseWidget
PlaceholderText string
OnDismiss func() OnDismiss func()
OnNavigateTo func(mediaprovider.ContentType, string) OnNavigateTo func(mediaprovider.ContentType, string)
OnSearched func(string) []*mediaprovider.SearchResult OnSearched func(string) []*mediaprovider.SearchResult
@@ -97,6 +99,13 @@ func (sd *SearchDialog) Show() {
sd.BaseWidget.Show() sd.BaseWidget.Show()
} }
func (sd *SearchDialog) Refresh() {
if sd.PlaceholderText != "" {
sd.searchEntry.SetPlaceHolder(sd.PlaceholderText)
}
sd.BaseWidget.Refresh()
}
func (sd *SearchDialog) onDismiss() { func (sd *SearchDialog) onDismiss() {
if sd.OnDismiss != nil { if sd.OnDismiss != nil {
sd.OnDismiss() sd.OnDismiss()
@@ -267,7 +276,7 @@ func (s *searchResult) Update(result *mediaprovider.SearchResult) {
if result == nil { if result == nil {
return return
} }
if s.contentType == result.Type && s.id == result.ID { if s.contentType == result.Type && s.id == result.ID && s.title.Text == result.Name {
return // nothing to do return // nothing to do
} }
s.id = result.ID s.id = result.ID
+1
View File
@@ -35,6 +35,7 @@ func NewSelectPlaylistDialog(mp mediaprovider.MediaProvider, im util.ImageFetche
sp.onSearched, sp.onSearched,
sp.onInit, sp.onInit,
) )
sd.PlaceholderText = "Search playlists or new playlist name"
sp.SearchDialog = sd sp.SearchDialog = sd
return sp return sp
} }