Skip to content

Conversation

@brandondiamond
Copy link
Contributor

@brandondiamond brandondiamond commented Jul 12, 2019

Description

Updates the CupertinoSwitch widget to reflect the revised design of switches in iOS 13. In particular, the border no longer animates in response to user interaction. Instead, the background fades between colors.

After:
https://i.imgur.com/dMV7T5G.gif (slow 5x)
https://i.imgur.com/arKDoNk.gif (normal)

Before:
https://i.imgur.com/SxDYis4.gif (slow 5x)
https://i.imgur.com/k7HCNJU.gif (normal)

Related Issues

Issue #33797

Tests

Added a test to verify golden images of the slider in on and off states.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read [Handling breaking changes]). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. While there are exceptions to this rule, if this patch modifies code it is probably not an exception.

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

/cc @dnfield

@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. labels Jul 12, 2019
@LongCatIsLooong
Copy link
Contributor

Hi @brandondiamond thank you for contributing, the PR looks awesome! However tests are mandatory for PRs like this. Could you add tests to ensure it works as expected?

In case you want to add golden tests: https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter

@brandondiamond
Copy link
Contributor Author

Thanks so much for the quick review! I'll get started on those golden tests right away. Given that this is a visual change, are there any additional tests (beyond the golden tests) that you would suggest?

@LongCatIsLooong
Copy link
Contributor

LongCatIsLooong commented Jul 16, 2019

@brandondiamond thanks for the GIFs! Adding golden images when the switch is inactive/active/somewhere in between should be good enough.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, this is great!

+1 for tests. I think that one golden image for on and one for off should be fine.

One very small visual nitpick. I think that our shadow extends below the switch track when it shouldn't anymore.

This Branch iOS 13
On Screen Shot 2019-07-17 at 9 52 57 AM
Off Screen Shot 2019-07-17 at 9 52 49 AM

@brandondiamond
Copy link
Contributor Author

brandondiamond commented Jul 17, 2019

Thanks Justin! I added a clip to ensure the thumb shadow doesn't exceed the track. I know clipping can be expensive so wanted to verify that it'd be okay in this case.

I also wanted to be mindful of antialiasing (since the clip is curved), so I used saveLayer to group the thumb drawing commands together. There's an additional save() and restore() around the clip because I wasn't certain whether there's an automatic save/restore around each paint() -- particularly for render objects that don't mark repaint boundaries; I don't want subsequent drawing operations to be affected by the clip.

I'm very grateful for the opportunity to contribute -- thanks again for reviewing :)

@brandondiamond
Copy link
Contributor Author

Added golden tests and generated goldens. I followed the instructions here but ran into permission issues when attempting to push my golden assets commit to the repo.

What's the correct way to push a change to the goldens repo without special permissions?

@justinmc
Copy link
Contributor

Thanks! I tried running this again and now that it's clipped it looks perfect to my eye.

Regarding performance and antialiasing, I'm going to track down someone that can confirm.

Regarding permissions on the goldens repo, I believe you'll have to fork that repo and open a PR like you did with this PR. I know we tightened up this process recently so I could be wrong, but that's how I did it a few months ago. If you post back with a link to the goldens PR, I can review it really quickly though.

@brandondiamond
Copy link
Contributor Author

Awesome, thanks Justin :)

Here's the goldens PR:
flutter/goldens#40

Once that goes through, I'll update this PR to reference the commit that includes the new goldens.

@codecov
Copy link

codecov bot commented Jul 17, 2019

Codecov Report

Merging #36087 into master will decrease coverage by 0.37%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #36087      +/-   ##
==========================================
- Coverage   55.74%   55.36%   -0.38%     
==========================================
  Files         190      188       -2     
  Lines       17585    17345     -240     
==========================================
- Hits         9802     9603     -199     
+ Misses       7783     7742      -41
Flag Coverage Δ
#flutter_tool 55.36% <0%> (-0.38%) ⬇️
Impacted Files Coverage Δ
...ages/flutter_tools/lib/src/commands/build_web.dart 33.33% <0%> (-28.21%) ⬇️
...ackages/flutter_tools/lib/src/reporting/usage.dart 68.25% <0%> (-17.67%) ⬇️
packages/flutter_tools/lib/src/web/workflow.dart 77.77% <0%> (-14.53%) ⬇️
...ages/flutter_tools/lib/src/commands/build_aot.dart 22.85% <0%> (-12.86%) ⬇️
packages/flutter_tools/lib/src/desktop.dart 78.57% <0%> (-8.39%) ⬇️
...ackages/flutter_tools/lib/src/resident_runner.dart 37.62% <0%> (-7.56%) ⬇️
...utter_tools/lib/src/build_system/targets/dart.dart 84.61% <0%> (-6.53%) ⬇️
...s/flutter_tools/lib/src/commands/build_bundle.dart 93.87% <0%> (-4.24%) ⬇️
packages/flutter_tools/lib/src/artifacts.dart 64.66% <0%> (-3.57%) ⬇️
packages/flutter_tools/lib/src/run_hot.dart 45.83% <0%> (-2.86%) ⬇️
... and 48 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebdc2cf...3ceef68. Read the comment docs.

@brandondiamond
Copy link
Contributor Author

Updated the tests, generated new goldens (ready to go in flutter/goldens#40 -- I'll update the golden hash here once that is merged), and switched to using the PaintingContext to push a clip.

@brandondiamond
Copy link
Contributor Author

Thanks for the review! I'm going to read the style guide today to make sure I don't repeat these formatting mistakes [too often :)]

LongCatIsLooong pushed a commit to flutter/goldens that referenced this pull request Jul 18, 2019
@brandondiamond
Copy link
Contributor Author

Goldens merged and bumped the golden version! Should be good to go.

));
);

context.pushClipRRect(needsCompositing, Offset.zero, thumbBounds, trackRRect, (PaintContext innerContext, Offset offset) {
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong Jul 18, 2019

Choose a reason for hiding this comment

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

PaintContext => PaintingContext, sorry for the wrong suggestion.

@brandondiamond
Copy link
Contributor Author

No worries! I've made that mistake many times

Co-Authored-By: LongCatIsLooong <[email protected]>
@Piinks
Copy link
Contributor

Piinks commented Jul 22, 2019

Currently blocked by #36690, which will resolve the golden sync issues that are causing the tests to fail here.

@brandondiamond
Copy link
Contributor Author

Thanks for looking into this. Please let me know if there is anything I can do to help.

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

#36690 has landed. You may need to update your branch by pulling down the changes from master.

@brandondiamond
Copy link
Contributor Author

@Piinks Thanks! What's the best way to do this without messing up commit history?

@Piinks
Copy link
Contributor

Piinks commented Jul 23, 2019

You should be able to do a
git fetch upstream
and then
git pull upstream master
This will create a commit that merges updates from master into your branch, which you can then push here. :)

@brandondiamond
Copy link
Contributor Author

Thanks so much! Just pushed -- hopefully all looks okay :)

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for the contribution! 🎉

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for this! I'll merge soon.

@justinmc justinmc merged commit e08538c into flutter:master Jul 24, 2019
johnsonmh pushed a commit to johnsonmh/flutter that referenced this pull request Jul 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants