feat: rename toolbar

This commit is contained in:
Lucas.Xu 2022-08-01 17:48:16 +08:00
parent 934cb6ab6b
commit 846a273de8
3 changed files with 11 additions and 12 deletions

View File

@ -451,7 +451,7 @@ class _FlowySelectionState extends State<FlowySelection>
_cursorOverlays _cursorOverlays
..forEach((overlay) => overlay.remove()) ..forEach((overlay) => overlay.remove())
..clear(); ..clear();
// clear floating shortcuts // clear toolbar
editorState.service.toolbarService.hide(); editorState.service.toolbarService.hide();
} }

View File

@ -21,9 +21,8 @@ class FlowyService {
// render plugin service // render plugin service
late FlowyRenderPlugin renderPluginService; late FlowyRenderPlugin renderPluginService;
// floating shortcut service // toolbar service
final toolbarServiceKey = final toolbarServiceKey = GlobalKey(debugLabel: 'flowy_toolbar_service');
GlobalKey(debugLabel: 'flowy_floating_shortcut_service');
ToolbarService get toolbarService { ToolbarService get toolbarService {
assert(toolbarServiceKey.currentState != null && assert(toolbarServiceKey.currentState != null &&
toolbarServiceKey.currentState is ToolbarService); toolbarServiceKey.currentState is ToolbarService);

View File

@ -3,10 +3,10 @@ import 'package:flowy_editor/render/selection/toolbar_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
mixin ToolbarService { mixin ToolbarService {
/// Show the floating shortcut widget beside the offset. /// Show the toolbar widget beside the offset.
void showInOffset(Offset offset, LayerLink layerLink); void showInOffset(Offset offset, LayerLink layerLink);
/// Hide the floating shortcut widget. /// Hide the toolbar widget.
void hide(); void hide();
} }
@ -25,12 +25,12 @@ class FlowyToolbar extends StatefulWidget {
} }
class _FlowyToolbarState extends State<FlowyToolbar> with ToolbarService { class _FlowyToolbarState extends State<FlowyToolbar> with ToolbarService {
OverlayEntry? _floatingShortcutOverlay; OverlayEntry? _toolbarOverlay;
@override @override
void showInOffset(Offset offset, LayerLink layerLink) { void showInOffset(Offset offset, LayerLink layerLink) {
_floatingShortcutOverlay?.remove(); _toolbarOverlay?.remove();
_floatingShortcutOverlay = OverlayEntry( _toolbarOverlay = OverlayEntry(
builder: (context) => ToolbarWidget( builder: (context) => ToolbarWidget(
editorState: widget.editorState, editorState: widget.editorState,
layerLink: layerLink, layerLink: layerLink,
@ -38,13 +38,13 @@ class _FlowyToolbarState extends State<FlowyToolbar> with ToolbarService {
handlers: const [], handlers: const [],
), ),
); );
Overlay.of(context)?.insert(_floatingShortcutOverlay!); Overlay.of(context)?.insert(_toolbarOverlay!);
} }
@override @override
void hide() { void hide() {
_floatingShortcutOverlay?.remove(); _toolbarOverlay?.remove();
_floatingShortcutOverlay = null; _toolbarOverlay = null;
} }
@override @override