mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -62,9 +62,11 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
/// * [AdaptiveTextSelectionToolbar.selectable], which builds the default
|
||||
/// children for content that is selectable but not editable.
|
||||
/// {@endtemplate}
|
||||
const AdaptiveTextSelectionToolbar(
|
||||
{super.key, required this.children, required this.anchors})
|
||||
: buttonItems = null;
|
||||
const AdaptiveTextSelectionToolbar({
|
||||
super.key,
|
||||
required this.children,
|
||||
required this.anchors,
|
||||
}) : buttonItems = null;
|
||||
|
||||
/// Create an instance of [AdaptiveTextSelectionToolbar] whose children will
|
||||
/// be built from the given [buttonItems].
|
||||
@@ -113,18 +115,18 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
required VoidCallback? onShare,
|
||||
required VoidCallback? onLiveTextInput,
|
||||
required this.anchors,
|
||||
}) : children = null,
|
||||
buttonItems = EditableText.getEditableButtonItems(
|
||||
clipboardStatus: clipboardStatus,
|
||||
onCopy: onCopy,
|
||||
onCut: onCut,
|
||||
onPaste: onPaste,
|
||||
onSelectAll: onSelectAll,
|
||||
onLookUp: onLookUp,
|
||||
onSearchWeb: onSearchWeb,
|
||||
onShare: onShare,
|
||||
onLiveTextInput: onLiveTextInput,
|
||||
);
|
||||
}) : children = null,
|
||||
buttonItems = EditableText.getEditableButtonItems(
|
||||
clipboardStatus: clipboardStatus,
|
||||
onCopy: onCopy,
|
||||
onCut: onCut,
|
||||
onPaste: onPaste,
|
||||
onSelectAll: onSelectAll,
|
||||
onLookUp: onLookUp,
|
||||
onSearchWeb: onSearchWeb,
|
||||
onShare: onShare,
|
||||
onLiveTextInput: onLiveTextInput,
|
||||
);
|
||||
|
||||
/// Create an instance of [AdaptiveTextSelectionToolbar] with the default
|
||||
/// children for an [EditableText].
|
||||
@@ -138,9 +140,9 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
AdaptiveTextSelectionToolbar.editableText({
|
||||
super.key,
|
||||
required EditableTextState editableTextState,
|
||||
}) : children = null,
|
||||
buttonItems = editableTextState.contextMenuButtonItems,
|
||||
anchors = editableTextState.contextMenuAnchors;
|
||||
}) : children = null,
|
||||
buttonItems = editableTextState.contextMenuButtonItems,
|
||||
anchors = editableTextState.contextMenuAnchors;
|
||||
|
||||
/// Create an instance of [AdaptiveTextSelectionToolbar] with the default
|
||||
/// children for selectable, but not editable, content.
|
||||
@@ -158,13 +160,13 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
required VoidCallback? onShare,
|
||||
required SelectionGeometry selectionGeometry,
|
||||
required this.anchors,
|
||||
}) : children = null,
|
||||
buttonItems = SelectableRegion.getSelectableButtonItems(
|
||||
selectionGeometry: selectionGeometry,
|
||||
onCopy: onCopy,
|
||||
onSelectAll: onSelectAll,
|
||||
onShare: onShare,
|
||||
);
|
||||
}) : children = null,
|
||||
buttonItems = SelectableRegion.getSelectableButtonItems(
|
||||
selectionGeometry: selectionGeometry,
|
||||
onCopy: onCopy,
|
||||
onSelectAll: onSelectAll,
|
||||
onShare: onShare,
|
||||
);
|
||||
|
||||
/// Create an instance of [AdaptiveTextSelectionToolbar] with the default
|
||||
/// children for a [SelectableRegion].
|
||||
@@ -179,9 +181,9 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
AdaptiveTextSelectionToolbar.selectableRegion({
|
||||
super.key,
|
||||
required SelectableRegionState selectableRegionState,
|
||||
}) : children = null,
|
||||
buttonItems = selectableRegionState.contextMenuButtonItems,
|
||||
anchors = selectableRegionState.contextMenuAnchors;
|
||||
}) : children = null,
|
||||
buttonItems = selectableRegionState.contextMenuButtonItems,
|
||||
anchors = selectableRegionState.contextMenuAnchors;
|
||||
|
||||
/// {@template flutter.material.AdaptiveTextSelectionToolbar.buttonItems}
|
||||
/// The [ContextMenuButtonItem]s that will be turned into the correct button
|
||||
@@ -200,7 +202,9 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
/// Returns the default button label String for the button of the given
|
||||
/// [ContextMenuButtonType] on any platform.
|
||||
static String getButtonLabel(
|
||||
BuildContext context, ContextMenuButtonItem buttonItem) {
|
||||
BuildContext context,
|
||||
ContextMenuButtonItem buttonItem,
|
||||
) {
|
||||
if (buttonItem.label != null) {
|
||||
return buttonItem.label!;
|
||||
}
|
||||
@@ -209,14 +213,17 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
case TargetPlatform.iOS:
|
||||
case TargetPlatform.macOS:
|
||||
return CupertinoTextSelectionToolbarButton.getButtonLabel(
|
||||
context, buttonItem);
|
||||
context,
|
||||
buttonItem,
|
||||
);
|
||||
case TargetPlatform.android:
|
||||
case TargetPlatform.fuchsia:
|
||||
case TargetPlatform.linux:
|
||||
case TargetPlatform.windows:
|
||||
assert(debugCheckHasMaterialLocalizations(context));
|
||||
final MaterialLocalizations localizations =
|
||||
MaterialLocalizations.of(context);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(
|
||||
context,
|
||||
);
|
||||
return switch (buttonItem.type) {
|
||||
ContextMenuButtonType.cut => localizations.cutButtonLabel,
|
||||
ContextMenuButtonType.copy => localizations.copyButtonLabel,
|
||||
@@ -261,7 +268,8 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
case TargetPlatform.iOS:
|
||||
return buttonItems.map((ContextMenuButtonItem buttonItem) {
|
||||
return CupertinoTextSelectionToolbarButton.buttonItem(
|
||||
buttonItem: buttonItem);
|
||||
buttonItem: buttonItem,
|
||||
);
|
||||
});
|
||||
case TargetPlatform.fuchsia:
|
||||
case TargetPlatform.android:
|
||||
@@ -271,7 +279,9 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
buttons.add(
|
||||
TextSelectionToolbarTextButton(
|
||||
padding: TextSelectionToolbarTextButton.getPadding(
|
||||
i, buttonItems.length),
|
||||
i,
|
||||
buttonItems.length,
|
||||
),
|
||||
onPressed: buttonItem.onPressed,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(getButtonLabel(context, buttonItem)),
|
||||
@@ -331,7 +341,9 @@ class AdaptiveTextSelectionToolbar extends StatelessWidget {
|
||||
case TargetPlatform.linux:
|
||||
case TargetPlatform.windows:
|
||||
return DesktopTextSelectionToolbar(
|
||||
anchor: anchors.primaryAnchor, children: resultChildren);
|
||||
anchor: anchors.primaryAnchor,
|
||||
children: resultChildren,
|
||||
);
|
||||
case TargetPlatform.macOS:
|
||||
return CupertinoDesktopTextSelectionToolbar(
|
||||
anchor: anchors.primaryAnchor,
|
||||
|
||||
Reference in New Issue
Block a user