Skip to content

Commit 68b3d02

Browse files
authored
[cupertino_ui] Fix the tinted button's fill opacity (flutter#13436)
`CupertinoButton.tinted` fills with 12% of the accent where UIKit uses 18%. On white that is `#e0efff` against UIKit's `#d1e7ff`. Dark mode already matched at 26%. Fixes flutter/flutter#195265 ## The constant has a second reader `kCupertinoButtonTintedOpacityLight` also paints `CupertinoActionSheetAction`'s focus highlight, so that changes as well. That reuse was deliberate. The focus support PR (flutter/flutter#167119) took the colour from `CupertinoButton` on purpose, and iOS has no fixed number of its own here, because the focus colour is a system setting the user can change. Splitting the constant would pin the highlight to a value, whose only source was the button's. ## Tests `button_test.dart` already pinned the light fill with a literal, so it just moves to 18%. `action_sheet_test.dart`'s light focus case computed its expected colour from the constant, so it could never fail on a value change and now carries the literal too. The dark cases still read the constant, which is correct, nothing here moves them. ## Not touched The same line sits in `packages/flutter/lib/src/cupertino/constants.dart` with the same two readers, so `CupertinoButton.tinted` in the SDK keeps the old value. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 8041cca commit 68b3d02

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎packages/cupertino_ui/lib/src/constants.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const double kCupertinoFocusColorOpacity = 0.80,
4646
/// See also:
4747
///
4848
/// * <https://developer.apple.com/design/human-interface-guidelines/buttons#iOS-iPadOS>
49-
const double kCupertinoButtonTintedOpacityLight = 0.12, kCupertinoButtonTintedOpacityDark = 0.26;
49+
const double kCupertinoButtonTintedOpacityLight = 0.18, kCupertinoButtonTintedOpacityDark = 0.26;
5050

5151
/// The default value for [IconThemeData.size] of [CupertinoButton.child].
5252
///
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
changelog: |
2+
- Fixes `CupertinoButton.tinted` and `CupertinoActionSheetAction`'s focus highlight filling with 12% of the accent color in light mode instead of iOS's 18%.
3+
version: patch

‎packages/cupertino_ui/test/action_sheet_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ void main() {
23592359
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
23602360

23612361
final Color defaultLightFocusColor = HSLColor.fromColor(
2362-
CupertinoColors.activeBlue.withOpacity(kCupertinoButtonTintedOpacityLight),
2362+
CupertinoColors.activeBlue.withOpacity(0.18),
23632363
).toColor();
23642364

23652365
await tester.pumpWidget(

‎packages/cupertino_ui/test/button_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ void main() {
498498
)
499499
.decoration
500500
as ShapeDecoration;
501-
expect(decoration.color, isSameColorAs(CupertinoColors.activeBlue.withOpacity(0.12)));
501+
expect(decoration.color, isSameColorAs(CupertinoColors.activeBlue.withOpacity(0.18)));
502502

503503
await tester.pumpWidget(
504504
CupertinoApp(

0 commit comments

Comments
 (0)