Skip to content

Commit

Permalink
Revert "Allow a theme to override the form factor of the tabs to be m…
Browse files Browse the repository at this point in the history
…obile"

This reverts commit d0421e6.
  • Loading branch information
andydotxyz committed Nov 5, 2024
1 parent dcc7dc9 commit 9eaedd7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
5 changes: 2 additions & 3 deletions container/apptabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions container/doctabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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
Expand Down
21 changes: 4 additions & 17 deletions container/tabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -522,8 +511,6 @@ type tabButton struct {
onClosed func()
text string
textAlignment fyne.TextAlign

tabs baseTabs
}

func (b *tabButton) CreateRenderer() fyne.WidgetRenderer {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9eaedd7

Please sign in to comment.