From f15d742dfa1da37332c92df8ba13378cded3879f Mon Sep 17 00:00:00 2001 From: Lenkomotive Date: Fri, 24 Jan 2025 15:12:04 +0100 Subject: [PATCH] PAINTROID-454: Flutter: Add Layers - revert layer combination --- .../providers/state/canvas_state_provider.dart | 18 ++++-------------- .../drawing_surface/drawing_canvas.dart | 2 -- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/core/providers/state/canvas_state_provider.dart b/lib/core/providers/state/canvas_state_provider.dart index f8c58d54..272cbe1f 100644 --- a/lib/core/providers/state/canvas_state_provider.dart +++ b/lib/core/providers/state/canvas_state_provider.dart @@ -7,7 +7,6 @@ import 'package:paintroid/core/commands/command_manager/command_manager_provider import 'package:paintroid/core/commands/graphic_factory/graphic_factory_provider.dart'; import 'package:paintroid/core/providers/object/device_service.dart'; import 'package:paintroid/core/providers/state/canvas_state_data.dart'; -import 'package:paintroid/core/providers/state/layer_menu_state_provider.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'canvas_state_provider.g.dart'; @@ -46,15 +45,11 @@ class CanvasStateProvider extends _$CanvasStateProvider { final canvas = state.graphicFactory.createCanvasWithRecorder(recorder); final size = state.size; final bounds = Rect.fromLTWH(0, 0, size.width, size.height); - - final currentLayer = - ref.read(layerMenuStateProvider.notifier).getSelectedLayer(); - - if (currentLayer.image != null) { + if (state.cachedImage != null) { paintImage( canvas: canvas, rect: bounds, - image: currentLayer.image!, + image: state.cachedImage!, fit: BoxFit.fill, filterQuality: FilterQuality.none, ); @@ -63,16 +58,11 @@ class CanvasStateProvider extends _$CanvasStateProvider { state.commandManager.executeLastCommand(canvas); final picture = recorder.endRecording(); final img = await picture.toImage(size.width.toInt(), size.height.toInt()); - ref.read(layerMenuStateProvider.notifier).updateImageOfLayer(img); - - final mergedImage = await ref - .read(layerMenuStateProvider.notifier) - .getMergedImageOfVisibleLayers(img); - - state = state.copyWith(cachedImage: mergedImage); + state = state.copyWith(cachedImage: img); } Future resetCanvasWithNewCommands(Iterable commands) async { + state.commandManager.clearRedoStack(); state.commandManager.clearUndoStack(newCommands: commands); if (commands.isEmpty) { state = state.copyWith(cachedImage: null); diff --git a/lib/ui/pages/workspace_page/components/drawing_surface/drawing_canvas.dart b/lib/ui/pages/workspace_page/components/drawing_surface/drawing_canvas.dart index a7945b3a..e180430e 100644 --- a/lib/ui/pages/workspace_page/components/drawing_surface/drawing_canvas.dart +++ b/lib/ui/pages/workspace_page/components/drawing_surface/drawing_canvas.dart @@ -4,7 +4,6 @@ import 'package:paintroid/core/enums/tool_types.dart'; import 'package:paintroid/core/providers/object/canvas_painter_provider.dart'; import 'package:paintroid/core/providers/object/device_service.dart'; import 'package:paintroid/core/providers/state/canvas_state_provider.dart'; -import 'package:paintroid/core/providers/state/layer_menu_state_provider.dart'; import 'package:paintroid/core/providers/state/toolbox_state_provider.dart'; import 'package:paintroid/core/providers/state/workspace_state_notifier.dart'; import 'package:paintroid/ui/pages/workspace_page/components/drawing_surface/canvas_painter.dart'; @@ -45,7 +44,6 @@ class _DrawingCanvasState extends ConsumerState { }); void _onPointerDown(PointerDownEvent _) { - ref.read(layerMenuStateProvider.notifier).hide(); _pointersOnScreen++; if (_pointersOnScreen >= 2) { _isZooming = true;