mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-22 19:40:10 +08:00
replace SelectableText with SelectionArea
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension EditableTextExt on EditableTextState {
|
||||
void addLaunchMenuIfNeeded(
|
||||
List<ContextMenuButtonItem> buttonItems, {
|
||||
required int index,
|
||||
}) {
|
||||
final selection = textEditingValue.selection;
|
||||
if (!selection.isCollapsed) {
|
||||
buttonItems.insertOrAdd(
|
||||
index,
|
||||
ContextMenuButtonItem(
|
||||
label: '打开',
|
||||
onPressed: () {
|
||||
hideToolbar();
|
||||
clearSelection(selection);
|
||||
PageUtils.launchURL(
|
||||
selection.textInside(textEditingValue.text).trim(),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void clearSelection(TextSelection currSelection) {
|
||||
widget.controller.selection = .collapsed(offset: currSelection.end);
|
||||
}
|
||||
|
||||
void clearSelectionIfNeeded() {
|
||||
final selection = textEditingValue.selection;
|
||||
if (!selection.isCollapsed) {
|
||||
clearSelection(selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
lib/utils/extension/selectable_region_ext.dart
Normal file
32
lib/utils/extension/selectable_region_ext.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension SelectableRegionStateExt on SelectableRegionState {
|
||||
void addLaunchMenuIfNeeded(
|
||||
List<ContextMenuButtonItem> buttonItems, {
|
||||
required int index,
|
||||
}) {
|
||||
try {
|
||||
if (selectionEndpoints.first != selectionEndpoints[1]) {
|
||||
buttonItems.insertOrAdd(
|
||||
index,
|
||||
ContextMenuButtonItem(
|
||||
label: '打开',
|
||||
onPressed: () {
|
||||
final text = (this as dynamic).selectable
|
||||
?.getSelectedContent()
|
||||
?.plainText
|
||||
.trim();
|
||||
hideToolbar();
|
||||
clearSelection();
|
||||
if (text != null && text.isNotEmpty) {
|
||||
PageUtils.launchURL(text);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart'
|
||||
show NeverSelectableScrollPhysics;
|
||||
import 'package:PiliPlus/common/widgets/selection_text.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show ReplyInfo;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -139,10 +138,7 @@ abstract final class ReplyUtils {
|
||||
barrierDismissible: isManual,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('评论检查结果'),
|
||||
content: SelectableText(
|
||||
message,
|
||||
scrollPhysics: const NeverSelectableScrollPhysics(),
|
||||
),
|
||||
content: SelectionText(message),
|
||||
actions: actions.isEmpty ? null : actions,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -3,8 +3,7 @@ import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/simple_dialog_option.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart'
|
||||
show NeverSelectableScrollPhysics;
|
||||
import 'package:PiliPlus/common/widgets/selection_text.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/im/type.pbenum.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show ReplyInfo;
|
||||
@@ -362,9 +361,8 @@ abstract final class RequestUtils {
|
||||
barrierDismissible: isManual,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('动态检查结果'),
|
||||
content: SelectableText(
|
||||
content: SelectionText(
|
||||
'${isSuccess ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'}${dynText != null ? ' \n\n动态内容: $dynText' : ''}',
|
||||
scrollPhysics: const NeverSelectableScrollPhysics(),
|
||||
),
|
||||
actions: actions.isEmpty ? null : actions,
|
||||
),
|
||||
@@ -580,9 +578,8 @@ abstract final class RequestUtils {
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) => AlertDialog(
|
||||
title: SelectableText(
|
||||
title: SelectionText(
|
||||
show ? response.name! : response.rejectPage?.title ?? '',
|
||||
scrollPhysics: const NeverSelectableScrollPhysics(),
|
||||
),
|
||||
content: show ? null : Text(response.rejectPage?.text ?? ''),
|
||||
actions: [
|
||||
|
||||
Reference in New Issue
Block a user