diff --git a/lib/ui/screens/canvas_screen.dart b/lib/ui/screens/canvas_screen.dart index 31a90fd..195c5be 100644 --- a/lib/ui/screens/canvas_screen.dart +++ b/lib/ui/screens/canvas_screen.dart @@ -85,6 +85,10 @@ class CanvasScreen extends StatelessWidget { context.read().toggleDrawingMode(); } + void _handleAddText(BuildContext context) { + context.read().addText('New Text'); + } + @override Widget build(BuildContext context) { return KeyboardShortcuts( @@ -94,6 +98,7 @@ class CanvasScreen extends StatelessWidget { onNew: () => _handleNew(context), onClear: () => _handleClear(context), onToggleDrawing: () => _handleToggleDrawing(context), + onAddText: () => _handleAddText(context), child: Scaffold( backgroundColor: ColorConstants.uiWhite, appBar: AppBar( @@ -418,7 +423,8 @@ class CanvasScreen extends StatelessWidget { child: const Icon(Icons.text_fields, color: ColorConstants.dialogButtonBlue), ), - title: const Text('Add Text'), + title: const Text( + kIsWeb ? 'Add Text (Ctrl+T)' : 'Add Text'), subtitle: const Text('Add and format text on canvas'), onTap: () { @@ -548,12 +554,15 @@ class CanvasScreen extends StatelessWidget { } } + // Helper method to get appropriate image provider for web and mobile ImageProvider _getImageProvider(String imagePath) { if (kIsWeb && imagePath.startsWith('data:')) { + // On web, if it's a data URL, decode it and use MemoryImage final String base64String = imagePath.split(',')[1]; final Uint8List bytes = base64Decode(base64String); return MemoryImage(bytes); } else { + // On mobile or if it's a file path, use FileImage return FileImage(File(imagePath)); } } @@ -570,6 +579,7 @@ class CanvasScreen extends StatelessWidget { children: [ _shortcutItem('Ctrl + S', 'Save page'), _shortcutItem('Ctrl + N', 'New page'), + _shortcutItem('Ctrl + T', 'Add text'), _shortcutItem('Ctrl + Z', 'Undo'), _shortcutItem('Ctrl + Shift + Z', 'Redo'), _shortcutItem('Ctrl + Y', 'Redo (alternative)'), @@ -690,4 +700,4 @@ class _DraggableTextBoxState extends State<_DraggableTextBox> { ), ); } -} \ No newline at end of file +} diff --git a/lib/utils/web_utils.dart b/lib/utils/web_utils.dart index 4f736c0..85188ee 100644 --- a/lib/utils/web_utils.dart +++ b/lib/utils/web_utils.dart @@ -24,6 +24,7 @@ class KeyboardShortcuts extends StatelessWidget { final VoidCallback? onNew; final VoidCallback? onClear; final VoidCallback? onToggleDrawing; + final VoidCallback? onAddText; const KeyboardShortcuts({ super.key, @@ -34,6 +35,7 @@ class KeyboardShortcuts extends StatelessWidget { this.onNew, this.onClear, this.onToggleDrawing, + this.onAddText, }); @override @@ -98,6 +100,14 @@ class KeyboardShortcuts extends StatelessWidget { const SingleActivator(LogicalKeyboardKey.keyD, meta: true): () { onToggleDrawing?.call(); }, + + // Add Text: Ctrl/Cmd + T + const SingleActivator(LogicalKeyboardKey.keyT, control: true): () { + onAddText?.call(); + }, + const SingleActivator(LogicalKeyboardKey.keyT, meta: true): () { + onAddText?.call(); + }, }, child: Focus( autofocus: true,