Selection controls internationalization (#22443)
* Fix internationalization issues with cupertinoTextSelectionControls
This commit is contained in:
parent
481cb77a4c
commit
a7303e040d
@ -185,6 +185,19 @@ abstract class CupertinoLocalizations {
|
||||
/// ```dart
|
||||
/// CupertinoLocalizations.of(context).anteMeridiemAbbreviation;
|
||||
/// ```
|
||||
|
||||
/// The term used for cutting
|
||||
String get cutButtonLabel;
|
||||
|
||||
/// The term used for copying
|
||||
String get copyButtonLabel;
|
||||
|
||||
/// The term used for pasting
|
||||
String get pasteButtonLabel;
|
||||
|
||||
/// The term used for selecting everything
|
||||
String get selectAllButtonLabel;
|
||||
|
||||
static CupertinoLocalizations of(BuildContext context) {
|
||||
return Localizations.of<CupertinoLocalizations>(context, CupertinoLocalizations);
|
||||
}
|
||||
@ -252,6 +265,8 @@ class DefaultCupertinoLocalizations implements CupertinoLocalizations {
|
||||
'December',
|
||||
];
|
||||
|
||||
|
||||
|
||||
@override
|
||||
String datePickerYear(int yearIndex) => yearIndex.toString();
|
||||
|
||||
@ -317,6 +332,18 @@ class DefaultCupertinoLocalizations implements CupertinoLocalizations {
|
||||
@override
|
||||
String timerPickerSecondLabel(int second) => 'sec';
|
||||
|
||||
@override
|
||||
String get cutButtonLabel => 'Cut';
|
||||
|
||||
@override
|
||||
String get copyButtonLabel => 'Copy';
|
||||
|
||||
@override
|
||||
String get pasteButtonLabel => 'Paste';
|
||||
|
||||
@override
|
||||
String get selectAllButtonLabel => 'Select All';
|
||||
|
||||
/// Creates an object that provides US English resource values for the
|
||||
/// cupertino library widgets.
|
||||
///
|
||||
|
@ -8,6 +8,7 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'button.dart';
|
||||
import 'localizations.dart';
|
||||
|
||||
// Padding around the line at the edge of the text selection that has 0 width and
|
||||
// the height of the text font.
|
||||
@ -73,27 +74,28 @@ class _TextSelectionToolbar extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> items = <Widget>[];
|
||||
final Widget onePhysicalPixelVerticalDivider =
|
||||
SizedBox(width: 1.0 / MediaQuery.of(context).devicePixelRatio);
|
||||
SizedBox(width: 1.0 / MediaQuery.of(context).devicePixelRatio);
|
||||
final CupertinoLocalizations localizations = CupertinoLocalizations.of(context);
|
||||
|
||||
if (handleCut != null)
|
||||
items.add(_buildToolbarButton('Cut', handleCut));
|
||||
items.add(_buildToolbarButton(localizations.cutButtonLabel, handleCut));
|
||||
|
||||
if (handleCopy != null) {
|
||||
if (items.isNotEmpty)
|
||||
items.add(onePhysicalPixelVerticalDivider);
|
||||
items.add(_buildToolbarButton('Copy', handleCopy));
|
||||
items.add(_buildToolbarButton(localizations.copyButtonLabel, handleCopy));
|
||||
}
|
||||
|
||||
if (handlePaste != null) {
|
||||
if (items.isNotEmpty)
|
||||
items.add(onePhysicalPixelVerticalDivider);
|
||||
items.add(_buildToolbarButton('Paste', handlePaste));
|
||||
items.add(_buildToolbarButton(localizations.pasteButtonLabel, handlePaste));
|
||||
}
|
||||
|
||||
if (handleSelectAll != null) {
|
||||
if (items.isNotEmpty)
|
||||
items.add(onePhysicalPixelVerticalDivider);
|
||||
items.add(_buildToolbarButton('Select All', handleSelectAll));
|
||||
items.add(_buildToolbarButton(localizations.selectAllButtonLabel, handleSelectAll));
|
||||
}
|
||||
|
||||
final Widget triangle = SizedBox.fromSize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user