Skip to content

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Sep 17, 2019

Description

Dark mode and fidelity updates. This change breaks goldens and the API of CupertinoThumbPainter.

Golden updates: flutter/goldens#45

Screenshots

Comparison

Native UIKit Cupertino
Simulator Screen Shot - iPhone Xʀ - 2019-09-16 at 19 31 25 Simulator Screen Shot - iPhone Xʀ - 2019-09-16 at 19 22 44
Simulator Screen Shot - iPhone Xʀ - 2019-09-16 at 19 28 36 Simulator Screen Shot - iPhone Xʀ - 2019-09-16 at 19 25 34

Dark Mode

activeOrange will be replaced once CupertinoTheme is updated. For now please bear with the wrong slider track color.

switches sliders
Simulator Screen Shot - iPhone Xʀ - 2019-09-17 at 17 13 20 Simulator Screen Shot - iPhone Xʀ - 2019-09-17 at 17 13 33

Related Issues

part of #35541
Fixes #37312

Tests

I added the following tests:

  • Switch renders correctly in dark mode
  • Scrollbar dark mode

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 fluttergithubbot added a: tests "flutter test", flutter_test, or one of our tests f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. c: API break Backwards-incompatible API changes will affect goldens Changes to golden files labels Sep 17, 2019
@fluttergithubbot
Copy link
Contributor

It looks like this pull request includes a golden file change. Please make sure to follow Handling Breaking Changes. While there are exceptions to this rule, if this patch modifies an existing golden file, it is probably not an exception. Only new golden files are not considered breaking changes.

Writing a golden file test for package:flutter may also provide guidance for this change.

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

@LongCatIsLooong LongCatIsLooong changed the title Dark mode for CupertinoSwitch and CupertinoScrollbar Dark mode for CupertinoSwitch and CupertinoScrollbar, Fidelity updates Sep 17, 2019
@@ -1 +1 @@
ae7615ce466a548b41a0f7b9860ec453646f73e9
aec919aee765d460a3dbe457e81c29e0a2221334
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This hash is a placeholder.

}

final CupertinoThumbPainter _thumbPainter = CupertinoThumbPainter();
final CupertinoThumbPainter _thumbPainter = const CupertinoThumbPainter.switchThumb();
Copy link
Contributor Author

@LongCatIsLooong LongCatIsLooong Sep 17, 2019

Choose a reason for hiding this comment

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

Interestingly the analyzer doesn't seem to have an opinion about the const. I assume const CupertinoThumbPainter.switchThumb() is different from CupertinoThumbPainter.switchThumb() and the former should be preferred?

Copy link
Contributor

Choose a reason for hiding this comment

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

Weird, I'm curious as to why. Definitely better to err on the side of including the const though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just substitute const CupertinoThumbPainter.switchThumb(); for _thumbPainter below?


import '../rendering/mock_canvas.dart';


Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Extra blank line

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

Have you seen #37312 and does this fix that as well?

}

final CupertinoThumbPainter _thumbPainter = CupertinoThumbPainter();
final CupertinoThumbPainter _thumbPainter = const CupertinoThumbPainter.switchThumb();
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird, I'm curious as to why. Definitely better to err on the side of including the const though.

@LongCatIsLooong
Copy link
Contributor Author

LongCatIsLooong commented Sep 17, 2019

@justinmc I believe it does: flutter/goldens#45. Updated the description to include that issue. Thanks for bringing it up! 👍

Copy link
Contributor

@HansMuller HansMuller 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 few small changes

// Extracted from iOS 13.1 beta using Debug View Hierarchy.
const Color _kScrollbarColor = CupertinoDynamicColor.withBrightness(
color: Color(0x59000000),
darkColor:Color(0x80FFFFFF),
Copy link
Contributor

Choose a reason for hiding this comment

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

space after the colon

_painter ??= _buildCupertinoScrollbarPainter(context);
_painter
..textDirection = Directionality.of(context)
..color = CupertinoDynamicColor.resolve(_kScrollbarColor, context);
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to update the painter's padding too, since it depends on MediaQuery.of(context).


final Offset thumbCenter = Offset(trackActive, trackCenter);
_thumbPainter.paint(canvas, Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius));
const CupertinoThumbPainter().paint(canvas, Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius));
Copy link
Contributor

Choose a reason for hiding this comment

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

NICE

}

final CupertinoThumbPainter _thumbPainter = CupertinoThumbPainter();
final CupertinoThumbPainter _thumbPainter = const CupertinoThumbPainter.switchThumb();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just substitute const CupertinoThumbPainter.switchThumb(); for _thumbPainter below?

set textDirection(TextDirection value) {
assert(value != null);
if (textDirection == value)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

two space indent

Copy link
Contributor

@brandondiamond brandondiamond left a comment

Choose a reason for hiding this comment

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

LGTM!

LongCatIsLooong added a commit to flutter/goldens that referenced this pull request Sep 23, 2019
@LongCatIsLooong LongCatIsLooong merged commit 4815b26 into flutter:master Sep 24, 2019
@LongCatIsLooong LongCatIsLooong deleted the dark-mode-s-part1 branch September 24, 2019 07:21
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests c: API break Backwards-incompatible API changes 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.

[iOS 13] Switch background sometimes incorrect

7 participants