Skip to content

Commit fbd79fe

Browse files
committed
refactor: update HorizontalBarrierPainter and TickIndicator to use dynamic rightMargin
1 parent 1755232 commit fbd79fe

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

lib/src/deriv_chart/chart/data_visualization/annotations/barriers/horizontal_barrier/horizontal_barrier_painter.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ class HorizontalBarrierPainter<T extends HorizontalBarrier>
2323

2424
late Paint _paint;
2525

26-
/// Right margin.
27-
static const double rightMargin = 4;
28-
2926
/// Distance between title area and label area.
3027
static const double _distanceBetweenTitleAndLabel = 16;
3128

@@ -124,7 +121,7 @@ class HorizontalBarrierPainter<T extends HorizontalBarrier>
124121
final Rect labelArea = Rect.fromCenter(
125122
center: Offset(
126123
size.width -
127-
rightMargin -
124+
style.rightMargin -
128125
style.labelPadding -
129126
valuePainter.width / 2,
130127
y),

lib/src/deriv_chart/chart/data_visualization/annotations/barriers/horizontal_barrier/tick_indicator.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ class TickIndicator extends HorizontalBarrier {
2020
String? id,
2121
HorizontalBarrierStyle? style,
2222
HorizontalBarrierVisibility visibility = HorizontalBarrierVisibility.normal,
23+
bool longLine = false,
2324
}) : super(
2425
tick.quote,
2526
epoch: tick.epoch,
2627
id: id,
2728
style: style ??
2829
const HorizontalBarrierStyle(labelShape: LabelShape.pentagon),
2930
visibility: visibility,
30-
longLine: false,
31+
longLine: longLine,
3132
);
3233
}
3334

lib/src/theme/painting_styles/barrier_style.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class HorizontalBarrierStyle extends BarrierStyle {
4343
this.labelShape = LabelShape.rectangle,
4444
this.labelHeight = 24,
4545
this.labelPadding = 4,
46+
this.rightMargin = 4,
4647
Color color = const Color(0xFF00A79E),
4748
Color titleBackgroundColor = const Color(0xFF0E0E0E),
4849
this.secondaryBackgroundColor = const Color(0xFF607D8B),
@@ -78,6 +79,9 @@ class HorizontalBarrierStyle extends BarrierStyle {
7879
/// Padding of label.
7980
final double labelPadding;
8081

82+
/// Right margin of the label from the edge of the chart.
83+
final double rightMargin;
84+
8185
/// Whether to have a blinking dot animation where barrier and chart data
8286
/// are intersected.
8387
final bool hasBlinkingDot;
@@ -116,6 +120,7 @@ class HorizontalBarrierStyle extends BarrierStyle {
116120
LabelShape? labelShape,
117121
double? labelHeight,
118122
double? labelPadding,
123+
double? rightMargin,
119124
Color? color,
120125
Color? titleBackgroundColor,
121126
Color? secondaryBackgroundColor,
@@ -132,6 +137,7 @@ class HorizontalBarrierStyle extends BarrierStyle {
132137
labelShape: labelShape ?? this.labelShape,
133138
labelHeight: labelHeight ?? this.labelHeight,
134139
labelPadding: labelPadding ?? this.labelPadding,
140+
rightMargin: rightMargin ?? this.rightMargin,
135141
color: color ?? this.color,
136142
titleBackgroundColor: titleBackgroundColor ?? this.titleBackgroundColor,
137143
secondaryBackgroundColor:

0 commit comments

Comments
 (0)