mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-24 04:20:12 +08:00
opt dyn/reply text menu
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
38
lib/utils/extension/editable_text_ext.dart
Normal file
38
lib/utils/extension/editable_text_ext.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,4 +68,12 @@ extension ListExt<T> on List<T> {
|
||||
T getOrFirst(int index) {
|
||||
return getOrNull(index) ?? first;
|
||||
}
|
||||
|
||||
void insertOrAdd(int index, T element) {
|
||||
if (length <= index) {
|
||||
add(element);
|
||||
} else {
|
||||
insert(index, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart'
|
||||
show NeverSelectableScrollPhysics;
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show ReplyInfo;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -137,7 +139,10 @@ abstract final class ReplyUtils {
|
||||
barrierDismissible: isManual,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('评论检查结果'),
|
||||
content: SelectableText(message),
|
||||
content: SelectableText(
|
||||
message,
|
||||
scrollPhysics: const NeverSelectableScrollPhysics(),
|
||||
),
|
||||
actions: actions.isEmpty ? null : actions,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:convert' show jsonEncode;
|
||||
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/grpc/bilibili/im/type.pbenum.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show ReplyInfo;
|
||||
@@ -363,6 +364,7 @@ abstract final class RequestUtils {
|
||||
title: const Text('动态检查结果'),
|
||||
content: SelectableText(
|
||||
'${isSuccess ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'}${dynText != null ? ' \n\n动态内容: $dynText' : ''}',
|
||||
scrollPhysics: const NeverSelectableScrollPhysics(),
|
||||
),
|
||||
actions: actions.isEmpty ? null : actions,
|
||||
),
|
||||
@@ -580,6 +582,7 @@ abstract final class RequestUtils {
|
||||
builder: (context) => AlertDialog(
|
||||
title: SelectableText(
|
||||
show ? response.name! : response.rejectPage?.title ?? '',
|
||||
scrollPhysics: const NeverSelectableScrollPhysics(),
|
||||
),
|
||||
content: show ? null : Text(response.rejectPage?.text ?? ''),
|
||||
actions: [
|
||||
|
||||
Reference in New Issue
Block a user