Unverified Commit 9e9e7416 authored by Bogdan Lukin's avatar Bogdan Lukin Committed by GitHub

fix cupertino selection handle paint with transparent color (#49910)

parent b24bca13
...@@ -260,26 +260,24 @@ class _TextSelectionHandlePainter extends CustomPainter { ...@@ -260,26 +260,24 @@ class _TextSelectionHandlePainter extends CustomPainter {
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
final Paint paint = Paint() const double halfStrokeWidth = 1.0;
..color = color final Paint paint = Paint()..color = color;
..strokeWidth = 2.0; final Rect circle = Rect.fromCircle(
canvas.drawCircle( center: const Offset(_kSelectionHandleRadius, _kSelectionHandleRadius),
const Offset(_kSelectionHandleRadius, _kSelectionHandleRadius), radius: _kSelectionHandleRadius,
_kSelectionHandleRadius,
paint,
); );
// Draw line so it slightly overlaps the circle. final Rect line = Rect.fromPoints(
canvas.drawLine(
const Offset( const Offset(
_kSelectionHandleRadius, _kSelectionHandleRadius - halfStrokeWidth,
2 * _kSelectionHandleRadius - _kSelectionHandleOverlap, 2 * _kSelectionHandleRadius - _kSelectionHandleOverlap,
), ),
Offset( Offset(_kSelectionHandleRadius + halfStrokeWidth, size.height),
_kSelectionHandleRadius,
size.height,
),
paint,
); );
final Path path = Path()
..addOval(circle)
// Draw line so it slightly overlaps the circle.
..addRect(line);
canvas.drawPath(path, paint);
} }
@override @override
......
...@@ -62,4 +62,40 @@ void main() { ...@@ -62,4 +62,40 @@ void main() {
expect(cupertinoTextSelectionControls.canSelectAll(key.currentState), false); expect(cupertinoTextSelectionControls.canSelectAll(key.currentState), false);
}); });
}); });
group('cupertino handles', () {
testWidgets('draws transparent handle correctly', (WidgetTester tester) async {
await tester.pumpWidget(RepaintBoundary(
child: CupertinoTheme(
data: const CupertinoThemeData(
primaryColor: Color(0x550000AA),
),
child: Builder(
builder: (BuildContext context) {
return Container(
color: CupertinoColors.white,
height: 800,
width: 800,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 250),
child: FittedBox(
child: cupertinoTextSelectionControls.buildHandle(
context,
TextSelectionHandleType.right,
10.0,
),
),
),
);
},
),
),
));
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile('text_selection.handle.transparent.png'),
);
});
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment