Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ramin/Update_dev_with_fe_changes #287

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a22c9f0
sahani/migrate_flutter_to_version_3_10 (#225)
sahani-deriv Jun 1, 2023
a4e0f4d
hamed/update_dependencies (#227)
hamed-rezaee Jun 1, 2023
fe78002
Maryia/78669/add drawing tools list (#195)
maryia-deriv Oct 31, 2022
c3b849e
bahar/82930/Add hollow chart type (#202)
Dec 28, 2022
8683d03
bahar/82932/feat: add_ohlc_chart_type (#204)
Jan 6, 2023
2a3b8dc
maryia|bahar/78755/Add vertical and line drawing tool (#207)
Feb 21, 2023
1389826
bahar/82785/Make drawings draggable (#224)
Jun 9, 2023
3557384
bahar/feat: add_continuous_drawing_tool (#229)
Aug 4, 2023
216cc35
Ahmad/Add trend drawing tool (#236)
ahmadtaimoor-deriv Aug 16, 2023
42951e5
bahar/Add ray drawing tool (#235)
Aug 21, 2023
dcae40a
bahar/Add fibfan drawing tool (#238)
Sep 6, 2023
55e6d83
bahar/Add channel drawing tool (#237)
Sep 7, 2023
9dd2500
Ahmad/Add rectangle drawing (#232)
ahmadtaimoor-deriv Sep 7, 2023
f1516f3
Ahmad /Add Horizontal Drawing Tool (#239)
ahmadtaimoor-deriv Sep 7, 2023
14d0abe
Drawing tool merge fix (#249)
ahmadtaimoor-deriv Sep 7, 2023
091d00a
ramin/drawing_tools_performance_improvement (#246)
ramin-deriv Sep 11, 2023
56414d0
fix market_selector_test.dart (#251)
ramin-deriv Sep 11, 2023
ec840ad
Bala/Add web support (#208)
balakrishna-deriv Sep 11, 2023
7d47595
bahar/Restore drawings (#242)
Sep 29, 2023
12c926f
Feat drawingtool integration (#247)
ahmadtaimoor-deriv Oct 6, 2023
c2ec0df
add a todo comment (#254)
Oct 12, 2023
ea8c278
Add combinePaths function & Performance improvement (#245)
balakrishna-deriv Oct 17, 2023
e1faa91
bahar/Add drawing tool documentation (#257)
Oct 31, 2023
1f1b4cc
ramin/fix_off_screen_calculation (#253)
ramin-deriv Nov 9, 2023
c42764d
fix: fix deriv_lint dependendency
ramin-deriv Dec 1, 2023
5167914
fix: fix merge issues
ramin-deriv Dec 1, 2023
df5f4ac
udpate technical analysis dependency
ramin-deriv Dec 10, 2023
da51929
Fix merge issues
ramin-deriv Dec 10, 2023
49d7f9e
update CHANGELOG file and increase version
ramin-deriv Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.1.0] - TODO: Add release date.

* Add drawing tools.
* Make the chart compatible with the `flutter_web` platform.

## [0.0.1] - TODO: Add release date.

* TODO: Describe initial release.
* TODO: Describe initial release.
42 changes: 42 additions & 0 deletions docs/drawing_tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Drawing Tools

The process initiates by opening the drawing tools dialog and selecting a preferred drawing tool. Subsequently, the user can add specific taps on the Deriv chart to start drawing with default configurations.

The GestureDetector on the Deriv chart, utilized by the `drawingCreator` captures user input. Within the `onTap` method, every captured input will be added to the list of edgePoints. Simultaneously, the `drawingParts` list is created to store the drawing parts. Both lists are then passed to the `onAddDrawing` callback, which adds the complete drawing to the drawing repository and saves it in shared preferences based on the active Symbol, so the drawing data can be retrieved based on the chart's symbol.

During the addition of drawing parts to the `drawingParts` list, each instance of the drawing is initialized. This initialization triggers the relevant `onPaint` method, allowing each drawing part to be painted to the chart. Since we maintain a list of `drawingParts`, each of which is an instance of a drawing, every drawing part has its own `onPaint` and `hitTest` methods inherited from CustomPaint. Consequently, any modifications in the drawing's position, such as dragging, result in the `repaint` and `hitTest` methods being invoked for each drawing part. For a more detailed explanation, please refer to the sections titled DrawingPainter, EdgePoints, and DraggableEdgePoints.

Any modifications or adjustments to the drawing can be made by the user through the drawing tools dialog, it will end up in triggering an update in the drawing configuration within drawing_tools_dialog widget.

To enable the drawings to be draggable, a distinct gesture is assigned to each drawing added to the chart. This gesture, embedded within the DrawingPainter, identifies any user taps on the drawing and designates the drawing as selected or deselected. The user can then drag the selected drawing across the chart.

To update the position of the dragged drawing, the drawing must be repainted on the chart. This operation is performed by the CustomPaint component within the DrawingPainter.

## Drawing Tool Chart

DrawingToolChart widget is embedded within MainChart, enabling users to sketch particular shapes on DerivChart. This feature comprises two main parts: DrawingToolWidget and DrawingPainter. The DrawingPainter is specifically tasked with painting and repainting the drawings and is invoked for every drawing added to the chart.
In other words, for each drawing a DrawingPainter widget is added on the DrawingToolChart stack, and DrawingToolWidget is for when any drawing tool is selected.

## DrawingToolWidget

It assigns the task of drawing creation to the respective drawing tool creator. Each creator employs the chart's gestures to detect user inputs and initially adds the drawing to the list by invoking the onAddDrawing callback. Every drawing tool creator extends from the DrawingCreator class.

## DrawingCreator

It is a base class for all drawing tool creators. It is responsible for adding the drawing to the list and invoking the onAddDrawing callback. It also provides the drawing tool creator with the chart's gestures to detect user inputs.

## DrawingPainter

A stateful widget which is responsible for painting and repainting the drawings based on theirs configs using `CustomPaint`. Since the CustomPaint is wrapped within GestureDetector, each drawing created possesses its dedicated gesture, designed specifically for enabling the drawings to be draggable.

In this widget we make drawings selectable by means of gesture and `hitTest` of `CustomPainter`. `hitTest` method checks if the user has clicked on a drawing or not, if yes it will return true. Inside `CustomPaint` we are calling `onPaint` and `hitTest` for each drawingPart.

![plot](drawing_tools.png)

## EdgePoints

EdgePoint is a term we coined to keep the data of points required to create a drawing. For instance, a line necessitates two points, while a channel requires three. Whenever a user taps on Deriv-chart to create a drawing, a new instance of this class is generated within each drawing creator. This instance contains data obtained from Deriv_chart's gesture detector. These EdgePoints are then passed as a list to the onAddDrawing callback for drawing creation.

## DraggableEdgePints

This class extends from EdgePoint. It incorporates functions to compute the edgePoints' positions after they are dragged (utilizing data obtained from the DrawingPainter gestureDetector). These instances will be created as the state of the drawing_painter widget. Subsequently, they will be passed to CustomPaint, where onPaint and hitTest methods utilize them for drawing selection and repainting the drawings on the chart.
Binary file added docs/drawing_tools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading