From 846a273de8ec4e3f76c56ff880f4e7b53329f520 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 1 Aug 2022 17:48:16 +0800 Subject: [PATCH] feat: rename toolbar --- .../lib/service/selection_service.dart | 2 +- .../flowy_editor/lib/service/service.dart | 5 ++--- .../lib/service/toolbar_service.dart | 16 ++++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart index f4034d4518..a6cee66829 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart @@ -451,7 +451,7 @@ class _FlowySelectionState extends State _cursorOverlays ..forEach((overlay) => overlay.remove()) ..clear(); - // clear floating shortcuts + // clear toolbar editorState.service.toolbarService.hide(); } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/service.dart index 93c103c40f..829ad2bde1 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/service.dart @@ -21,9 +21,8 @@ class FlowyService { // render plugin service late FlowyRenderPlugin renderPluginService; - // floating shortcut service - final toolbarServiceKey = - GlobalKey(debugLabel: 'flowy_floating_shortcut_service'); + // toolbar service + final toolbarServiceKey = GlobalKey(debugLabel: 'flowy_toolbar_service'); ToolbarService get toolbarService { assert(toolbarServiceKey.currentState != null && toolbarServiceKey.currentState is ToolbarService); diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/toolbar_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/toolbar_service.dart index 794e4da72b..b8b8f95e46 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/toolbar_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/toolbar_service.dart @@ -3,10 +3,10 @@ import 'package:flowy_editor/render/selection/toolbar_widget.dart'; import 'package:flutter/material.dart'; mixin ToolbarService { - /// Show the floating shortcut widget beside the offset. + /// Show the toolbar widget beside the offset. void showInOffset(Offset offset, LayerLink layerLink); - /// Hide the floating shortcut widget. + /// Hide the toolbar widget. void hide(); } @@ -25,12 +25,12 @@ class FlowyToolbar extends StatefulWidget { } class _FlowyToolbarState extends State with ToolbarService { - OverlayEntry? _floatingShortcutOverlay; + OverlayEntry? _toolbarOverlay; @override void showInOffset(Offset offset, LayerLink layerLink) { - _floatingShortcutOverlay?.remove(); - _floatingShortcutOverlay = OverlayEntry( + _toolbarOverlay?.remove(); + _toolbarOverlay = OverlayEntry( builder: (context) => ToolbarWidget( editorState: widget.editorState, layerLink: layerLink, @@ -38,13 +38,13 @@ class _FlowyToolbarState extends State with ToolbarService { handlers: const [], ), ); - Overlay.of(context)?.insert(_floatingShortcutOverlay!); + Overlay.of(context)?.insert(_toolbarOverlay!); } @override void hide() { - _floatingShortcutOverlay?.remove(); - _floatingShortcutOverlay = null; + _toolbarOverlay?.remove(); + _toolbarOverlay = null; } @override