From 183d7b2924762a0a9c8be8d78163f24f3d0bf512 Mon Sep 17 00:00:00 2001 From: mobile-apps-deriv <134251399+mobile-apps-deriv@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:12:29 +0800 Subject: [PATCH 1/9] chore(version): bump version and update changelog (#820) Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 36 +++++++++++++++++++ packages/deriv_auth/CHANGELOG.md | 4 +++ packages/deriv_auth/pubspec.yaml | 10 +++--- packages/deriv_language_selector/CHANGELOG.md | 4 +++ packages/deriv_language_selector/pubspec.yaml | 4 +-- .../deriv_mobile_chart_wrapper/CHANGELOG.md | 4 +++ .../deriv_mobile_chart_wrapper/pubspec.yaml | 4 +-- packages/deriv_passkeys/CHANGELOG.md | 4 +++ packages/deriv_passkeys/pubspec.yaml | 4 +-- packages/deriv_ui/CHANGELOG.md | 4 +++ packages/deriv_ui/pubspec.yaml | 2 +- packages/deriv_widgetbook/CHANGELOG.md | 4 +++ packages/deriv_widgetbook/pubspec.yaml | 4 +-- 13 files changed, 74 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 867141883..3eb23f974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,42 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-09-13 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`deriv_ui` - `v0.1.0+2`](#deriv_ui---v0102) + - [`deriv_language_selector` - `v0.0.3+9`](#deriv_language_selector---v0039) + - [`deriv_widgetbook` - `v0.0.2+29`](#deriv_widgetbook---v00229) + - [`deriv_passkeys` - `v0.0.4+4`](#deriv_passkeys---v0044) + - [`deriv_auth` - `v6.7.48`](#deriv_auth---v6748) + - [`deriv_mobile_chart_wrapper` - `v0.1.0+4`](#deriv_mobile_chart_wrapper---v0104) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `deriv_language_selector` - `v0.0.3+9` + - `deriv_widgetbook` - `v0.0.2+29` + - `deriv_passkeys` - `v0.0.4+4` + - `deriv_auth` - `v6.7.48` + - `deriv_mobile_chart_wrapper` - `v0.1.0+4` + +--- + +#### `deriv_ui` - `v0.1.0+2` + + - **FIX**(deriv-ui): [DRGO-126]call the passed onDispose method inside dispose method ([#819](https://github.com/regentmarkets/flutter-deriv-packages/issues/819)). ([2e29a1ee](https://github.com/regentmarkets/flutter-deriv-packages/commit/2e29a1eeb7dbb5c77bc04e1e7f7ee12081a1fd2d)) + + ## 2024-09-11 ### Changes diff --git a/packages/deriv_auth/CHANGELOG.md b/packages/deriv_auth/CHANGELOG.md index ac97afb3b..9f1b27e29 100644 --- a/packages/deriv_auth/CHANGELOG.md +++ b/packages/deriv_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.7.48 + + - Update a dependency to the latest release. + ## 6.7.47 - Update a dependency to the latest release. diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 6f5266fee..f1b4b3b78 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_auth description: Provides deriv authentication functionalities for dart/flutter apps. -version: 6.7.47 +version: 6.7.48 environment: sdk: ">=3.0.0 <4.0.0" @@ -28,7 +28,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.1.0+1 + ref: deriv_ui-v0.1.0+2 deriv_http_client: git: @@ -57,13 +57,13 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: deriv_passkeys-v0.0.4+3 + ref: deriv_passkeys-v0.0.4+4 deriv_language_selector: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_language_selector - ref: deriv_language_selector-v0.0.3+8 + ref: deriv_language_selector-v0.0.3+9 flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 @@ -79,7 +79,7 @@ dependency_overrides: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.1.0+1 + ref: deriv_ui-v0.1.0+2 dev_dependencies: mocktail: ^1.0.3 diff --git a/packages/deriv_language_selector/CHANGELOG.md b/packages/deriv_language_selector/CHANGELOG.md index 790be5483..f8e3c3a28 100644 --- a/packages/deriv_language_selector/CHANGELOG.md +++ b/packages/deriv_language_selector/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.3+9 + + - Update a dependency to the latest release. + ## 0.0.3+8 - Update a dependency to the latest release. diff --git a/packages/deriv_language_selector/pubspec.yaml b/packages/deriv_language_selector/pubspec.yaml index 5332fb9d0..d36b4f834 100644 --- a/packages/deriv_language_selector/pubspec.yaml +++ b/packages/deriv_language_selector/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_language_selector description: A package to select language for the app. It provides both UI and logic for language selection. -version: 0.0.3+8 +version: 0.0.3+9 publish_to: "none" environment: @@ -14,7 +14,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.1.0+1 + ref: deriv_ui-v0.1.0+2 shared_preferences: ^2.2.2 flutter_bloc: ^8.1.4 equatable: ^2.0.5 diff --git a/packages/deriv_mobile_chart_wrapper/CHANGELOG.md b/packages/deriv_mobile_chart_wrapper/CHANGELOG.md index 3500f2b59..8a9435fbe 100644 --- a/packages/deriv_mobile_chart_wrapper/CHANGELOG.md +++ b/packages/deriv_mobile_chart_wrapper/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.0+4 + + - Update a dependency to the latest release. + ## 0.1.0+3 - **FIX**(deriv_mobile_chart_wrapper): fix text alignment ([#816](https://github.com/regentmarkets/flutter-deriv-packages/issues/816)). ([8fd35364](https://github.com/regentmarkets/flutter-deriv-packages/commit/8fd35364760d7bc1b101f9414a2d9d340a1b5a32)) diff --git a/packages/deriv_mobile_chart_wrapper/pubspec.yaml b/packages/deriv_mobile_chart_wrapper/pubspec.yaml index 49525b9f5..52ca368e9 100644 --- a/packages/deriv_mobile_chart_wrapper/pubspec.yaml +++ b/packages/deriv_mobile_chart_wrapper/pubspec.yaml @@ -1,7 +1,7 @@ name: deriv_mobile_chart_wrapper description: A new Flutter package project. publish_to: "none" # Remove this line if you wish to publish to pub.dev -version: 0.1.0+3 +version: 0.1.0+4 homepage: @@ -32,7 +32,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.1.0+1 + ref: deriv_ui-v0.1.0+2 provider: ^6.0.5 flutter_svg: ^2.0.9 diff --git a/packages/deriv_passkeys/CHANGELOG.md b/packages/deriv_passkeys/CHANGELOG.md index 64c59989f..caa11cb61 100644 --- a/packages/deriv_passkeys/CHANGELOG.md +++ b/packages/deriv_passkeys/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.4+4 + + - Update a dependency to the latest release. + ## 0.0.4+3 - Update a dependency to the latest release. diff --git a/packages/deriv_passkeys/pubspec.yaml b/packages/deriv_passkeys/pubspec.yaml index 77822a6d7..bef435a46 100644 --- a/packages/deriv_passkeys/pubspec.yaml +++ b/packages/deriv_passkeys/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_passkeys description: Deriv Passkeys Flutter Plugin -version: 0.0.4+3 +version: 0.0.4+4 publish_to: "none" environment: @@ -32,7 +32,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.1.0+1 + ref: deriv_ui-v0.1.0+2 deriv_http_client: git: diff --git a/packages/deriv_ui/CHANGELOG.md b/packages/deriv_ui/CHANGELOG.md index 6ec789f96..14e7a9727 100644 --- a/packages/deriv_ui/CHANGELOG.md +++ b/packages/deriv_ui/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.0+2 + + - **FIX**(deriv-ui): [DRGO-126]call the passed onDispose method inside dispose method ([#819](https://github.com/regentmarkets/flutter-deriv-packages/issues/819)). ([2e29a1ee](https://github.com/regentmarkets/flutter-deriv-packages/commit/2e29a1eeb7dbb5c77bc04e1e7f7ee12081a1fd2d)) + ## 0.1.0+1 - **FIX**(deriv_ui): fix value selector issues. ([#800](https://github.com/regentmarkets/flutter-deriv-packages/issues/800)). ([9c783d58](https://github.com/regentmarkets/flutter-deriv-packages/commit/9c783d58d52e753ede1ee40a9da4ce038ed1c991)) diff --git a/packages/deriv_ui/pubspec.yaml b/packages/deriv_ui/pubspec.yaml index 260d3ffb4..1c84a20ee 100644 --- a/packages/deriv_ui/pubspec.yaml +++ b/packages/deriv_ui/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_ui description: A new Flutter package project. -version: 0.1.0+1 +version: 0.1.0+2 publish_to: none environment: diff --git a/packages/deriv_widgetbook/CHANGELOG.md b/packages/deriv_widgetbook/CHANGELOG.md index e96edfaa7..21ef1ddc6 100644 --- a/packages/deriv_widgetbook/CHANGELOG.md +++ b/packages/deriv_widgetbook/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.2+29 + + - Update a dependency to the latest release. + ## 0.0.2+28 - Update a dependency to the latest release. diff --git a/packages/deriv_widgetbook/pubspec.yaml b/packages/deriv_widgetbook/pubspec.yaml index 2984d63a3..41aad3835 100644 --- a/packages/deriv_widgetbook/pubspec.yaml +++ b/packages/deriv_widgetbook/pubspec.yaml @@ -1,7 +1,7 @@ name: deriv_widgetbook description: Storybook for Deriv UI widgets and components. publish_to: "none" -version: 0.0.2+28 +version: 0.0.2+29 environment: sdk: ">=3.0.0 <4.0.0" @@ -16,7 +16,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.1.0+1 + ref: deriv_ui-v0.1.0+2 deriv_theme: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git From ebd9ab92707630df3bc185aab5a503399df786b4 Mon Sep 17 00:00:00 2001 From: Ilya <106583608+ilya-deriv@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:21:20 +0300 Subject: [PATCH 2/9] feat(deriv_mobile_chart_wrapper): [DRGO-74] Add drawing tools bottom sheet UI (#815) --- .../icons/ic_drawing_tools_empty_state.svg | 12 + .../assets/icons/ic_line.svg | 5 + .../lib/src/assets.dart | 6 + .../lib/src/helpers.dart | 30 ++ .../lib/src/mobile_chart_wrapper.dart | 45 ++- .../active_drawing_tool_list_item.dart | 66 ++++ .../drawing_tool_icon_button.dart | 0 .../drawing_tools/drawing_tool_list_item.dart | 73 +++++ .../drawing_tools/drawing_tools_selector.dart | 281 ++++++++++++++++++ .../src/mobile_tools_ui/mobile_tools_ui.dart | 2 +- .../lib/src/models/config_item_model.dart | 7 +- .../src/models/drawing_tool_item_model.dart | 20 ++ .../deriv_mobile_chart_wrapper/pubspec.yaml | 2 + 13 files changed, 541 insertions(+), 8 deletions(-) create mode 100644 packages/deriv_mobile_chart_wrapper/assets/icons/ic_drawing_tools_empty_state.svg create mode 100644 packages/deriv_mobile_chart_wrapper/assets/icons/ic_line.svg create mode 100644 packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart rename packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/{ => drawing_tools}/drawing_tool_icon_button.dart (100%) create mode 100644 packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart create mode 100644 packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart create mode 100644 packages/deriv_mobile_chart_wrapper/lib/src/models/drawing_tool_item_model.dart diff --git a/packages/deriv_mobile_chart_wrapper/assets/icons/ic_drawing_tools_empty_state.svg b/packages/deriv_mobile_chart_wrapper/assets/icons/ic_drawing_tools_empty_state.svg new file mode 100644 index 000000000..f1cb865c6 --- /dev/null +++ b/packages/deriv_mobile_chart_wrapper/assets/icons/ic_drawing_tools_empty_state.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/packages/deriv_mobile_chart_wrapper/assets/icons/ic_line.svg b/packages/deriv_mobile_chart_wrapper/assets/icons/ic_line.svg new file mode 100644 index 000000000..559f43486 --- /dev/null +++ b/packages/deriv_mobile_chart_wrapper/assets/icons/ic_line.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/assets.dart b/packages/deriv_mobile_chart_wrapper/lib/src/assets.dart index 91b2945d8..7b25ee92c 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/assets.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/assets.dart @@ -1,5 +1,6 @@ const String iconAssetsFolder = 'assets/icons/'; +/// Indicators assets path. const String macdIcon = '${iconAssetsFolder}ic_macd.svg'; const String rsiIcon = '${iconAssetsFolder}ic_rsi.svg'; const String bollingerBandsIcon = '${iconAssetsFolder}ic_bollinger_bands.svg'; @@ -7,4 +8,9 @@ const String movingAverageIcon = '${iconAssetsFolder}ic_moving_average.svg'; const String indicatorsMenuIcon = '${iconAssetsFolder}ic_indicators_menu.svg'; const String emptyStateIndicatorsIcon = '${iconAssetsFolder}ic_indicators_empty_state.svg'; + +/// Drawing tools assets path. +const String lineIcon = '${iconAssetsFolder}ic_line.svg'; +const String emptyStateDrawingToolsIcon = + '${iconAssetsFolder}ic_drawing_tools_empty_state.svg'; const String drawingToolIcon = '${iconAssetsFolder}ic_drawing_tool.svg'; diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart b/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart index 3e939af8c..5c162b928 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart @@ -1,6 +1,7 @@ import 'package:deriv_chart/deriv_chart.dart'; import 'package:deriv_mobile_chart_wrapper/src/assets.dart'; import 'package:deriv_mobile_chart_wrapper/src/extensions.dart'; +import 'package:deriv_mobile_chart_wrapper/src/models/drawing_tool_item_model.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/utils/popup_dialogs_helper.dart'; import 'package:flutter/material.dart'; @@ -43,6 +44,35 @@ String getIndicatorIconPath(IndicatorConfig config) { } } +/// Returns the path to the icon of the drawing tool +/// for the given [drawingToolType]. +String getDrawingToolIconPath(Type drawingToolType) { + switch (drawingToolType) { + case LineDrawingToolConfig: + return lineIcon; + case RayDrawingToolConfig: + return rsiIcon; + default: + return ''; + } +} + +List getDrawingToolsList(BuildContext context) { + List drawingTools = [ + DrawingToolItemModel( + title: context.mobileChartWrapperLocalizations.labelLine, + icon: lineIcon, + config: const LineDrawingToolConfig(), + ), + DrawingToolItemModel( + title: context.mobileChartWrapperLocalizations.labelRay, + icon: macdIcon, + config: const RayDrawingToolConfig(), + ), + ]; + return drawingTools; +} + Map getSourcesOptions(BuildContext context) => { 'close': context.mobileChartWrapperLocalizations.labelClose, 'open': context.mobileChartWrapperLocalizations.labelOpen, diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart index fd683ebc6..0d67ef00b 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart @@ -1,5 +1,6 @@ import 'package:deriv_chart/deriv_chart.dart'; import 'package:deriv_mobile_chart_wrapper/src/extensions.dart'; +import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart'; import 'package:deriv_mobile_chart_wrapper/src/models/config_item_model.dart'; import 'package:deriv_mobile_chart_wrapper/src/models/indicator_tab_label.dart'; import 'package:deriv_ui/components/components.dart'; @@ -163,6 +164,7 @@ class MobileChartWrapper extends StatefulWidget { class MobileChartWrapperState extends State { AddOnsRepository? _indicatorsRepo; AddOnsRepository? _drawingToolsRepo; + final DrawingTools _drawingTools = DrawingTools(); @override void initState() { @@ -191,10 +193,16 @@ class MobileChartWrapperState extends State { _showDrawingToolsSheet(_drawingToolsRepo!); } }; + _indicatorsRepo?.addListener(() { - _updateIndicatorsConfig(); + _updateConfigs(); + }); + + _drawingToolsRepo?.addListener(() { + _updateConfigs(); }); - _updateIndicatorsConfig(); + + _updateConfigs(); } void _initRepos() async { @@ -274,7 +282,29 @@ class MobileChartWrapperState extends State { void _showDrawingToolsSheet( AddOnsRepository drawingToolsRepo) { - ///Todo(osama): Implement the drawing tools sheet. + setState(() { + _drawingTools + ..init() + ..drawingToolsRepo = drawingToolsRepo; + }); + showModalBottomSheet( + context: context, + builder: (_) => + ChangeNotifierProvider>.value( + value: drawingToolsRepo, + child: SafeArea( + child: DerivBottomSheet( + title: context.mobileChartWrapperLocalizations.labelDrawingTools, + child: DrawingToolSelector( + onSelection: (DrawingToolConfig selectedDrawingTool) { + _drawingTools.onDrawingToolSelection(selectedDrawingTool); + Navigator.of(context).pop(); + }, + ), + ), + ), + ), + ); } @override @@ -293,6 +323,7 @@ class MobileChartWrapperState extends State { DrawingToolConfig.fromJson(map), sharedPrefKey: widget.toolsStoreKey, ), + drawingTools: _drawingTools, controller: widget.controller, mainSeries: widget.mainSeries, markerSeries: widget.markerSeries, @@ -307,8 +338,10 @@ class MobileChartWrapperState extends State { activeSymbol: widget.toolsStoreKey, ); - void _updateIndicatorsConfig() { - widget.toolsController?.updateConfigs( - ConfigItemModel(indicatorConfigs: _indicatorsRepo?.items ?? [])); + void _updateConfigs() { + widget.toolsController?.updateConfigs(ConfigItemModel( + indicatorConfigs: _indicatorsRepo?.items ?? [], + drawingToolConfigs: _drawingToolsRepo?.items ?? [], + )); } } diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart new file mode 100644 index 000000000..7930edbe6 --- /dev/null +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart @@ -0,0 +1,66 @@ +import 'package:deriv_mobile_chart_wrapper/src/extensions.dart'; +import 'package:deriv_theme/deriv_theme.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +/// List item for the active drawing tools list. +class ActiveDrawingToolListItem extends StatelessWidget { + /// Initializes the active indicator list item. + const ActiveDrawingToolListItem({ + required this.iconAssetPath, + required this.title, + required this.onTapSettings, + required this.onTapDelete, + super.key, + }); + + /// The path to the SVG icon asset. + final String iconAssetPath; + + /// The title of the drawing tool. + final String title; + + /// The callback which will be called when the + /// drawing tool settings button is tapped. + final VoidCallback onTapSettings; + + /// The callback which will be called when the + /// drawing tool delete button is tapped. + final VoidCallback onTapDelete; + + @override + Widget build(BuildContext context) { + return Card( + margin: EdgeInsets.zero, + color: context.themeProvider.colors.secondary, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(ThemeProvider.borderRadius08), + ), + ), + child: ListTile( + leading: SvgPicture.asset( + iconAssetPath, + height: ThemeProvider.iconSize24, + package: 'deriv_mobile_chart_wrapper', + ), + title: Text(title), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + onPressed: () {}, + color: context.themeProvider.colors.prominent, + icon: const Icon(Icons.settings_outlined), + ), + IconButton( + onPressed: () {}, + color: context.themeProvider.colors.prominent, + icon: const Icon(Icons.delete_outline), + ), + ], + ), + ), + ); + } +} diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tool_icon_button.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_icon_button.dart similarity index 100% rename from packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tool_icon_button.dart rename to packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_icon_button.dart diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart new file mode 100644 index 000000000..553ac419c --- /dev/null +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart @@ -0,0 +1,73 @@ +import 'package:deriv_mobile_chart_wrapper/src/extensions.dart'; +import 'package:deriv_theme/deriv_theme.dart'; +import 'package:deriv_ui/widgets/widgets.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +/// List item widget to show a drawing tool. +class DrawingToolListItem extends StatelessWidget { + /// Constructor of the widget + const DrawingToolListItem({ + required this.iconAssetPath, + required this.title, + required this.onTap, + this.count = 0, + super.key, + }); + + /// The path to the SVG icon asset. + final String iconAssetPath; + + /// The title of the drawing tool. + final String title; + + /// The callback which will be called when the drawing tool item is tapped. + final VoidCallback onTap; + + /// Number of added drawing tools of this type. + /// + /// It will show in the item if it's greater than 0. + final int count; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + behavior: HitTestBehavior.translucent, + child: Padding( + padding: const EdgeInsets.all(ThemeProvider.margin16), + child: Row( + children: [ + _buildDrawingToolIcon(), + const SizedBox(width: Dimens.margin08), + _buildDrawingToolTitle(context), + const SizedBox(width: Dimens.margin08), + _buildDrawingToolBadge(count), + ], + ), + ), + ); + } + + Widget _buildDrawingToolIcon() => SvgPicture.asset( + iconAssetPath, + width: ThemeProvider.margin24, + height: ThemeProvider.margin24, + package: 'deriv_mobile_chart_wrapper', + ); + + Widget _buildDrawingToolTitle(BuildContext context) => Text( + title, + style: context.themeProvider.textStyle( + textStyle: TextStyles.body1, + color: context.themeProvider.colors.general, + ), + ); + + Widget _buildDrawingToolBadge(int count) { + return DerivBadge( + count: count, + enabled: count > 0, + ); + } +} diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart new file mode 100644 index 000000000..e10420bec --- /dev/null +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart @@ -0,0 +1,281 @@ +import 'package:deriv_chart/deriv_chart.dart'; +import 'package:deriv_mobile_chart_wrapper/src/assets.dart'; +import 'package:deriv_mobile_chart_wrapper/src/extensions.dart'; +import 'package:deriv_mobile_chart_wrapper/src/helpers.dart'; +import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart'; +import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart'; +import 'package:deriv_mobile_chart_wrapper/src/models/drawing_tool_item_model.dart'; +import 'package:deriv_theme/deriv_theme.dart'; +import 'package:deriv_ui/deriv_ui.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class DrawingToolSelector extends StatefulWidget { + const DrawingToolSelector({ + required this.onSelection, + super.key, + }); + + /// Drawing tools selection callback. + final void Function(DrawingToolConfig drawingToolConfig)? onSelection; + + @override + State createState() => _DrawingToolSelectorState(); +} + +class _DrawingToolSelectorState extends State + with SingleTickerProviderStateMixin { + late TabController _tabController; + final List _activeDrawingTools = []; + + late List _drawingTools; + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 2, vsync: this); + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + _drawingTools = getDrawingToolsList(context); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + + void _onToolSelection(DrawingToolItemModel selectedTool) { + setState(() { + if (_activeDrawingTools.contains(selectedTool)) { + _activeDrawingTools.remove(selectedTool); + } else { + _activeDrawingTools.add(selectedTool); + } + }); + } + + @override + Widget build(BuildContext context) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: context.theme.colors.disabled, + width: ThemeProvider.margin02, + ), + ), + ), + ), + TabBar( + controller: _tabController, + indicatorColor: context.theme.colors.danger, + labelStyle: context.theme.textStyle( + textStyle: TextStyles.body2, + color: context.theme.colors.prominent, + ), + unselectedLabelStyle: context.theme.textStyle( + textStyle: TextStyles.body1, + color: context.theme.colors.general, + ), + tabs: [ + Tab( + text: + '${context.mobileChartWrapperLocalizations.labelActive} (${_activeDrawingTools.length})'), + Tab(text: context.mobileChartWrapperLocalizations.labelTools), + ], + ), + ], + ), + Expanded( + child: Ink( + color: context.theme.colors.primary, + child: TabBarView( + controller: _tabController, + children: [ + _buildActiveDrawingToolsTab(context), + _buildDrawingToolListTab(context), + ], + ), + ), + ), + ], + ); + } + + Widget _buildActiveDrawingToolsTab(BuildContext context) { + if (_activeDrawingTools.isEmpty) { + return _buildDrawingToolEmptyState(); + } else { + return _buildActiveDrawingToolsList(); + } + } + + Widget _buildActiveDrawingToolsList() { + return Column( + children: [ + _buildActiveTabHeader(), + Expanded( + child: ListView( + children: _activeDrawingTools + .map( + (tool) => Card( + margin: const EdgeInsets.symmetric( + horizontal: ThemeProvider.margin16, + vertical: ThemeProvider.margin08, + ), + color: context.themeProvider.colors.secondary, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(ThemeProvider.borderRadius08), + ), + ), + child: ActiveDrawingToolListItem( + iconAssetPath: tool.icon, + title: tool.title, + onTapDelete: () {}, + onTapSettings: () {}, + ), + ), + ) + .toList(), + ), + ), + ], + ); + } + + Widget _buildDrawingToolListTab(BuildContext context) { + return ListView( + children: _drawingTools.map((toolItem) { + final List selectedToolItems = _activeDrawingTools + .where((DrawingToolItemModel activeToolItem) => + activeToolItem == toolItem) + .toList(); + return DrawingToolListItem( + iconAssetPath: toolItem.icon, + title: toolItem.title, + count: selectedToolItems.length, + onTap: () => _onToolSelection(toolItem), + ); + }).toList(), + ); + } + + Widget _buildDrawingToolEmptyState() { + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset( + emptyStateDrawingToolsIcon, + height: Dimens.iconSize48, + package: 'deriv_mobile_chart_wrapper', + ), + const SizedBox(height: ThemeProvider.margin08), + Text( + context.mobileChartWrapperLocalizations + .informNoActiveDrawingTools, + style: context.themeProvider.textStyle( + textStyle: TextStyles.body1, + color: const Color(0xFF999999), + ), + ), + ], + ), + ), + ), + Container( + color: context.theme.colors.secondary, + padding: const EdgeInsets.all(ThemeProvider.margin16), + child: PrimaryButton( + child: Text( + context.mobileChartWrapperLocalizations.actionAddDrawingTool, + style: context.theme.textStyle( + textStyle: TextStyles.body2, + color: context.theme.colors.prominent, + ), + ), + onPressed: () { + setState(() { + _tabController.animateTo(1); + }); + }, + ), + ), + ], + ); + } + + Widget _buildActiveTabHeader() { + return Padding( + padding: const EdgeInsets.only( + top: ThemeProvider.margin16, + bottom: ThemeProvider.margin08, + left: ThemeProvider.margin16, + right: ThemeProvider.margin16, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Visibility( + visible: _activeDrawingTools.isNotEmpty, + maintainSize: true, + maintainState: true, + maintainAnimation: true, + child: SecondaryButton( + onPressed: _showDeleteAllDrawingToolsDialog, + child: Center( + child: Text( + context.mobileChartWrapperLocalizations.labelDeleteAll, + style: context.themeProvider.textStyle( + textStyle: TextStyles.caption, + color: context.themeProvider.colors.prominent, + ), + ), + ), + ), + ), + ], + ), + ); + } + + void _showDeleteAllDrawingToolsDialog() { + showAlertDialog( + context: context, + title: context.mobileChartWrapperLocalizations.labelDeleteAllIndicators, + content: Text( + context.mobileChartWrapperLocalizations.infoDeleteAllIndicators, + style: TextStyles.subheading, + ), + positiveActionLabel: + context.mobileChartWrapperLocalizations.labelDeleteAll, + negativeButtonLabel: + context.mobileChartWrapperLocalizations.labelCancel, + showLoadingIndicator: false, + onPositiveActionPressed: () { + _activeDrawingTools.clear(); + setState(() {}); + Navigator.pop(context); + }, + onNegativeActionPressed: () { + Navigator.pop(context); + }); + } +} diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart index 15d7273f3..726294bd5 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart @@ -5,4 +5,4 @@ export 'indicator_list_item.dart'; export 'indicator_menu_button.dart'; export 'mobile_tools_bottom_sheet_content.dart'; export 'tools_controller.dart'; -export 'drawing_tool_icon_button.dart'; +export 'drawing_tools/drawing_tool_icon_button.dart'; diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/models/config_item_model.dart b/packages/deriv_mobile_chart_wrapper/lib/src/models/config_item_model.dart index e49e4d2be..5cc169b48 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/models/config_item_model.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/models/config_item_model.dart @@ -3,5 +3,10 @@ import 'package:deriv_mobile_chart_wrapper/deriv_mobile_chart_wrapper.dart'; class ConfigItemModel { final List indicatorConfigs; - ConfigItemModel({required this.indicatorConfigs}); + final List drawingToolConfigs; + + ConfigItemModel({ + required this.indicatorConfigs, + required this.drawingToolConfigs, + }); } diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/models/drawing_tool_item_model.dart b/packages/deriv_mobile_chart_wrapper/lib/src/models/drawing_tool_item_model.dart new file mode 100644 index 000000000..5aa9809bc --- /dev/null +++ b/packages/deriv_mobile_chart_wrapper/lib/src/models/drawing_tool_item_model.dart @@ -0,0 +1,20 @@ +import 'package:deriv_chart/deriv_chart.dart'; + +/// Model class to keep the information of an drawing tool item. +class DrawingToolItemModel { + /// Initializes a drawing tool item model. + const DrawingToolItemModel({ + required this.title, + required this.icon, + required this.config, + }); + + /// The title. + final String title; + + /// The path to the SVG icon. + final String icon; + + /// The [config] property holds the drawing tool configuration. + final DrawingToolConfig config; +} diff --git a/packages/deriv_mobile_chart_wrapper/pubspec.yaml b/packages/deriv_mobile_chart_wrapper/pubspec.yaml index 52ca368e9..6a0cf82c8 100644 --- a/packages/deriv_mobile_chart_wrapper/pubspec.yaml +++ b/packages/deriv_mobile_chart_wrapper/pubspec.yaml @@ -60,6 +60,8 @@ flutter: - assets/icons/ic_indicators_menu.svg - assets/icons/ic_indicators_empty_state.svg - assets/icons/ic_drawing_tool.svg + - assets/icons/ic_drawing_tools_empty_state.svg + - assets/icons/ic_line.svg # # For details regarding assets in packages, see # https://flutter.dev/assets-and-images/#from-packages From 1d65034ccc0592d53d273dc6ddf7a14ebfac92a3 Mon Sep 17 00:00:00 2001 From: mobile-apps-deriv <134251399+mobile-apps-deriv@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:45:07 +0800 Subject: [PATCH 3/9] chore(version): bump version and update changelog (#822) Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: waqas-younas-deriv --- CHANGELOG.md | 21 +++++++++++++++++++ README.md | 14 ++++++------- .../deriv_mobile_chart_wrapper/CHANGELOG.md | 4 ++++ .../deriv_mobile_chart_wrapper/pubspec.yaml | 2 +- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eb23f974..1486f6dd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-09-18 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`deriv_mobile_chart_wrapper` - `v0.1.1`](#deriv_mobile_chart_wrapper---v011) + +--- + +#### `deriv_mobile_chart_wrapper` - `v0.1.1` + + - **FEAT**(deriv_mobile_chart_wrapper): [DRGO-74] Add drawing tools bottom sheet UI ([#815](https://github.com/regentmarkets/flutter-deriv-packages/issues/815)). ([ebd9ab92](https://github.com/regentmarkets/flutter-deriv-packages/commit/ebd9ab92707630df3bc185aab5a503399df786b4)) + + ## 2024-09-13 ### Changes diff --git a/README.md b/README.md index 6443aaab2..f917b0889 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ cp $HOME/Downloads/commit-msg $HOME/.git/hooks/commit-msg \ ## Using the packages -Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.7.47)`. To use the package, add the following to your pubspec.yaml file: +Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.7.48)`. To use the package, add the following to your pubspec.yaml file: ```yaml deriv_ui: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.1.0+1 #your prefered version + ref: deriv_ui-v0.1.0+2 #your prefered version ``` ## Packages @@ -30,7 +30,7 @@ deriv_ui: | Name | Description | Version | | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | | [analytics](./packages/analytics) | Used to collect and send analytical information to 'Firebase', 'Rudderstack' and 'Datadog'. | [v2.2.2](./packages/analytics/CHANGELOG.md) | | [v2.2.2](./packages/analytics/CHANGELOG.md) | -| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.7.47 ](./packages/deriv_auth/CHANGELOG.md) | +| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.7.48 ](./packages/deriv_auth/CHANGELOG.md) | | [deriv_banner](./packages/deriv_banner) | A widget to show banner in apps. | [v0.0.1+1](./packages/deriv_banner/CHANGELOG.md) | | [deriv_bloc_manager](./packages/deriv_bloc_manager) | Provides some tools to manage blocs. | [v0.0.1](./packages/deriv_bloc_manager/CHANGELOG.md) | | [deriv_datadog](./packages/deriv_datadog) | A package that helps you monitor the performance and user interactions of your Flutter app by sending data to Datadog. | [v0.0.1](./packages/deriv_datadog/CHANGELOG.md) | @@ -41,22 +41,22 @@ deriv_ui: | [deriv_http_client](./packages/deriv_http_client) | A package that provides a wrapper for http package. | [v2.0.0](./packages/deriv_http_client/CHANGELOG.md) | | [deriv_lint](./packages/deriv_lint) | A Dart package that provides lint rules for Dart and Flutter. | [v1.0.0](./packages/deriv_lint/CHANGELOG.md) | | [deriv_live_chat](./packages/deriv_live_chat) | A plugin for live chat SDK support to dart. | [v0.0.2](./packages/deriv_live_chat/CHANGELOG.md) | -| [deriv_language_selector](./packages/deriv_language_selector) | A package to handle language change of the app. | [v0.0.3+8](./packages/deriv_language_selector/CHANGELOG.md) | +| [deriv_language_selector](./packages/deriv_language_selector) | A package to handle language change of the app. | [v0.0.3+9](./packages/deriv_language_selector/CHANGELOG.md) | | [deriv_localizations](./packages/deriv_localizations) | A Package that contains the localization arb(coming from Crowdin) and dart generated files for flutter_deriv_packages. | [v1.6.0](./packages/deriv_localizations/CHANGELOG.md) | | [deriv_numpad](./packages/deriv_numpad) | Number Pad Widget for number input. | [v1.1.8](./packages/deriv_numpad/CHANGELOG.md) | | [deriv_rudderstack](./packages/deriv_rudderstack) | A plugin that add RudderStack SDK support to Flutter. | [v1.1.0](./packages/deriv_rudderstack/CHANGELOG.md) | | [deriv_store_launcher](./packages/deriv_store_launcher) | A plugin to launch app stores base on platform and manufacturer. | [v0.0.1+1](./packages/deriv_store_launcher/CHANGELOG.md) | | [deriv_technical_analysis](./packages/deriv_technical_analysis) | A Dart package for Technical Analysis. | [v0.0.1](./packages/deriv_technical_analysis/CHANGELOG.md) | | [deriv_theme](./packages/deriv_theme) | A package that contains the theme used by Deriv products. | [v2.7.0](./packages/deriv_theme/CHANGELOG.md) | -| [deriv_ui](./packages/deriv_ui) | A package that contains the UI components used by Deriv products. | [v0.1.0+1](./packages/deriv_ui/CHANGELOG.md) | +| [deriv_ui](./packages/deriv_ui) | A package that contains the UI components used by Deriv products. | [v0.1.0+2](./packages/deriv_ui/CHANGELOG.md) | | [deriv_utilities](./packages/deriv_utilities) | A package that contains the utilities including helper functions, mixins, and extensions. | [v1.0.0](./packages/deriv_utilities/CHANGELOG.md) | | [deriv_websocket](./packages/deriv_web_socket_client) | A package that provides a easy to use websocket client. | [v1.0.1](./packages/deriv_web_socket_client/CHANGELOG.md) | | [deriv_web_view](./packages/deriv_web_view) | Deriv web view package. | [v0.2.2+3](./packages/deriv_web_view/CHANGELOG.md) | -| [deriv_widgetbook](./packages/deriv_widgetbook) | Storybook for Deriv UI Widgets and Components | [v0.0.2+28](./packages/deriv_widgetbook/CHANGELOG.md) | +| [deriv_widgetbook](./packages/deriv_widgetbook) | Storybook for Deriv UI Widgets and Components | [v0.0.2+29](./packages/deriv_widgetbook/CHANGELOG.md) | | [form_builder](./packages/form_builder) | A simpler and cleaner way to create, validate and submit forms. | [v1.0.0+1](./packages/form_builder/CHANGELOG.md) | | [update_checker](./packages/update_checker) | Check and retrieve update information from the server for the given package. | [v1.5.1](./packages/update_checker/CHANGELOG.md) | | [deriv_feature_flag](./packages/deriv_feature_flag) | A package to provide feature flag functionality for apps. | [v0.1.1](./packages/deriv_feature_flag/CHANGELOG.md) | -| [deriv_mobile_chart_wrapper](./packages/deriv_mobile_chart_wrapper) | A wrapper package around package _**deriv_chart**_ to implement any functionality specific to mobile and can be wrapped around the main chart package. | [v0.1.0+3](./packages/deriv_mobile_chart_wrapper/CHANGELOG.md) | +| [deriv_mobile_chart_wrapper](./packages/deriv_mobile_chart_wrapper) | A wrapper package around package _**deriv_chart**_ to implement any functionality specific to mobile and can be wrapped around the main chart package. | [v0.1.1](./packages/deriv_mobile_chart_wrapper/CHANGELOG.md) | ## Environment Setup diff --git a/packages/deriv_mobile_chart_wrapper/CHANGELOG.md b/packages/deriv_mobile_chart_wrapper/CHANGELOG.md index 8a9435fbe..3401da667 100644 --- a/packages/deriv_mobile_chart_wrapper/CHANGELOG.md +++ b/packages/deriv_mobile_chart_wrapper/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.1 + + - **FEAT**(deriv_mobile_chart_wrapper): [DRGO-74] Add drawing tools bottom sheet UI ([#815](https://github.com/regentmarkets/flutter-deriv-packages/issues/815)). ([ebd9ab92](https://github.com/regentmarkets/flutter-deriv-packages/commit/ebd9ab92707630df3bc185aab5a503399df786b4)) + ## 0.1.0+4 - Update a dependency to the latest release. diff --git a/packages/deriv_mobile_chart_wrapper/pubspec.yaml b/packages/deriv_mobile_chart_wrapper/pubspec.yaml index 6a0cf82c8..b6335c139 100644 --- a/packages/deriv_mobile_chart_wrapper/pubspec.yaml +++ b/packages/deriv_mobile_chart_wrapper/pubspec.yaml @@ -1,7 +1,7 @@ name: deriv_mobile_chart_wrapper description: A new Flutter package project. publish_to: "none" # Remove this line if you wish to publish to pub.dev -version: 0.1.0+4 +version: 0.1.1 homepage: From abbb8905263517c32c1e990fdc9dbfd2fb38ae9b Mon Sep 17 00:00:00 2001 From: WAQAS YOUNAS <78855520+waqas-younas-deriv@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:03:58 +0400 Subject: [PATCH 4/9] fix(deriv_auth): unassigned token for account created on web (#756) Co-authored-by: ramin-deriv <55975218+ramin-deriv@users.noreply.github.com> --- .../auth/services/deriv_auth_service.dart | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/deriv_auth/lib/features/auth/services/deriv_auth_service.dart b/packages/deriv_auth/lib/features/auth/services/deriv_auth_service.dart index fe64da79c..ca14c5ab4 100644 --- a/packages/deriv_auth/lib/features/auth/services/deriv_auth_service.dart +++ b/packages/deriv_auth/lib/features/auth/services/deriv_auth_service.dart @@ -86,20 +86,10 @@ class DerivAuthService extends BaseAuthService { responseAuthorizeEntity!.copyWith( signupProvider: signupProvider, refreshToken: refreshToken, - accountList: responseAuthorizeEntity.accountList - ?.map( - (AccountListItem accountListItem) => accountListItem.copyWith( - token: accounts - .where( - (AccountModel element) => - element.accountId == accountListItem.loginid, - ) - .firstOrNull - ?.token ?? - token, - ), - ) - .toList(), + accountList: _getAccountListWithToken( + responseAuthorizeEntity.accountList, + accounts, + ), ); await authRepository.onLogin(_enhancedAuthorizeEntity); @@ -115,6 +105,28 @@ class DerivAuthService extends BaseAuthService { } } + List? _getAccountListWithToken( + List? accountListItems, + List accounts, + ) => + accountListItems?.map( + (AccountListItem accountListItem) { + final AccountModel? account = accounts.firstWhereOrNull( + (AccountModel element) => + element.accountId == accountListItem.loginid, + ); + + if (account == null) { + throw DerivAuthException( + message: 'Login is Expired', + type: AuthErrorType.expiredAccount, + ); + } + + return accountListItem.copyWith(token: account.token); + }, + ).toList(); + @override Future getDefaultAccount() => authRepository.getDefaultAccount(); From 0b67b5e6157f0fbba33f59f2ab428ff417b122a6 Mon Sep 17 00:00:00 2001 From: mobile-apps-deriv <134251399+mobile-apps-deriv@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:01:00 +0800 Subject: [PATCH 5/9] chore(version): bump version and update changelog (#823) Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: waqas-younas-deriv --- CHANGELOG.md | 21 +++++++++++++++++++++ README.md | 4 ++-- packages/deriv_auth/CHANGELOG.md | 4 ++++ packages/deriv_auth/pubspec.yaml | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1486f6dd8..58cb4e7f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-09-19 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`deriv_auth` - `v6.7.49`](#deriv_auth---v6749) + +--- + +#### `deriv_auth` - `v6.7.49` + + - **FIX**(deriv_auth): unassigned token for account created on web ([#756](https://github.com/regentmarkets/flutter-deriv-packages/issues/756)). ([abbb8905](https://github.com/regentmarkets/flutter-deriv-packages/commit/abbb8905263517c32c1e990fdc9dbfd2fb38ae9b)) + + ## 2024-09-18 ### Changes diff --git a/README.md b/README.md index f917b0889..283a30fe2 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ cp $HOME/Downloads/commit-msg $HOME/.git/hooks/commit-msg \ ## Using the packages -Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.7.48)`. To use the package, add the following to your pubspec.yaml file: +Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.7.49)`. To use the package, add the following to your pubspec.yaml file: ```yaml deriv_ui: @@ -30,7 +30,7 @@ deriv_ui: | Name | Description | Version | | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | | [analytics](./packages/analytics) | Used to collect and send analytical information to 'Firebase', 'Rudderstack' and 'Datadog'. | [v2.2.2](./packages/analytics/CHANGELOG.md) | | [v2.2.2](./packages/analytics/CHANGELOG.md) | -| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.7.48 ](./packages/deriv_auth/CHANGELOG.md) | +| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.7.49 ](./packages/deriv_auth/CHANGELOG.md) | | [deriv_banner](./packages/deriv_banner) | A widget to show banner in apps. | [v0.0.1+1](./packages/deriv_banner/CHANGELOG.md) | | [deriv_bloc_manager](./packages/deriv_bloc_manager) | Provides some tools to manage blocs. | [v0.0.1](./packages/deriv_bloc_manager/CHANGELOG.md) | | [deriv_datadog](./packages/deriv_datadog) | A package that helps you monitor the performance and user interactions of your Flutter app by sending data to Datadog. | [v0.0.1](./packages/deriv_datadog/CHANGELOG.md) | diff --git a/packages/deriv_auth/CHANGELOG.md b/packages/deriv_auth/CHANGELOG.md index 9f1b27e29..932cc597e 100644 --- a/packages/deriv_auth/CHANGELOG.md +++ b/packages/deriv_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.7.49 + + - **FIX**(deriv_auth): unassigned token for account created on web ([#756](https://github.com/regentmarkets/flutter-deriv-packages/issues/756)). ([abbb8905](https://github.com/regentmarkets/flutter-deriv-packages/commit/abbb8905263517c32c1e990fdc9dbfd2fb38ae9b)) + ## 6.7.48 - Update a dependency to the latest release. diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index f1b4b3b78..41cc9ada1 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_auth description: Provides deriv authentication functionalities for dart/flutter apps. -version: 6.7.48 +version: 6.7.49 environment: sdk: ">=3.0.0 <4.0.0" From bd197376cf450ec375a9759c9511563a253a0c64 Mon Sep 17 00:00:00 2001 From: Ilya <106583608+ilya-deriv@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:14:18 +0300 Subject: [PATCH 6/9] feat(analytics): Amend tracking events Rudderstack (#821) Co-authored-by: ramin-deriv <55975218+ramin-deriv@users.noreply.github.com> --- packages/analytics/lib/sdk/rudderstack/models/user_info.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/analytics/lib/sdk/rudderstack/models/user_info.dart b/packages/analytics/lib/sdk/rudderstack/models/user_info.dart index 4dab62df6..b8e7d2032 100644 --- a/packages/analytics/lib/sdk/rudderstack/models/user_info.dart +++ b/packages/analytics/lib/sdk/rudderstack/models/user_info.dart @@ -1,6 +1,6 @@ -/// User info model. +/// User Info model. class UserInfo { - /// Constructor for UserInfo model. + /// Constructor for User Info model. UserInfo({ required this.userId, this.countryResidence, From c989bddeb6f224d6ef6b48646de24ca5390db8d1 Mon Sep 17 00:00:00 2001 From: mobile-apps-deriv <134251399+mobile-apps-deriv@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:00:43 +0800 Subject: [PATCH 7/9] chore(version): bump version and update changelog (#824) Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: ramin-deriv --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++ README.md | 6 +++--- packages/analytics/CHANGELOG.md | 4 ++++ packages/analytics/pubspec.yaml | 2 +- packages/deriv_auth/CHANGELOG.md | 4 ++++ packages/deriv_auth/pubspec.yaml | 6 +++--- packages/deriv_passkeys/CHANGELOG.md | 4 ++++ packages/deriv_passkeys/pubspec.yaml | 4 ++-- 8 files changed, 51 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58cb4e7f8..4e42be51b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,36 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-09-19 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`analytics` - `v2.3.0`](#analytics---v230) + - [`deriv_passkeys` - `v0.0.4+5`](#deriv_passkeys---v0045) + - [`deriv_auth` - `v6.7.50`](#deriv_auth---v6750) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `deriv_passkeys` - `v0.0.4+5` + - `deriv_auth` - `v6.7.50` + +--- + +#### `analytics` - `v2.3.0` + + - **FEAT**(analytics): Amend tracking events Rudderstack ([#821](https://github.com/regentmarkets/flutter-deriv-packages/issues/821)). ([bd197376](https://github.com/regentmarkets/flutter-deriv-packages/commit/bd197376cf450ec375a9759c9511563a253a0c64)) + + ## 2024-09-19 ### Changes diff --git a/README.md b/README.md index 283a30fe2..bfdb1b0c5 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ cp $HOME/Downloads/commit-msg $HOME/.git/hooks/commit-msg \ ## Using the packages -Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.7.49)`. To use the package, add the following to your pubspec.yaml file: +Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.7.50)`. To use the package, add the following to your pubspec.yaml file: ```yaml deriv_ui: @@ -29,8 +29,8 @@ deriv_ui: | Name | Description | Version | | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | -| [analytics](./packages/analytics) | Used to collect and send analytical information to 'Firebase', 'Rudderstack' and 'Datadog'. | [v2.2.2](./packages/analytics/CHANGELOG.md) | | [v2.2.2](./packages/analytics/CHANGELOG.md) | -| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.7.49 ](./packages/deriv_auth/CHANGELOG.md) | +| [analytics](./packages/analytics) | Used to collect and send analytical information to 'Firebase', 'Rudderstack' and 'Datadog'. | [v2.2.2](./packages/analytics/CHANGELOG.md) | | [v2.3.0](./packages/analytics/CHANGELOG.md) | +| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.7.50 ](./packages/deriv_auth/CHANGELOG.md) | | [deriv_banner](./packages/deriv_banner) | A widget to show banner in apps. | [v0.0.1+1](./packages/deriv_banner/CHANGELOG.md) | | [deriv_bloc_manager](./packages/deriv_bloc_manager) | Provides some tools to manage blocs. | [v0.0.1](./packages/deriv_bloc_manager/CHANGELOG.md) | | [deriv_datadog](./packages/deriv_datadog) | A package that helps you monitor the performance and user interactions of your Flutter app by sending data to Datadog. | [v0.0.1](./packages/deriv_datadog/CHANGELOG.md) | diff --git a/packages/analytics/CHANGELOG.md b/packages/analytics/CHANGELOG.md index 5e03a9fb5..47061758c 100644 --- a/packages/analytics/CHANGELOG.md +++ b/packages/analytics/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.0 + + - **FEAT**(analytics): Amend tracking events Rudderstack ([#821](https://github.com/regentmarkets/flutter-deriv-packages/issues/821)). ([bd197376](https://github.com/regentmarkets/flutter-deriv-packages/commit/bd197376cf450ec375a9759c9511563a253a0c64)) + ## 2.2.2 - **REFACTOR**(analytics): Amend virtual n real tracking events ([#771](https://github.com/regentmarkets/flutter-deriv-packages/issues/771)). ([fc8850f0](https://github.com/regentmarkets/flutter-deriv-packages/commit/fc8850f01c1bb0a6805b41b3ff10e2a6e33b6e0f)) diff --git a/packages/analytics/pubspec.yaml b/packages/analytics/pubspec.yaml index e25211eba..13a931242 100644 --- a/packages/analytics/pubspec.yaml +++ b/packages/analytics/pubspec.yaml @@ -1,6 +1,6 @@ name: analytics description: A new Flutter package for collecting and sending analytical information from the app. -version: 2.2.2 +version: 2.3.0 homepage: https://deriv.com/ publish_to: "none" diff --git a/packages/deriv_auth/CHANGELOG.md b/packages/deriv_auth/CHANGELOG.md index 932cc597e..c91c08cce 100644 --- a/packages/deriv_auth/CHANGELOG.md +++ b/packages/deriv_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.7.50 + + - Update a dependency to the latest release. + ## 6.7.49 - **FIX**(deriv_auth): unassigned token for account created on web ([#756](https://github.com/regentmarkets/flutter-deriv-packages/issues/756)). ([abbb8905](https://github.com/regentmarkets/flutter-deriv-packages/commit/abbb8905263517c32c1e990fdc9dbfd2fb38ae9b)) diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 41cc9ada1..2d1571d53 100644 --- a/packages/deriv_auth/pubspec.yaml +++ b/packages/deriv_auth/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_auth description: Provides deriv authentication functionalities for dart/flutter apps. -version: 6.7.49 +version: 6.7.50 environment: sdk: ">=3.0.0 <4.0.0" @@ -16,7 +16,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/analytics - ref: analytics-v2.2.2 + ref: analytics-v2.3.0 deriv_theme: git: @@ -57,7 +57,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_passkeys - ref: deriv_passkeys-v0.0.4+4 + ref: deriv_passkeys-v0.0.4+5 deriv_language_selector: git: diff --git a/packages/deriv_passkeys/CHANGELOG.md b/packages/deriv_passkeys/CHANGELOG.md index caa11cb61..d8a1bb8a5 100644 --- a/packages/deriv_passkeys/CHANGELOG.md +++ b/packages/deriv_passkeys/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.4+5 + + - Update a dependency to the latest release. + ## 0.0.4+4 - Update a dependency to the latest release. diff --git a/packages/deriv_passkeys/pubspec.yaml b/packages/deriv_passkeys/pubspec.yaml index bef435a46..dd9841351 100644 --- a/packages/deriv_passkeys/pubspec.yaml +++ b/packages/deriv_passkeys/pubspec.yaml @@ -1,6 +1,6 @@ name: deriv_passkeys description: Deriv Passkeys Flutter Plugin -version: 0.0.4+4 +version: 0.0.4+5 publish_to: "none" environment: @@ -14,7 +14,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/analytics - ref: analytics-v2.2.2 + ref: analytics-v2.3.0 deriv_theme: git: From 05d5c85f9b5c204ec54eb3828b262fe7c0293ac0 Mon Sep 17 00:00:00 2001 From: Ali Akbar <116874053+aliakbar-deriv@users.noreply.github.com> Date: Fri, 20 Sep 2024 11:59:04 +0400 Subject: [PATCH 8/9] feat(deriv_mobile_chart_wrapper): [DRGO-81] Functionality to add dots for drawing tool. (#810) --- .../lib/src/helpers.dart | 8 +- .../lib/src/mobile_chart_wrapper.dart | 5 +- ...tem.dart => active_drawing_tool_item.dart} | 12 +- .../drawing_tool_icon_button.dart | 49 ++- ..._list_item.dart => drawing_tool_item.dart} | 4 +- .../drawing_tools/drawing_tools.dart | 4 + .../drawing_tools/drawing_tools_selector.dart | 412 ++++++++++-------- .../src/mobile_tools_ui/mobile_tools_ui.dart | 2 +- .../src/mobile_tools_ui/tools_controller.dart | 9 + .../deriv_mobile_chart_wrapper/pubspec.yaml | 4 +- 10 files changed, 285 insertions(+), 224 deletions(-) rename packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/{active_drawing_tool_list_item.dart => active_drawing_tool_item.dart} (88%) rename packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/{drawing_tool_list_item.dart => drawing_tool_item.dart} (95%) create mode 100644 packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools.dart diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart b/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart index 5c162b928..156238b84 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart @@ -57,12 +57,15 @@ String getDrawingToolIconPath(Type drawingToolType) { } } +/// Returns the list of drawing tools available for the chart. List getDrawingToolsList(BuildContext context) { - List drawingTools = [ + List drawingTools = [ DrawingToolItemModel( title: context.mobileChartWrapperLocalizations.labelLine, icon: lineIcon, - config: const LineDrawingToolConfig(), + config: const LineDrawingToolConfig( + lineStyle: LineStyle(thickness: 0.9, color: BrandColors.coral), + ), ), DrawingToolItemModel( title: context.mobileChartWrapperLocalizations.labelRay, @@ -70,6 +73,7 @@ List getDrawingToolsList(BuildContext context) { config: const RayDrawingToolConfig(), ), ]; + return drawingTools; } diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart index 0d67ef00b..f20e87ebe 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_chart_wrapper.dart @@ -287,6 +287,7 @@ class MobileChartWrapperState extends State { ..init() ..drawingToolsRepo = drawingToolsRepo; }); + showModalBottomSheet( context: context, builder: (_) => @@ -295,8 +296,8 @@ class MobileChartWrapperState extends State { child: SafeArea( child: DerivBottomSheet( title: context.mobileChartWrapperLocalizations.labelDrawingTools, - child: DrawingToolSelector( - onSelection: (DrawingToolConfig selectedDrawingTool) { + child: DrawingToolsSelector( + onDrawingToolSelected: (DrawingToolConfig selectedDrawingTool) { _drawingTools.onDrawingToolSelection(selectedDrawingTool); Navigator.of(context).pop(); }, diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_item.dart similarity index 88% rename from packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart rename to packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_item.dart index 7930edbe6..93c9db9fa 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/active_drawing_tool_item.dart @@ -4,9 +4,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; /// List item for the active drawing tools list. -class ActiveDrawingToolListItem extends StatelessWidget { +class ActiveDrawingToolItem extends StatelessWidget { /// Initializes the active indicator list item. - const ActiveDrawingToolListItem({ + const ActiveDrawingToolItem({ required this.iconAssetPath, required this.title, required this.onTapSettings, @@ -22,11 +22,11 @@ class ActiveDrawingToolListItem extends StatelessWidget { /// The callback which will be called when the /// drawing tool settings button is tapped. - final VoidCallback onTapSettings; + final VoidCallback? onTapSettings; /// The callback which will be called when the /// drawing tool delete button is tapped. - final VoidCallback onTapDelete; + final VoidCallback? onTapDelete; @override Widget build(BuildContext context) { @@ -49,12 +49,12 @@ class ActiveDrawingToolListItem extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ IconButton( - onPressed: () {}, + onPressed: onTapSettings, color: context.themeProvider.colors.prominent, icon: const Icon(Icons.settings_outlined), ), IconButton( - onPressed: () {}, + onPressed: onTapDelete, color: context.themeProvider.colors.prominent, icon: const Icon(Icons.delete_outline), ), diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_icon_button.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_icon_button.dart index d2a5bd2a0..d079aa94d 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_icon_button.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_icon_button.dart @@ -1,37 +1,52 @@ import 'package:deriv_mobile_chart_wrapper/src/assets.dart'; import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/chart_setting_button_with_background.dart'; +import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/tools_controller.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; /// Drawing tool Icon button. -class DrawingToolIconButton extends StatelessWidget { +class DrawingToolIconButton extends StatefulWidget { /// Initializes a new instance of [DrawingToolIconButton]. const DrawingToolIconButton({ - required this.onTap, - this.noOfActiveDrawingTools = 0, + required this.toolsController, Key? key, }) : super(key: key); /// On tap callback. - final VoidCallback onTap; + final ToolsController toolsController; - /// No.of active drawing tools. - /// This is used to show the count badge on the icon. - /// The default value is 0. If the value is 0, the badge will not be shown. - final int noOfActiveDrawingTools; + @override + State createState() => _DrawingToolIconButtonState(); +} + +class _DrawingToolIconButtonState extends State { + final ValueNotifier _activeDrawingToolsCountNotifier = + ValueNotifier(0); + + @override + void initState() { + super.initState(); + widget.toolsController.addListener(() { + _activeDrawingToolsCountNotifier.value = + widget.toolsController.activeDrawingToolsCount; + }); + } @override - Widget build(BuildContext context) => DerivBadge( - count: noOfActiveDrawingTools, - child: ChartSettingButtonWithBackground( - onTap: onTap, - child: SvgPicture.asset( - drawingToolIcon, - width: ThemeProvider.margin18, - height: ThemeProvider.margin18, - package: 'deriv_mobile_chart_wrapper', + Widget build(BuildContext context) => ValueListenableBuilder( + valueListenable: _activeDrawingToolsCountNotifier, + builder: (_, int? value, __) => DerivBadge( + count: value ?? 0, + child: ChartSettingButtonWithBackground( + onTap: () => widget.toolsController.showDrawingToolsMenu(), + child: SvgPicture.asset( + drawingToolIcon, + width: ThemeProvider.margin18, + height: ThemeProvider.margin18, + package: 'deriv_mobile_chart_wrapper', + ), ), ), ); diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_item.dart similarity index 95% rename from packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart rename to packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_item.dart index 553ac419c..b58ebb24d 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tool_item.dart @@ -5,9 +5,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; /// List item widget to show a drawing tool. -class DrawingToolListItem extends StatelessWidget { +class DrawingToolItem extends StatelessWidget { /// Constructor of the widget - const DrawingToolListItem({ + const DrawingToolItem({ required this.iconAssetPath, required this.title, required this.onTap, diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools.dart new file mode 100644 index 000000000..8c657c273 --- /dev/null +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools.dart @@ -0,0 +1,4 @@ +export 'drawing_tool_icon_button.dart'; +export 'active_drawing_tool_item.dart'; +export 'drawing_tool_item.dart'; +export 'drawing_tools_selector.dart'; diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart index e10420bec..f2b5c88b3 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/drawing_tools/drawing_tools_selector.dart @@ -1,37 +1,39 @@ +import 'package:collection/collection.dart'; import 'package:deriv_chart/deriv_chart.dart'; import 'package:deriv_mobile_chart_wrapper/src/assets.dart'; import 'package:deriv_mobile_chart_wrapper/src/extensions.dart'; import 'package:deriv_mobile_chart_wrapper/src/helpers.dart'; -import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/drawing_tools/active_drawing_tool_list_item.dart'; -import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/drawing_tools/drawing_tool_list_item.dart'; +import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/drawing_tools/active_drawing_tool_item.dart'; +import 'package:deriv_mobile_chart_wrapper/src/mobile_tools_ui/drawing_tools/drawing_tool_item.dart'; import 'package:deriv_mobile_chart_wrapper/src/models/drawing_tool_item_model.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; -class DrawingToolSelector extends StatefulWidget { - const DrawingToolSelector({ - required this.onSelection, +class DrawingToolsSelector extends StatefulWidget { + const DrawingToolsSelector({ + required this.onDrawingToolSelected, super.key, }); /// Drawing tools selection callback. - final void Function(DrawingToolConfig drawingToolConfig)? onSelection; + final void Function(DrawingToolConfig drawingToolConfig)? + onDrawingToolSelected; @override - State createState() => _DrawingToolSelectorState(); + State createState() => _DrawingToolsSelectorState(); } -class _DrawingToolSelectorState extends State +class _DrawingToolsSelectorState extends State with SingleTickerProviderStateMixin { late TabController _tabController; - final List _activeDrawingTools = []; late List _drawingTools; + late AddOnsRepository drawingToolsRepo; + @override void initState() { super.initState(); @@ -41,6 +43,10 @@ class _DrawingToolSelectorState extends State @override void didChangeDependencies() { super.didChangeDependencies(); + + drawingToolsRepo = Provider.of>( + context, + ); _drawingTools = getDrawingToolsList(context); } @@ -50,214 +56,239 @@ class _DrawingToolSelectorState extends State super.dispose(); } - void _onToolSelection(DrawingToolItemModel selectedTool) { - setState(() { - if (_activeDrawingTools.contains(selectedTool)) { - _activeDrawingTools.remove(selectedTool); - } else { - _activeDrawingTools.add(selectedTool); - } - }); - } - @override - Widget build(BuildContext context) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - Stack( - alignment: Alignment.bottomCenter, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: context.theme.colors.disabled, - width: ThemeProvider.margin02, - ), - ), + Widget build(BuildContext context) => Column( + mainAxisSize: MainAxisSize.min, + children: [ + _buildTabBar(context), + Expanded( + child: Ink( + color: context.theme.colors.primary, + child: TabBarView( + controller: _tabController, + children: [ + _buildActiveDrawingToolsTab(context), + _buildDrawingToolListTab(context), + ], ), ), - TabBar( - controller: _tabController, - indicatorColor: context.theme.colors.danger, - labelStyle: context.theme.textStyle( - textStyle: TextStyles.body2, - color: context.theme.colors.prominent, - ), - unselectedLabelStyle: context.theme.textStyle( - textStyle: TextStyles.body1, - color: context.theme.colors.general, + ), + ], + ); + + Widget _buildTabBar(BuildContext context) => Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: context.theme.colors.disabled, + width: ThemeProvider.margin02, + ), ), - tabs: [ - Tab( - text: - '${context.mobileChartWrapperLocalizations.labelActive} (${_activeDrawingTools.length})'), - Tab(text: context.mobileChartWrapperLocalizations.labelTools), - ], ), - ], - ), - Expanded( - child: Ink( - color: context.theme.colors.primary, - child: TabBarView( - controller: _tabController, - children: [ - _buildActiveDrawingToolsTab(context), - _buildDrawingToolListTab(context), - ], + ), + TabBar( + controller: _tabController, + indicatorColor: context.theme.colors.danger, + labelStyle: context.theme.textStyle( + textStyle: TextStyles.body2, + color: context.theme.colors.prominent, + ), + unselectedLabelStyle: context.theme.textStyle( + textStyle: TextStyles.body1, + color: context.theme.colors.general, ), + tabs: [ + Tab( + text: '${context.mobileChartWrapperLocalizations.labelActive}' + ' (${drawingToolsRepo.items.length})'), + Tab(text: context.mobileChartWrapperLocalizations.labelTools), + ], ), - ), - ], - ); - } + ], + ); Widget _buildActiveDrawingToolsTab(BuildContext context) { - if (_activeDrawingTools.isEmpty) { - return _buildDrawingToolEmptyState(); + final List activeDrawingTools = drawingToolsRepo.items; + + if (activeDrawingTools.isEmpty) { + return _buildEmptyActiveDrawingTools(); } else { - return _buildActiveDrawingToolsList(); + return _buildActiveDrawingToolsList(activeDrawingTools); } } - Widget _buildActiveDrawingToolsList() { - return Column( - children: [ - _buildActiveTabHeader(), - Expanded( - child: ListView( - children: _activeDrawingTools - .map( - (tool) => Card( - margin: const EdgeInsets.symmetric( - horizontal: ThemeProvider.margin16, - vertical: ThemeProvider.margin08, - ), - color: context.themeProvider.colors.secondary, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(ThemeProvider.borderRadius08), - ), - ), - child: ActiveDrawingToolListItem( - iconAssetPath: tool.icon, - title: tool.title, - onTapDelete: () {}, - onTapSettings: () {}, - ), - ), - ) - .toList(), - ), - ), - ], - ); - } - Widget _buildDrawingToolListTab(BuildContext context) { - return ListView( - children: _drawingTools.map((toolItem) { - final List selectedToolItems = _activeDrawingTools - .where((DrawingToolItemModel activeToolItem) => - activeToolItem == toolItem) - .toList(); - return DrawingToolListItem( + final activeDrawingTools = drawingToolsRepo.items; + final toolCounts = _computeToolCounts(activeDrawingTools); + + return ListView.builder( + itemCount: _drawingTools.length, + itemBuilder: (context, index) { + final toolItem = _drawingTools[index]; + final count = toolCounts[toolItem.config.runtimeType] ?? 0; + + return DrawingToolItem( iconAssetPath: toolItem.icon, title: toolItem.title, - count: selectedToolItems.length, - onTap: () => _onToolSelection(toolItem), + count: count, + onTap: () => widget.onDrawingToolSelected?.call(toolItem.config), ); - }).toList(), + }, ); } - Widget _buildDrawingToolEmptyState() { - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SvgPicture.asset( - emptyStateDrawingToolsIcon, - height: Dimens.iconSize48, - package: 'deriv_mobile_chart_wrapper', - ), - const SizedBox(height: ThemeProvider.margin08), - Text( - context.mobileChartWrapperLocalizations - .informNoActiveDrawingTools, - style: context.themeProvider.textStyle( - textStyle: TextStyles.body1, - color: const Color(0xFF999999), + Widget _buildEmptyActiveDrawingTools() => Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset( + emptyStateDrawingToolsIcon, + height: Dimens.iconSize48, + package: 'deriv_mobile_chart_wrapper', ), - ), - ], + const SizedBox(height: ThemeProvider.margin08), + Text( + context.mobileChartWrapperLocalizations + .informNoActiveDrawingTools, + style: context.themeProvider.textStyle( + textStyle: TextStyles.body1, + color: context.theme.colors.lessProminent, + ), + ), + ], + ), ), ), - ), - Container( - color: context.theme.colors.secondary, - padding: const EdgeInsets.all(ThemeProvider.margin16), - child: PrimaryButton( - child: Text( - context.mobileChartWrapperLocalizations.actionAddDrawingTool, - style: context.theme.textStyle( - textStyle: TextStyles.body2, - color: context.theme.colors.prominent, + Container( + color: context.theme.colors.secondary, + padding: const EdgeInsets.all(ThemeProvider.margin16), + child: PrimaryButton( + child: Text( + context.mobileChartWrapperLocalizations.actionAddDrawingTool, + style: context.theme.textStyle( + textStyle: TextStyles.body2, + color: context.theme.colors.prominent, + ), ), + onPressed: () => _tabController.animateTo(1), ), - onPressed: () { - setState(() { - _tabController.animateTo(1); - }); - }, ), - ), - ], - ); - } + ], + ); + + Widget _buildActiveDrawingToolsList( + List activeDrawingTools, + ) => + Column( + children: [ + _buildActiveDrawingToolsActionBar(activeDrawingTools), + Expanded( + child: ListView.builder( + itemCount: activeDrawingTools.length, + itemBuilder: (BuildContext context, int index) { + final activeDrawingToolItem = activeDrawingTools[index]; + final DrawingToolItemModel? drawingToolItem = + _drawingTools.firstWhereOrNull((element) => + element.config.runtimeType == + activeDrawingToolItem.runtimeType); + + if (drawingToolItem != null) { + return _buildActiveDrawingToolItem( + context, + toolIcon: drawingToolItem.icon, + title: drawingToolItem.title, + onTapDelete: () => drawingToolsRepo.removeAt(index), + onTapSettings: () {}, + ); + } else { + return const SizedBox.shrink(); + } + }, + ), + ), + ], + ); - Widget _buildActiveTabHeader() { - return Padding( - padding: const EdgeInsets.only( - top: ThemeProvider.margin16, - bottom: ThemeProvider.margin08, - left: ThemeProvider.margin16, - right: ThemeProvider.margin16, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Visibility( - visible: _activeDrawingTools.isNotEmpty, - maintainSize: true, - maintainState: true, - maintainAnimation: true, - child: SecondaryButton( - onPressed: _showDeleteAllDrawingToolsDialog, - child: Center( - child: Text( - context.mobileChartWrapperLocalizations.labelDeleteAll, - style: context.themeProvider.textStyle( - textStyle: TextStyles.caption, - color: context.themeProvider.colors.prominent, + Widget _buildActiveDrawingToolsActionBar( + List activeDrawingTools, + ) => + Padding( + padding: const EdgeInsets.only( + top: ThemeProvider.margin16, + bottom: ThemeProvider.margin08, + left: ThemeProvider.margin16, + right: ThemeProvider.margin16, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Visibility( + visible: activeDrawingTools.isNotEmpty, + maintainSize: true, + maintainState: true, + maintainAnimation: true, + child: SecondaryButton( + onPressed: _showDeleteAllDrawingToolsDialog, + child: Center( + child: Text( + context.mobileChartWrapperLocalizations.labelDeleteAll, + style: context.themeProvider.textStyle( + textStyle: TextStyles.caption, + color: context.themeProvider.colors.prominent, + ), ), ), ), ), + ], + ), + ); + + Widget _buildActiveDrawingToolItem( + BuildContext context, { + required String toolIcon, + required String title, + required VoidCallback? onTapDelete, + required VoidCallback? onTapSettings, + }) => + Card( + margin: const EdgeInsets.symmetric( + horizontal: ThemeProvider.margin16, + vertical: ThemeProvider.margin08, + ), + color: context.themeProvider.colors.secondary, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(ThemeProvider.borderRadius08), ), - ], - ), - ); - } + ), + child: ActiveDrawingToolItem( + iconAssetPath: toolIcon, + title: title, + onTapDelete: onTapDelete, + onTapSettings: onTapSettings, + ), + ); - void _showDeleteAllDrawingToolsDialog() { - showAlertDialog( + Map _computeToolCounts( + List activeDrawingTools, + ) => + activeDrawingTools.fold( + {}, + (counts, tool) { + counts[tool.runtimeType] = (counts[tool.runtimeType] ?? 0) + 1; + return counts; + }, + ); + + void _showDeleteAllDrawingToolsDialog() => showAlertDialog( context: context, title: context.mobileChartWrapperLocalizations.labelDeleteAllIndicators, content: Text( @@ -270,12 +301,9 @@ class _DrawingToolSelectorState extends State context.mobileChartWrapperLocalizations.labelCancel, showLoadingIndicator: false, onPositiveActionPressed: () { - _activeDrawingTools.clear(); - setState(() {}); + drawingToolsRepo.clear(); Navigator.pop(context); }, - onNegativeActionPressed: () { - Navigator.pop(context); - }); - } + onNegativeActionPressed: () => Navigator.pop(context), + ); } diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart index 726294bd5..18887d6db 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/mobile_tools_ui.dart @@ -5,4 +5,4 @@ export 'indicator_list_item.dart'; export 'indicator_menu_button.dart'; export 'mobile_tools_bottom_sheet_content.dart'; export 'tools_controller.dart'; -export 'drawing_tools/drawing_tool_icon_button.dart'; +export 'drawing_tools/drawing_tools.dart'; diff --git a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/tools_controller.dart b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/tools_controller.dart index c14a35e77..ec9df8493 100644 --- a/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/tools_controller.dart +++ b/packages/deriv_mobile_chart_wrapper/lib/src/mobile_tools_ui/tools_controller.dart @@ -1,3 +1,4 @@ +import 'package:deriv_chart/deriv_chart.dart'; import 'package:deriv_mobile_chart_wrapper/src/models/config_item_model.dart'; import 'package:flutter/material.dart'; @@ -38,4 +39,12 @@ class ToolsController extends ChangeNotifier { /// Shows drawing tools menu. void showDrawingToolsMenu() => onShowDrawingToolsMenu?.call(); + + /// Returns the count of active drawing tools. + int get activeDrawingToolsCount => + _configs?.drawingToolConfigs + .where((DrawingToolConfig config) => + config.drawingData?.isDrawingFinished ?? false) + .length ?? + 0; } diff --git a/packages/deriv_mobile_chart_wrapper/pubspec.yaml b/packages/deriv_mobile_chart_wrapper/pubspec.yaml index b6335c139..e171bca5c 100644 --- a/packages/deriv_mobile_chart_wrapper/pubspec.yaml +++ b/packages/deriv_mobile_chart_wrapper/pubspec.yaml @@ -4,9 +4,8 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 0.1.1 homepage: - environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.3.3 <4.0.0" dependencies: flutter: @@ -16,6 +15,7 @@ dependencies: git: url: git@github.com:regentmarkets/flutter-chart.git ref: dev + deriv_theme: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git From 3eb3d0e24adc3d523fad96ea42ef18e30094e126 Mon Sep 17 00:00:00 2001 From: mobile-apps-deriv <134251399+mobile-apps-deriv@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:21:36 +0800 Subject: [PATCH 9/9] chore(version): bump version and update changelog (#825) Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: waqas-younas-deriv --- CHANGELOG.md | 21 +++++++++++++++++++ README.md | 2 +- .../deriv_mobile_chart_wrapper/CHANGELOG.md | 4 ++++ .../deriv_mobile_chart_wrapper/pubspec.yaml | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e42be51b..2d089749c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-09-20 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`deriv_mobile_chart_wrapper` - `v0.1.2`](#deriv_mobile_chart_wrapper---v012) + +--- + +#### `deriv_mobile_chart_wrapper` - `v0.1.2` + + - **FEAT**(deriv_mobile_chart_wrapper): [DRGO-81] Functionality to add dots for drawing tool. ([#810](https://github.com/regentmarkets/flutter-deriv-packages/issues/810)). ([05d5c85f](https://github.com/regentmarkets/flutter-deriv-packages/commit/05d5c85f9b5c204ec54eb3828b262fe7c0293ac0)) + + ## 2024-09-19 ### Changes diff --git a/README.md b/README.md index bfdb1b0c5..d1527b651 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ deriv_ui: | [form_builder](./packages/form_builder) | A simpler and cleaner way to create, validate and submit forms. | [v1.0.0+1](./packages/form_builder/CHANGELOG.md) | | [update_checker](./packages/update_checker) | Check and retrieve update information from the server for the given package. | [v1.5.1](./packages/update_checker/CHANGELOG.md) | | [deriv_feature_flag](./packages/deriv_feature_flag) | A package to provide feature flag functionality for apps. | [v0.1.1](./packages/deriv_feature_flag/CHANGELOG.md) | -| [deriv_mobile_chart_wrapper](./packages/deriv_mobile_chart_wrapper) | A wrapper package around package _**deriv_chart**_ to implement any functionality specific to mobile and can be wrapped around the main chart package. | [v0.1.1](./packages/deriv_mobile_chart_wrapper/CHANGELOG.md) | +| [deriv_mobile_chart_wrapper](./packages/deriv_mobile_chart_wrapper) | A wrapper package around package _**deriv_chart**_ to implement any functionality specific to mobile and can be wrapped around the main chart package. | [v0.1.2](./packages/deriv_mobile_chart_wrapper/CHANGELOG.md) | ## Environment Setup diff --git a/packages/deriv_mobile_chart_wrapper/CHANGELOG.md b/packages/deriv_mobile_chart_wrapper/CHANGELOG.md index 3401da667..eb2b4977b 100644 --- a/packages/deriv_mobile_chart_wrapper/CHANGELOG.md +++ b/packages/deriv_mobile_chart_wrapper/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2 + + - **FEAT**(deriv_mobile_chart_wrapper): [DRGO-81] Functionality to add dots for drawing tool. ([#810](https://github.com/regentmarkets/flutter-deriv-packages/issues/810)). ([05d5c85f](https://github.com/regentmarkets/flutter-deriv-packages/commit/05d5c85f9b5c204ec54eb3828b262fe7c0293ac0)) + ## 0.1.1 - **FEAT**(deriv_mobile_chart_wrapper): [DRGO-74] Add drawing tools bottom sheet UI ([#815](https://github.com/regentmarkets/flutter-deriv-packages/issues/815)). ([ebd9ab92](https://github.com/regentmarkets/flutter-deriv-packages/commit/ebd9ab92707630df3bc185aab5a503399df786b4)) diff --git a/packages/deriv_mobile_chart_wrapper/pubspec.yaml b/packages/deriv_mobile_chart_wrapper/pubspec.yaml index e171bca5c..8db5f3603 100644 --- a/packages/deriv_mobile_chart_wrapper/pubspec.yaml +++ b/packages/deriv_mobile_chart_wrapper/pubspec.yaml @@ -1,7 +1,7 @@ name: deriv_mobile_chart_wrapper description: A new Flutter package project. publish_to: "none" # Remove this line if you wish to publish to pub.dev -version: 0.1.1 +version: 0.1.2 homepage: environment: