Skip to content

refactor: Jim/grwt 5290/update crosshair UI based on design refactor #386

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

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
877c1ad
chore: update crosshair and move it to interactive layer
jim-deriv May 8, 2025
7fd072c
chore: add candle highlighter painter
jim-deriv May 8, 2025
08a1b84
chore: make local variables final
jim-deriv May 8, 2025
bee755d
chore: hide dot for candles
jim-deriv May 9, 2025
abfb6d5
chore: replace gestureManager from context with the internal GestureD…
jim-deriv May 9, 2025
d4ba6dd
chore: replace old drawing tools
jim-deriv May 10, 2025
981408f
chore: change return types for event and gesture handlers
jim-deriv May 10, 2025
cc15a6d
refactor: separate small and large screen crosshair line
jim-deriv May 13, 2025
d718f5d
chore: add CrosshairLinePainter base class
jim-deriv May 13, 2025
b09f989
fix: fix crosshair header colour
jim-deriv May 13, 2025
89d11b9
feat: implement gesture arena
jim-deriv May 13, 2025
af91d57
chore: add theme and crosshair toggles
jim-deriv May 13, 2025
8952992
chore: create gesture recogniser only once
jim-deriv May 13, 2025
8a8a4c9
chore: make showCrosshair required for MainChart
jim-deriv May 13, 2025
c9d2490
implement crosshair highlight painter
jim-deriv May 13, 2025
d42d0be
style: fix formatting issue
jim-deriv May 13, 2025
f9f02c8
chore: set light theme as the default in showcase_app
jim-deriv May 14, 2025
09068ea
chore rename property from enabled to isCrosshairActive
jim-deriv May 14, 2025
9bf3fbc
Merge branch 'master' of github.com:deriv-com/flutter-chart into jim/…
jim-deriv May 14, 2025
29ac969
style: resolve formatting issues
jim-deriv May 14, 2025
5f0cc6d
chore: ignore hover events for small screens
jim-deriv May 14, 2025
261adab
perf: add RepaintBoundary
jim-deriv May 15, 2025
4b81567
chore: user blur from the theme
jim-deriv May 16, 2025
0b02399
chore: move the IntrinsicWidth widget deeper into the tree
jim-deriv May 16, 2025
9a08a76
style: fix formatting issues
jim-deriv May 16, 2025
01068fb
Merge branch 'master' of github.com:deriv-com/flutter-chart into jim/…
jim-deriv May 16, 2025
c23f7af
chore: remove unnecessary even handler
jim-deriv May 16, 2025
3a05cb1
chore: remove extra padding and update font size to 10px
jim-deriv May 16, 2025
d8463f6
docs: add documentation for the _calculateDetailsPosition method
jim-deriv May 17, 2025
4623dee
feat: add CrosshairBehaviour
jim-deriv May 21, 2025
295e95d
Merge branch 'master' of github.com:deriv-com/flutter-chart into jim/…
jim-deriv May 21, 2025
c7dd77c
chore: add override annotation
jim-deriv May 21, 2025
2e98d46
docs: add documentation
jim-deriv May 21, 2025
bf2322f
refactor: replace the factory pattern with the strategy pattern
jim-deriv May 21, 2025
04e2c16
refactor: update folder structure
jim-deriv May 21, 2025
fc3ddec
style: resolve formatting issues
jim-deriv May 21, 2025
5b5e15e
chore: make dot painter non nullable
jim-deriv May 28, 2025
4d485d6
chore: make dot painter return type non-nullable and remove width pro…
jim-deriv May 28, 2025
c7ccf69
chore: implement shouldRepaint logic for line and dot painter
jim-deriv May 28, 2025
8d1bd2b
chore: rename gesture recogniser funtion
jim-deriv May 28, 2025
184a538
chore: update blur to 24
jim-deriv May 28, 2025
9db3512
chore: add no-op painter to address review comments
jim-deriv May 28, 2025
fb39c6a
refactor: move logic to private method to avoid code duplication
jim-deriv May 28, 2025
57b4577
refactor: make method private to address code reviews
jim-deriv May 28, 2025
173c0cc
chore: address code reviews
jim-deriv May 28, 2025
9980e77
chore: address code reviews
jim-deriv May 28, 2025
1a50244
style: resolve formatting issues
jim-deriv May 28, 2025
8c1257d
chore: remove unused property
jim-deriv May 28, 2025
ea700f8
chore: fix failing tests and address code review comments
jim-deriv May 28, 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
4 changes: 4 additions & 0 deletions lib/deriv_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,7 @@ export 'src/deriv_chart/chart/data_visualization/models/chart_scale_model.dart';
export 'src/deriv_chart/chart/data_visualization/markers/marker_props.dart';
export 'src/theme/colors.dart';
export 'src/add_ons/drawing_tools_ui/drawing_tools_dialog.dart';
export 'src/deriv_chart/interactive_layer/crosshair/core/crosshair_variant.dart';
export 'src/deriv_chart/interactive_layer/crosshair/behaviour/crosshair_behaviour.dart';
export 'src/deriv_chart/interactive_layer/crosshair/behaviour/line_series_crosshair_behaviour.dart';
export 'src/deriv_chart/interactive_layer/crosshair/behaviour/ohlc_series_crosshair_behaviour.dart';
28 changes: 13 additions & 15 deletions lib/src/deriv_chart/chart/bottom_chart.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:deriv_chart/src/widgets/bottom_indicator_title.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:deriv_chart/deriv_chart.dart';
import 'package:deriv_chart/src/deriv_chart/chart/crosshair/crosshair_area_web.dart';
import 'package:provider/provider.dart';

import 'basic_chart.dart';
Expand Down Expand Up @@ -173,18 +171,18 @@ class _BottomChartState extends BasicChartState<BottomChart> {
),
);
}

Widget _buildCrosshairAreaWeb() => CrosshairAreaWeb(
mainSeries: widget.mainSeries,
epochFromCanvasX: xAxis.epochFromX,
quoteFromCanvasY: chartQuoteFromCanvasY,
epochToCanvasX: xAxis.xFromEpoch,
quoteToCanvasY: chartQuoteToCanvasY,
quoteLabelsTouchAreaWidth: quoteLabelsTouchAreaWidth,
showCrosshairCursor: widget.showCrosshair,
onCrosshairDisappeared: widget.onCrosshairDisappeared,
onCrosshairHover: widget.onCrosshairHover,
);
// TODO(Jim): Remember to address the crosshair area for web indicators.
// Widget _buildCrosshairAreaWeb() => CrosshairAreaWeb(
// mainSeries: widget.mainSeries,
// epochFromCanvasX: xAxis.epochFromX,
// quoteFromCanvasY: chartQuoteFromCanvasY,
// epochToCanvasX: xAxis.xFromEpoch,
// quoteToCanvasY: chartQuoteToCanvasY,
// quoteLabelsTouchAreaWidth: quoteLabelsTouchAreaWidth,
// showCrosshairCursor: widget.showCrosshair,
// onCrosshairDisappeared: widget.onCrosshairDisappeared,
// onCrosshairHover: widget.onCrosshairHover,
// );

@override
Widget build(BuildContext context) {
Expand All @@ -208,7 +206,7 @@ class _BottomChartState extends BasicChartState<BottomChart> {
Expanded(child: super.build(context)),
],
),
if (kIsWeb) _buildCrosshairAreaWeb(),
// if (kIsWeb) _buildCrosshairAreaWeb(), // TODO(Jim): Address the crosshair area for web indicators.
_buildBottomChartOptions(context)
],
),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/deriv_chart/chart/bottom_chart_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ class IndicatorLabelMobile extends StatelessWidget {
borderRadius: BorderRadius.circular(Dimens.margin04),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: Dimens.crosshairInformationBoxContainerGlassBackgroundBlur,
sigmaY: Dimens.crosshairInformationBoxContainerGlassBackgroundBlur),
sigmaX: theme.crosshairInformationBoxContainerGlassBackgroundBlur,
sigmaY: theme.crosshairInformationBoxContainerGlassBackgroundBlur),
child: Container(
padding: const EdgeInsets.all(Dimens.margin04),
decoration: BoxDecoration(
Expand Down
17 changes: 17 additions & 0 deletions lib/src/deriv_chart/chart/chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'package:collection/collection.dart';
import 'package:deriv_chart/src/deriv_chart/chart/data_visualization/models/chart_scale_model.dart';
import 'package:deriv_chart/src/deriv_chart/chart/mobile_chart_frame_dividers.dart';
import 'package:deriv_chart/src/deriv_chart/chart/x_axis/x_axis_model.dart';
import 'package:deriv_chart/src/deriv_chart/interactive_layer/crosshair/behaviour/crosshair_behaviour.dart';
import 'package:deriv_chart/src/deriv_chart/interactive_layer/crosshair/core/crosshair_variant.dart';
import 'package:deriv_chart/src/theme/dimens.dart';
import 'package:flutter/foundation.dart';
import 'package:deriv_chart/src/deriv_chart/chart/gestures/gesture_manager.dart';
Expand Down Expand Up @@ -43,6 +45,7 @@ class Chart extends StatefulWidget {
const Chart({
required this.mainSeries,
required this.granularity,
required this.crosshairVariant,
this.drawingTools,
this.pipSize = 4,
this.controller,
Expand Down Expand Up @@ -74,6 +77,7 @@ class Chart extends StatefulWidget {
this.showDataFitButton,
this.showScrollToLastTickButton,
this.loadingAnimationColor,
this.crosshairBehaviour,
Key? key,
}) : super(key: key);

Expand Down Expand Up @@ -185,6 +189,19 @@ class Chart extends StatefulWidget {
/// Chart's indicators
final Repository<IndicatorConfig>? indicatorsRepo;

/// The variant of the crosshair to be used.
/// This is used to determine the type of crosshair to display.
/// The default is [CrosshairVariant.smallScreen].
/// [CrosshairVariant.largeScreen] is mostly for web.
final CrosshairVariant crosshairVariant;

/// The behavior implementation that defines how the crosshair should be displayed.
///
/// If provided, this behavior will be used instead of the default behavior created
/// based on the chart's main series and the specified crosshair variant. This allows
/// for customization of the crosshair appearance and behavior.
final CrosshairBehaviour? crosshairBehaviour;

@override
State<StatefulWidget> createState() =>
// TODO(Ramin): Make this customizable from outside.
Expand Down
1 change: 1 addition & 0 deletions lib/src/deriv_chart/chart/chart_state_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class _ChartStateMobile extends _ChartState {
quoteBoundsAnimationDuration: quoteBoundsAnimationDuration,
showCurrentTickBlinkAnimation:
widget.showCurrentTickBlinkAnimation ?? true,
crosshairVariant: widget.crosshairVariant,
),
Align(
alignment: Alignment.topLeft,
Expand Down
1 change: 1 addition & 0 deletions lib/src/deriv_chart/chart/chart_state_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class _ChartStateWeb extends _ChartState {
quoteBoundsAnimationDuration: quoteBoundsAnimationDuration,
showCurrentTickBlinkAnimation:
widget.showCurrentTickBlinkAnimation ?? true,
crosshairVariant: widget.crosshairVariant,
),
),
if (bottomSeries?.isNotEmpty ?? false)
Expand Down
234 changes: 0 additions & 234 deletions lib/src/deriv_chart/chart/crosshair/crosshair_area.dart

This file was deleted.

Loading
Loading