Skip to content

Conversation

@vizakenjack
Copy link
Contributor

@vizakenjack vizakenjack commented Jan 15, 2025

Issue: #161590

This pull request adds color argument for CupertinoButton.filled constructor

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla
Copy link

google-cla bot commented Jan 15, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Jan 15, 2025
@Piinks
Copy link
Contributor

Piinks commented Jan 15, 2025

Hey @vizakenjack welcome! Thanks for contributing, this will need a test to verify it works as expected, and a signed CLA.

Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

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

Ack, we've got our colors messed up. I don't believe the proposed solution will fully fix the problem, however.

The use case you are trying to solve should be for CupertinoButton.filled. Regular CupertinoButton should have no background color.
Screenshot 2025-01-15 at 3 02 32 PM

So color should be exposed for CupertinoButton.filled. The text color of which is the primaryContrastingColor from the theme. But also, color should not be changing the background of plain CupertinoButton, it should be changing the foreground. A plain CupertinoButton should have purple text with no background.

Also as said above, we will need a CLA signed to move forward with this PR. It also will need a test to be merged, especially as this is a regression.

@vizakenjack
Copy link
Contributor Author

@MitchellGoodwin thanks! I think I have filled a CLA.

I'll post another commit later, with a CupertinoButton.filled and color argument

However, it would be a breaking change for people upgrading to 3.27

@MitchellGoodwin
Copy link
Contributor

However, it would be a breaking change for people upgrading to 3.27

Somewhat, but because Cupertino is trying to match Apple's designs at the default, we kind of have to make breaking changes according to what they do. If there was a way to guess how people are using these colors and convert them to the right API, then we'd do that, but I don't think that exists here. We should at least make it so that the APIs enable them to swap over to what use case they wanted.

@vizakenjack
Copy link
Contributor Author

Added color argument in the recent commit. Let me know if it's fine so I can add tests

Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

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

Change looks good. Please also update the documentation for CupertinoButton.filled to say the background defaults to the theme's primaryColor if color isn't provided.

@Piinks
Copy link
Contributor

Piinks commented Jan 17, 2025

@vizakenjack can you also update the PR description to reflect what the changes here are?

@vizakenjack
Copy link
Contributor Author

vizakenjack commented Jan 17, 2025

Added tests, fixed documentation, edited PR description

@MitchellGoodwin MitchellGoodwin changed the title Fix incorrect foregroundColor of CupertinoButton Add color to CupertinoButton.filled constructor Jan 17, 2025
Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

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

Tentatively LGTM. Thank you for putting this together. Check failures match the failures on the tree, so unlikely caused by this PR. Waiting for the tree issues to be resolved.

@MitchellGoodwin
Copy link
Contributor

@vizakenjack I rebased the PR to pick up the tree fixes. The linter check is all that's failing, and just needs you to format the button test file.

@vizakenjack
Copy link
Contributor Author

@vizakenjack I rebased the PR to pick up the tree fixes. The linter check is all that's failing, and just needs you to format the button test file.

Thanks! That's strange but I have no idea how to fix the linter (did all the edits in github editor)

@MitchellGoodwin
Copy link
Contributor

Thanks! That's strange but I have no idea how to fix the linter (did all the edits in github editor)

I'm not sure the best way to apply the formatting with the github editor. I'm not familiar with it, and I believe a lot of Flutter specific actions aren't supported by it. Locally you can enable autoformatting on save with your IDE, or run dart format packages/flutter/test/cupertino/button_test.dart. In the check error logs there's a git apply command you can copy into your terminal too.

If you want to try and get it to work with the github editor, from the Linux analyze check it seems to want this:

    decoration = tester
        .widget<DecoratedBox>(
          find.descendant(
            of: find.byType(CupertinoButton),
            matching: find.byType(DecoratedBox),
          ),
        )
        .decoration as BoxDecoration;

turned into roughly this, but I do not think I have the spacing right:

    decoration =
        tester
                .widget<DecoratedBox>(
                  find.descendant(
                    of: find.byType(CupertinoButton),
                    matching: find.byType(DecoratedBox),
                  ),
                )
                .decoration
            as BoxDecoration;

I would strongly request that you try and fix it locally, or at least try not to manually format it and see if it passes more than once or twice. When PRs are updated all the checks run again which can be expensive on our infrastructure, and slow down other PRs.

@Piinks
Copy link
Contributor

Piinks commented Jan 29, 2025

It looks like the formatting fix is done, I am going to rebase to see if it resolves the remaining failures.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino 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.

4 participants