summaryrefslogtreecommitdiff
path: root/tag.go
diff options
context:
space:
mode:
Diffstat (limited to 'tag.go')
-rw-r--r--tag.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/tag.go b/tag.go
index 642e8dd..0d03b9d 100644
--- a/tag.go
+++ b/tag.go
@@ -8,6 +8,7 @@ import (
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
+ widget2 "fyne.io/x/fyne/widget"
"log"
"math"
"random.chars.jp/git/image-board/store"
@@ -21,7 +22,7 @@ func init() {
tagSearchBar = func() *fyne.Container {
var (
submit *widget.Button
- entry = widget.NewEntry()
+ entry = widget2.NewCompletionEntry(nil)
)
entry.PlaceHolder = "Enter tags here"
doSearch := func(s string) {
@@ -37,7 +38,21 @@ func init() {
doSearch(entry.Text)
})
entry.OnSubmitted = doSearch
- return container.NewBorder(nil, nil, nil, submit, entry, submit)
+ entry.OnChanged = func(substr string) {
+ var opts []string
+ for _, tag := range tags {
+ if strings.Contains(tag, substr) {
+ opts = append(opts, tag)
+ }
+ }
+ if len(opts) == 0 {
+ entry.HideCompletion()
+ return
+ }
+ entry.SetOptions(opts)
+ entry.ShowCompletion()
+ }
+ return container.NewBorder(nil, nil, nil, submit, entry)
}()
}