Skip to content

Commit

Permalink
Merge pull request #4240 from andydotxyz/fix/alignmobilemenu
Browse files Browse the repository at this point in the history
Correctly align mobile menu content
  • Loading branch information
andydotxyz committed Sep 13, 2023
2 parents bff233b + 92f62dc commit 307f928
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/driver/mobile/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/driver/mobile"
"fyne.io/fyne/v2/internal/app"
"fyne.io/fyne/v2/internal/driver"
Expand Down Expand Up @@ -167,6 +168,9 @@ func (c *mobileCanvas) setMenu(menu fyne.CanvasObject) {
}

func (c *mobileCanvas) setWindowHead(head fyne.CanvasObject) {
if c.padded {
head = container.NewPadded(head)
}
c.windowHead = head
c.SetMobileWindowHeadTree(head)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/driver/mobile/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func (c *mobileCanvas) showMenu(menu *fyne.MainMenu) {
for _, item := range menu.Items {
panel.Add(newMenuLabel(item, panel, c))
}
if c.padded {
panel = container.NewPadded(panel)
}

bg := canvas.NewRectangle(theme.BackgroundColor())
shadow := canvas.NewHorizontalGradient(theme.ShadowColor(), color.Transparent)
Expand Down
1 change: 1 addition & 0 deletions internal/driver/mobile/menu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestMobileCanvas_DismissBar(t *testing.T) {

func TestMobileCanvas_DismissMenu(t *testing.T) {
c := NewCanvas().(*mobileCanvas)
c.padded = false
c.SetContent(canvas.NewRectangle(theme.BackgroundColor()))
menu := fyne.NewMainMenu(
fyne.NewMenu("Test", fyne.NewMenuItem("TapMe", func() {})))
Expand Down

0 comments on commit 307f928

Please sign in to comment.