Skip to content

feat: add buildSemantics to base classes and vertical barrier painter #388

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 1 commit into
base: master
Choose a base branch
from

Conversation

behnam-deriv
Copy link
Contributor

@behnam-deriv behnam-deriv commented May 29, 2025

Clickup link: https://app.clickup.com/t/20696747/GRWT-6126
Fixes issue: #

This PR contains the following changes:

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Developers Note (Optional)

Pre-launch Checklist (For PR creator)

As a creator of this PR:

  • ✍️ I have included clickup id and package/app_name in the PR title.
  • 👁️ I have gone through the code and removed any temporary changes (commented lines, prints, debug statements etc.).
  • ⚒️ I have fixed any errors/warnings shown by the analyzer/linter.
  • 📝 I have added documentation, comments and logging wherever required.
  • 🧪 I have added necessary tests for these changes.
  • 🔎 I have ensured all existing tests are passing.

Reviewers

Pre-launch Checklist (For Reviewers)

As a reviewer I ensure that:

  • ✴️ This PR follows the standard PR template.
  • 🪩 The information in this PR properly reflects the code changes.
  • 🧪 All the necessary tests for this PR's are passing.

Pre-launch Checklist (For QA)

  • 👌 It passes the acceptance criteria.

Pre-launch Checklist (For Maintainer)

  • [MAINTAINER_NAME] I make sure this PR fulfills its purpose.

Summary by Sourcery

Add accessibility semantics support across chart components by defining buildSemantics methods on chart data and painters, integrating semanticsBuilder in ChartPainter, and initializing semantics in the example app.

New Features:

  • Provide accessibility semantics for chart elements via CustomPainterSemantics entries in vertical barrier painter
  • Expose buildSemantics interface on ChartData, Series, and SeriesPainter to propagate semantic nodes
  • Integrate SemanticsBinding initialization in example app to enable semantics

Enhancements:

  • Refactor VerticalBarrierPainter by extracting helper methods for animation, line positioning, title layout, and label positioning
  • Add default buildSemantics stub implementations in various painters (barriers, candles, markers, indicators, data painters)

Copy link

sourcery-ai bot commented May 29, 2025

Reviewer's Guide

This PR introduces accessibility semantics across the chart rendering pipeline by extending the ChartData and SeriesPainter interfaces, wiring a semanticsBuilder in ChartPainter and example app, and adding buildSemantics overrides to most painter classes. It also refactors VerticalBarrierPainter by extracting helper methods for animation, line placement, and labeling, and implements full semantics support for vertical barriers.

Sequence Diagram for Chart Semantics Generation

sequenceDiagram
    title Sequence Diagram for Chart Semantics Generation
    participant Client as "Flutter Engine/SemanticsBinding"
    participant ChartPainter_Instance as "ChartPainter"
    participant Series_Instance as "Series (implements ChartData)"
    participant SeriesPainter_Instance as "SeriesPainter (e.g. VerticalBarrierPainter)"

    Client->>ChartPainter_Instance: Accesses semanticsBuilder property
    ChartPainter_Instance->>Series_Instance: buildSemantics(size, epochToX, quoteToY)
    Series_Instance->>SeriesPainter_Instance: buildSemantics(size, epochToX, quoteToY)
    SeriesPainter_Instance-->>Series_Instance: Returns List~CustomPainterSemantics~
    Series_Instance-->>ChartPainter_Instance: Returns List~CustomPainterSemantics~
    ChartPainter_Instance-->>Client: Provides SemanticsBuilderCallback (which returns the List)
Loading

File-Level Changes

Change Details Files
Refactor VerticalBarrierPainter to modularize drawing logic and add full semantics support
  • Extract _calculateAnimatedEpoch, _calculateDotY, _calculateLinePositions, _createTitlePainter, and _calculateTitleStartX helper methods
  • Simplify onPaint to delegate to the extracted helpers
  • Implement buildSemantics to produce CustomPainterSemantics for the barrier line and its label
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/vertical_barrier/vertical_barrier_painter.dart
Introduce semantics API in core chart abstractions and wire it up
  • Add abstract buildSemantics to ChartData and SeriesPainter
  • Implement buildSemantics in Series to delegate to its painter
  • Add semanticsBuilder getter in ChartPainter to invoke chartData.buildSemantics
  • Initialize SemanticsBinding in example main and import flutter/semantics
lib/src/deriv_chart/chart/data_visualization/chart_data.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/series_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/series.dart
lib/src/deriv_chart/chart/custom_painters/chart_painter.dart
example/lib/main.dart
Add placeholder buildSemantics overrides in various painter classes
  • Override buildSemantics in HorizontalBarrierPainter and IconBarrierPainter
  • Override buildSemantics stub in EntryTickAnnotationPainter
  • Override buildSemantics stub in CandlePainter, HollowCandlePainter, and OhlcCandlePainter
  • Override buildSemantics stub in MarkerPainter
  • Override buildSemantics stub in Accumulators*IndicatorPainter classes
  • Override buildSemantics stub in BarPainter, ScatterPainter, ArrowPainter, SampleMultiPainter, ChannelFillPainter, LinePainter, and MarkerGroupPainter
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/horizontal_barrier/horizontal_barrier_painter.dart
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/horizontal_barrier/icon_barrier_painter.dart
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/entry_tick_annotation.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/ohlc_series/candle/candle_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/ohlc_series/hollow_candle/hollow_candle_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/ohlc_series/ohlc_candle/ohlc_candle_painter.dart
lib/src/deriv_chart/chart/data_visualization/markers/marker_painter.dart
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/accumulators_barriers/accumulators_closed_indicator_painter.dart
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/accumulators_barriers/accumulators_entry_spot_barrier_painter.dart
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/accumulators_barriers/accumulators_indicator_painter.dart
lib/src/deriv_chart/chart/data_visualization/annotations/barriers/accumulators_barriers/accumulators_recently_closed_indicator_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/data_painters/bar_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/data_painters/scatter_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/indicators_series/fractals_series/arrow_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/indicators_series/sample_multi_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/line_series/channel_fill_painter.dart
lib/src/deriv_chart/chart/data_visualization/chart_series/line_series/line_painter.dart
lib/src/deriv_chart/chart/data_visualization/markers/marker_group_painter.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant