Skip to content

Conversation

@zmtzawqlp
Copy link
Contributor

@zmtzawqlp zmtzawqlp commented Aug 16, 2022

wrong position of TabBarIndicator when set indicatorSize to TabBarIndicatorSize.label and it has labelPadding.

simulator_screenshot_6A60CB7F-D587-4A63-B059-EF4E5CDBA542

Related issue:

#109604
#63700

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Add test to the case TabBarIndicatorSize.label and has labelPadding

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Aug 16, 2022
@AlexV525 AlexV525 requested a review from xu-baolin August 17, 2022 09:43
Copy link
Member

@xu-baolin xu-baolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more reasonable solution should be to achieve the purpose through the same value of labelPadding and indicatorPadding.

We only need to take into account the padding layout information of the tabs.

      return Center(
        heightFactor: 1.0,
        child: KeyedSubtree(
          key: _tabKeys[index],
          child: Padding(
            padding: adjustedPadding ?? widget.labelPadding ?? tabBarTheme.labelPadding ?? kTabLabelPadding,
            child: widget.tabs[index],
          ),
        ),
      );

@zmtzawqlp
Copy link
Contributor Author

A more reasonable solution should be to achieve the purpose through the same value of labelPadding and indicatorPadding.

We only need to take into account the padding layout information of the tabs.

      return Center(
        heightFactor: 1.0,
        child: KeyedSubtree(
          key: _tabKeys[index],
          child: Padding(
            padding: adjustedPadding ?? widget.labelPadding ?? tabBarTheme.labelPadding ?? kTabLabelPadding,
            child: widget.tabs[index],
          ),
        ),
      );

Actual labelPadding is different for each tabs and base on adjustedPadding(it's changing frequently, i means the logic). RenderPadding is always here, findAncestorRenderObjectOfType method, In my opinion, it doesn't waste the performance. and it's not the same like _tabKeys, _initIndicatorPainter method is called before build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call findAncestorRenderObjectOfType to find the RenderPadding looks a little odd.
What will hanppen if the Padding widget remove in the future?

Copy link
Contributor Author

@zmtzawqlp zmtzawqlp Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. label padding is the padding outsize of label, if you put it into KeyedSubtree, the size from key is also changed, you can't clarify what is the TabBarIndicatorSize.label.
  2. if someone remove Padding, it will be a big breaking change for the customer, and test case will not be passed. and we are in nullsafety, 'EdgeInsetsGeometry? labelPadding ' should not be, if we already know it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a better way to get the label padding info?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have no better idea for now 😳

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reaching out to the RenderObject does not look right. If this padding is controlled by the TabBar, we should pass it directly into the painter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabLeft += (delta + insets.left)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that () is not necessary, 'Unnecessary parenthesis can be removed(unnecessary_parenthesis).'

Copy link
Member

@xu-baolin xu-baolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with a small nit.

@xu-baolin xu-baolin added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Aug 19, 2022

  • Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Aug 19, 2022

Validations Fail.

@xu-baolin xu-baolin requested a review from goderbauer August 19, 2022 01:43
@xu-baolin
Copy link
Member

@goderbauer Hi, Could you take a second review for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reaching out to the RenderObject does not look right. If this padding is controlled by the TabBar, we should pass it directly into the painter.

@zmtzawqlp zmtzawqlp requested a review from goderbauer August 23, 2022 06:21
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #109605 at sha 3dc39c12ef2b34ba6ed0bc56c1a42913c8a5a19a

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Sep 1, 2022
@zmtzawqlp
Copy link
Contributor Author

@goderbauer all tests are passed, please take a look if you have a time

@goderbauer
Copy link
Member

Sorry about the delay, but this PR slipped through the cracks. Could you pull in the latest master and resolve the merge conflicts? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants