Skip to content

Commit

Permalink
Improve implants layout for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikKalkoken committed Jan 30, 2025
1 parent a7a0ae8 commit 1b25a29
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 36 deletions.
47 changes: 34 additions & 13 deletions internal/app/ui/implants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"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/ErikKalkoken/evebuddy/internal/app"
kxwidget "github.com/ErikKalkoken/fyne-kx/widget"
)

// ImplantsArea is the UI area that shows the skillqueue
Expand All @@ -35,37 +38,55 @@ func (u *BaseUI) NewImplantsArea() *ImplantsArea {
}

func (a *ImplantsArea) makeImplantList() *widget.List {
p := theme.Padding()
l := widget.NewList(
func() int {
return len(a.implants)
},
func() fyne.CanvasObject {
icon := canvas.NewImageFromResource(IconCharacterplaceholder32Jpeg)
icon.FillMode = canvas.ImageFillContain
icon.SetMinSize(fyne.Size{Width: 42, Height: 42})
return container.NewHBox(icon, widget.NewLabel("placeholder\nslot"))
iconMain := canvas.NewImageFromResource(IconCharacterplaceholder32Jpeg)
iconMain.FillMode = canvas.ImageFillContain
iconMain.SetMinSize(fyne.Size{Width: 42, Height: 42})
iconInfo := kxwidget.NewTappableIcon(theme.InfoIcon(), nil)
name := widget.NewLabel("placeholder")
name.Truncation = fyne.TextTruncateEllipsis
slot := widget.NewLabel("placeholder")
slot.Truncation = fyne.TextTruncateEllipsis
return container.NewBorder(
nil,
nil,
iconMain,
iconInfo,
container.New(
layout.NewCustomPaddedVBoxLayout(0),
container.New(layout.NewCustomPaddedLayout(0, -p, 0, 0), name),
container.New(layout.NewCustomPaddedLayout(-p, 0, 0, 0), slot),
),
)
},
func(id widget.ListItemID, co fyne.CanvasObject) {
if id >= len(a.implants) {
return
}
o := a.implants[id]
row := co.(*fyne.Container).Objects
icon := row[0].(*canvas.Image)
label := row[1].(*widget.Label)
label.SetText(fmt.Sprintf("%s\nSlot %d", o.EveType.Name, o.SlotNum))
RefreshImageResourceAsync(icon, func() (fyne.Resource, error) {
vbox := row[0].(*fyne.Container).Objects
name := vbox[0].(*fyne.Container).Objects[0].(*widget.Label)
name.SetText(o.EveType.Name)
slot := vbox[1].(*fyne.Container).Objects[0].(*widget.Label)
slot.SetText(fmt.Sprintf("Slot %d", o.SlotNum))
iconMain := row[1].(*canvas.Image)
RefreshImageResourceAsync(iconMain, func() (fyne.Resource, error) {
return a.u.EveImageService.InventoryTypeIcon(o.EveType.ID, DefaultIconPixelSize)
})
iconInfo := row[2].(*kxwidget.TappableIcon)
iconInfo.OnTapped = func() {
a.u.ShowTypeInfoWindow(o.EveType.ID, a.u.CharacterID(), DescriptionTab)
}
})

l.OnSelected = func(id widget.ListItemID) {
defer l.UnselectAll()
if id >= len(a.implants) {
return
}
o := a.implants[id]
a.u.ShowTypeInfoWindow(o.EveType.ID, a.u.CharacterID(), DescriptionTab)
}
return l
}
Expand Down
39 changes: 17 additions & 22 deletions internal/app/ui/jumpclones.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
kwidget "github.com/ErikKalkoken/fyne-kx/widget"
kxwidget "github.com/ErikKalkoken/fyne-kx/widget"

"github.com/ErikKalkoken/evebuddy/internal/app"
"github.com/ErikKalkoken/evebuddy/internal/app/widgets"
Expand Down Expand Up @@ -77,36 +77,36 @@ func (a *JumpClonesArea) makeTree() *widget.Tree {
return a.treeData.IsBranch(uid)
},
func(branch bool) fyne.CanvasObject {
icon := canvas.NewImageFromResource(IconCharacterplaceholder32Jpeg)
icon.FillMode = canvas.ImageFillContain
icon.SetMinSize(fyne.NewSquareSize(DefaultIconUnitSize))
iconMain := canvas.NewImageFromResource(IconCharacterplaceholder32Jpeg)
iconMain.FillMode = canvas.ImageFillContain
iconMain.SetMinSize(fyne.NewSquareSize(DefaultIconUnitSize))
main := widgets.NewLabelWithSize("Template", labelSizeName)
main.Truncation = fyne.TextTruncateEllipsis
infoIcon := kwidget.NewTappableIcon(theme.InfoIcon(), nil)
iconInfo := kxwidget.NewTappableIcon(theme.InfoIcon(), nil)
prefix := widgets.NewLabelWithSize("[8]", labelSizeName)
return container.NewBorder(nil, nil, container.NewHBox(icon, prefix), infoIcon, main)
return container.NewBorder(nil, nil, container.NewHBox(iconMain, prefix), iconInfo, main)
},
func(uid widget.TreeNodeID, b bool, co fyne.CanvasObject) {
border := co.(*fyne.Container).Objects
main := border[0].(*widgets.Label)
hbox := border[1].(*fyne.Container).Objects
mainIcon := hbox[0].(*canvas.Image)
iconMain := hbox[0].(*canvas.Image)
prefix := hbox[1].(*widgets.Label)
infoIcon := border[2].(*kwidget.TappableIcon)
iconInfo := border[2].(*kxwidget.TappableIcon)
n, ok := a.treeData.Value(uid)
if !ok {
return
}
if n.IsRoot() {
mainIcon.Resource = eveicon.GetResourceByName(eveicon.CloningCenter)
mainIcon.Refresh()
iconMain.Resource = eveicon.GetResourceByName(eveicon.CloningCenter)
iconMain.Refresh()
if !n.IsUnknown {
infoIcon.OnTapped = func() {
iconInfo.OnTapped = func() {
a.u.ShowLocationInfoWindow(n.LocationID)
}
infoIcon.Show()
iconInfo.Show()
} else {
infoIcon.Hide()
iconInfo.Hide()
}
main.SetText(n.LocationName)
if !n.IsUnknown {
Expand All @@ -118,24 +118,19 @@ func (a *JumpClonesArea) makeTree() *widget.Tree {
}
prefix.Show()
} else {
RefreshImageResourceAsync(mainIcon, func() (fyne.Resource, error) {
RefreshImageResourceAsync(iconMain, func() (fyne.Resource, error) {
return a.u.EveImageService.InventoryTypeIcon(n.ImplantTypeID, DefaultIconPixelSize)
})
main.SetText(n.ImplantTypeName)
infoIcon.Hide()
iconInfo.OnTapped = func() {
a.u.ShowTypeInfoWindow(n.ImplantTypeID, a.u.CharacterID(), DescriptionTab)
}
prefix.Hide()
}
},
)
t.OnSelected = func(uid widget.TreeNodeID) {
defer t.UnselectAll()
n, ok := a.treeData.Value(uid)
if !ok {
return
}
if !n.IsRoot() {
a.u.ShowTypeInfoWindow(n.ImplantTypeID, a.u.CharacterID(), DescriptionTab)
}
}
return t
}
Expand Down
2 changes: 1 addition & 1 deletion internal/app/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type BaseUI struct {
OnShowAndRun func()

// need to be implemented for each platform
ShowTypeInfoWindow func(int32, int32, TypeWindowTab)
ShowTypeInfoWindow func(typeID, characterID int32, selectTab TypeWindowTab)
ShowLocationInfoWindow func(int64)

FyneApp fyne.App
Expand Down

0 comments on commit 1b25a29

Please sign in to comment.