Skip to content

Commit

Permalink
Code fixes for DRY and copy paste amends:)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nortsx authored and andydotxyz committed Dec 21, 2019
1 parent 88b6dd4 commit eb2497f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions widget/tabcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (t *TabContainer) buildTabBar(buttons []fyne.CanvasObject) *fyne.Container
return tabBar
}

// Append adds a new CanvasObject to the end of the group
// Append adds a new TabItem to the rightmost side of the tab panel
func (t *TabContainer) Append(item *TabItem) {
r := cache.Renderer(t).(*tabContainerRenderer)
t.Items = append(t.Items, item)
Expand All @@ -157,16 +157,12 @@ func (t *TabContainer) Append(item *TabItem) {

// Remove tab by value
func (t *TabContainer) Remove(item *TabItem) {
r := cache.Renderer(t).(*tabContainerRenderer)

for index, existingItem := range t.Items {
if existingItem == item {
t.Items = append(t.Items[:index], t.Items[index+1:]...)
r.tabBar.Objects = append(r.tabBar.Objects[:index], r.tabBar.Objects[index+1:]...)
t.RemoveIndex(index)
break
}
}

t.Refresh()
}

// RemoveIndex removes tab by index
Expand Down

0 comments on commit eb2497f

Please sign in to comment.