diff --git a/container/apptabs.go b/container/apptabs.go index 813b88b7b9..5f2d5cd416 100644 --- a/container/apptabs.go +++ b/container/apptabs.go @@ -215,7 +215,7 @@ func (t *AppTabs) SetItems(items []*TabItem) { // SetTabLocation sets the location of the tab bar func (t *AppTabs) SetTabLocation(l TabLocation) { - t.location = tabsAdjustedLocation(l, t) + t.location = tabsAdjustedLocation(l) t.Refresh() } @@ -357,7 +357,7 @@ func (r *appTabsRenderer) buildTabButtons(count int) *fyne.Container { buttons := &fyne.Container{} var iconPos buttonIconPosition - if isMobile(r.tabs) { + if fyne.CurrentDevice().IsMobile() { cells := count if cells == 0 { cells = 1 @@ -381,7 +381,6 @@ func (r *appTabsRenderer) buildTabButtons(count int) *fyne.Container { if item.button == nil { item.button = &tabButton{ onTapped: func() { r.appTabs.Select(item) }, - tabs: r.tabs, } } button := item.button diff --git a/container/doctabs.go b/container/doctabs.go index a713913210..a2bdc8cfc5 100644 --- a/container/doctabs.go +++ b/container/doctabs.go @@ -173,7 +173,7 @@ func (t *DocTabs) SetItems(items []*TabItem) { // SetTabLocation sets the location of the tab bar func (t *DocTabs) SetTabLocation(l TabLocation) { - t.location = tabsAdjustedLocation(l, t) + t.location = tabsAdjustedLocation(l) t.Refresh() } @@ -338,7 +338,6 @@ func (r *docTabsRenderer) buildTabButtons(count int, buttons *fyne.Container) { item.button = &tabButton{ onTapped: func() { r.docTabs.Select(item) }, onClosed: func() { r.docTabs.close(item) }, - tabs: r.tabs, } } button := item.button diff --git a/container/tabs.go b/container/tabs.go index d3f95ca65d..742523e91c 100644 --- a/container/tabs.go +++ b/container/tabs.go @@ -12,8 +12,6 @@ import ( "fyne.io/fyne/v2/widget" ) -const sizeNameDeviceForm = "deviceType" - // TabItem represents a single view in a tab view. // The Text and Icon are used for the tab button and the Content is shown when the corresponding tab is active. // @@ -93,19 +91,10 @@ type baseTabs interface { setTransitioning(bool) } -func isMobile(b baseTabs) bool { - d := fyne.CurrentDevice() - if t := theme.SizeForWidget(sizeNameDeviceForm, b); t != 0 { - return t == 1 - } - - return d.IsMobile() -} - -func tabsAdjustedLocation(l TabLocation, b baseTabs) TabLocation { +func tabsAdjustedLocation(l TabLocation) TabLocation { // Mobile has limited screen space, so don't put app tab bar on long edges - if isMobile(b) { - if o := fyne.CurrentDevice().Orientation(); fyne.IsVertical(o) { + if d := fyne.CurrentDevice(); d.IsMobile() { + if o := d.Orientation(); fyne.IsVertical(o) { if l == TabLocationLeading { return TabLocationTop } else if l == TabLocationTrailing { @@ -522,8 +511,6 @@ type tabButton struct { onClosed func() text string textAlignment fyne.TextAlign - - tabs baseTabs } func (b *tabButton) CreateRenderer() fyne.WidgetRenderer { @@ -733,7 +720,7 @@ func (r *tabButtonRenderer) Refresh() { r.icon.Hide() } - if r.button.onClosed != nil && (isMobile(r.button.tabs) || r.button.hovered || r.close.hovered) { + if d := fyne.CurrentDevice(); r.button.onClosed != nil && (d.IsMobile() || r.button.hovered || r.close.hovered) { r.close.Show() } else { r.close.Hide()