custom dyn text menu

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-02-01 20:18:06 +08:00
parent 3d453bafdb
commit 2596859778

View File

@@ -78,6 +78,8 @@ Widget content(
style: isSave
? const TextStyle(fontSize: 15)
: const TextStyle(fontSize: 16),
contextMenuBuilder: (_, state) =>
_contextMenuBuilder(state, moduleDynamic),
)
: custom_text.Text.rich(
style: floor == 1
@@ -107,3 +109,37 @@ Widget content(
),
);
}
Widget _contextMenuBuilder(
EditableTextState state,
ModuleDynamicModel? moduleDynamic,
) {
return AdaptiveTextSelectionToolbar.buttonItems(
buttonItems: state.contextMenuButtonItems
..add(
ContextMenuButtonItem(
label: '文本',
onPressed: () => _onCopyText(moduleDynamic),
),
),
anchors: state.contextMenuAnchors,
);
}
void _onCopyText(ModuleDynamicModel? moduleDynamic) {
final text =
moduleDynamic?.desc?.text ?? moduleDynamic?.major?.opus?.summary?.text;
if (text == null || text.isEmpty) return;
showDialog(
context: Get.context!,
builder: (context) => Dialog(
child: Padding(
padding: const .symmetric(horizontal: 20, vertical: 16),
child: SelectableText(
text,
style: const TextStyle(fontSize: 15, height: 1.7),
),
),
),
);
}