Skip to content

Commit f8a4008

Browse files
authored
Revert "Modernize selection menu appearance (flutter#59115)" (flutter#59561)
This reverts commit b3c237c.
1 parent 248d746 commit f8a4008

14 files changed

+241
-373
lines changed

packages/flutter/lib/src/material/material_localizations.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,19 +899,19 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
899899
String get continueButtonLabel => 'CONTINUE';
900900

901901
@override
902-
String get copyButtonLabel => 'Copy';
902+
String get copyButtonLabel => 'COPY';
903903

904904
@override
905-
String get cutButtonLabel => 'Cut';
905+
String get cutButtonLabel => 'CUT';
906906

907907
@override
908908
String get okButtonLabel => 'OK';
909909

910910
@override
911-
String get pasteButtonLabel => 'Paste';
911+
String get pasteButtonLabel => 'PASTE';
912912

913913
@override
914-
String get selectAllButtonLabel => 'Select all';
914+
String get selectAllButtonLabel => 'SELECT ALL';
915915

916916
@override
917917
String get viewLicensesButtonLabel => 'VIEW LICENSES';

packages/flutter/lib/src/material/text_selection.dart

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import 'package:flutter/scheduler.dart';
1111
import 'package:flutter/services.dart';
1212
import 'package:flutter/widgets.dart';
1313

14-
import 'button_theme.dart';
15-
import 'colors.dart';
16-
import 'constants.dart';
1714
import 'debug.dart';
1815
import 'flat_button.dart';
1916
import 'icon_button.dart';
@@ -57,18 +54,6 @@ class _TextSelectionToolbar extends StatefulWidget {
5754
_TextSelectionToolbarState createState() => _TextSelectionToolbarState();
5855
}
5956

60-
// Intermediate data used for building menu items with the _getItems method.
61-
class _ItemData {
62-
const _ItemData(
63-
this.onPressed,
64-
this.label,
65-
) : assert(onPressed != null),
66-
assert(label != null);
67-
68-
final VoidCallback onPressed;
69-
final String label;
70-
}
71-
7257
class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with TickerProviderStateMixin {
7358
ClipboardStatusNotifier _clipboardStatus;
7459

@@ -80,25 +65,11 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke
8065
// The key for _TextSelectionToolbarContainer.
8166
UniqueKey _containerKey = UniqueKey();
8267

83-
Widget _getItem(_ItemData itemData, bool isFirst, bool isLast) {
84-
assert(isFirst != null);
85-
assert(isLast != null);
86-
return ButtonTheme.fromButtonThemeData(
87-
data: ButtonTheme.of(context).copyWith(
88-
height: kMinInteractiveDimension,
89-
minWidth: kMinInteractiveDimension,
90-
),
91-
child: FlatButton(
92-
onPressed: itemData.onPressed,
93-
padding: EdgeInsets.only(
94-
// These values were eyeballed to match the native text selection menu
95-
// on a Pixel 2 running Android 10.
96-
left: 9.5 + (isFirst ? 5.0 : 0.0),
97-
right: 9.5 + (isLast ? 5.0 : 0.0),
98-
),
99-
shape: Border.all(width: 0.0, color: Colors.transparent),
100-
child: Text(itemData.label),
101-
),
68+
FlatButton _getItem(VoidCallback onPressed, String label) {
69+
assert(onPressed != null);
70+
return FlatButton(
71+
child: Text(label),
72+
onPressed: onPressed,
10273
);
10374
}
10475

@@ -182,20 +153,20 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke
182153
}
183154

184155
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
185-
final List<_ItemData> itemDatas = <_ItemData>[
156+
final List<Widget> items = <Widget>[
186157
if (widget.handleCut != null)
187-
_ItemData(widget.handleCut, localizations.cutButtonLabel),
158+
_getItem(widget.handleCut, localizations.cutButtonLabel),
188159
if (widget.handleCopy != null)
189-
_ItemData(widget.handleCopy, localizations.copyButtonLabel),
160+
_getItem(widget.handleCopy, localizations.copyButtonLabel),
190161
if (widget.handlePaste != null
191162
&& _clipboardStatus.value == ClipboardStatus.pasteable)
192-
_ItemData(widget.handlePaste, localizations.pasteButtonLabel),
163+
_getItem(widget.handlePaste, localizations.pasteButtonLabel),
193164
if (widget.handleSelectAll != null)
194-
_ItemData(widget.handleSelectAll, localizations.selectAllButtonLabel),
165+
_getItem(widget.handleSelectAll, localizations.selectAllButtonLabel),
195166
];
196167

197168
// If there is no option available, build an empty widget.
198-
if (itemDatas.isEmpty) {
169+
if (items.isEmpty) {
199170
return const SizedBox(width: 0.0, height: 0.0);
200171
}
201172

@@ -208,20 +179,14 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke
208179
// API 28.
209180
duration: const Duration(milliseconds: 140),
210181
child: Material(
211-
// This value was eyeballed to match the native text selection menu on
212-
// a Pixel 2 running Android 10.
213-
borderRadius: const BorderRadius.all(Radius.circular(7.0)),
214-
clipBehavior: Clip.antiAlias,
215182
elevation: 1.0,
216-
type: MaterialType.card,
217183
child: _TextSelectionToolbarItems(
218184
isAbove: widget.isAbove,
219185
overflowOpen: _overflowOpen,
220186
children: <Widget>[
221187
// The navButton that shows and hides the overflow menu is the
222188
// first child.
223189
Material(
224-
type: MaterialType.card,
225190
child: IconButton(
226191
// TODO(justinmc): This should be an AnimatedIcon, but
227192
// AnimatedIcons doesn't yet support arrow_back to more_vert.
@@ -237,8 +202,7 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke
237202
: localizations.moreButtonTooltip,
238203
),
239204
),
240-
for (int i = 0; i < itemDatas.length; i++)
241-
_getItem(itemDatas[i], i == 0, i == itemDatas.length - 1)
205+
...items,
242206
],
243207
),
244208
),

packages/flutter/test/cupertino/text_field_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void main() {
175175

176176
setUp(() async {
177177
EditableText.debugDeterministicCursor = false;
178-
// Fill the clipboard so that the Paste option is available in the text
178+
// Fill the clipboard so that the PASTE option is available in the text
179179
// selection menu.
180180
await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
181181
});

packages/flutter/test/material/app_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ void main() {
507507
);
508508

509509
// Default US "select all" text.
510-
expect(find.text('Select all'), findsOneWidget);
510+
expect(find.text('SELECT ALL'), findsOneWidget);
511511
// Default Cupertino US "select all" text.
512512
expect(find.text('Select All'), findsOneWidget);
513513
});

packages/flutter/test/material/date_picker_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void main() {
7373
fieldLabelText = null;
7474
helpText = null;
7575

76-
// Fill the clipboard so that the Paste option is available in the text
76+
// Fill the clipboard so that the PASTE option is available in the text
7777
// selection menu.
7878
SystemChannels.platform.setMockMethodCallHandler(mockClipboard.handleMethodCall);
7979
await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));

packages/flutter/test/material/search_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void main() {
3232
final MockClipboard mockClipboard = MockClipboard();
3333

3434
setUp(() async {
35-
// Fill the clipboard so that the Paste option is available in the text
35+
// Fill the clipboard so that the PASTE option is available in the text
3636
// selection menu.
3737
SystemChannels.platform.setMockMethodCallHandler(mockClipboard.handleMethodCall);
3838
await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));

0 commit comments

Comments
 (0)