Skip to content

Commit c32d264

Browse files
committed
Add an "about" and update the diagram in the README.
1 parent 2084f2a commit c32d264

File tree

1 file changed

+15
-23
lines changed
  • patterns/abstract_factory/tool_panel_factory

1 file changed

+15
-23
lines changed

patterns/abstract_factory/tool_panel_factory/README.md

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,32 @@ Click on the picture to see the [demo](https://RefactoringGuru.github.io/design-
99

1010
[![image](https://user-images.githubusercontent.com/8049534/168668992-369a1bab-9f97-4333-a20e-ffd06bf91b54.png)](https://refactoringguru.github.io/design-patterns-dart/#/abstract_factory/tool_panel_factory)
1111

12+
### About
13+
![image](https://user-images.githubusercontent.com/8049534/169521422-052cc59a-7b3d-4889-8d76-5664a75b271a.png)
14+
1215
### Diagram:
13-
![image](https://user-images.githubusercontent.com/8049534/168672053-73ae1c9c-8fad-45ae-9247-429f7b5da565.png)
16+
![image](https://user-images.githubusercontent.com/8049534/169528461-d7c5279d-7e7f-4ce7-b8d2-87388ec2d32f.png)
1417

15-
### Client code (using the "createShape" method):
18+
### Client code:
1619
```dart
17-
final app = App(
18-
tools: Tools(
19-
factories: [
20-
TxtFactory(),
21-
LineFactory(),
22-
CircleFactory(),
23-
TriangleFactory(),
24-
StarFactory(),
25-
],
26-
),
27-
);
28-
2920
class App {
3021
void addShape(double x, double y) {
31-
final newShape = activeFactory.createShape(x, y, activeColor);
22+
final newShape = activeToolFactory.createShape(x, y, activeColor);
3223
shapes.add(newShape);
3324
}
3425
}
3526
36-
mixin IconBoxMixin implements FactoryTool {
37-
Image? _icon;
3827
39-
@override
40-
Image get icon => _icon!;
28+
class PropertyPanel extends StatelessWidget {
29+
final PropertyWidgetFactories factories;
4130
42-
Future<void> updateIcon(Color color) async {
43-
final shape = createShape(0, 0, color);
44-
final pngBytes = await _pngImageFromShape(shape);
45-
_icon = Image.memory(pngBytes);
31+
@override
32+
Widget build(BuildContext context) {
33+
return Row(
34+
children: propertyWidgetFactories
35+
.createListWidgetsFrom(activeToolFactory.properties)
36+
.toList(),
37+
);
4638
}
4739
}
4840
```

0 commit comments

Comments
 (0)