diff --git a/CHANGELOG.md b/CHANGELOG.md index e633b4700..ed43c204f 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-05-15 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`deriv_auth` - `v6.5.0`](#deriv_auth---v650) + +--- + +#### `deriv_auth` - `v6.5.0` + + - **FEAT**(deriv_auth): Add language selector in auth package ([#576](https://github.com/regentmarkets/flutter-deriv-packages/issues/576)). ([cd3768ef](https://github.com/regentmarkets/flutter-deriv-packages/commit/cd3768ef2b6bd7420e7957277461e95e78eee545)) + + ## 2024-05-07 ### Changes diff --git a/README.md b/README.md index 138d11478..9fcc445dd 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repository contains private packages & plugins that are used by the company ## Using the packages -Each package has been released as git tag with convention as **packageName-vVersionNumber**`(Example: deriv_auth-v6.4.2)`. 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.5.0)`. To use the package, add the following to your pubspec.yaml file: ```yaml @@ -12,15 +12,15 @@ deriv_ui: git: url: git@github.com:regentmarkets/flutter-deriv-packages.git path: packages/deriv_ui - ref: deriv_ui-v0.0.7+3 #your prefered version + ref: deriv_ui-v0.0.7+4 #your prefered version ``` ## Packages | Name | Description | Version | | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | -| [analytics](./packages/analytics) | Used to collect and send analytical information to 'Firebase' and 'Segment'. | [v1.0.2](./packages/analytics/CHANGELOG.md) | -| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.4.2 ](./packages/deriv_auth/CHANGELOG.md) | +| [analytics](./packages/analytics) | Used to collect and send analytical information to 'Firebase' and 'Segment'. | [v1.0.4](./packages/analytics/CHANGELOG.md) | +| [deriv_auth](./packages/deriv_auth) | A Dart package that provides Authentication logic for Deriv applications. | [v6.5.0 ](./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) | @@ -31,18 +31,18 @@ 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.1+1](./packages/deriv_live_chat/CHANGELOG.md) | -| [deriv_language_selector](./packages/deriv_language_selector) | A package to handle language change of the app. | [v0.0.2+1](./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.1.1](./packages/deriv_localizations/CHANGELOG.md) | | [v1.3.0](./packages/deriv_localizations/CHANGELOG.md) | +| [deriv_language_selector](./packages/deriv_language_selector) | A package to handle language change of the app. | [v0.0.2+2](./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.1.1](./packages/deriv_localizations/CHANGELOG.md) | | [v1.3.1](./packages/deriv_localizations/CHANGELOG.md) | | [deriv_numpad](./packages/deriv_numpad) | Number Pad Widget for number input. | [v1.1.3](./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.4.0](./packages/deriv_theme/CHANGELOG.md) | -| [deriv_ui](./packages/deriv_ui) | A package that contains the UI components used by Deriv products. | [v0.0.7+3](./packages/deriv_ui/CHANGELOG.md) | +| [deriv_ui](./packages/deriv_ui) | A package that contains the UI components used by Deriv products. | [v0.0.7+4](./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+1](./packages/deriv_web_view/CHANGELOG.md) | -| [deriv_widgetbook](./packages/deriv_widgetbook) |Storybook for Deriv UI Widgets and Components | [v0.0.2+3](./packages/deriv_widgetbook/CHANGELOG.md) | +| [deriv_widgetbook](./packages/deriv_widgetbook) |Storybook for Deriv UI Widgets and Components | [v0.0.2+4](./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.2.2](./packages/update_checker/CHANGELOG.md) | | [deriv_feature_flag](./packages/deriv_feature_flag) | A package to provide feature flag functionality for apps. | [v0.1.0+1](./packages/deriv_feature_flag/CHANGELOG.md) | diff --git a/packages/deriv_auth/CHANGELOG.md b/packages/deriv_auth/CHANGELOG.md index ccd78b8bb..aba68a96a 100644 --- a/packages/deriv_auth/CHANGELOG.md +++ b/packages/deriv_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.5.0 + + - **FEAT**(deriv_auth): Add language selector in auth package ([#576](https://github.com/regentmarkets/flutter-deriv-packages/issues/576)). ([cd3768ef](https://github.com/regentmarkets/flutter-deriv-packages/commit/cd3768ef2b6bd7420e7957277461e95e78eee545)) + ## 6.4.3 - Update a dependency to the latest release. diff --git a/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart b/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart index 2924059d7..2c15b8dd3 100644 --- a/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart +++ b/packages/deriv_auth/lib/features/get_started/presentation/layouts/deriv_get_started_layout.dart @@ -6,6 +6,7 @@ import 'dart:math' as math; import 'package:deriv_auth/core/extensions/context_extension.dart'; import 'package:deriv_auth/core/helpers/semantic_labels.dart'; import 'package:deriv_auth/features/get_started/models/deriv_get_started_slide_model.dart'; +import 'package:deriv_language_selector/deriv_language_selector.dart'; import 'package:deriv_theme/deriv_theme.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; @@ -110,6 +111,17 @@ class _DerivGetStartedLayoutState extends State { title: AppSettingGestureDetector( onTapNavigation: widget.onTapNavigation, child: SvgPicture.asset(widget.appLogoIconPath)), + actions: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: ThemeProvider.margin16, + vertical: ThemeProvider.margin08, + ), + child: LanguageSelector.button( + bottomsheetTitle: context.derivAuthLocalization.labelLanguage, + ), + ), + ], ); Timer _buildNewScrollTimer() => Timer.periodic( diff --git a/packages/deriv_auth/lib/features/single_entry/core/auth_provider.dart b/packages/deriv_auth/lib/features/single_entry/core/auth_provider.dart index f6fb0adcb..20d6e6195 100644 --- a/packages/deriv_auth/lib/features/single_entry/core/auth_provider.dart +++ b/packages/deriv_auth/lib/features/single_entry/core/auth_provider.dart @@ -2,6 +2,7 @@ import 'package:deriv_auth/features/auth/cubit/deriv_auth_cubit.dart'; import 'package:deriv_auth/features/reset_password/cubit/reset_password_cubit.dart'; import 'package:deriv_auth/features/signup/cubit/signup_cubit.dart'; import 'package:deriv_auth/features/social_auth/cubit/social_auth_cubit.dart'; +import 'package:deriv_language_selector/deriv_language_selector.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -14,6 +15,7 @@ class AuthProvider extends StatelessWidget { required this.socialAuthCubit, required this.derivResetPassCubit, required this.derivSignupCubit, + required this.languageCubit, }); /// Child widget @@ -31,6 +33,9 @@ class AuthProvider extends StatelessWidget { /// Instance of Signup Cubit final DerivSignupCubit derivSignupCubit; + /// Instance of language Cubit + final LanguageCubit languageCubit; + Widget build(BuildContext context) => MultiBlocProvider( providers: [ BlocProvider.value( @@ -45,6 +50,9 @@ class AuthProvider extends StatelessWidget { BlocProvider.value( value: derivSignupCubit, ), + BlocProvider.value( + value: languageCubit, + ), ], child: widget, ); diff --git a/packages/deriv_auth/pubspec.yaml b/packages/deriv_auth/pubspec.yaml index 5b667df4d..296870cac 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.4.3 +version: 6.5.0 environment: @@ -48,6 +48,12 @@ dependencies: path: packages/deriv_localizations ref: deriv_localizations-v1.3.1 + deriv_language_selector: + git: + url: git@github.com:regentmarkets/flutter-deriv-packages.git + path: packages/deriv_language_selector + ref: deriv_language_selector-v0.0.2+1 + flutter_bloc: ^8.1.3 flutter_svg: ^2.0.7 smooth_page_indicator: ^1.1.0 diff --git a/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart b/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart index 2f01f1bae..ca0c48003 100644 --- a/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart +++ b/packages/deriv_auth/test/features/get_started/presentation/layouts/deriv_get_started_layout_test.dart @@ -1,9 +1,14 @@ // ignore_for_file: always_specify_types +import 'package:bloc_test/bloc_test.dart'; import 'package:deriv_auth/features/get_started/models/deriv_get_started_slide_model.dart'; import 'package:deriv_auth/features/get_started/presentation/layouts/deriv_get_started_layout.dart'; +import 'package:deriv_language_selector/deriv_language_selector.dart'; +import 'package:deriv_localizations/l10n/generated/deriv_auth/deriv_auth_localizations.dart'; +import 'package:deriv_localizations/l10n/generated/deriv_auth/deriv_auth_localizations_ar.dart'; import 'package:deriv_ui/deriv_ui.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:patrol_finders/patrol_finders.dart'; @@ -13,6 +18,9 @@ import '../../../../pump_app.dart'; class MockDerivGetStartedSlideModel extends Mock implements DerivGetStartedSlideModel {} +class MockLanguageCubit extends MockCubit + implements LanguageCubit {} + void main() { group('DerivGetStartedLayout', () { late MockDerivGetStartedSlideModel mockSlideModel; @@ -20,43 +28,52 @@ void main() { const String appLogoIconPath = 'assets/icons/ic_logo_extended.svg'; const String backgroundImagePath = 'assets/images/triangles.svg'; + final MockLanguageCubit mockLanguageCubit = MockLanguageCubit(); + setUpAll(() { mockSlideModel = MockDerivGetStartedSlideModel(); when(() => mockSlideModel.imagePath) .thenReturn('assets/images/charts.svg'); when(() => mockSlideModel.supportingText).thenReturn('Supporting text'); - }); - patrolWidgetTest('should render DerivGetStartedLayout', - (PatrolTester $) async { - await $.pumpApp(DerivGetStartedLayout( - onTapNavigation: (context) {}, - slides: [mockSlideModel], - appLogoIconPath: appLogoIconPath, - backgroundImagePath: backgroundImagePath, - onLoginTapped: () {}, - onSignupTapped: () {}, - )); - - expect($(DerivGetStartedLayout), findsOneWidget); - expect($(AppBar), findsOneWidget); - expect($(PrimaryButton), findsOneWidget); - expect($(SecondaryButton), findsOneWidget); + final LanguageModel languageModel = LanguageModel( + code: 'en', + flag: 'assets/icons/flags/ic_flag_en.png', + name: 'English', + ); + + when(() => mockLanguageCubit.state).thenReturn( + LanguageLoadedState( + activeLanguages: [ + languageModel, + ], + language: languageModel, + ), + ); }); patrolWidgetTest('should call onLoginTapped when login button is pressed', (PatrolTester $) async { bool loginTapped = false; - await $.pumpApp(DerivGetStartedLayout( - onTapNavigation: (context) {}, - slides: [mockSlideModel], - appLogoIconPath: appLogoIconPath, - backgroundImagePath: backgroundImagePath, - onLoginTapped: () { - loginTapped = true; - }, - onSignupTapped: () {}, + await $.pumpApp(BlocProvider( + create: (_) => mockLanguageCubit, + child: MaterialApp( + localizationsDelegates: const [DerivAuthLocalizations.delegate], + locale: const Locale('en'), + home: Scaffold( + body: DerivGetStartedLayout( + onTapNavigation: (context) {}, + slides: [mockSlideModel], + appLogoIconPath: appLogoIconPath, + backgroundImagePath: backgroundImagePath, + onLoginTapped: () { + loginTapped = true; + }, + onSignupTapped: () {}, + ), + ), + ), )); await $.tap($(SecondaryButton)); @@ -68,16 +85,27 @@ void main() { (PatrolTester $) async { bool signupTapped = false; - await $.pumpApp(DerivGetStartedLayout( - onTapNavigation: (context) {}, - slides: [mockSlideModel], - appLogoIconPath: appLogoIconPath, - backgroundImagePath: backgroundImagePath, - onLoginTapped: () {}, - onSignupTapped: () { - signupTapped = true; - }, - )); + await $.pumpApp( + BlocProvider( + create: (_) => mockLanguageCubit, + child: MaterialApp( + localizationsDelegates: const [DerivAuthLocalizations.delegate], + locale: const Locale('en'), + home: Scaffold( + body: DerivGetStartedLayout( + onTapNavigation: (context) {}, + slides: [mockSlideModel], + appLogoIconPath: appLogoIconPath, + backgroundImagePath: backgroundImagePath, + onLoginTapped: () {}, + onSignupTapped: () { + signupTapped = true; + }, + ), + ), + ), + ), + ); await $.tap($(PrimaryButton));