Skip to content

Commit

Permalink
more docs; move custom comp widgets from canvas to Component
Browse files Browse the repository at this point in the history
  • Loading branch information
Arokip committed Apr 27, 2021
1 parent 7043f84 commit b129bf6
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions lib/src/abstraction_layer/rw/model_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
1 change: 1 addition & 0 deletions lib/src/abstraction_layer/rw/model_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions lib/src/abstraction_layer/rw/state_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions lib/src/abstraction_layer/rw/state_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 9 additions & 24 deletions lib/src/widget/canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,16 @@ class _DiagramEditorCanvasState extends State<DiagramEditorCanvas>
var zOrderedComponents = canvasModel.components.values.toList();
zOrderedComponents.sort((a, b) => a.zOrder.compareTo(b.zOrder));

List<Widget> componentWidgetList = [];
zOrderedComponents.forEach((componentData) {
componentWidgetList.add(
ChangeNotifierProvider<ComponentData>.value(
value: componentData,
child: Component(
policy: widget.policy,
return zOrderedComponents
.map(
(componentData) => ChangeNotifierProvider<ComponentData>.value(
value: componentData,
child: Component(
policy: widget.policy,
),
),
),
);
componentWidgetList.add(
ChangeNotifierProvider<ComponentData>.value(
value: componentData,
builder: (context, child) {
return Consumer<ComponentData>(
builder: (context, data, child) {
return widget.policy
.showCustomWidgetWithComponentData(context, data);
},
);
},
),
);
});
return componentWidgetList;
)
.toList();
}

List<Widget> showLinks(CanvasModel canvasModel) {
Expand Down
1 change: 1 addition & 0 deletions lib/src/widget/component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Component extends StatelessWidget {
child: policy.showComponentBody(componentData),
),
),
policy.showCustomWidgetWithComponentData(context, componentData),
],
),
onTap: () => policy.onComponentTap(componentData.id),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit b129bf6

Please sign in to comment.