Skip to content

Commit

Permalink
Don't use the fat icons for doctabs on mobile, that was apptabs only (#…
Browse files Browse the repository at this point in the history
…4388)

Updated test data from mobile changes
  • Loading branch information
andydotxyz authored Nov 16, 2023
1 parent 4128839 commit 31ef3ed
Show file tree
Hide file tree
Showing 32 changed files with 314 additions and 349 deletions.
13 changes: 1 addition & 12 deletions container/doctabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,7 @@ func (r *docTabsRenderer) buildTabButtons(count int, buttons *fyne.Container) {
buttons.Objects = nil

var iconPos buttonIconPosition
if fyne.CurrentDevice().IsMobile() {
cells := count
if cells == 0 {
cells = 1
}
if r.docTabs.location == TabLocationTop || r.docTabs.location == TabLocationBottom {
buttons.Layout = layout.NewGridLayoutWithColumns(cells)
} else {
buttons.Layout = layout.NewGridLayoutWithRows(cells)
}
iconPos = buttonIconTop
} else if r.docTabs.location == TabLocationLeading || r.docTabs.location == TabLocationTrailing {
if r.docTabs.location == TabLocationLeading || r.docTabs.location == TabLocationTrailing {
buttons.Layout = layout.NewVBoxLayout()
iconPos = buttonIconTop
} else {
Expand Down
6 changes: 3 additions & 3 deletions container/doctabs_mobile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,19 @@ func TestDocTabs_Tapped(t *testing.T) {
require.Equal(t, 0, tabs.SelectedIndex())
test.AssertRendersToMarkup(t, "doctabs/mobile/tapped_first_selected.xml", c)

test.TapCanvas(c, fyne.NewPos(120, 10))
test.TapCanvas(c, fyne.NewPos(100, 10))
assert.Equal(t, 1, tabs.SelectedIndex())
test.AssertRendersToMarkup(t, "doctabs/mobile/tapped_second_selected.xml", c)

test.TapCanvas(c, fyne.NewPos(240, 10))
test.TapCanvas(c, fyne.NewPos(180, 10))
assert.Equal(t, 2, tabs.SelectedIndex())
test.AssertRendersToMarkup(t, "doctabs/mobile/tapped_third_selected.xml", c)

test.TapCanvas(c, fyne.NewPos(10, 10))
require.Equal(t, 0, tabs.SelectedIndex())
test.AssertRendersToMarkup(t, "doctabs/mobile/tapped_first_selected.xml", c)

test.TapCanvas(c, fyne.NewPos(330, 10))
test.TapCanvas(c, fyne.NewPos(320, 10))
require.Equal(t, 3, tabs.SelectedIndex())
test.AssertRendersToMarkup(t, "doctabs/mobile/tapped_create_tab.xml", c)

Expand Down
20 changes: 10 additions & 10 deletions container/testdata/doctabs/mobile/change_content_change_hidden.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<widget size="150x150" type="*container.DocTabs">
<container size="150x36">
<widget size="110x36" type="*widget.Scroll">
<container size="148x36">
<widget size="72x36" type="*container.tabButton">
<text bold color="primary" pos="4,8" size="64x19">Test1</text>
<widget pos="48,8" size="20x20" type="*container.tabCloseButton">
<container size="156x36">
<widget size="76x36" type="*container.tabButton">
<text bold color="primary" pos="8,8" size="60x20">Test1</text>
<widget pos="52,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
</widget>
<widget pos="76,0" size="72x36" type="*container.tabButton">
<text bold pos="4,8" size="64x19">Test2</text>
<widget pos="48,8" size="20x20" type="*container.tabCloseButton">
<widget pos="80,0" size="76x36" type="*container.tabButton">
<text bold pos="8,8" size="60x20">Test2</text>
<widget pos="52,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize"/>
</widget>
</widget>
Expand All @@ -21,8 +21,8 @@
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x36"/>
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="81x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="81x3"/>
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
</widget>
</widget>
</widget>
Expand All @@ -35,7 +35,7 @@
</container>
</container>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="72x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="76x4"/>
<widget pos="0,40" size="150x110" type="*widget.Label">
<text pos="8,8" size="34x19">Text3</text>
</widget>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/doctabs/mobile/change_content_change_visible.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<widget size="150x150" type="*container.DocTabs">
<container size="150x36">
<widget size="110x36" type="*widget.Scroll">
<container size="148x36">
<widget size="72x36" type="*container.tabButton">
<text bold color="primary" pos="4,8" size="64x19">Test1</text>
<widget pos="48,8" size="20x20" type="*container.tabCloseButton">
<container size="156x36">
<widget size="76x36" type="*container.tabButton">
<text bold color="primary" pos="8,8" size="60x20">Test1</text>
<widget pos="52,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
</widget>
<widget pos="76,0" size="72x36" type="*container.tabButton">
<text bold pos="4,8" size="64x19">Test2</text>
<widget pos="48,8" size="20x20" type="*container.tabCloseButton">
<widget pos="80,0" size="76x36" type="*container.tabButton">
<text bold pos="8,8" size="60x20">Test2</text>
<widget pos="52,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize"/>
</widget>
</widget>
Expand All @@ -21,8 +21,8 @@
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x36"/>
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="81x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="81x3"/>
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
</widget>
</widget>
</widget>
Expand All @@ -35,7 +35,7 @@
</container>
</container>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="72x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="76x4"/>
<widget pos="0,40" size="150x110" type="*widget.Label">
<text pos="8,8" size="34x19">Text3</text>
</widget>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/doctabs/mobile/change_content_initial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<widget size="150x150" type="*container.DocTabs">
<container size="150x36">
<widget size="110x36" type="*widget.Scroll">
<container size="148x36">
<widget size="72x36" type="*container.tabButton">
<text bold color="primary" pos="4,8" size="64x19">Test1</text>
<widget pos="48,8" size="20x20" type="*container.tabCloseButton">
<container size="156x36">
<widget size="76x36" type="*container.tabButton">
<text bold color="primary" pos="8,8" size="60x20">Test1</text>
<widget pos="52,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
</widget>
<widget pos="76,0" size="72x36" type="*container.tabButton">
<text bold pos="4,8" size="64x19">Test2</text>
<widget pos="48,8" size="20x20" type="*container.tabCloseButton">
<widget pos="80,0" size="76x36" type="*container.tabButton">
<text bold pos="8,8" size="60x20">Test2</text>
<widget pos="52,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize"/>
</widget>
</widget>
Expand All @@ -21,8 +21,8 @@
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x36"/>
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="81x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="81x3"/>
<widget pos="0,3" size="77x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="77x3"/>
</widget>
</widget>
</widget>
Expand All @@ -35,7 +35,7 @@
</container>
</container>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="72x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="76x4"/>
<widget pos="0,40" size="150x110" type="*widget.Label">
<text pos="8,8" size="34x19">Text1</text>
</widget>
Expand Down
42 changes: 17 additions & 25 deletions container/testdata/doctabs/mobile/change_icon_change_selected.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.DocTabs">
<container size="150x56">
<widget size="110x56" type="*widget.Scroll">
<container size="148x56">
<widget size="72x56" type="*container.tabButton">
<widget pos="48,18" size="20x20" type="*container.tabCloseButton">
<container size="150x36">
<widget size="110x36" type="*widget.Scroll">
<container size="110x36">
<widget size="52x36" type="*container.tabButton">
<widget pos="28,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
<image pos="16,8" rsc="infoIcon" size="40x40" themed="primary"/>
<image pos="4,8" rsc="infoIcon" size="iconInlineSize" themed="primary"/>
</widget>
<widget pos="76,0" size="72x56" type="*container.tabButton">
<widget pos="48,18" size="20x20" type="*container.tabCloseButton">
<widget pos="56,0" size="52x36" type="*container.tabButton">
<widget pos="28,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize"/>
</widget>
<image pos="16,8" rsc="confirmIcon" size="40x40"/>
<image pos="4,8" rsc="confirmIcon" size="iconInlineSize"/>
</widget>
</container>
<widget pos="110,0" size="0x56" type="*widget.Shadow">
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x56"/>
</widget>
<widget pos="0,50" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="81x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="81x3"/>
</widget>
</widget>
</widget>
<container pos="114,0" size="36x56">
<widget size="36x56" type="*widget.Button">
<rectangle radius="4" size="36x56"/>
<rectangle size="36x56"/>
<image fillMode="contain" pos="8,18" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
<container pos="114,0" size="36x36">
<widget size="36x36" type="*widget.Button">
<rectangle radius="4" size="36x36"/>
<rectangle size="36x36"/>
<image fillMode="contain" pos="8,8" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,56" size="150x4"/>
<rectangle fillColor="primary" pos="0,56" radius="4" size="72x4"/>
<widget pos="0,60" size="150x90" type="*widget.Label">
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="52x4"/>
<widget pos="0,40" size="150x110" type="*widget.Label">
<text pos="8,8" size="34x19">Text1</text>
</widget>
</widget>
Expand Down
42 changes: 17 additions & 25 deletions container/testdata/doctabs/mobile/change_icon_change_unselected.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.DocTabs">
<container size="150x56">
<widget size="110x56" type="*widget.Scroll">
<container size="148x56">
<widget size="72x56" type="*container.tabButton">
<widget pos="48,18" size="20x20" type="*container.tabCloseButton">
<container size="150x36">
<widget size="110x36" type="*widget.Scroll">
<container size="110x36">
<widget size="52x36" type="*container.tabButton">
<widget pos="28,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
<image pos="16,8" rsc="infoIcon" size="40x40" themed="primary"/>
<image pos="4,8" rsc="infoIcon" size="iconInlineSize" themed="primary"/>
</widget>
<widget pos="76,0" size="72x56" type="*container.tabButton">
<widget pos="48,18" size="20x20" type="*container.tabCloseButton">
<widget pos="56,0" size="52x36" type="*container.tabButton">
<widget pos="28,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize"/>
</widget>
<image pos="16,8" rsc="contentAddIcon" size="40x40"/>
<image pos="4,8" rsc="contentAddIcon" size="iconInlineSize"/>
</widget>
</container>
<widget pos="110,0" size="0x56" type="*widget.Shadow">
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x56"/>
</widget>
<widget pos="0,50" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="81x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="81x3"/>
</widget>
</widget>
</widget>
<container pos="114,0" size="36x56">
<widget size="36x56" type="*widget.Button">
<rectangle radius="4" size="36x56"/>
<rectangle size="36x56"/>
<image fillMode="contain" pos="8,18" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
<container pos="114,0" size="36x36">
<widget size="36x36" type="*widget.Button">
<rectangle radius="4" size="36x36"/>
<rectangle size="36x36"/>
<image fillMode="contain" pos="8,8" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,56" size="150x4"/>
<rectangle fillColor="primary" pos="0,56" radius="4" size="72x4"/>
<widget pos="0,60" size="150x90" type="*widget.Label">
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="52x4"/>
<widget pos="0,40" size="150x110" type="*widget.Label">
<text pos="8,8" size="34x19">Text1</text>
</widget>
</widget>
Expand Down
42 changes: 17 additions & 25 deletions container/testdata/doctabs/mobile/change_icon_initial.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.DocTabs">
<container size="150x56">
<widget size="110x56" type="*widget.Scroll">
<container size="148x56">
<widget size="72x56" type="*container.tabButton">
<widget pos="48,18" size="20x20" type="*container.tabCloseButton">
<container size="150x36">
<widget size="110x36" type="*widget.Scroll">
<container size="110x36">
<widget size="52x36" type="*container.tabButton">
<widget pos="28,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
<image pos="16,8" rsc="cancelIcon" size="40x40" themed="primary"/>
<image pos="4,8" rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
<widget pos="76,0" size="72x56" type="*container.tabButton">
<widget pos="48,18" size="20x20" type="*container.tabCloseButton">
<widget pos="56,0" size="52x36" type="*container.tabButton">
<widget pos="28,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize"/>
</widget>
<image pos="16,8" rsc="confirmIcon" size="40x40"/>
<image pos="4,8" rsc="confirmIcon" size="iconInlineSize"/>
</widget>
</container>
<widget pos="110,0" size="0x56" type="*widget.Shadow">
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x56"/>
</widget>
<widget pos="0,50" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="81x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="81x3"/>
</widget>
</widget>
</widget>
<container pos="114,0" size="36x56">
<widget size="36x56" type="*widget.Button">
<rectangle radius="4" size="36x56"/>
<rectangle size="36x56"/>
<image fillMode="contain" pos="8,18" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
<container pos="114,0" size="36x36">
<widget size="36x36" type="*widget.Button">
<rectangle radius="4" size="36x36"/>
<rectangle size="36x36"/>
<image fillMode="contain" pos="8,8" rsc="more-horizontal.svg" size="iconInlineSize" themed="default"/>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,56" size="150x4"/>
<rectangle fillColor="primary" pos="0,56" radius="4" size="72x4"/>
<widget pos="0,60" size="150x90" type="*widget.Label">
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="52x4"/>
<widget pos="0,40" size="150x110" type="*widget.Label">
<text pos="8,8" size="34x19">Text1</text>
</widget>
</widget>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/doctabs/mobile/change_label_change_selected.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<widget size="150x150" type="*container.DocTabs">
<container size="150x36">
<widget size="110x36" type="*widget.Scroll">
<container size="154x36">
<widget size="75x36" type="*container.tabButton">
<text bold color="primary" pos="4,8" size="67x19">New 1</text>
<widget pos="51,8" size="20x20" type="*container.tabCloseButton">
<container size="163x36">
<widget size="83x36" type="*container.tabButton">
<text bold color="primary" pos="8,8" size="67x20">New 1</text>
<widget pos="59,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
</widget>
<widget pos="79,0" size="75x36" type="*container.tabButton">
<text bold pos="4,8" size="67x19">Test2</text>
<widget pos="51,8" size="20x20" type="*container.tabCloseButton">
<widget pos="87,0" size="76x36" type="*container.tabButton">
<text bold pos="8,8" size="60x20">Test2</text>
<widget pos="52,8" size="20x20" type="*container.tabCloseButton">
<image rsc="cancelIcon" size="iconInlineSize"/>
</widget>
</widget>
Expand All @@ -21,8 +21,8 @@
<linearGradient angle="270" endColor="shadow" pos="-8,0" size="8x36"/>
</widget>
<widget pos="0,30" size="110x6" type="*widget.scrollBarArea">
<widget pos="0,3" size="78x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="78x3"/>
<widget pos="0,3" size="74x3" type="*widget.scrollBar">
<rectangle fillColor="scrollbar" size="74x3"/>
</widget>
</widget>
</widget>
Expand All @@ -35,7 +35,7 @@
</container>
</container>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="75x4"/>
<rectangle fillColor="primary" pos="0,36" radius="4" size="83x4"/>
<widget pos="0,40" size="150x110" type="*widget.Label">
<text pos="8,8" size="34x19">Text1</text>
</widget>
Expand Down
Loading

0 comments on commit 31ef3ed

Please sign in to comment.