refactor: renamed EditorToolBar

This commit is contained in:
jideguru 2021-05-29 22:51:04 +01:00
parent d5b8305fa3
commit 5e20c582e6
7 changed files with 35 additions and 17 deletions

View File

@ -1,5 +1,5 @@
library rich_editor;
export 'src/rendering/rich_editor.dart';
export 'src/widgets/tabs.dart';
export 'src/widgets/editor_tool_bar.dart';
export 'src/widgets/tab_button.dart';

View File

@ -0,0 +1,15 @@
import 'package:rich_editor/src/models/enum.dart';
import 'command_state.dart';
class EditorState {
bool didHtmlChange;
String html;
Map<CommandName, CommandState> commandStates;
EditorState({
this.didHtmlChange = false,
this.html = '',
this.commandStates = const <CommandName, CommandState>{},
});
}

View File

@ -6,7 +6,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:rich_editor/src/services/local_server.dart';
import 'package:rich_editor/src/utils/javascript_executor_base.dart';
import 'package:rich_editor/src/widgets/tabs.dart';
import 'package:rich_editor/src/widgets/editor_tool_bar.dart';
import 'package:webview_flutter/webview_flutter.dart';
class RichEditor extends StatefulWidget {
@ -76,9 +76,10 @@ class RichEditorState extends State<RichEditor> {
Widget build(BuildContext context) {
return Column(
children: [
GroupedTab(
EditorToolBar(
controller: _controller,
getImageUrl: widget.getImageUrl,
javascriptExecutorBase: javascriptExecutorBase,
),
Expanded(
child: WebView(
@ -111,9 +112,6 @@ class RichEditorState extends State<RichEditor> {
print("error ${e.description}");
},
),
// child: InAppWebView(
// initialFile: 'packages/rich_editor/assets/editor/index.html',
// ),
)
],
);

View File

@ -3,7 +3,7 @@ import 'package:rich_editor/src/extensions/extensions.dart';
import 'package:rich_editor/src/models/enum.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'command_state.dart';
import '../models/command_state.dart';
class JavascriptExecutorBase {
WebViewController? _controller;

View File

@ -13,24 +13,28 @@ import 'color_picker_dialog.dart';
import 'font_size_dialog.dart';
import 'heading_dialog.dart';
class GroupedTab extends StatelessWidget {
class EditorToolBar extends StatelessWidget {
final WebViewController? controller;
final Function(File image)? getImageUrl;
final Function(File video)? getVideoUrl;
final JavascriptExecutorBase javascriptExecutorBase;
GroupedTab({this.controller, this.getImageUrl, this.getVideoUrl});
JavascriptExecutorBase javascriptExecutorBase = JavascriptExecutorBase();
EditorToolBar({
this.controller,
this.getImageUrl,
this.getVideoUrl,
required this.javascriptExecutorBase,
});
@override
Widget build(BuildContext context) {
if (controller != null) {
javascriptExecutorBase.init(controller!);
}
// if (controller != null) {
// javascriptExecutorBase.init(controller!);
// }
return Container(
// color: Color(0xff424242),
height: 59.0,
height: 54.0,
child: Column(
children: [
Flexible(
@ -309,6 +313,7 @@ class GroupedTab extends StatelessWidget {
await javascriptExecutorBase.insertCheckbox(text);
},
),
/// TODO: Implement Search feature
// TabButton(
// tooltip: 'Search',

View File

@ -14,8 +14,8 @@ class TabButton extends StatelessWidget {
child: Tooltip(
message: '$tooltip',
child: Container(
height: 45.0,
width: 45.0,
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
// color: Color(0xff212121),
borderRadius: BorderRadius.all(