Skip to content

Commit

Permalink
Improve folder menu position
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikKalkoken committed Jan 23, 2025
1 parent ff1984a commit fabd464
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
9 changes: 2 additions & 7 deletions internal/app/ui/mobile/mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ func NewMobileUI(fyneApp fyne.App) *MobileUI {
items = append(items, it)
}
}
widget.ShowPopUpMenuAtRelativePosition(
fyne.NewMenu("", items...),
fyne.CurrentApp().Driver().CanvasForObject(o),
fyne.Position{},
o,
)
ShowContextMenu(o, fyne.NewMenu("", items...))
}

newCharacterAppBar := func(title string, body fyne.CanvasObject, items ...widget.ToolbarItem) *AppBar {
Expand Down Expand Up @@ -115,7 +110,7 @@ func NewMobileUI(fyneApp fyne.App) *MobileUI {
func() {
u.NotificationsArea.OnSelectNotification = func() {
characterNav.Push(
newCharacterAppBar("", u.NotificationsArea.Detail),
NewAppBar("", u.NotificationsArea.Detail),
)
}
characterNav.Push(
Expand Down
15 changes: 9 additions & 6 deletions internal/app/ui/mobile/toolbaraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ func NewToolbarActionMenu(icon fyne.Resource, menu *fyne.Menu) *widget.ToolbarAc
a := widget.NewToolbarAction(icon, nil)
o := a.ToolbarObject()
a.OnActivated = func() {
widget.ShowPopUpMenuAtRelativePosition(
menu,
fyne.CurrentApp().Driver().CanvasForObject(o),
fyne.Position{},
o,
)
ShowContextMenu(o, menu)
}
return a
}

func ShowContextMenu(o fyne.CanvasObject, menu *fyne.Menu) {
m := widget.NewPopUpMenu(menu, fyne.CurrentApp().Driver().CanvasForObject(o))
m.ShowAtRelativePosition(fyne.NewPos(
-m.Size().Width+o.Size().Width,
o.Size().Height,
), o)
}
3 changes: 2 additions & 1 deletion internal/app/ui/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ func (a *NotificationsArea) makeNotificationList() *widget.List {
l.OnSelected = func(id widget.ListItemID) {
a.clearDetail()
if id >= len(a.notifications) {
defer l.UnselectAll()
l.UnselectAll()
return
}
a.setDetail(a.notifications[id])
if a.OnSelectNotification != nil {
a.OnSelectNotification()
l.UnselectAll()
}
}
return l
Expand Down

0 comments on commit fabd464

Please sign in to comment.