Let text selection toolbar buttons be independent from theme (#27573)
This commit is contained in:
parent
dc1eefa997
commit
07d015d441
@ -8,6 +8,7 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'button.dart';
|
||||
import 'colors.dart';
|
||||
import 'localizations.dart';
|
||||
|
||||
// Padding around the line at the edge of the text selection that has 0 width and
|
||||
@ -33,9 +34,11 @@ const EdgeInsets _kToolbarButtonPadding = EdgeInsets.symmetric(vertical: 10.0, h
|
||||
const BorderRadius _kToolbarBorderRadius = BorderRadius.all(Radius.circular(7.5));
|
||||
|
||||
const TextStyle _kToolbarButtonFontStyle = TextStyle(
|
||||
inherit: false,
|
||||
fontSize: 14.0,
|
||||
letterSpacing: -0.11,
|
||||
fontWeight: FontWeight.w300,
|
||||
color: CupertinoColors.white,
|
||||
);
|
||||
|
||||
/// Paints a triangle below the toolbar.
|
||||
@ -113,8 +116,12 @@ class _TextSelectionToolbar extends StatelessWidget {
|
||||
ClipRRect(
|
||||
borderRadius: _kToolbarBorderRadius,
|
||||
child: DecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
color: _kToolbarDividerColor,
|
||||
borderRadius: _kToolbarBorderRadius,
|
||||
// Add a hairline border with the button color to avoid
|
||||
// antialiasing artifacts.
|
||||
border: Border.all(color: _kToolbarBackgroundColor, width: 0),
|
||||
),
|
||||
child: Row(mainAxisSize: MainAxisSize.min, children: items),
|
||||
),
|
||||
|
@ -702,6 +702,68 @@ void main() {
|
||||
expect(controller.text, 'abcdef');
|
||||
});
|
||||
|
||||
testWidgets('toolbar has the same visual regardless of theming', (WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: "j'aime la poutine",
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Column(
|
||||
children: <Widget>[
|
||||
CupertinoTextField(
|
||||
controller: controller,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.longPressAt(
|
||||
tester.getTopRight(find.text("j'aime la poutine"))
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
|
||||
Text text = tester.widget<Text>(find.text('Paste'));
|
||||
expect(text.style.color, CupertinoColors.white);
|
||||
expect(text.style.fontSize, 14);
|
||||
expect(text.style.letterSpacing, -0.11);
|
||||
expect(text.style.fontWeight, FontWeight.w300);
|
||||
|
||||
// Change the theme.
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
theme: const CupertinoThemeData(
|
||||
brightness: Brightness.dark,
|
||||
textTheme: CupertinoTextThemeData(
|
||||
textStyle: TextStyle(fontSize: 100, fontWeight: FontWeight.w800),
|
||||
),
|
||||
),
|
||||
home: Column(
|
||||
children: <Widget>[
|
||||
CupertinoTextField(
|
||||
controller: controller,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.longPressAt(
|
||||
tester.getTopRight(find.text("j'aime la poutine"))
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
|
||||
text = tester.widget<Text>(find.text('Paste'));
|
||||
// The toolbar buttons' text are still the same style.
|
||||
expect(text.style.color, CupertinoColors.white);
|
||||
expect(text.style.fontSize, 14);
|
||||
expect(text.style.letterSpacing, -0.11);
|
||||
expect(text.style.fontWeight, FontWeight.w300);
|
||||
});
|
||||
|
||||
testWidgets('copy paste', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
|
Loading…
x
Reference in New Issue
Block a user