Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
weng-deriv committed Mar 20, 2024
2 parents 2f01df9 + 9c4c80f commit 8123b2d
Show file tree
Hide file tree
Showing 726 changed files with 21,225 additions and 10,604 deletions.
82 changes: 0 additions & 82 deletions .circleci/config.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Flutter Analyze, Test, and Build

on:
push:
branches:
- master
- dev
pull_request:
branches:
- "*"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- name: 📚 Git Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: 🐦 Setup Flutter
uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
with:
flutter-version: "3.10.2"
channel: stable
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

- name: 📦 Install Dependencies
run: flutter pub get

# do not fail if the analyze issue is info level
- name: 🕵️ Analyze
run: |
if flutter analyze 2>&1 | grep -q -E 'error:|warning:';
then exit 1
else exit 0
fi
- name: 🧪 Run Tests
run: flutter test

- name: Build Example app
working-directory: ./example
run: flutter build apk --target-platform android-arm
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "binary-websocket-api"]
path = binary-websocket-api
url = https://github.com/regentmarkets/binary-websocket-api.git
url = git@github.com:regentmarkets/binary-websocket-api.git
branch = master
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ dependencies:
```
$ git submodule init
$ git submodule update --remote
$ ./setup.sh
$ flutter pub run build_runner build --delete-conflicting-outputs
```

### Run the tests
Expand Down
7 changes: 3 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ analyzer:
exclude:
- lib/basic_api/generated/api.dart

strong-mode:
implicit-dynamic: false

language:
strict-raw-types: true
errors:
todo: ignore
missing_required_param: warning
Expand Down Expand Up @@ -92,7 +92,6 @@ linter:
- prefer_const_literals_to_create_immutables
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_equal_for_default_values
- prefer_expression_function_bodies # https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
- prefer_final_fields
- prefer_final_in_for_each
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'com.deriv.flutter_deriv_api'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.7.10'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
43 changes: 25 additions & 18 deletions api_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class APIBuilder extends Builder {
/// Initialize $classFullName.
const $classFullName({
${_getConstructorParameters(methodName, schema, schemaType, properties)}
${_getSuperClassParameters(schemaType)},
}): super(${_getSuperClassCallParameters(schemaType, methodName)},);
${_getSuperClassConstructorParameters(schemaType, methodName)},
});
${_getFromJsonMethod(classFullName, schema, schemaType, properties)}
Expand Down Expand Up @@ -169,6 +169,7 @@ class APIBuilder extends Builder {
return '${_isFieldRequired(key, schemaType, property) ? 'required ' : ''} this.${ReCase(key).camelCase}';
},
).join(', ');

return fields.isEmpty ? result : '$result , ';
}

Expand Down Expand Up @@ -380,6 +381,7 @@ class APIBuilder extends Builder {
fields.map(
(String key) {
final String name = ReCase(key).camelCase;

return '$name: $name ?? this.$name';
},
).join(', '),
Expand All @@ -388,40 +390,45 @@ class APIBuilder extends Builder {
..write('${_getSupperClassAssignments(schemaType)},);');
}

static String _getSuperClassParameters(String? schemaType) {
static String _getSuperClassParameters(String schemaType) {
final Map<String, String> superClassFields =
_getSuperClassFields(schemaType);

return superClassFields.keys
.map((String key) =>
'${typeMap[superClassFields[key]!]} ${ReCase(key).camelCase}')
.join(', ');
final Iterable<String> parameters = superClassFields.keys.map((String key) {
final String type = typeMap[superClassFields[key]!] ?? 'dynamic';
final String parameterName = ReCase(key).camelCase;

return '$type $parameterName';
});

return parameters.join(', ');
}

static String _getSuperClassCallParameters(
static String _getSuperClassConstructorParameters(
String schemaType,
String methodName,
) {
final StringBuffer superCallParameters = StringBuffer();
final Map<String, String> superClassFields =
_getSuperClassFields(schemaType);
final StringBuffer superClassParameters = StringBuffer();

if (schemaType == 'send') {
superCallParameters.write('msgType: \'$methodName\',');
superClassParameters.write('super.msgType = \'$methodName\', ');
}

superCallParameters.write(_getSuperClassFields(schemaType).keys.map(
(String key) {
final String parameterName = ReCase(key).camelCase;
return '$parameterName: $parameterName';
},
).join(', '));
final Iterable<String> parameters = superClassFields.keys
.map((String key) => 'super.${ReCase(key).camelCase}');

return superCallParameters.toString();
superClassParameters.write(parameters.join(', '));

return superClassParameters.toString();
}

static String _getSupperClassAssignments(String schemaType) =>
_getSuperClassFields(schemaType).keys.map(
(String key) {
final String propertyName = ReCase(key).camelCase;

return '$propertyName: $propertyName ?? this.$propertyName';
},
).join(', ');
Expand Down Expand Up @@ -458,7 +465,7 @@ class APIBuilder extends Builder {
}
}

class GeneratedResponseJson extends Comparable<GeneratedResponseJson> {
class GeneratedResponseJson implements Comparable<GeneratedResponseJson> {
GeneratedResponseJson({
this.msgType,
this.fileName,
Expand Down
2 changes: 1 addition & 1 deletion binary-websocket-api
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -39,7 +39,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.deriv.flutter_deriv_api_example"
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.7.10'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
Loading

0 comments on commit 8123b2d

Please sign in to comment.