Skip to content

Commit 554e6a6

Browse files
committed
Refactor & version bump
1 parent 4238091 commit 554e6a6

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

FyneApp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Website = "https://github.com/ErikKalkoken/janice"
44
Icon = "icon.png"
55
Name = "Janice"
66
ID = "io.github.erikkalkoken.janice"
7-
Version = "0.5.0"
7+
Version = "0.6.0"
88
Build = 1
99

1010
[Release]

internal/ui/searchbar.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var type2importance = map[jsondocument.JSONType]widget.Importance{
3636
// searchBarFrame represents the search bar frame in the UI.
3737
type searchBarFrame struct {
3838
content *fyne.Container
39-
ui *UI
39+
u *UI
4040

4141
searchEntry *widget.Entry
4242
searchButton *ttwidget.Button
@@ -48,7 +48,7 @@ type searchBarFrame struct {
4848

4949
func (u *UI) newSearchBarFrame() *searchBarFrame {
5050
f := &searchBarFrame{
51-
ui: u,
51+
u: u,
5252
searchEntry: widget.NewEntry(),
5353
}
5454
// search frame
@@ -71,15 +71,15 @@ func (u *UI) newSearchBarFrame() *searchBarFrame {
7171
})
7272
f.searchButton.SetToolTip("Search")
7373
f.scrollBottom = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceVerticalalignbottomSvg), func() {
74-
f.ui.treeWidget.ScrollToBottom()
74+
f.u.treeWidget.ScrollToBottom()
7575
})
7676
f.scrollBottom.SetToolTip("Scroll to bottom")
7777
f.scrollTop = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceVerticalaligntopSvg), func() {
78-
f.ui.treeWidget.ScrollToTop()
78+
f.u.treeWidget.ScrollToTop()
7979
})
8080
f.scrollTop.SetToolTip("Scroll to top")
8181
f.collapseAll = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceUnfoldlessSvg), func() {
82-
f.ui.treeWidget.CloseAllBranches()
82+
f.u.treeWidget.CloseAllBranches()
8383
})
8484
f.collapseAll.SetToolTip("Collapse all")
8585
c := container.NewBorder(
@@ -131,7 +131,7 @@ func (f *searchBarFrame) doSearch() {
131131
b := widget.NewButton("Cancel", func() {
132132
cancel()
133133
})
134-
d := dialog.NewCustomWithoutButtons("Search", container.NewVBox(c, b), f.ui.window)
134+
d := dialog.NewCustomWithoutButtons("Search", container.NewVBox(c, b), f.u.window)
135135
d.Show()
136136
d.SetOnClosed(func() {
137137
cancel()
@@ -146,30 +146,30 @@ func (f *searchBarFrame) doSearch() {
146146
search = strings.ToLower(search)
147147
if search != "true" && search != "false" && search != "null" {
148148
d.Hide()
149-
f.ui.showErrorDialog("Allowed keywords are: true, false, null", nil)
149+
f.u.showErrorDialog("Allowed keywords are: true, false, null", nil)
150150
return
151151
}
152152
case searchTypeString:
153153
typ = jsondocument.SearchString
154154
case searchTypeNumber:
155155
typ = jsondocument.SearchNumber
156156
}
157-
uid, err := f.ui.document.Search(ctx, f.ui.selection.selectedUID, search, typ)
157+
uid, err := f.u.document.Search(ctx, f.u.selection.selectedUID, search, typ)
158158
d.Hide()
159159
if errors.Is(err, jsondocument.ErrCallerCanceled) {
160160
return
161161
} else if errors.Is(err, jsondocument.ErrNotFound) {
162162
d2 := dialog.NewInformation(
163163
"No match",
164164
fmt.Sprintf("No %s found matching %s", searchType, search),
165-
f.ui.window,
165+
f.u.window,
166166
)
167167
d2.Show()
168168
return
169169
} else if err != nil {
170-
f.ui.showErrorDialog("Search failed", err)
170+
f.u.showErrorDialog("Search failed", err)
171171
return
172172
}
173-
f.ui.scrollTo(uid)
173+
f.u.scrollTo(uid)
174174
}()
175175
}

internal/ui/selection.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
// selection represents the selection frame in the UI.
1616
type selectionFrame struct {
1717
content *fyne.Container
18-
ui *UI
18+
u *UI
1919

2020
selectedUID widget.TreeNodeID
2121
selectedPath *fyne.Container
@@ -27,7 +27,7 @@ func (u *UI) newSelectionFrame() *selectionFrame {
2727
myHBox := layout.NewCustomPaddedHBoxLayout(-5)
2828

2929
f := &selectionFrame{
30-
ui: u,
30+
u: u,
3131
selectedPath: container.New(myHBox),
3232
}
3333
f.jumpToSelection = ttwidget.NewButtonWithIcon("", theme.NewThemedResource(resourceReadmoreSvg), func() {
@@ -88,19 +88,19 @@ type NodePlus struct {
8888

8989
func (f *selectionFrame) set(uid string) {
9090
f.selectedUID = uid
91-
p := f.ui.document.Path(uid)
91+
p := f.u.document.Path(uid)
9292
var path []NodePlus
9393
for _, uid2 := range p {
94-
path = append(path, NodePlus{Node: f.ui.document.Value(uid2), UID: uid2})
94+
path = append(path, NodePlus{Node: f.u.document.Value(uid2), UID: uid2})
9595
}
96-
path = append(path, NodePlus{Node: f.ui.document.Value(uid), UID: uid})
96+
path = append(path, NodePlus{Node: f.u.document.Value(uid), UID: uid})
9797
f.selectedPath.RemoveAll()
9898
for i, n := range path {
9999
isLast := i == len(path)-1
100100
if !isLast {
101101
l := kxwidget.NewTappableLabel(n.Key, func() {
102-
f.ui.scrollTo(n.UID)
103-
f.ui.selectElement(n.UID)
102+
f.u.scrollTo(n.UID)
103+
f.u.selectElement(n.UID)
104104
})
105105
f.selectedPath.Add(l)
106106
} else {

internal/ui/statusbar.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ const (
2323
// statusBarFrame represents the status bar frame in the UI.
2424
type statusBarFrame struct {
2525
content *fyne.Container
26-
ui *UI
26+
u *UI
2727

2828
elementsCount *ttwidget.Label
2929
}
3030

3131
func (u *UI) newStatusBarFrame() *statusBarFrame {
3232
f := &statusBarFrame{
33-
ui: u,
33+
u: u,
3434
elementsCount: ttwidget.NewLabel(""),
3535
}
3636
f.elementsCount.SetToolTip("Total count of elements in the JSON document")

internal/ui/value.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// valueFrame represents the value frame in the UI.
1717
type valueFrame struct {
1818
content *fyne.Container
19-
ui *UI
19+
u *UI
2020

2121
copyValueClipboard *ttwidget.Button
2222
valueDisplay *widget.RichText
@@ -25,7 +25,7 @@ type valueFrame struct {
2525

2626
func (u *UI) newValueFrame() *valueFrame {
2727
f := &valueFrame{
28-
ui: u,
28+
u: u,
2929
valueDisplay: widget.NewRichText(),
3030
}
3131
// value frame
@@ -63,18 +63,18 @@ func (f *valueFrame) reset() {
6363
}
6464

6565
func (f *valueFrame) set(uid widget.TreeNodeID) {
66-
node := f.ui.document.Value(uid)
66+
node := f.u.document.Value(uid)
6767
typeText := fmt.Sprint(node.Type)
6868
var v string
69-
if f.ui.document.IsBranch(uid) {
69+
if f.u.document.IsBranch(uid) {
7070
f.copyValueClipboard.Disable()
7171
switch node.Type {
7272
case jsondocument.Array:
7373
v = "[...]"
7474
case jsondocument.Object:
7575
v = "{...}"
7676
}
77-
ids := f.ui.document.ChildUIDs(uid)
77+
ids := f.u.document.ChildUIDs(uid)
7878
typeText += fmt.Sprintf(", %d elements", len(ids))
7979
} else {
8080
f.copyValueClipboard.Enable()

0 commit comments

Comments
 (0)