Skip to content

Commit

Permalink
change example; update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Arokip committed Apr 12, 2021
1 parent a675e7e commit e08c78c
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 92 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

# 0.0.2

* Add example.
* Update dependencies.
* Description in yaml.

# 0.0.1

* Initial release.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

[![pub package](https://img.shields.io/pub/v/diagram_editor.svg)](https://pub.dev/packages/diagram_editor)

Flutter diagram editor library for showing and editing diagrams of custom type. [Github](https://github.com/Arokip/fdl)
[Github](https://github.com/Arokip/fdl)

Flutter diagram editor library for showing and editing diagrams of custom type. It provides DiagramEditor widget and a possibility to customize all editor design and behavior.

<img src="https://user-images.githubusercontent.com/20387953/114435850-f1f20f00-9bc4-11eb-8d97-a16c40c326cb.png">

Expand All @@ -11,7 +13,7 @@ Flutter diagram editor library for showing and editing diagrams of custom type.

## Getting Started

Simple example of this package usage is in [`/example`](https://github.com/Arokip/fdl/tree/master/lib/example) folder.
Simple example of this package usage is in [`/example`](https://github.com/Arokip/fdl/tree/master/example) folder.

Use of `DiagramEditor` widget:

Expand Down
73 changes: 72 additions & 1 deletion lib/example/my_policy_set.dart → example/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,78 @@
import 'dart:math' as math;

import 'package:diagram_editor/diagram_editor.dart';
import 'package:diagram_editor/example/my_component_data.dart';
import 'package:flutter/material.dart';

void main() => runApp(DiagramApp());

class DiagramApp extends StatefulWidget {
@override
_DiagramAppState createState() => _DiagramAppState();
}

class _DiagramAppState extends State<DiagramApp> {
MyPolicySet myPolicySet = MyPolicySet();

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Stack(
children: [
Container(color: Colors.grey),
Padding(
padding: EdgeInsets.all(16),
child: Container(
color: Colors.green,
child: DiagramEditor(
diagramEditorContext: DiagramEditorContext(
policySet: myPolicySet,
),
),
),
),
GestureDetector(
onTap: () => myPolicySet.deleteAllComponents(),
child: Container(
width: 64,
height: 32,
color: Colors.red,
child: Center(child: Text('delete all')),
),
),
],
),
),
),
);
}
}

// Custom component Data

class MyComponentData {
bool isHighlightVisible;
Color color =
Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);

MyComponentData({this.isHighlightVisible = false});

switchHighlight() {
isHighlightVisible = !isHighlightVisible;
}

showHighlight() {
isHighlightVisible = true;
}

hideHighlight() {
isHighlightVisible = false;
}
}

// Policy set and individual policy implementations.

class MyPolicySet extends PolicySet
with
MyInitPolicy,
Expand Down
50 changes: 0 additions & 50 deletions lib/example/main.dart

This file was deleted.

23 changes: 0 additions & 23 deletions lib/example/my_component_data.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/src/widget/canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ class _DiagramEditorCanvasState extends State<DiagramEditorCanvas>

@override
Widget build(BuildContext context) {
print('CANVAS build: ${widget.policy.runtimeType}');
final canvasModel = Provider.of<CanvasModel>(context);
final canvasState = Provider.of<CanvasState>(context);

Expand Down
15 changes: 4 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
version: "3.0.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -108,7 +101,7 @@ packages:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.3"
version: "5.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -169,7 +162,7 @@ packages:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
version: "3.0.4"
vector_math:
dependency: transitive
description:
Expand All @@ -178,5 +171,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
8 changes: 4 additions & 4 deletions 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.
version: 0.0.1
description: A flutter diagram editor library that provides DiagramEditor widget and a possibility to customize all editor design and behavior.
version: 0.0.2
homepage: https://github.com/Arokip/fdl

environment:
Expand All @@ -10,8 +10,8 @@ environment:
dependencies:
flutter:
sdk: flutter
provider: ^4.3.3
uuid: ^2.2.2
provider: ^5.0.0
uuid: ^3.0.4


dev_dependencies:
Expand Down

0 comments on commit e08c78c

Please sign in to comment.