Skip to content

Commit 8db767c

Browse files
committed
Merge remote-tracking branch 'refs/remotes/upstream/dev' into reza/fix_support_web_issue
# Conflicts: # lib/services/connection/api_manager/binary_api.dart # pubspec.yaml
2 parents 11ccab4 + 29c03f3 commit 8db767c

File tree

510 files changed

+15407
-6451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

510 files changed

+15407
-6451
lines changed

.circleci/config.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/main.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Flutter Analyze, Test, and Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
pull_request:
9+
branches:
10+
- "*"
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
runs-on: "ubuntu-latest"
19+
steps:
20+
- name: 📚 Git Checkout
21+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
22+
23+
- name: 🐦 Setup Flutter
24+
uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
25+
with:
26+
flutter-version: "3.10.2"
27+
channel: stable
28+
cache: true
29+
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
30+
31+
- name: 📦 Install Dependencies
32+
run: flutter pub get
33+
34+
# do not fail if the analyze issue is info level
35+
- name: 🕵️ Analyze
36+
run: |
37+
if flutter analyze 2>&1 | grep -q -E 'error:|warning:';
38+
then exit 1
39+
else exit 0
40+
fi
41+
42+
- name: 🧪 Run Tests
43+
run: flutter test
44+
45+
- name: Build Example app
46+
working-directory: ./example
47+
run: flutter build apk --target-platform android-arm

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "binary-websocket-api"]
22
path = binary-websocket-api
3-
url = https://github.com/regentmarkets/binary-websocket-api.git
3+
url = git@github.com:regentmarkets/binary-websocket-api.git
44
branch = master

binary-websocket-api

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ android {
3939
defaultConfig {
4040
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4141
applicationId "com.deriv.flutter_deriv_api_example"
42-
minSdkVersion 16
42+
minSdkVersion 19
4343
targetSdkVersion 28
4444
versionCode flutterVersionCode.toInteger()
4545
versionName flutterVersionName

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '9.0'
2+
platform :ios, '12.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Runner/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,9 @@
4141
</array>
4242
<key>UIViewControllerBasedStatusBarAppearance</key>
4343
<false/>
44+
<key>CADisableMinimumFrameDurationOnPhone</key>
45+
<true/>
46+
<key>UIApplicationSupportsIndirectInputEvents</key>
47+
<true/>
4448
</dict>
4549
</plist>

example/lib/blocs/active_symbols/active_symbols_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ class ActiveSymbolsBloc extends Bloc<ActiveSymbolsEvent, ActiveSymbolsState> {
5151
Future<ActiveSymbolsResponse> _fetchActiveSymbols() async =>
5252
ActiveSymbolsResponse.fetchActiveSymbols(const ActiveSymbolsRequest(
5353
activeSymbols: 'brief',
54-
productType: 'basic',
54+
productType: 'basic', landingCompany: '',
5555
));
5656
}

example/lib/blocs/available_contracts/available_contracts_bloc.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:flutter_deriv_api/basic_api/generated/api.dart';
99
import '../active_symbols/active_symbols_bloc.dart';
1010

1111
part 'available_contracts_event.dart';
12+
1213
part 'available_contracts_state.dart';
1314

1415
/// AvailableContractsBloc
@@ -75,5 +76,6 @@ class AvailableContractsBloc
7576
) async =>
7677
ContractsForResponse.fetchContractsForSymbol(ContractsForRequest(
7778
contractsFor: selectedSymbol?.symbol,
79+
landingCompany: '',
7880
));
7981
}

example/lib/pages/main_page.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter_deriv_api_example/blocs/active_symbols/active_symbols_bl
44
import 'package:flutter_deriv_api_example/blocs/available_contracts/available_contracts_bloc.dart';
55
import 'package:flutter_deriv_api_example/widgets/active_symbols_widget.dart';
66
import 'package:flutter_deriv_api_example/widgets/contracts_type_widget.dart';
7+
import 'package:flutter_deriv_api_example/widgets/exchange_rate_widget.dart';
78
import 'package:flutter_deriv_api_example/widgets/price_proposal_widget.dart';
89

910
/// MainPage
@@ -47,6 +48,7 @@ class _MainPageState extends State<MainPage> {
4748
Expanded(child: ActiveSymbolsWidget()),
4849
Expanded(child: ContractsTypeWidget()),
4950
Expanded(flex: 2, child: PriceProposalWidget()),
51+
const Expanded(flex: 2, child: ExchangeRateWidget()),
5052
],
5153
),
5254
);

example/lib/sample_app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class _SampleAppState extends State<SampleApp> {
2424
appId: '1089',
2525
brand: 'binary',
2626
endpoint: 'frontend.binaryws.com',
27+
authEndpoint: '',
2728
),
2829
);
2930
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import 'dart:async';
2+
import 'dart:developer';
3+
4+
import 'package:flutter/material.dart';
5+
import 'package:flutter_deriv_api/api/response/exchange_rates_response_result.dart';
6+
import 'package:flutter_deriv_api/api/response/exchange_rates_response_extended.dart';
7+
import 'package:flutter_deriv_api/basic_api/generated/exchange_rates_send.dart';
8+
9+
/// Test widget for the exchange rates for BTC -> USD.
10+
class ExchangeRateWidget extends StatefulWidget {
11+
/// Test widget for exchange rates for BTC -> USD
12+
const ExchangeRateWidget({super.key});
13+
14+
@override
15+
State<ExchangeRateWidget> createState() => _ExchangeRateWidgetState();
16+
}
17+
18+
class _ExchangeRateWidgetState extends State<ExchangeRateWidget> {
19+
double value = 0;
20+
21+
bool isSubscribed = false;
22+
int exchangeUpdateTime = 0;
23+
String subscriptionId = '';
24+
25+
Timer? _refreshingTimer;
26+
27+
@override
28+
Widget build(BuildContext context) => Column(
29+
mainAxisSize: MainAxisSize.min,
30+
children: [
31+
ElevatedButton(
32+
onPressed: () =>
33+
isSubscribed ? _unsubscribe() : _subscribeUSDtoBTC(),
34+
child: isSubscribed
35+
? const Text('Unsubscribe')
36+
: const Text('Subscribe to exchange rate'),
37+
),
38+
const Text('USD:'),
39+
Text(value.toString()),
40+
const SizedBox(height: 12),
41+
const SizedBox(height: 12),
42+
Text(
43+
'Last updated after: ${exchangeUpdateTime.toStringAsFixed(2)} seconds',
44+
)
45+
],
46+
);
47+
48+
Future<void> _subscribeUSDtoBTC() async {
49+
final Stream<ExchangeRatesResponse?> ratesStream =
50+
ExchangeRatesResponseExtended.subscribeToExchangeRates(
51+
const ExchangeRatesRequest(
52+
baseCurrency: 'BTC',
53+
targetCurrency: 'USD',
54+
subscribe: true,
55+
));
56+
57+
// ignore: cascade_invocations
58+
ratesStream.listen((ExchangeRatesResponse? response) {
59+
setState(() {
60+
subscriptionId = response!.subscription!.id;
61+
isSubscribed = true;
62+
value = response.exchangeRates!.rates!['USD'] as double;
63+
_resetTimer();
64+
});
65+
});
66+
}
67+
68+
void _resetTimer() {
69+
_refreshingTimer?.cancel();
70+
71+
_refreshingTimer = Timer.periodic(
72+
const Duration(seconds: 1),
73+
(Timer timer) {
74+
exchangeUpdateTime = timer.tick;
75+
},
76+
);
77+
}
78+
79+
Future<void> _unsubscribe() async {
80+
try {
81+
final bool $ =
82+
await ExchangeRatesResponseExtended.unsubscribeFromExchangeRates(
83+
subscriptionId);
84+
$.toString();
85+
_refreshingTimer?.cancel();
86+
} on Exception catch (e) {
87+
log(e.toString());
88+
}
89+
setState(() {
90+
isSubscribed = false;
91+
});
92+
}
93+
}

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: flutter_deriv_api_example
22
description: Demonstrates how to use the flutter_deriv_api plugin.
33
publish_to: "none"
4+
version: 0.0.1
45

56
environment:
67
sdk: ">=3.0.0"

lib/api/response/account_closure_response_result.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ abstract class AccountClosureResponseModel {
1919
class AccountClosureResponse extends AccountClosureResponseModel {
2020
/// Initializes Account closure response class.
2121
const AccountClosureResponse({
22-
bool? accountClosure,
23-
}) : super(
24-
accountClosure: accountClosure,
25-
);
22+
super.accountClosure,
23+
});
2624

2725
/// Creates an instance from JSON.
2826
factory AccountClosureResponse.fromJson(

0 commit comments

Comments
 (0)