Skip to content

Commit

Permalink
Merge pull request #13 from ErikKalkoken/next-version
Browse files Browse the repository at this point in the history
Improve dialogs and add new switch widget
  • Loading branch information
ErikKalkoken authored Nov 2, 2024
2 parents 4c27233 + efbe35a commit 493c3a1
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Website = "https://github.com/ErikKalkoken/janice"
Icon = "icon.png"
Name = "Janice"
ID = "io.github.erikkalkoken.janice"
Version = "0.6.0"
Version = "0.6.1"
Build = 1

[Release]
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23

require (
fyne.io/fyne/v2 v2.5.2
github.com/ErikKalkoken/fyne-kx v0.0.0-20241025174815-e140dbe057e4
github.com/ErikKalkoken/fyne-kx v0.1.0
github.com/dweymouth/fyne-tooltip v0.2.1
github.com/hashicorp/go-version v1.7.0
github.com/jarcoal/httpmock v1.3.1
Expand All @@ -18,7 +18,7 @@ require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fredbi/uri v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fyne-io/gl-js v0.0.0-20230506162202-1fdaa286a934 // indirect
github.com/fyne-io/glfw-js v0.0.0-20240101223322-6e1efdc71b7a // indirect
github.com/fyne-io/image v0.0.0-20240417123036-dc0ee9e7c964 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ErikKalkoken/fyne-kx v0.0.0-20241025174815-e140dbe057e4 h1:7JZ55BPANlRZtMeHevNiFRtLhGYrTenLyoNpQJisGaQ=
github.com/ErikKalkoken/fyne-kx v0.0.0-20241025174815-e140dbe057e4/go.mod h1:N/YVe+viCUiSOr2TziRV7s9iEOlIfS/n/s5r5LiPcXg=
github.com/ErikKalkoken/fyne-kx v0.1.0 h1:vJ7ja3DnIAR/wDSatFcJbqcMqlv8F4Zz8O87mw8uTjU=
github.com/ErikKalkoken/fyne-kx v0.1.0/go.mod h1:N/YVe+viCUiSOr2TziRV7s9iEOlIfS/n/s5r5LiPcXg=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
Expand Down Expand Up @@ -84,6 +86,8 @@ github.com/fredbi/uri v1.1.0/go.mod h1:aYTUoAXBOq7BLfVJ8GnKmfcuURosB1xyHDIfWeC/i
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/fyne-io/gl-js v0.0.0-20230506162202-1fdaa286a934 h1:dZC5aKobSN07hf71oMivxUmAofFja5GrfPK2rBlttX4=
github.com/fyne-io/gl-js v0.0.0-20230506162202-1fdaa286a934/go.mod h1:d4clgH0/GrRwWjRzJJQXxT/h1TyuNSfF/X64zb/3Ggg=
github.com/fyne-io/glfw-js v0.0.0-20240101223322-6e1efdc71b7a h1:ybgRdYvAHTn93HW79bLiBiJwVL4jVeyGQRZMgImoeWs=
Expand Down
3 changes: 3 additions & 0 deletions internal/jsondocument/jsondocument.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func (j *JSONDocument) Value(uid widget.TreeNodeID) Node {
func (j *JSONDocument) Load(ctx context.Context, reader fyne.URIReadCloser, progressInfo binding.Untyped) error {
j.progressInfo = progressInfo
data, err := j.load(ctx, reader)
if errors.Is(err, context.Canceled) {
err = ErrCallerCanceled
}
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions internal/ui/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"

kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
)

func (u *UI) showAboutDialog() {
Expand All @@ -26,5 +28,6 @@ func (u *UI) showAboutDialog() {
widget.NewHyperlink("Website", x),
)
d := dialog.NewCustom("About", "OK", c, u.window)
kxdialog.AddDialogKeyHandler(d, u.window)
d.Show()
}
4 changes: 4 additions & 0 deletions internal/ui/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/storage"
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"

"github.com/ErikKalkoken/janice/internal/jsondocument"
)

Expand Down Expand Up @@ -71,6 +73,7 @@ func (u *UI) makeMenu() *fyne.MainMenu {
return
}
}, u.window)
kxdialog.AddDialogKeyHandler(d, u.window)
d.Show()
}),
fyne.NewMenuItem("Export Selection To Clipboard", func() {
Expand Down Expand Up @@ -149,6 +152,7 @@ func (u *UI) fileOpen() {
}
u.loadDocument(reader)
}, u.window)
kxdialog.AddDialogKeyHandler(d, u.window)
d.Show()
filterEnabled := u.app.Preferences().BoolWithFallback(settingExtensionFilter, settingExtensionDefault)
if filterEnabled {
Expand Down
3 changes: 3 additions & 0 deletions internal/ui/searchbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
ttwidget "github.com/dweymouth/fyne-tooltip/widget"

"github.com/ErikKalkoken/janice/internal/jsondocument"
Expand Down Expand Up @@ -132,6 +133,7 @@ func (f *searchBarFrame) doSearch() {
cancel()
})
d := dialog.NewCustomWithoutButtons("Search", container.NewVBox(c, b), f.u.window)
kxdialog.AddDialogKeyHandler(d, f.u.window)
d.Show()
d.SetOnClosed(func() {
cancel()
Expand Down Expand Up @@ -164,6 +166,7 @@ func (f *searchBarFrame) doSearch() {
fmt.Sprintf("No %s found matching %s", searchType, search),
f.u.window,
)
kxdialog.AddDialogKeyHandler(d, f.u.window)
d2.Show()
return
} else if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions internal/ui/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ui
import (
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"
kxwidget "github.com/ErikKalkoken/fyne-kx/widget"
)

Expand All @@ -26,13 +27,13 @@ func (u *UI) showSettingsDialog() {
}

// apply file filter
extFilter := kxwidget.NewToggle(func(v bool) {
extFilter := kxwidget.NewSwitch(func(v bool) {
u.app.Preferences().SetBool(settingExtensionFilter, v)
})
y := u.app.Preferences().BoolWithFallback(settingExtensionFilter, settingExtensionDefault)
extFilter.SetState(y)

notifyUpdates := kxwidget.NewToggle(func(v bool) {
notifyUpdates := kxwidget.NewSwitch(func(v bool) {
u.app.Preferences().SetBool(settingNotifyUpdates, v)
})
z := u.app.Preferences().BoolWithFallback(settingNotifyUpdates, settingNotifyUpdatesDefault)
Expand All @@ -44,5 +45,6 @@ func (u *UI) showSettingsDialog() {
{Text: "Notify about updates", Widget: notifyUpdates, HintText: "Wether to notify when an update is available (requires restart)"},
}
d := dialog.NewCustom("Settings", "Close", widget.NewForm(items...), u.window)
kxdialog.AddDialogKeyHandler(d, u.window)
d.Show()
}
4 changes: 4 additions & 0 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"golang.org/x/text/language"
"golang.org/x/text/message"

kxdialog "github.com/ErikKalkoken/fyne-kx/dialog"

"github.com/ErikKalkoken/janice/internal/jsondocument"
)

Expand Down Expand Up @@ -207,6 +209,7 @@ func (u *UI) showErrorDialog(message string, err error) {
slog.Error(message, "err", err)
}
d := dialog.NewInformation("Error", message, u.window)
kxdialog.AddDialogKeyHandler(d, u.window)
d.Show()
}

Expand Down Expand Up @@ -286,6 +289,7 @@ func (u *UI) loadDocument(reader fyne.URIReadCloser) {
d2.SetOnClosed(func() {
cancel()
})
kxdialog.AddDialogKeyHandler(d2, u.window)
d2.Show()
go func() {
doc := jsondocument.New()
Expand Down

0 comments on commit 493c3a1

Please sign in to comment.