chore: Implement SearchDialog component

Currently, this component is used by QuickSearch dialog. And then, it will be
used by the "Add to playlist" dialog.

I added some setters and getters to the QuickSearch dialog to abstract the interaction
between QuickSearch and SearchDialog from the Controller.

After this PR, I will implement the 'Add to playlist' dialog to incorporate the SearchDialog.
This commit is contained in:
natilou
2024-05-05 12:54:35 -03:00
parent ae441656aa
commit 4eefa4d1fb
3 changed files with 310 additions and 241 deletions
+7 -7
View File
@@ -617,12 +617,12 @@ func (c *Controller) ShowSettingsDialog(themeUpdateCallbk func(), themeFiles map
func (c *Controller) ShowQuickSearch() {
qs := dialogs.NewQuickSearch(c.App.ServerManager.Server, c.App.ImageManager)
pop := widget.NewModalPopUp(qs, c.MainWindow.Canvas())
qs.OnDismiss = func() {
pop := widget.NewModalPopUp(qs.SearchDialog, c.MainWindow.Canvas())
qs.SetOnDismiss(func() {
pop.Hide()
c.doModalClosed()
}
qs.OnNavigateTo = func(contentType mediaprovider.ContentType, id string) {
})
qs.SetOnNavigateTo(func(contentType mediaprovider.ContentType, id string) {
pop.Hide()
c.doModalClosed()
switch contentType {
@@ -637,14 +637,14 @@ func (c *Controller) ShowQuickSearch() {
case mediaprovider.ContentTypeGenre:
c.NavigateTo(GenreRoute(id))
}
}
})
c.ClosePopUpOnEscape(pop)
c.haveModal = true
min := qs.MinSize()
min := qs.GetMinSize()
height := fyne.Max(min.Height, fyne.Min(min.Height*1.5, c.MainWindow.Canvas().Size().Height*0.7))
pop.Resize(fyne.NewSize(min.Width, height))
pop.Show()
c.MainWindow.Canvas().Focus(qs.SearchEntry)
c.MainWindow.Canvas().Focus(qs.GetSearchEntry())
}
func (c *Controller) trySetPasswordAndConnectToServer(server *backend.ServerConfig, password string) error {