Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
322 commits
Select commit Hold shift + click to select a range
1293445
keep InteractiveLayer disabled for the moment
Mar 7, 2025
d3027ff
fix some import issues
Mar 7, 2025
741ed17
code cleanup :recycle:
Mar 7, 2025
1ca45a0
WIP: control repaiting
Mar 11, 2025
fd18911
providing YAxisModel
Mar 11, 2025
57c5b5d
Merge remote-tracking branch 'upstream/master' into ramin/restructure…
Apr 16, 2025
0ff90a5
use ListenableProvider instead
Apr 21, 2025
ab63b68
Check isInEpochRange for drawings
Apr 21, 2025
02e48d3
call setState after gesture callbacks
Apr 21, 2025
90540ef
some minor changes
Apr 21, 2025
90bba13
check the drawing state inside painter
Apr 21, 2025
fed0212
check interacting state inside the drawing
Apr 21, 2025
a41cb5c
minor change in shouldRepaint logic
Apr 21, 2025
7db9e4c
add animating state to drawing tools
Apr 22, 2025
d104707
pass selection animation controller in another place as well
Apr 22, 2025
d585944
remove a redundant parameter from Selected state
Apr 22, 2025
fba20be
fix lint warnings
Apr 22, 2025
98c4707
remove EquatableMixin from InteractableDrawing
Apr 22, 2025
024677f
code cleanup :recycle:
Apr 22, 2025
a389ea7
add a comment
Apr 22, 2025
9cf6e91
code cleanup :recycle:
Apr 22, 2025
001f267
fix: drawing positions not updated when drawing multiple at the same …
Apr 23, 2025
c2b287f
remove get state callback and get state directly
Apr 23, 2025
be4bc6a
chore: code cleanup :recycle:
Apr 23, 2025
8084e47
remove unused import
Apr 23, 2025
210649d
override isInEpochRange inside horizontal drawing tool
Apr 23, 2025
426cd7a
change isInEpochRange to isInViewPort to support Y-axis visibility check
Apr 23, 2025
6496913
WIP: don't animate when series is changed
Apr 25, 2025
0a3661f
return for horizontal line isInViewPort
Apr 25, 2025
4f55b42
do some fixes
Apr 25, 2025
61a0526
fix some lint warnings
Apr 25, 2025
22a2d6e
fix some lint warnings
Apr 25, 2025
b2df2ab
chore: code cleanup
Apr 25, 2025
d00516a
fix formatting
Apr 25, 2025
2ca691d
revert back the usage of InteractiveLayer to use the old implementati…
Apr 25, 2025
ade5fd4
add a comment
Apr 28, 2025
0c236a0
rename state normal to idle
Apr 28, 2025
b19205a
chore: code cleanup :recycle:
Apr 28, 2025
8f84884
use setEquals instead of a custom helper function
Apr 28, 2025
5152fee
code cleanup :recycle:
Apr 28, 2025
cfeb5cd
don't show drawing tools when input is empty and chart is in loading …
Apr 28, 2025
eff0266
Merge 'upstream/master' into ramin/restructure_drawing_tools_attempt_…
May 5, 2025
0e69c80
feat: add InteractiveLayerBahaviour
May 7, 2025
32f05cb
move first point when adding the line tool
May 7, 2025
c4ae7f5
line preview in mobile
May 8, 2025
fb099bf
default value for interactive layer behavour
May 8, 2025
e71f251
show alignment cross-hair when adding a tool in desktop
May 8, 2025
67d92c9
code cleanup :recycle:
May 8, 2025
e086356
code cleanup :recycle:
May 8, 2025
6caaf18
use polymorphism to get the prevew line according to the current beha…
May 9, 2025
b564d5c
code cleanup :recycle:
May 9, 2025
4273e11
remove doing tap in mobile adding state
May 9, 2025
1e541ec
WIP: making preview lines separate classes
May 9, 2025
1123502
reuse paint helper functions
May 9, 2025
7fc2aff
feat: add preview line drawing tool for desktop
May 9, 2025
a5565a3
code cleanup :recycle:
May 9, 2025
c73b15f
chore: move trend line files to a separate folder
May 9, 2025
22e3b14
chore: move horizontal line files to a separate folder
May 9, 2025
6c2cf93
feat: add desktop preivew line for horizontal line
May 9, 2025
bce64c9
chore: add some docs
May 9, 2025
1e27e26
use AddingToolAlignmentCrossHair inside TrendLine adding preview
May 9, 2025
53352ab
adding spawn point of the line preview on mobile inside the preview i…
May 9, 2025
8767bba
code cleanup :recycle:
May 9, 2025
538ae30
implement mobile preview for horizontal line'
May 9, 2025
fa82e3f
code cleanup :recycle:
May 9, 2025
387f161
add size property to interactive layer
May 9, 2025
a0b35c9
paint horizontal line preview as dashed
May 9, 2025
195d338
remove a redundant method
May 9, 2025
2b5fa10
code cleanup :recycle:
May 9, 2025
c4623cf
chore: code cleanup :recycle:
May 9, 2025
31f711c
chore: code cleanup :recycle:
May 9, 2025
7511a0d
chore: code cleanup :recycle:
May 9, 2025
a7b95e3
chore: add some docs
May 12, 2025
f6e6287
chore: improve documentations
May 12, 2025
c24124e
update documentation
May 12, 2025
7888e7e
update documentation
May 12, 2025
26adc21
add Mermaid and SVG files for diagrams in interactive layer docs
May 13, 2025
cfff28f
chore: update docs
May 13, 2025
011a9e7
show a different visuals when preview is being dragged
May 14, 2025
1ccd476
fix: fix the issue of line start point not getting dragged
May 14, 2025
0744610
chore: code cleanup :recycle:
May 14, 2025
14b1020
fix: fix the issue of horizontal line start point not getting dragged
May 14, 2025
304476a
chore: code cleanup :recycle:
May 14, 2025
316d47a
chore: fix formatting of a few files
May 14, 2025
b470bbf
chore: fix lint warnings
May 14, 2025
fff3741
change diagram files's extension to mmd
May 14, 2025
0eb6137
update diagram images using mermaid CLI
May 14, 2025
f4f0835
fix EOF of diagram file
May 14, 2025
300beed
chore: update README file
May 14, 2025
57f813a
chore: update README file
May 14, 2025
8c9bbd6
chore: code cleanup :recycle:
May 14, 2025
36ed044
chore: update README file
May 14, 2025
72af106
add interactiveLayerBehaviour param to DerivChart widget
May 14, 2025
d6e5ddb
chore: remove a method implemetation in DrawingV2 interface
May 14, 2025
ccae82d
chore: code cleanup :recycle:
May 14, 2025
3eaf524
chore: update docs
May 14, 2025
cb26f0d
chore: update docs
May 14, 2025
0057328
chore: code cleanup :recycle:
May 14, 2025
e4259d6
chore: update docs
May 14, 2025
99c74f1
chore: update docs
May 14, 2025
48712a5
chore: update docs
May 14, 2025
222c4d8
add key to interactive layer custom painter
May 14, 2025
9823f02
fix: fix drawing style change not affecting
May 14, 2025
84d7af7
update drawing tools architecture diagram
May 15, 2025
bcdb25d
update drawing tools architecture diagram
May 15, 2025
9937a31
Merge remote-tracking branch 'upstream/master' into ramin/restructure…
May 15, 2025
a8bca70
use the interactive behaviour provided from outside
May 15, 2025
fbf70e1
Merge 'upstream/master' into ramin/restructure_drawing_tools_attempt_…
May 20, 2025
a1190c8
check if behaviour is initialized
May 20, 2025
a6ddff7
chore: rename drawing tools state from idle to normal
May 20, 2025
29c56be
update docs
May 20, 2025
863750a
chore: update docs
May 20, 2025
a5e323e
update doc
May 20, 2025
513f02f
chore: rename methods in InteractiveLayerBase
May 20, 2025
18dd234
feat: animation effect when dragging trend line in mobile
May 20, 2025
55a7470
chore: add a comment
May 20, 2025
c21813b
feat: trend line second point start position from center
May 20, 2025
18a4c36
update a doc
May 20, 2025
790aa07
animate second point in trend line after first when it spawned
May 21, 2025
59c7ccf
refactor: don't check hitTest in adding tool state pan update
May 21, 2025
157f591
have a map for drawings passed to layer
May 21, 2025
e63db3a
minor change in onPanEnd adding state
May 22, 2025
660a581
add flag to switch between new and old impl of drawing tools
May 22, 2025
e494ae0
chore: update drawing tools doc
May 22, 2025
c7f597d
chore: update drawing tools doc
May 22, 2025
b3fef68
add barrel files
May 22, 2025
2c824bf
fix export file formatting
May 22, 2025
e1f074e
remove unused code
May 22, 2025
7af7115
update a doc
May 22, 2025
0ccd02e
use LayoutBuilder instead to determine the layer size'
May 22, 2025
3aab569
new behaviour when adding trend line in mobile
May 22, 2025
55f159b
chore: code cleanup :recycle:
May 26, 2025
b64565c
feat: show trend line preview on mobile as dashed line
May 27, 2025
fa26a1b
feat: add chartConfig to drawingv2 paint methods
May 27, 2025
e4f0fe3
feat: add paintOverYAxis method to DrawingV2 class
May 27, 2025
460fd8e
WIP: update the preview label based on design
May 27, 2025
6016baf
feat: add chartTheme to the paint method as well
May 27, 2025
b0d0256
fix the drawing preview label color
May 27, 2025
3c76d65
feat: show the label when horizontal tools is selected
May 27, 2025
6b8349c
feat: showing neon glowing effect when horizontal line is selected
May 27, 2025
636b9e4
feat: showing selected tool menu
May 28, 2025
19834f3
check start-end point distance for onTap in CustomGestureDetector
May 28, 2025
c44e0cf
chore: code cleanup :recycle:
May 28, 2025
fd2ea37
check if initialized drawing are initailzied
May 28, 2025
5045b8c
chore: remove debugging code
May 29, 2025
28a24c1
Merge 'upstream/master' into ramin/add_horizontal_line_tool_v2
May 29, 2025
2075701
move current state to controller
May 30, 2025
f640e27
move floating menu widget and controller to a separate file
May 30, 2025
1ebf0b8
chore: code cleanup:
May 30, 2025
cca3f13
prevent floating menu going out of screen
May 30, 2025
c81fc66
get tool bar widget from each drawing themselves
May 30, 2025
cc196de
fix: drawing tools change not being applied
Jun 3, 2025
c13dc81
chore: code cleanup:
Jun 3, 2025
b589342
Merge remote-tracking branch 'upstream/master' into ramin/add_horizon…
Jun 4, 2025
99657e7
delete drawing when floating menu delete button is tapped
Jun 4, 2025
f732a80
code cleanup :recycle:
Jun 4, 2025
777886d
refactor: move showing floating menu to selected state
Jun 4, 2025
8837fce
remove dependency to controller in floating menu widget
Jun 4, 2025
d6161c9
avoid reanimating if the drawing tools is already selected
Jun 4, 2025
d6b8f03
endup in selected state after a tool is added
Jun 4, 2025
f231abd
preview line on desktop based on design
Jun 5, 2025
c1d9a56
add labelStyle to config
Jun 5, 2025
00960e7
generate toJson/fromJson for labelStyle
Jun 5, 2025
c848fd2
pass labelStyle to draw label function
Jun 5, 2025
12b21be
fix: drawing not focused after just being added
Jun 5, 2025
68c69cf
go to selected state in layer itself
Jun 5, 2025
16d6fb6
go to selected state inside behaviour class after a tool just been added
Jun 5, 2025
a55e47b
change the default textStyle of the horizontal line
Jun 5, 2025
2763dfd
fix: fix a formatting issue
Jun 5, 2025
d77eb31
update selected tool floating menu based on design
Jun 5, 2025
119a381
chore: code cleanup:
Jun 5, 2025
1e1b912
chore: code cleanup:
Jun 5, 2025
a21bae3
fix lint warnings
Jun 5, 2025
6046605
revert some unnecessary changes
Jun 5, 2025
73b77b3
add some doc
Jun 5, 2025
5a373d6
fix lint warnings
Jun 5, 2025
887464b
apply design on floating tool bar menu
Jun 6, 2025
5cbb8f7
update toolbar based on design
Jun 6, 2025
c4ecd18
reset drawing preview after tools is added
Jun 6, 2025
ad9e54c
fix: fix issue of tool removing sometimes not working
Jun 6, 2025
a34b275
fix: fix issue floating menu not dismissing if delete from outside menu
Jun 6, 2025
c3cd6ac
add animation for open/closing flaoting menu
Jun 6, 2025
660d00a
fix: label text not animating
Jun 6, 2025
d141e72
chore: code cleanup:
Jun 9, 2025
44301ae
chore: add a comment
Jun 9, 2025
360a2f2
code cleanup :recycle:
Jun 9, 2025
942acd5
fix issue tool not following when you select and drag in one move
Jun 9, 2025
822a0b4
dispose contollers in interactive_layer.dart
Jun 9, 2025
d578f2b
minor change
Jun 9, 2025
8b95685
fix formatting
Jun 9, 2025
ca7a9b9
prevent re-selecting the tool which is already selected
Jun 9, 2025
d017e4f
make switching to different selected tools smooth
Jun 9, 2025
87a15d9
don't animate the other tool if we switch the selected tool
Jun 9, 2025
8fc71ff
update horizontal line painting based on design
Jun 9, 2025
51f9f01
code cleanup :recycle:
Jun 9, 2025
e9142cb
add neon effect to label as well
Jun 11, 2025
f82d755
fix delay when adding preview appears
Jun 11, 2025
0decbc2
don't animate even when switching selected tool on panStart
Jun 11, 2025
54b8d32
provide size as context to drawings
Jun 11, 2025
f856fe0
fix: hitTest for horizontal line not return true when touch position …
Jun 11, 2025
d746360
chore: remove debounce when saving drawing tools
Jun 12, 2025
be8f836
revert pubspec change
Jun 12, 2025
42cedc3
fix formatting
Jun 12, 2025
ed27cb4
minor change in UI dimensions
Jun 12, 2025
1fc1048
make the floating menu initial position customizable
Jun 12, 2025
adecc7e
fix lint warnings
Jun 12, 2025
b58881b
Merge branch 'ramin/add_horizontal_line_tool_v2' of github.com:ramin-…
jim-deriv Jun 12, 2025
8c023b7
Merge branch 'master' of github.com:deriv-com/flutter-chart into jim/…
jim-deriv Jun 24, 2025
46eaf1c
feat: add fibonacci fan drawing tool to the interactive layer
jim-deriv Jun 25, 2025
ec66e2c
refactor: use ratios from the FibonacciFanHelpers class
jim-deriv Jun 25, 2025
b55f42e
style: resolve code formatting issue
jim-deriv Jun 25, 2025
43aad46
feat: add edge points for preview drawing on mobile
jim-deriv Jun 25, 2025
b91f50b
chore: adjust the y-position of the fibonacci fan drawing tool on mobile
jim-deriv Jun 25, 2025
654b9ff
fix(fibfan): correct upside-down preview orientation on mobile
jim-deriv Jun 26, 2025
a49fe19
refactor(fibfan): extract common validation logic into utility methods
jim-deriv Jun 26, 2025
eb6a8bc
refactor(fibfan): Replace magic numbers with centralized constants
jim-deriv Jun 26, 2025
b68ec6d
docs(fibfan): Add comprehensive documentation and fix analyzer issues
jim-deriv Jun 26, 2025
ddbc324
perf(fibfan): Implement paint object caching for improved rendering p…
jim-deriv Jun 26, 2025
c5fb6a0
feat(showcase): Add expandable controls to all chart example screens
jim-deriv Jun 26, 2025
d925d0a
chore: remove unnecessary comment
jim-deriv Jun 26, 2025
1118efc
feat: implement angle-based Fibonacci fan calculations
jim-deriv Jun 26, 2025
1963b9f
fix(fibfan): only the edgePoint being dragged should glow
jim-deriv Jun 26, 2025
7afb70a
docs(fibfan): add documentation for edge point visual feedback logic
jim-deriv Jun 26, 2025
6073dc2
feat(fibfan): enhance control point visibility and remove mobile glow…
jim-deriv Jun 30, 2025
1fca11c
fix(fibfan): reverse fan angle mapping and fix hit testing consistency
jim-deriv Jun 30, 2025
12ecc09
perf(fibfan): optimize text painter cache to eliminate performance bo…
jim-deriv Jul 1, 2025
ede97a5
refactor(fibfan): replace nullable bool with enum for drag state
jim-deriv Jul 1, 2025
1c78e8f
fix(fibfan): align mobile preview angle calculations with main fan
jim-deriv Jul 1, 2025
8eed82c
Merge branch 'master' of github.com:deriv-com/flutter-chart into jim/…
jim-deriv Jul 9, 2025
0899b16
fix: resolve Fibonacci Fan compilation errors and implement completio…
jim-deriv Jul 9, 2025
97f7e57
feat: update Fibonacci Fan toolbar to match horizontal line implement…
jim-deriv Jul 9, 2025
057f7c1
feat: update generated files and configurations for fibonacci fan dra…
jim-deriv Jul 14, 2025
31c6bc2
feat: add 4 color selection slots for fibfan drawing tool
jim-deriv Jul 14, 2025
8edd545
fix: make fibfan fill color match level0 color from fibonacciLevelColors
jim-deriv Jul 14, 2025
02bd1a1
Fix Fibonacci fan angle calculation and update drawing tool config
jim-deriv Jul 15, 2025
c892b9d
Merge branch 'master' of github.com:deriv-com/flutter-chart into jim/…
jim-deriv Jul 15, 2025
72a647d
feat: implement z-index functionality for edge point labels during dr…
jim-deriv Jul 15, 2025
06512b4
feat: apply z-index functionality to trend line drawing tool
jim-deriv Jul 15, 2025
45030a6
style: fix formatting in trend line drawing tool
jim-deriv Jul 15, 2025
09d6b65
feat: implement automated cache management for Fibonacci Fan drawing …
jim-deriv Jul 15, 2025
5ceb836
Fix generic type constraint in drawLabelsWithZIndex function
jim-deriv Jul 15, 2025
5b90b99
fix: enhance TextPainter cache key to include font family and weight
jim-deriv Jul 15, 2025
970d7b6
feat: make fibfan edge points use same color as top/bottom lines
jim-deriv Jul 17, 2025
cf8ceaa
feat: update fibfan alignment guides to use same color as edge points
jim-deriv Jul 17, 2025
29d1120
feat: update fibfan value and epoch labels to use same color as edge …
jim-deriv Jul 17, 2025
5c604b3
Fix label text colors to match border colors in drawEpochLabel and dr…
jim-deriv Jul 17, 2025
0538d4e
feat: implement crosshair visibility logic for drawing tool selection
jim-deriv Jul 17, 2025
71bb881
feat: make entire fibfan area draggable using fan fill logic
jim-deriv Jul 17, 2025
f8ed6aa
refactor: consolidate fibfan hit testing and drawing logic
jim-deriv Jul 17, 2025
00efac0
Merge branch 'master' of github.com:deriv-com/flutter-chart into jim/…
jim-deriv Sep 26, 2025
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
20 changes: 10 additions & 10 deletions lib/src/add_ons/drawing_tools_ui/drawing_tools_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,39 @@ class _DrawingToolsDialogState extends State<DrawingToolsDialog> {
DropdownButton<DrawingToolConfig>(
value: _selectedDrawingTool,
hint: Text(ChartLocalization.of(context).selectDrawingTool),
items: const <DropdownMenuItem<DrawingToolConfig>>[
DropdownMenuItem<DrawingToolConfig>(
items: <DropdownMenuItem<DrawingToolConfig>>[
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Channel'),
value: ChannelDrawingToolConfig(),
),
DropdownMenuItem<DrawingToolConfig>(
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Continuous'),
value: ContinuousDrawingToolConfig(),
),
DropdownMenuItem<DrawingToolConfig>(
child: Text('Fib Fan'),
child: const Text('Fib Fan'),
value: FibfanDrawingToolConfig(),
),
DropdownMenuItem<DrawingToolConfig>(
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Horizontal'),
value: HorizontalDrawingToolConfig(),
),
DropdownMenuItem<DrawingToolConfig>(
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Line'),
value: LineDrawingToolConfig(),
),
DropdownMenuItem<DrawingToolConfig>(
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Ray'),
value: RayDrawingToolConfig(),
),
DropdownMenuItem<DrawingToolConfig>(
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Rectangle'),
value: RectangleDrawingToolConfig()),
DropdownMenuItem<DrawingToolConfig>(
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Trend'),
value: TrendDrawingToolConfig(),
),
DropdownMenuItem<DrawingToolConfig>(
const DropdownMenuItem<DrawingToolConfig>(
child: Text('Vertical'),
value: VerticalDrawingToolConfig(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import 'package:deriv_chart/src/add_ons/drawing_tools_ui/callbacks.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/drawing_tools/data_model/drawing_pattern.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/drawing_tools/data_model/edge_point.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/drawing_tools/drawing_data.dart';
import 'package:deriv_chart/src/deriv_chart/chart/helpers/color_converter.dart';
import 'package:deriv_chart/src/deriv_chart/chart/helpers/text_style_json_converter.dart';
import 'package:deriv_chart/src/deriv_chart/interactive_layer/drawing_context.dart';
import 'package:deriv_chart/src/deriv_chart/interactive_layer/helpers/types.dart';
import 'package:deriv_chart/src/deriv_chart/interactive_layer/interactable_drawings/fibfan/fibfan_interactable_drawing.dart';
import 'package:deriv_chart/src/theme/design_tokens/core_design_tokens.dart';
import 'package:deriv_chart/src/theme/design_tokens/light_theme_design_tokens.dart';
import 'package:deriv_chart/src/theme/painting_styles/line_style.dart';
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
Expand All @@ -13,16 +20,34 @@ part 'fibfan_drawing_tool_config.g.dart';

/// Fibfan drawing tool config
@JsonSerializable()
@ColorConverter()
class FibfanDrawingToolConfig extends DrawingToolConfig {
/// Initializes
const FibfanDrawingToolConfig({
FibfanDrawingToolConfig({
String? configId,
DrawingData? drawingData,
List<EdgePoint> edgePoints = const <EdgePoint>[],
this.fillStyle = const LineStyle(thickness: 0.9, color: Colors.blue),
this.lineStyle = const LineStyle(thickness: 0.9, color: Colors.white),
this.fibonacciLevelColors = const <String, Color>{
'level0': CoreDesignTokens.coreColorSolidBlue700, // Blue for 0%
'level38_2': LightThemeDesignTokens
.semanticColorSeawaterSolidBorderStaticMid, // Cyan for 38.2%
'level50': LightThemeDesignTokens
.semanticColorMustardSolidBorderStaticHigh, // Amber for 50%
'level61_8': LightThemeDesignTokens
.semanticColorYellowSolidBorderStaticMid, // Orange for 61.8%
'level100': CoreDesignTokens.coreColorSolidBlue700, // Blue for 100%
},
LineStyle? fillStyle,
this.lineStyle =
const LineStyle(color: CoreDesignTokens.coreColorSolidBlue700),
this.labelStyle = const TextStyle(
color: CoreDesignTokens.coreColorSolidBlue700,
fontSize: 12,
),
super.number,
}) : super(
}) : fillStyle =
fillStyle ?? LineStyle(color: fibonacciLevelColors['level0']!),
super(
configId: configId,
drawingData: drawingData,
edgePoints: edgePoints,
Expand All @@ -45,6 +70,13 @@ class FibfanDrawingToolConfig extends DrawingToolConfig {
/// Drawing tool fill style
final LineStyle fillStyle;

/// Colors for each Fibonacci level
final Map<String, Color> fibonacciLevelColors;

/// The style of the label showing on y-axis.
@TextStyleJsonConverter()
final TextStyle labelStyle;

@override
DrawingToolItem getItem(
UpdateDrawingTool updateDrawingTool,
Expand All @@ -62,17 +94,39 @@ class FibfanDrawingToolConfig extends DrawingToolConfig {
DrawingData? drawingData,
LineStyle? lineStyle,
LineStyle? fillStyle,
TextStyle? labelStyle,
DrawingPatterns? pattern,
List<EdgePoint>? edgePoints,
bool? enableLabel,
int? number,
Map<String, Color>? fibonacciLevelColors,
}) =>
FibfanDrawingToolConfig(
configId: configId ?? this.configId,
drawingData: drawingData ?? this.drawingData,
lineStyle: lineStyle ?? this.lineStyle,
fillStyle: fillStyle ?? this.fillStyle,
labelStyle: labelStyle ?? this.labelStyle,
edgePoints: edgePoints ?? this.edgePoints,
number: number ?? this.number,
fibonacciLevelColors: fibonacciLevelColors ?? this.fibonacciLevelColors,
);

@override
FibfanInteractableDrawing getInteractableDrawing(
DrawingContext drawingContext,
GetDrawingState getDrawingState,
) {
final EdgePoint? startPoint =
edgePoints.isNotEmpty ? edgePoints.first : null;
final EdgePoint? endPoint = edgePoints.length > 1 ? edgePoints[1] : null;

return FibfanInteractableDrawing(
config: this,
startPoint: startPoint,
endPoint: endPoint,
drawingContext: drawingContext,
getDrawingState: getDrawingState,
);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import '../callbacks.dart';
/// Fibfan drawing tool item in the list of drawing tools
class FibfanDrawingToolItem extends DrawingToolItem {
/// Initializes
const FibfanDrawingToolItem({
FibfanDrawingToolItem({
required UpdateDrawingTool updateDrawingTool,
required VoidCallback deleteDrawingTool,
Key? key,
FibfanDrawingToolConfig config = const FibfanDrawingToolConfig(),
FibfanDrawingToolConfig? config,
}) : super(
key: key,
title: 'Fib fan',
config: config,
config: config ?? FibfanDrawingToolConfig(),
updateDrawingTool: updateDrawingTool,
deleteDrawingTool: deleteDrawingTool,
);
Expand Down
71 changes: 69 additions & 2 deletions lib/src/deriv_chart/interactive_layer/helpers/paint_helpers.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import 'dart:ui';

import 'package:deriv_chart/src/add_ons/drawing_tools_ui/drawing_tool_config.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/chart_data.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/drawing_tools/data_model/drawing_paint_style.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/drawing_tools/data_model/edge_point.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/models/animation_info.dart';
import 'package:deriv_chart/src/deriv_chart/chart/helpers/chart_date_utils.dart';
import 'package:deriv_chart/src/deriv_chart/interactive_layer/interactive_layer_export.dart';
import 'package:deriv_chart/src/models/chart_config.dart';
import 'package:deriv_chart/src/theme/chart_theme.dart';
import 'package:deriv_chart/src/theme/painting_styles/line_style.dart';
import 'package:flutter/material.dart';

import '../enums/drawing_tool_state.dart';
import 'types.dart';

/// Draws alignment guides (horizontal and vertical lines) for a single point
void drawPointAlignmentGuides(Canvas canvas, Size size, Offset pointOffset,
{Color lineColor = const Color(0x80FFFFFF)}) {
Expand Down Expand Up @@ -202,7 +210,7 @@ void drawValueLabel({
final TextPainter textPainter = _getTextPainter(
formattedValue,
textStyle: textStyle.copyWith(
color: textStyle.color?.withOpacity(animationProgress),
color: color.withOpacity(animationProgress),
),
)..layout();

Expand Down Expand Up @@ -283,7 +291,7 @@ void drawEpochLabel({
final TextPainter textPainter = _getTextPainter(
formattedTime,
textStyle: textStyle.copyWith(
color: textStyle.color?.withOpacity(animationProgress),
color: color.withOpacity(animationProgress),
),
)..layout();

Expand Down Expand Up @@ -327,6 +335,65 @@ void drawEpochLabel({
);
}

/// Helper method to draw labels with proper z-index based on drag state.
///
/// This method handles the logic for drawing labels in the correct order
/// to ensure the dragged point's labels appear on top of the non-dragged point's labels.
///
/// **Parameters:**
/// - [canvas]: The canvas to draw on
/// - [size]: The size of the drawing area
/// - [animationInfo]: Animation information for state changes
/// - [chartConfig]: Chart configuration
/// - [chartTheme]: Chart theme
/// - [getDrawingState]: Function to get the current drawing state
/// - [drawStartPointLabel]: Callback function to draw the start point label
/// - [drawEndPointLabel]: Callback function to draw the end point label
/// - [isDraggingStartPoint]: Whether the start point is currently being dragged
/// - [isDraggingEndPoint]: Whether the end point is currently being dragged
///
/// **Usage:**
/// This function is designed to be reusable across different drawing tools that have
/// two edge points and need proper z-index handling during drag operations.
void drawLabelsWithZIndex<T extends DrawingToolConfig>({
required Canvas canvas,
required Size size,
required AnimationInfo animationInfo,
required ChartConfig chartConfig,
required ChartTheme chartTheme,
required GetDrawingState getDrawingState,
required InteractableDrawing<T> drawing,
required void Function() drawStartPointLabel,
required void Function() drawEndPointLabel,
required bool isDraggingStartPoint,
required bool isDraggingEndPoint,
}) {
if (!getDrawingState(drawing).contains(DrawingToolState.selected)) {
return;
}

// When dragging individual points, draw the non-dragged point first (lower z-index)
// and the dragged point last (higher z-index)
if (getDrawingState(drawing).contains(DrawingToolState.dragging) &&
(isDraggingStartPoint || isDraggingEndPoint)) {
if (isDraggingStartPoint) {
// Start point is being dragged, so draw end point first (lower z-index)
drawEndPointLabel();
// Then draw start point (higher z-index)
drawStartPointLabel();
} else {
// End point is being dragged, so draw start point first (lower z-index)
drawStartPointLabel();
// Then draw end point (higher z-index)
drawEndPointLabel();
}
} else {
// Default behavior when not dragging individual points
drawStartPointLabel();
drawEndPointLabel();
}
}

/// Returns a [TextPainter] for the given formatted value and color.
TextPainter _getTextPainter(
String formattedValue, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// Enum representing the different drag states for Fibonacci Fan drawing tool.
///
/// This enum provides clear, explicit states for drag interactions, improving
/// code readability and reducing the risk of misinterpreting the drag state
/// compared to using a nullable boolean.
enum FibfanDragState {
/// User is dragging the start point of the fan.
///
/// In this state, only the start point moves while the end point remains fixed.
/// This allows users to adjust the origin of the Fibonacci fan lines.
draggingStartPoint,

/// User is dragging the end point of the fan.
///
/// In this state, only the end point moves while the start point remains fixed.
/// This allows users to adjust the direction and scale of the Fibonacci fan lines.
draggingEndPoint,

/// User is dragging the entire fan.
///
/// In this state, both start and end points move together, maintaining their
/// relative positions. This allows users to reposition the entire fan without
/// changing its shape or orientation.
draggingEntireFan,
}
Loading
Loading