From b129bf6ad372e196dbdb83a7110804b370a92452 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Apr 2021 22:50:41 +0200 Subject: [PATCH] more docs; move custom comp widgets from canvas to Component --- CHANGELOG.md | 5 +++ .../abstraction_layer/rw/model_reader.dart | 1 + .../abstraction_layer/rw/model_writer.dart | 1 + .../abstraction_layer/rw/state_reader.dart | 1 + .../abstraction_layer/rw/state_writer.dart | 1 + lib/src/widget/canvas.dart | 33 +++++-------------- lib/src/widget/component.dart | 1 + pubspec.yaml | 2 +- 8 files changed, 20 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbcd52e..c516a68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +# 0.0.9 + +* Add documentation comments to reader/writer +* Move custom components widgets from Canvas to Component + # 0.0.8 * Add some more documentation comments. diff --git a/lib/src/abstraction_layer/rw/model_reader.dart b/lib/src/abstraction_layer/rw/model_reader.dart index a61a204..fb86aa9 100644 --- a/lib/src/abstraction_layer/rw/model_reader.dart +++ b/lib/src/abstraction_layer/rw/model_reader.dart @@ -10,6 +10,7 @@ class CanvasModelReader { final CanvasModel canvasModel; final CanvasState canvasState; + /// Allows you to read data from the model (component and link data). CanvasModelReader(this.canvasModel, this.canvasState); /// Returns a component with [id]. diff --git a/lib/src/abstraction_layer/rw/model_writer.dart b/lib/src/abstraction_layer/rw/model_writer.dart index 678a4bf..a5e25db 100644 --- a/lib/src/abstraction_layer/rw/model_writer.dart +++ b/lib/src/abstraction_layer/rw/model_writer.dart @@ -13,6 +13,7 @@ class ModelWriter { class CanvasModelWriter extends ModelWriter with ComponentWriter, LinkWriter, ConnectionWriter { + /// Allows you to change the model. CanvasModelWriter(CanvasModel canvasModel, CanvasState canvasState) : super(canvasModel, canvasState); diff --git a/lib/src/abstraction_layer/rw/state_reader.dart b/lib/src/abstraction_layer/rw/state_reader.dart index 82c617c..5a87925 100644 --- a/lib/src/abstraction_layer/rw/state_reader.dart +++ b/lib/src/abstraction_layer/rw/state_reader.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; class CanvasStateReader { final CanvasState canvasState; + /// Allows you to read state (position and scale) of the canvas. CanvasStateReader(this.canvasState); /// Position of the canvas. Coordinates where the (0, 0) of the canvas is currently located. diff --git a/lib/src/abstraction_layer/rw/state_writer.dart b/lib/src/abstraction_layer/rw/state_writer.dart index 9dc6662..ea68272 100644 --- a/lib/src/abstraction_layer/rw/state_writer.dart +++ b/lib/src/abstraction_layer/rw/state_writer.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; class CanvasStateWriter { final CanvasState _canvasState; + /// Allows you to change the state of the canvas. CanvasStateWriter(this._canvasState); /// Updates everything on canvas. diff --git a/lib/src/widget/canvas.dart b/lib/src/widget/canvas.dart index 8a43f01..ed2dbda 100644 --- a/lib/src/widget/canvas.dart +++ b/lib/src/widget/canvas.dart @@ -53,31 +53,16 @@ class _DiagramEditorCanvasState extends State var zOrderedComponents = canvasModel.components.values.toList(); zOrderedComponents.sort((a, b) => a.zOrder.compareTo(b.zOrder)); - List componentWidgetList = []; - zOrderedComponents.forEach((componentData) { - componentWidgetList.add( - ChangeNotifierProvider.value( - value: componentData, - child: Component( - policy: widget.policy, + return zOrderedComponents + .map( + (componentData) => ChangeNotifierProvider.value( + value: componentData, + child: Component( + policy: widget.policy, + ), ), - ), - ); - componentWidgetList.add( - ChangeNotifierProvider.value( - value: componentData, - builder: (context, child) { - return Consumer( - builder: (context, data, child) { - return widget.policy - .showCustomWidgetWithComponentData(context, data); - }, - ); - }, - ), - ); - }); - return componentWidgetList; + ) + .toList(); } List showLinks(CanvasModel canvasModel) { diff --git a/lib/src/widget/component.dart b/lib/src/widget/component.dart index ef99032..204d791 100644 --- a/lib/src/widget/component.dart +++ b/lib/src/widget/component.dart @@ -44,6 +44,7 @@ class Component extends StatelessWidget { child: policy.showComponentBody(componentData), ), ), + policy.showCustomWidgetWithComponentData(context, componentData), ], ), onTap: () => policy.onComponentTap(componentData.id), diff --git a/pubspec.yaml b/pubspec.yaml index f4658f7..7503d66 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: diagram_editor description: A flutter diagram editor library that provides DiagramEditor widget and a possibility to customize all editor design and behavior. -version: 0.0.8 +version: 0.0.9 homepage: https://github.com/Arokip/fdl environment: