-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bugs with appTabs render #3983
Conversation
Thanks for this @spxvszero but you'll need to fix the failures in CI before it will get reviewed |
@spxvszero could you request review if you are ready so we can hopefully get this merged :) Id like to see these fixes in something I'mbuilding. |
I'm sorry that this has taken some time to review. It is indeed a good idea to request a re-review (top right on the little circling arrows) once you feel happy enough with the code to do so. Commits can go unnoticed depending on notification settings here on GitHub. It makes it a bit easier for us to know that we should have a look at it again :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. I just have a minor comment about keeping the code in line with our preferred code style. Apart from that, it looks good to me
container/apptabs.go
Outdated
@@ -389,8 +393,12 @@ func (r *appTabsRenderer) buildTabButtons(count int) *fyne.Container { | |||
|
|||
func (r *appTabsRenderer) updateIndicator(animate bool) { | |||
if r.appTabs.current < 0 { | |||
r.divider.Hide() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure the divider should be hidden?
Just because there are no tabs does not mean that this widget becomes invisible. Won't the MinSize still leave room for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andydotxyz I am pretty sure this divider should be hidden, show you the picture, it looks better after hidden the divider.
And the tabs minSize calculation does not contains divider, so i think it is ok for doing this.
Lines 367 to 399 in 7996862
func (r *baseTabsRenderer) minSize(t baseTabs) fyne.Size { | |
pad := theme.Padding() | |
buttonPad := pad | |
barMin := r.bar.MinSize() | |
tabsMin := r.bar.Objects[0].MinSize() | |
accessory := r.bar.Objects[1] | |
accessoryMin := accessory.MinSize() | |
if scroll, ok := r.bar.Objects[0].(*Scroll); ok && len(scroll.Content.(*fyne.Container).Objects) == 0 { | |
tabsMin = fyne.Size{} // scroller forces 32 where we don't need any space | |
buttonPad = 0 | |
} else if group, ok := r.bar.Objects[0].(*fyne.Container); ok && len(group.Objects) > 0 { | |
tabsMin = group.Objects[0].MinSize() | |
buttonPad = 0 | |
} | |
if !accessory.Visible() || accessoryMin.Width == 0 { | |
buttonPad = 0 | |
accessoryMin = fyne.Size{} | |
} | |
contentMin := fyne.NewSize(0, 0) | |
for _, content := range t.items() { | |
contentMin = contentMin.Max(content.Content.MinSize()) | |
} | |
switch t.tabLocation() { | |
case TabLocationLeading, TabLocationTrailing: | |
return fyne.NewSize(barMin.Width+contentMin.Width+pad, | |
fyne.Max(contentMin.Height, accessoryMin.Height+buttonPad+tabsMin.Height)) | |
default: | |
return fyne.NewSize(fyne.Max(contentMin.Width, accessoryMin.Width+buttonPad+tabsMin.Width), | |
barMin.Height+contentMin.Height+pad) | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No other widgets exhibit the behaviour of appearing invisible if they have no content. I wonder what the use-case is for the bar disappearing if items are removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it looks much better with the bar hidden, but my question is why would you ever have no tabs in this widget? In the case of not having tabs, it should probably be up to the user to hide the apptabs widget I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, no tabs in a tab container seems a bit strange. Most applications that I know of close the whole window if you close the last tab. That, or just hiding the tab widget itself if necessary, seems like something the developers can do already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my applications I make that a "Welcome" tab. That assumes people would like to go back to it of course.
I also wonder if you are describing DocTabs
where user can add and remove tabs themselves, AppTabs are considered more static (developer controlled app sections).
Perhaps the "right" fix is that the line should not only remain visible but the bar should not collapse in height as it is currently doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance you were able to finish this up @spxvszero ? Sorry to bug, but would really like to see this get merged in as the current bug on develop looks terrible.
I guess I could just use your fork instead. lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be wise to separate out the bug fix and the behaviour change. I think it should make this land more quickly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andydotxyz @ismyhc @Jacalz Sorry for replying so late. I think we cannot figure out all the use case and stand for their perspectives. But we can make it looks more natural and comfortable, so i did these change. I agree with @Jacalz , i should separate out the bug fix and the behavior change, i discard the behavior change.Thanks for reviewing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. @spxvszero you may need to request review from @andydotxyz or @Jacalz
Co-authored-by: Andy Williams <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. As suggested leaving the behavior changes for another request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great thanks
FYI: I'll review and merge this later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Thanks for the contribution and congratulations on landing your first PR to Fyne. I also want to add that I especially appreciated the test code that you added to the description. It made it nice and easy to review the bug fix part of this :)
Description:
Fixes #3980
I also fix the appTabs indicator and seperator line does not show properly.
you can compare with this demo code :
Checklist: