feat: custom upload image menu style

This commit is contained in:
Lucas.Xu 2022-10-26 11:47:38 +08:00
parent a68903918c
commit 799ed2fdb9

View File

@ -2,6 +2,7 @@ import 'package:appflowy_editor/src/core/document/node.dart';
import 'package:appflowy_editor/src/editor_state.dart';
import 'package:appflowy_editor/src/infra/flowy_svg.dart';
import 'package:appflowy_editor/src/render/selection_menu/selection_menu_service.dart';
import 'package:appflowy_editor/src/render/style/editor_style.dart';
import 'package:flutter/material.dart';
OverlayEntry? _imageUploadMenu;
@ -20,6 +21,7 @@ void showImageUploadMenu(
left: menuService.topLeft.dx,
child: Material(
child: ImageUploadMenu(
editorState: editorState,
onSubmitted: (text) {
// _dismissImageUploadMenu();
editorState.insertImageNode(text);
@ -53,10 +55,12 @@ class ImageUploadMenu extends StatefulWidget {
Key? key,
required this.onSubmitted,
required this.onUpload,
this.editorState,
}) : super(key: key);
final void Function(String text) onSubmitted;
final void Function(String text) onUpload;
final EditorState? editorState;
@override
State<ImageUploadMenu> createState() => _ImageUploadMenuState();
@ -66,6 +70,8 @@ class _ImageUploadMenuState extends State<ImageUploadMenu> {
final _textEditingController = TextEditingController();
final _focusNode = FocusNode();
EditorStyle? get style => widget.editorState?.editorStyle;
@override
void initState() {
super.initState();
@ -84,7 +90,7 @@ class _ImageUploadMenuState extends State<ImageUploadMenu> {
width: 300,
padding: const EdgeInsets.all(24.0),
decoration: BoxDecoration(
color: Colors.white,
color: style?.selectionMenuBackgroundColor ?? Colors.white,
boxShadow: [
BoxShadow(
blurRadius: 5,
@ -108,12 +114,12 @@ class _ImageUploadMenuState extends State<ImageUploadMenu> {
}
Widget _buildHeader(BuildContext context) {
return const Text(
return Text(
'URL Image',
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
color: style?.selectionMenuItemTextColor ?? Colors.black,
fontWeight: FontWeight.w500,
),
);