Skip to content

Commit 75c2e0d

Browse files
committed
feat: add loading animation control for historical data
1 parent b7f6d7a commit 75c2e0d

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

lib/src/deriv_chart/chart/chart.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Chart extends StatefulWidget {
7777
this.bottomChartTitleMargin,
7878
this.showDataFitButton,
7979
this.showScrollToLastTickButton,
80+
this.showLoadingAnimationForHistoricalData = true,
8081
this.loadingAnimationColor,
8182
this.useDrawingToolsV2 = false,
8283
this.enableYAxisScaling = true,
@@ -188,6 +189,14 @@ class Chart extends StatefulWidget {
188189
/// Whether to show the scroll to last tick button or not.
189190
final bool? showScrollToLastTickButton;
190191

192+
/// Whether to show the loading animation for historical data.
193+
///
194+
/// When set to `false`, the loading animation will always be hidden.
195+
/// When set to `true` (default), the visibility will be determined by
196+
/// the [dataFitEnabled] property (hidden when dataFitEnabled is true,
197+
/// shown otherwise).
198+
final bool showLoadingAnimationForHistoricalData;
199+
191200
/// The color of the loading animation.
192201
final Color? loadingAnimationColor;
193202

lib/src/deriv_chart/chart/chart_state_mobile.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ class _ChartStateMobile extends _ChartState {
125125
onCrosshairAppeared: widget.onCrosshairAppeared,
126126
onQuoteAreaChanged: widget.onQuoteAreaChanged,
127127
isLive: widget.isLive,
128-
showLoadingAnimationForHistoricalData: !widget.dataFitEnabled,
128+
showLoadingAnimationForHistoricalData:
129+
widget.showLoadingAnimationForHistoricalData &&
130+
!widget.dataFitEnabled,
129131
showDataFitButton:
130132
widget.showDataFitButton ?? widget.dataFitEnabled,
131133
showScrollToLastTickButton:

lib/src/deriv_chart/chart/chart_state_web.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class _ChartStateWeb extends _ChartState {
3030
onCrosshairAppeared: widget.onCrosshairAppeared,
3131
onQuoteAreaChanged: widget.onQuoteAreaChanged,
3232
isLive: widget.isLive,
33-
showLoadingAnimationForHistoricalData: !widget.dataFitEnabled,
33+
showLoadingAnimationForHistoricalData:
34+
widget.showLoadingAnimationForHistoricalData &&
35+
!widget.dataFitEnabled,
3436
showDataFitButton:
3537
widget.showDataFitButton ?? widget.dataFitEnabled,
3638
showScrollToLastTickButton:

lib/src/deriv_chart/deriv_chart.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class DerivChart extends StatefulWidget {
6666
this.bottomChartTitleMargin,
6767
this.showDataFitButton,
6868
this.showScrollToLastTickButton,
69+
this.showLoadingAnimationForHistoricalData = true,
6970
this.loadingAnimationColor,
7071
this.crosshairVariant = CrosshairVariant.smallScreen,
7172
this.interactiveLayerBehaviour,
@@ -174,6 +175,14 @@ class DerivChart extends StatefulWidget {
174175
/// Whether to show the scroll to last tick button or not.
175176
final bool? showScrollToLastTickButton;
176177

178+
/// Whether to show the loading animation for historical data.
179+
///
180+
/// When set to `false`, the loading animation will always be hidden.
181+
/// When set to `true` (default), the visibility will be determined by
182+
/// the [dataFitEnabled] property (hidden when dataFitEnabled is true,
183+
/// shown otherwise).
184+
final bool showLoadingAnimationForHistoricalData;
185+
177186
/// The color of the loading animation.
178187
final Color? loadingAnimationColor;
179188

@@ -409,6 +418,8 @@ class _DerivChartState extends State<DerivChart> {
409418
bottomChartTitleMargin: widget.bottomChartTitleMargin,
410419
showDataFitButton: widget.showDataFitButton,
411420
showScrollToLastTickButton: widget.showScrollToLastTickButton,
421+
showLoadingAnimationForHistoricalData:
422+
widget.showLoadingAnimationForHistoricalData,
412423
loadingAnimationColor: widget.loadingAnimationColor,
413424
chartAxisConfig: widget.chartAxisConfig,
414425
crosshairVariant: widget.crosshairVariant,

0 commit comments

Comments
 (0)