diff --git a/lib/features/workspace/pages/desktop/workspace_desktop.dart b/lib/features/workspace/pages/desktop/workspace_desktop.dart index 54ac060..1dd0bc5 100644 --- a/lib/features/workspace/pages/desktop/workspace_desktop.dart +++ b/lib/features/workspace/pages/desktop/workspace_desktop.dart @@ -1,4 +1,5 @@ // lib/features/workspace/pages/workspace_desktop.dart (Fully Modified) +import 'package:cookethflow/core/helpers/responsive_layout.helper.dart' as rh; import 'package:cookethflow/core/providers/supabase_provider.dart'; import 'package:cookethflow/core/utils/enums.dart'; import 'package:cookethflow/features/workspace/pages/canvas_page.dart'; @@ -6,6 +7,7 @@ import 'package:cookethflow/features/workspace/providers/canvas_provider.dart'; import 'package:cookethflow/features/workspace/providers/workspace_provider.dart'; import 'package:cookethflow/features/workspace/widgets/export_project_button.dart'; import 'package:cookethflow/features/workspace/widgets/node_editing_toolbox.dart'; +import 'package:cookethflow/features/workspace/widgets/sticky_notes.dart'; import 'package:cookethflow/features/workspace/widgets/toolbar.dart'; import 'package:cookethflow/features/workspace/widgets/undo_redo_button.dart'; import 'package:cookethflow/features/workspace/widgets/workspace_drawer.dart'; @@ -75,6 +77,44 @@ class _WorkspaceDesktopState extends State { return null; }, ), + StickyNoteIntent: CallbackAction( + onInvoke: (intent) { + final provider = Provider.of(context, listen: false); + final device = rh.DeviceType.desktop; + _showStickyNote(context, device, provider); + return null; + }, + ), + ResetIntent: CallbackAction( + onInvoke: (intent) { + final canvasProvider = Provider.of( + context, + listen: false, + ); + canvasProvider.resetZoom(); + return null; + }, + ), + ZoomInIntent: CallbackAction( + onInvoke: (intent) { + final canvasProvider = Provider.of( + context, + listen: false, + ); + canvasProvider.zoomIn(); + return null; + }, + ), + ZoomOutIntent: CallbackAction( + onInvoke: (intent) { + final canvasProvider = Provider.of( + context, + listen: false, + ); + canvasProvider.zoomOut(); + return null; + }, + ), }; return Consumer2( @@ -182,4 +222,43 @@ class _WorkspaceDesktopState extends State { }, ); } + + void _showStickyNote( + BuildContext context, + rh.DeviceType device, + SupabaseService su, + ) { + final RenderBox? renderBox = context.findRenderObject() as RenderBox?; + if (renderBox != null) { + final position = renderBox.localToGlobal(Offset.zero); + showDialog( + context: context, + barrierColor: Colors.transparent, + builder: + (context) => Stack( + children: [ + Positioned.fill( + child: GestureDetector( + onTap: () => Navigator.pop(context), + child: Container(color: Colors.transparent), + ), + ), + Positioned( + right: device == rh.DeviceType.mobile ? position.dx : 150.w, + top: + device == rh.DeviceType.desktop + ? 500.h + : device == rh.DeviceType.tab + ? 500.h + : position.dy - 390.h, + child: Material( + color: Colors.transparent, + child: StickyNotesWidget(su: su), + ), + ), + ], + ), + ); + } + } } diff --git a/lib/features/workspace/widgets/workspace_shortcuts.dart b/lib/features/workspace/widgets/workspace_shortcuts.dart index 0e1e2bc..e3209a4 100644 --- a/lib/features/workspace/widgets/workspace_shortcuts.dart +++ b/lib/features/workspace/widgets/workspace_shortcuts.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; - // define intents class PointerIntent extends Intent {} @@ -10,12 +9,22 @@ class PanIntent extends Intent {} class TextIntent extends Intent {} +class StickyNoteIntent extends Intent {} + +class ResetIntent extends Intent {} + +class ZoomInIntent extends Intent {} + +class ZoomOutIntent extends Intent {} + // define shortcuts final Map workspaceShortCut = { LogicalKeySet(LogicalKeyboardKey.keyP): PointerIntent(), LogicalKeySet(LogicalKeyboardKey.keyA): PanIntent(), LogicalKeySet(LogicalKeyboardKey.keyT): TextIntent(), + LogicalKeySet(LogicalKeyboardKey.keyS): StickyNoteIntent(), + LogicalKeySet(LogicalKeyboardKey.keyR): ResetIntent(), + LogicalKeySet(LogicalKeyboardKey.keyZ): ZoomInIntent(), + LogicalKeySet(LogicalKeyboardKey.keyX): ZoomOutIntent(), }; - -