mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: custom link menu style
This commit is contained in:
parent
a702c06dc8
commit
a68903918c
@ -1,10 +1,13 @@
|
|||||||
|
import 'package:appflowy_editor/src/editor_state.dart';
|
||||||
import 'package:appflowy_editor/src/infra/flowy_svg.dart';
|
import 'package:appflowy_editor/src/infra/flowy_svg.dart';
|
||||||
|
import 'package:appflowy_editor/src/render/style/editor_style.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LinkMenu extends StatefulWidget {
|
class LinkMenu extends StatefulWidget {
|
||||||
const LinkMenu({
|
const LinkMenu({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.linkText,
|
this.linkText,
|
||||||
|
this.editorState,
|
||||||
required this.onSubmitted,
|
required this.onSubmitted,
|
||||||
required this.onOpenLink,
|
required this.onOpenLink,
|
||||||
required this.onCopyLink,
|
required this.onCopyLink,
|
||||||
@ -13,6 +16,7 @@ class LinkMenu extends StatefulWidget {
|
|||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String? linkText;
|
final String? linkText;
|
||||||
|
final EditorState? editorState;
|
||||||
final void Function(String text) onSubmitted;
|
final void Function(String text) onSubmitted;
|
||||||
final VoidCallback onOpenLink;
|
final VoidCallback onOpenLink;
|
||||||
final VoidCallback onCopyLink;
|
final VoidCallback onCopyLink;
|
||||||
@ -27,6 +31,8 @@ class _LinkMenuState extends State<LinkMenu> {
|
|||||||
final _textEditingController = TextEditingController();
|
final _textEditingController = TextEditingController();
|
||||||
final _focusNode = FocusNode();
|
final _focusNode = FocusNode();
|
||||||
|
|
||||||
|
EditorStyle? get style => widget.editorState?.editorStyle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -48,7 +54,7 @@ class _LinkMenuState extends State<LinkMenu> {
|
|||||||
width: 350,
|
width: 350,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: style?.selectionMenuBackgroundColor ?? Colors.white,
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
blurRadius: 5,
|
blurRadius: 5,
|
||||||
@ -71,17 +77,19 @@ class _LinkMenuState extends State<LinkMenu> {
|
|||||||
if (widget.linkText != null) ...[
|
if (widget.linkText != null) ...[
|
||||||
_buildIconButton(
|
_buildIconButton(
|
||||||
iconName: 'link',
|
iconName: 'link',
|
||||||
|
color: style?.selectionMenuItemIconColor,
|
||||||
text: 'Open link',
|
text: 'Open link',
|
||||||
onPressed: widget.onOpenLink,
|
onPressed: widget.onOpenLink,
|
||||||
),
|
),
|
||||||
_buildIconButton(
|
_buildIconButton(
|
||||||
iconName: 'copy',
|
iconName: 'copy',
|
||||||
color: Colors.black,
|
color: style?.selectionMenuItemIconColor,
|
||||||
text: 'Copy link',
|
text: 'Copy link',
|
||||||
onPressed: widget.onCopyLink,
|
onPressed: widget.onCopyLink,
|
||||||
),
|
),
|
||||||
_buildIconButton(
|
_buildIconButton(
|
||||||
iconName: 'delete',
|
iconName: 'delete',
|
||||||
|
color: style?.selectionMenuItemIconColor,
|
||||||
text: 'Remove link',
|
text: 'Remove link',
|
||||||
onPressed: widget.onRemoveLink,
|
onPressed: widget.onRemoveLink,
|
||||||
),
|
),
|
||||||
@ -154,8 +162,8 @@ class _LinkMenuState extends State<LinkMenu> {
|
|||||||
label: Text(
|
label: Text(
|
||||||
text,
|
text,
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: style?.selectionMenuItemTextColor ?? Colors.black,
|
||||||
fontSize: 14.0,
|
fontSize: 14.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -348,6 +348,7 @@ void showLinkMenu(
|
|||||||
child: Material(
|
child: Material(
|
||||||
child: LinkMenu(
|
child: LinkMenu(
|
||||||
linkText: linkText,
|
linkText: linkText,
|
||||||
|
editorState: editorState,
|
||||||
onOpenLink: () async {
|
onOpenLink: () async {
|
||||||
await safeLaunchUrl(linkText);
|
await safeLaunchUrl(linkText);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user