Skip to content

Commit 15161ae

Browse files
authored
Merge pull request #37 from ilopX/refactoring_v0_18
Refactoring v0.18.9
2 parents e31af6b + 1f5925f commit 15161ae

File tree

19 files changed

+47
-54
lines changed

19 files changed

+47
-54
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ It contains **Dart** examples for all classic **GoF** design patterns.
55
# Implementation checklist:
66
- [ ] **Creation**
77
- [ ] **Abstract Factory**
8-
- [x] **Builder** - [[Color Text Format](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/builder/color_text_format)]
8+
- [x] **Builder** - [[Color Text Format](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/builder/color_text_format)]
99
- [ ] **Factory Method**
10-
- [x] **Prototype**] - [[Shapes](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/prototype/shapes)]
10+
- [x] **Prototype**] - [[Shapes](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/prototype/shapes)]
1111
- [ ] **Singleton**
1212
- [ ] **Behavioral**
13-
- [x] **Chain of Responsibility** - [[Server Middleware](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/chain_of_responsibility/server_middleware)]
14-
- [x] **Command** - [[Text Editor](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/command/text_editor)]
13+
- [x] **Chain of Responsibility** - [[Server Middleware](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/chain_of_responsibility/server_middleware)]
14+
- [x] **Command** - [[Text Editor](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/command/text_editor)]
1515
- [ ] Interpreter
1616
- [ ] **Iterator**
1717
- [ ] **Mediator**
18-
- [x] **Memento** - [[Conceptual](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/memento/conceptual)] [[Memento Editor](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/memento/memento_editor)]
19-
- [x] **Observer** - [[Open-Close Editor Events](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/observer/open_close_editor_events)] [[AppObserver](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/observer/app_observer)] [[Subscriber Flutter Widget](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/observer/subscriber_flutter_widget)]
18+
- [x] **Memento** - [[Conceptual](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/memento/conceptual)] [[Memento Editor](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/memento/memento_editor)]
19+
- [x] **Observer** - [[Open-Close Editor Events](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/open_close_editor_events)] [[AppObserver](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/app_observer)] [[Subscriber Flutter Widget](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/subscriber_flutter_widget)]
2020
- [ ] **State**
2121
- [ ] **Template Method**
2222
- [ ] **Visitor**
2323
- [ ] **Strategy**
2424
- [ ] **Structural**
25-
- [x] **Adapter** - [[Text Graphics](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/adapter/text_graphics)] [[Square Round conflict](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/adapter/square_round_conflict)] [[Flutter Adapter](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/adapter/flutter_adapter)]
26-
- [x] **Bridge** - [[Remote Device Control](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/bridge/devices_remote_control)] [[Clock](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/bridge/clock)]
27-
- [x] **Composite** - [[Image Editor](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/composite/image_editor)] [[Products and Boxes](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/composite/products_and_boxes)]
28-
- [x] **Decorator** - [[Data Source Decoder](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/decorator/data_source_decoder)]
25+
- [x] **Adapter** - [[Text Graphics](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/adapter/text_graphics)] [[Square Round conflict](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/adapter/square_round_conflict)] [[Flutter Adapter](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/adapter/flutter_adapter)]
26+
- [x] **Bridge** - [[Remote Device Control](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/bridge/devices_remote_control)] [[Clock](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/bridge/clock)]
27+
- [x] **Composite** - [[Image Editor](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/composite/image_editor)] [[Products and Boxes](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/composite/products_and_boxes)]
28+
- [x] **Decorator** - [[Data Source Decoder](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/decorator/data_source_decoder)]
2929
- [ ] **Facade**
3030
- [ ] **Flyweight**
3131
- [ ] **Proxy**

patterns/adapter/flutter_adapter/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This example shows how to adapt a non-reactive classic type application for Flut
99

1010
### Dependency
1111
This complex example includes these implementations:
12-
- [[AppObserver](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/observer/app_observer)]
13-
- [[SubscriberWidget](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/observer/subscriber_flutter_widget)]
12+
- [[AppObserver](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/app_observer)]
13+
- [[SubscriberWidget](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/subscriber_flutter_widget)]
1414

1515
### Online demo:
1616
Click on the picture to see a [demo](https://refactoringguru.github.io/design-patterns-dart/#/adapter/flutter_adapter).

patterns/adapter/text_graphics/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ https://refactoring.guru/design-patterns/adapter
88
Adding shapes from a third-party library.
99

1010
### Class Diagram:
11-
![image](https://user-images.githubusercontent.com/8049534/146028651-1262b66d-b0ac-4fc9-9487-76a2d588f97e.png)
11+
![image](https://user-images.githubusercontent.com/8049534/165749605-5361d5e2-e4a1-41ed-9d27-1c4965fa30d2.png)
1212

1313
### Client code:
1414
```dart

patterns/bridge/devices_remote_control/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Bridge pattern
2-
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/master/src/refactoring_guru/bridge/example)
2+
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/main/src/refactoring_guru/bridge/example)
33
But removed the ability to use null for devices. Instead, the EmptyDevice class is used.
44

55
### Remote device example

patterns/builder/color_text_format/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ https://refactoring.guru/design-patterns/builder
88
Using different text formats.
99

1010
### Class diagram
11-
![image](https://user-images.githubusercontent.com/8049534/152780645-4eed27fc-a483-432e-99b0-4a77f2adbd5d.png)
11+
![image](https://user-images.githubusercontent.com/8049534/165747411-75d587d4-aa16-4a14-a16d-52f3fa461a11.png)
1212

1313
### Client code:
1414
```dart
1515
main() {
1616
final reader = ColorTextReader(
17-
text: 'I love looking at the blue sky, '
18-
'eating red apples, '
19-
'sitting on the green grass.',
17+
text: 'I love looking at the blue sky, eating red apples and sitting on the green grass.',
2018
);
2119
2220
final html = reader.convert(HtmlConverter());

patterns/chain_of_responsibility/server_middleware/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Chain of Responsibility is a behavioral design pattern that lets you pass reques
88
https://refactoring.guru/design-patterns/chain-of-responsibility?#problem
99

1010
### Origin source code:
11-
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/master/src/refactoring_guru/chain_of_responsibility/example)
11+
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/main/src/refactoring_guru/chain_of_responsibility/example)
1212

1313
### Diagram:
1414
![image](https://user-images.githubusercontent.com/8049534/149488654-7ff5f659-4086-4d1a-ae44-326c71fb880a.png)

patterns/command/text_editor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ possible to revert an operation if needed.
1111
More detailed explanation on [RefactoringGuru](https://refactoring.guru/design-patterns/command?#pseudocode).
1212

1313
## Origin source code:
14-
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/master/src/refactoring_guru/command/example).
14+
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/main/src/refactoring_guru/command/example).
1515
But slightly changed, see the class diagram.
1616

1717
## Diagram:

patterns/composite/image_editor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Composite is a structural design pattern that lets you compose objects into tree
55
https://refactoring.guru/design-patterns/composite?#pseudocode
66

77
## Origin source code:
8-
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/master/src/refactoring_guru/composite/example)
8+
This example rewrite from [java example](https://github.com/RefactoringGuru/design-patterns-java/tree/main/src/refactoring_guru/composite/example)
99

1010
### Diagram:
1111
![image](https://user-images.githubusercontent.com/8049534/149174388-25ca21b1-d762-40b5-a853-528abe18b66c.png)

patterns/memento/memento_editor/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ object without revealing the details of its implementation.
55
Tutorial: [here](https://refactoring.guru/design-patterns/memento).
66

77
### Online demo:
8-
Click on the picture to see a [demo](https://RefactoringGuru.github.io/design-patterns-dart/#/memento/flutter_memento_editor).
8+
Click on the picture to see the [demo](https://RefactoringGuru.github.io/design-patterns-dart/#/memento/flutter_memento_editor).
99

1010
[![image](https://user-images.githubusercontent.com/8049534/165401175-88bc4593-4624-45b4-8c03-6f1390ed771a.png)](https://refactoringguru.github.io/design-patterns-dart/#/memento/flutter_memento_editor)
1111

12-
1312
### Dependency Patterns
1413
This complex example includes these implementations:
15-
- [[AppObserver](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/observer/app_observer)]
16-
- [[SubscriberWidget](https://github.com/RefactoringGuru/design-patterns-dart/tree/master/patterns/observer/subscriber_flutter_widget)]
14+
- [[AppObserver](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/app_observer)]
15+
- [[SubscriberWidget](https://github.com/RefactoringGuru/design-patterns-dart/tree/main/patterns/observer/subscriber_flutter_widget)]
1716

1817
### Diagram:
19-
![image](https://user-images.githubusercontent.com/8049534/165399085-06835617-8ef1-4e2f-930f-03d730433afb.png)
18+
![image](https://user-images.githubusercontent.com/8049534/165758516-1de543f5-666d-4e07-958d-2d8fceb73af9.png)
2019

2120
### Client code:
2221
```dart

patterns/memento/memento_editor/editor/manipulator.dart

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
1-
import '../../../adapter/flutter_adapter/classic_app/classic_app.dart';
21
import '../shapes/shapes.dart';
32

4-
mixin Manipulator implements ClassicApp, Shapes {
3+
mixin Manipulator implements Shapes {
54
var _isMouseDown = false;
65

76
@override
87
void onMouseDown(double x, double y) {
98
_isMouseDown = true;
10-
final currSelection = activeShape;
11-
129
select(x, y);
13-
14-
if (currSelection == activeShape) {
15-
return;
16-
}
17-
18-
if (activeShape == null) {
19-
unSelect();
20-
}
21-
22-
repaint();
2310
}
2411

2512
@override
2613
void onMouseMove(double x, double y) {
2714
if (_isMouseDown) {
2815
activeShape?.dragTo(x, y);
29-
repaint();
3016
}
3117
}
3218

0 commit comments

Comments
 (0)