Skip to content
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: use container to fix expansion of tab #101

Merged
merged 2 commits into from
Oct 8, 2020

Conversation

shreyas1599
Copy link
Contributor

Fixes #95

I initially made the suggestion to change the padding to 12 from 10, but that didn't work when I tried it on the iPad. Changing to a container with a fixed width did the trick.

width: 100,
child: Center(
child: Text(text),
),
))),
Copy link
Owner

Choose a reason for hiding this comment

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

How about adding Row > Expanded as CupertinoSlidingSegmentedControl's parent? Then it would expand to the full width.

Copy link
Owner

Choose a reason for hiding this comment

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

The magic number 100 would break again if the word becomes long enough at next time.

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 tried using Row > Expanded as I mentioned in the issue. Didn't work

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure if I made it clear. The following code seems work fine.

  Widget _buildTitle(BuildContext context) {
    switch (Provider.of<ThemeModel>(context).theme) {
      case AppThemeType.cupertino:
        return DefaultTextStyle(
          style: DefaultTextStyle.of(context).style.copyWith(fontSize: 14),
          child: Row(
            children: [
              Expanded(
                child: CupertinoSlidingSegmentedControl(
                  groupValue: activeTab,
                  onValueChanged: onTabSwitch,
                  children: tabs.asMap().map((key, text) => MapEntry(
                      key,
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 8),
                        child: Text(text),
                      ))),
                ),
              ),
            ],
          ),
        );
      default:
        return title;
    }
  }

image

@pd4d10 pd4d10 merged commit c71c2da into pd4d10:master Oct 8, 2020
@pd4d10
Copy link
Owner

pd4d10 commented Oct 8, 2020

Hi, @shreyas1599 , I've pushed an extra commit to make it ready to merge. Feel free to ping me if there are other problems.

@shreyas1599
Copy link
Contributor Author

Hi, @pd4d10 sorry for the late reply. I understood my mistake. My mistake was that I put Row > Expanded under CupertinoSlidingSegmentedControl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI : Container length of TabStatefulScaffold in "Cupertino style" changes when switching tabs
2 participants