Skip to content

Commit

Permalink
Improve asset and jump clones spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikKalkoken committed Jan 30, 2025
1 parent 63923aa commit 5396ce9
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 42 deletions.
50 changes: 25 additions & 25 deletions internal/app/ui/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"cmp"
"context"
"fmt"
"image/color"
"log/slog"
"slices"
"strings"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/dustin/go-humanize"
Expand Down Expand Up @@ -72,7 +72,6 @@ type AssetsArea struct {
assetCollection assetcollection.AssetCollection
assetGrid *widget.GridWrap
assets []*app.CharacterAsset
locationIcon *kxwidget.TappableIcon
assetsBottom *widget.Label
locationPath *widget.Label
locationsData *fynetree.FyneTree[locationDataNode]
Expand Down Expand Up @@ -103,21 +102,7 @@ func (u *BaseUI) NewAssetsArea() *AssetsArea {
)

a.assetGrid = a.makeAssetGrid()
a.locationIcon = kxwidget.NewTappableIcon(theme.InfoIcon(), func() {
if a.selectedLocation.IsEmpty() {
return
}
p := a.locationsData.Path(a.selectedLocation.MustValue().UID())
if len(p) == 0 {
return
}
root, ok := a.locationsData.Value(p[0])
if !ok {
return
}
u.ShowLocationInfoWindow(root.ContainerID)
})
gridTop := container.NewBorder(nil, nil, nil, a.locationIcon, a.locationPath)
gridTop := a.locationPath
a.LocationAssets = container.NewBorder(
container.NewVBox(gridTop, widget.NewSeparator()),
container.NewVBox(widget.NewSeparator(), a.assetsBottom),
Expand Down Expand Up @@ -146,19 +131,29 @@ func (a *AssetsArea) makeLocationsTree() *widget.Tree {
return a.locationsData.IsBranch(uid)
},
func(branch bool) fyne.CanvasObject {
return container.New(layout.NewCustomPaddedHBoxLayout(-5),
widget.NewLabel("1.0"),
widget.NewLabel("Location"),
iconInfo := kxwidget.NewTappableIcon(theme.InfoIcon(), nil)
main := widget.NewLabel("Location")
main.Truncation = fyne.TextTruncateEllipsis
spacer := canvas.NewRectangle(color.Transparent)
spacer.SetMinSize(fyne.NewSize(40, 10))
return container.NewBorder(
nil,
nil,
container.NewStack(spacer, widget.NewLabel("-9.9")),
iconInfo,
main,
)
},
func(uid widget.TreeNodeID, b bool, co fyne.CanvasObject) {
row := co.(*fyne.Container).Objects
prefix := row[0].(*widget.Label)
label := row[1].(*widget.Label)
n, ok := a.locationsData.Value(uid)
if !ok {
return
}
row := co.(*fyne.Container).Objects
label := row[0].(*widget.Label)
spacer := row[1].(*fyne.Container).Objects[0]
prefix := row[1].(*fyne.Container).Objects[1].(*widget.Label)
infoIcon := row[2].(*kxwidget.TappableIcon)
label.SetText(makeNameWithCount(n.Name, n.Count))
if n.IsRoot() {
if !n.IsUnknown {
Expand All @@ -170,8 +165,15 @@ func (a *AssetsArea) makeLocationsTree() *widget.Tree {
}
prefix.Refresh()
prefix.Show()
infoIcon.OnTapped = func() {
a.u.ShowLocationInfoWindow(n.ContainerID)
}
infoIcon.Show()
spacer.Show()
} else {
prefix.Hide()
infoIcon.Hide()
spacer.Hide()
}
},
)
Expand Down Expand Up @@ -201,7 +203,6 @@ func (a *AssetsArea) clearAssets() error {
a.assetGrid.Refresh()
a.locationPath.SetText("")
a.selectedLocation.Clear()
a.locationIcon.Hide()
return nil
}

Expand Down Expand Up @@ -510,7 +511,6 @@ func (a *AssetsArea) selectLocation(location locationDataNode) error {
}
a.updateLocationPath(location)
a.assetsBottom.SetText(fmt.Sprintf("%d Items - %s ISK Est. Price", len(assets), ihumanize.Number(total, 1)))
a.locationIcon.Show()
return nil
}

Expand Down
26 changes: 19 additions & 7 deletions internal/app/ui/jumpclones.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ui
import (
"context"
"fmt"
"image/color"
"log/slog"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -78,20 +79,29 @@ func (a *JumpClonesArea) makeTree() *widget.Tree {
main := widget.NewLabel("Template")
main.Truncation = fyne.TextTruncateEllipsis
iconInfo := kxwidget.NewTappableIcon(theme.InfoIcon(), nil)
prefix := widget.NewLabel("1.0")
return container.NewBorder(nil, nil, container.NewHBox(iconMain, prefix), iconInfo, main)
spacer := canvas.NewRectangle(color.Transparent)
spacer.SetMinSize(fyne.NewSize(40, 10))
prefix := widget.NewLabel("-9.9")
return container.NewBorder(
nil,
nil,
container.NewHBox(iconMain, container.NewStack(spacer, prefix)),
iconInfo,
main,
)
},
func(uid widget.TreeNodeID, b bool, co fyne.CanvasObject) {
n, ok := a.treeData.Value(uid)
if !ok {
return
}
border := co.(*fyne.Container).Objects
main := border[0].(*widget.Label)
hbox := border[1].(*fyne.Container).Objects
iconMain := hbox[0].(*canvas.Image)
prefix := hbox[1].(*widget.Label)
spacer := hbox[1].(*fyne.Container).Objects[0]
prefix := hbox[1].(*fyne.Container).Objects[1].(*widget.Label)
iconInfo := border[2].(*kxwidget.TappableIcon)
n, ok := a.treeData.Value(uid)
if !ok {
return
}
if n.IsRoot() {
iconMain.Resource = eveicon.GetResourceByName(eveicon.CloningCenter)
iconMain.Refresh()
Expand All @@ -112,6 +122,7 @@ func (a *JumpClonesArea) makeTree() *widget.Tree {
prefix.Importance = widget.LowImportance
}
prefix.Show()
spacer.Show()
} else {
RefreshImageResourceAsync(iconMain, func() (fyne.Resource, error) {
return a.u.EveImageService.InventoryTypeIcon(n.ImplantTypeID, DefaultIconPixelSize)
Expand All @@ -121,6 +132,7 @@ func (a *JumpClonesArea) makeTree() *widget.Tree {
a.u.ShowTypeInfoWindow(n.ImplantTypeID, a.u.CharacterID(), DescriptionTab)
}
prefix.Hide()
spacer.Hide()
}
},
)
Expand Down
5 changes: 4 additions & 1 deletion internal/app/ui/mobile/mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,10 @@ func NewMobileUI(fyneApp fyne.App) *MobileUI {
moreNav.Push(widgets.NewAppBar(
"Manage characters",
u.AccountArea.Content,
widget.NewToolbarAction(theme.ContentAddIcon(), u.AccountArea.ShowAddCharacterDialog),
widget.NewToolbarAction(
theme.NewPrimaryThemedResource(theme.ContentAddIcon()),
u.AccountArea.ShowAddCharacterDialog,
),
))
},
),
Expand Down
6 changes: 3 additions & 3 deletions internal/app/ui/wealth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
)

const (
chartBaseSize = 300
chartWidth = chartBaseSize * 1.618
chartHeight = chartBaseSize
chartBaseSize = 440
chartWidth = chartBaseSize
chartHeight = chartBaseSize / 1.618
)

type WealthArea struct {
Expand Down
3 changes: 1 addition & 2 deletions internal/app/widgets/assetbadge.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type assetQuantityBadge struct {

func NewAssetQuantityBadge() *assetQuantityBadge {
q := canvas.NewText("", theme.Color(theme.ColorNameForeground))
q.TextSize = theme.CaptionTextSize()
q.TextSize = sizeLabelText
w := &assetQuantityBadge{
quantity: q,
bg: canvas.NewRectangle(theme.Color(colorAssetQuantityBadgeBackground)),
Expand Down Expand Up @@ -51,7 +51,6 @@ func (w *assetQuantityBadge) CreateRenderer() fyne.WidgetRenderer {
p := theme.Padding()
bgPadding := layout.NewCustomPaddedLayout(0, 0, p, p)
customPadding := layout.NewCustomPaddedLayout(p/2, p/2, p/2, p/2)

c := container.New(customPadding, container.NewStack(
w.bg,
container.New(bgPadding, w.quantity),
Expand Down
2 changes: 1 addition & 1 deletion internal/app/widgets/assetlabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewAssetLabel() *assetLabel {
l1 := canvas.NewText("", theme.Color(theme.ColorNameForeground))
l1.TextSize = theme.CaptionTextSize()
l2 := canvas.NewText("", theme.Color(theme.ColorNameForeground))
l2.TextSize = theme.CaptionTextSize()
l2.TextSize = l1.TextSize
w := &assetLabel{label1: l1, label2: l2}
w.ExtendBaseWidget(w)
return w
Expand Down
1 change: 1 addition & 0 deletions internal/app/widgets/assetlabel_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestSplitLines(t *testing.T) {
{"two lines with truncation", "first second third", "first", "second thi"},
{"one long word", "firstSecondThirdForth", "firstSecon", "dThirdFort"},
{"special 1", "Erik Kalkoken's Cald", "Erik", "Kalkoken's"},
// {"two lines two words", "Contaminated Nanite", "Contaminat", "ed Nanite"}, FIXME!
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/app/widgets/navlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package widgets
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)

Expand All @@ -26,7 +25,7 @@ func (w *NavList) CreateRenderer() fyne.WidgetRenderer {
return len(w.items)
},
func() fyne.CanvasObject {
return newNavListItem(theme.BrokenImageIcon(), "", "")
return newNavListItem(iconBlankSvg, "", "")
},
func(id widget.ListItemID, co fyne.CanvasObject) {
item := w.items[id]
Expand Down
5 changes: 5 additions & 0 deletions internal/app/widgets/resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/app/widgets/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
package widgets

const (
sizeIcon = 32
sizeIcon = 32
sizeLabelText = 12
)
41 changes: 41 additions & 0 deletions resources/widgets/blank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5396ce9

Please sign in to comment.