Skip to content

Commit

Permalink
Merge branch 'master' into update-datadog
Browse files Browse the repository at this point in the history
  • Loading branch information
sahani-deriv authored Dec 23, 2024
2 parents cabba23 + b57430a commit a384bae
Show file tree
Hide file tree
Showing 123 changed files with 5,855 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ lib/basic_api/generated/*.json
*.iws
.idea/

.fvm

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
Expand All @@ -32,7 +30,6 @@ coverage/
/packages/**/pubspec_overrides.yaml
/packages/**/pubspec.lock


gradlew.bat
local.properties
gradlew
Expand Down Expand Up @@ -73,3 +70,6 @@ gradle/
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
/.idea/

# FVM Version Cache
.fvm/
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-12-19

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`deriv_mobile_chart_wrapper` - `v0.1.10+1`](#deriv_mobile_chart_wrapper---v01101)

---

#### `deriv_mobile_chart_wrapper` - `v0.1.10+1`

- **FIX**(deriv_mobile_chart_wrapper): [GRWT-3474] Point_Highlight_Enlarges_when_navigating_back_to_same_chart_view ([#918](https://github.com/regentmarkets/flutter-deriv-packages/issues/918)). ([c751b552](https://github.com/regentmarkets/flutter-deriv-packages/commit/c751b552915c91e9386a90143a2291b512cd3dbd))


## 2024-12-12

### Changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | [v3.1.1](./packages/update_checker/CHANGELOG.md) |
| [deriv_feature_flag](./packages/deriv_feature_flag) | A package to provide feature flag functionality for apps. | [v0.1.2](./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.10](./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.10+1](./packages/deriv_mobile_chart_wrapper/CHANGELOG.md) |
| [deriv_cipher](./packages/deriv_cipher) | A package to encrypt and decrypt data using AES encryption.| [v0.0.2](./packages/deriv_cipher/CHANGELOG.md) |
Expand Down
4 changes: 4 additions & 0 deletions packages/deriv_mobile_chart_wrapper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.10+1

- **FIX**(deriv_mobile_chart_wrapper): [GRWT-3474] Point_Highlight_Enlarges_when_navigating_back_to_same_chart_view ([#918](https://github.com/regentmarkets/flutter-deriv-packages/issues/918)). ([c751b552](https://github.com/regentmarkets/flutter-deriv-packages/commit/c751b552915c91e9386a90143a2291b512cd3dbd))

## 0.1.10

- **FEAT**(deriv_mobile_chart_wrapper): [GRWT-3362] update chart package version ([#919](https://github.com/regentmarkets/flutter-deriv-packages/issues/919)). ([d79b9d5e](https://github.com/regentmarkets/flutter-deriv-packages/commit/d79b9d5e9d7216085e60c49be98a8cd0a7caea18))
Expand Down
2 changes: 1 addition & 1 deletion packages/deriv_mobile_chart_wrapper/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:deriv_chart/deriv_chart.dart';

// A set of drawing tool types that has to show drawing tool info bar.
const Set<Type> drawingToolTypesToShowInfoBar = {
LineDrawingToolConfig,
LineDrawingToolConfigMobile,
RayDrawingToolConfig,
};

Expand Down
12 changes: 8 additions & 4 deletions packages/deriv_mobile_chart_wrapper/lib/src/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ String getIndicatorIconPath(IndicatorConfig config) {
/// for the given [drawingToolType].
String getDrawingToolIconPath(Type drawingToolType) {
switch (drawingToolType) {
case LineDrawingToolConfig:
case LineDrawingToolConfigMobile:
return lineIcon;
case RayDrawingToolConfig:
return rsiIcon;
Expand All @@ -70,8 +70,12 @@ List<DrawingToolItemModel> getDrawingToolsList(
DrawingToolItemModel(
title: context.mobileChartWrapperLocalizations.labelLine,
icon: lineIcon,
config: const LineDrawingToolConfig(
lineStyle: LineStyle(thickness: 0.9, color: BrandColors.coral),
config: const LineDrawingToolConfigMobile(
lineStyle: LineStyle(
thickness: 0.9,
color: BrandColors.coral,
markerRadius: 4,
),
),
),
// Add more drawing tools here.
Expand Down Expand Up @@ -99,7 +103,7 @@ String getDrawingToolTitle(
DrawingToolConfig config,
) {
switch (config.runtimeType) {
case LineDrawingToolConfig:
case LineDrawingToolConfigMobile:
return context.mobileChartWrapperLocalizations.labelLine;
case RayDrawingToolConfig:
return context.mobileChartWrapperLocalizations.labelRay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class DrawingToolInfoBar extends StatelessWidget
BuildContext context, {
required DrawingToolConfig drawingTool,
}) {
if (drawingTool is LineDrawingToolConfig ||
if (drawingTool is LineDrawingToolConfigMobile ||
drawingTool is RayDrawingToolConfig) {
final bool isDrawingToolSelected =
toolsController.drawingToolsData?.selectedDrawingTool?.drawingData ==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ToolsController extends ChangeNotifier {
ContinuousDrawingToolConfig,
FibfanDrawingToolConfig,
HorizontalDrawingToolConfig,
LineDrawingToolConfig,
LineDrawingToolConfigMobile,
RayDrawingToolConfig,
RectangleDrawingToolConfig,
TrendDrawingToolConfig,
Expand Down
4 changes: 2 additions & 2 deletions packages/deriv_mobile_chart_wrapper/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.10
version: 0.1.10+1
homepage:

environment:
Expand All @@ -14,7 +14,7 @@ dependencies:
deriv_chart:
git:
url: [email protected]:regentmarkets/flutter-chart.git
ref: v0.3.3
ref: v0.3.4

deriv_theme:
git:
Expand Down
1 change: 1 addition & 0 deletions packages/intercom_flutter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/intercom_flutter/example/lib/generated_plugin_registrant.dart
212 changes: 212 additions & 0 deletions packages/intercom_flutter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# intercom_flutter

[![Pub](https://img.shields.io/pub/v/intercom_flutter.svg)](https://pub.dev/packages/intercom_flutter)
![CI](https://github.com/v3rm0n/intercom_flutter/workflows/CI/badge.svg)

Flutter wrapper for Intercom [Android](https://github.com/intercom/intercom-android), [iOS](https://github.com/intercom/intercom-ios), and [Web](https://developers.intercom.com/installing-intercom/docs/basic-javascript) projects.

- Uses Intercom Android SDK Version `15.11.2`.
- The minimum Android SDK `minSdk` required is 21.
- The compile Android SDK `compileSdk` required is 34.
- Uses Intercom iOS SDK Version `18.2.2`.
- The minimum iOS target version required is 15.
- The Xcode version required is 15.

## Usage

Import `package:intercom_flutter/intercom_flutter.dart` and use the methods in `Intercom` class.

Example:
```dart
import 'package:flutter/material.dart';
import 'package:intercom_flutter/intercom_flutter.dart';
void main() async {
// initialize the flutter binding.
WidgetsFlutterBinding.ensureInitialized();
// initialize the Intercom.
// make sure to add keys from your Intercom workspace.
// don't forget to set up the custom application class on Android side.
await Intercom.instance.initialize('appIdHere', iosApiKey: 'iosKeyHere', androidApiKey: 'androidKeyHere');
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text('Open Intercom'),
onPressed: () async {
// messenger will load the messages only if the user is registered in Intercom.
// either identified or unidentified.
await Intercom.instance.displayMessenger();
},
);
}
}
```

See Intercom [Android](https://developers.intercom.com/installing-intercom/docs/intercom-for-android) and [iOS](https://developers.intercom.com/installing-intercom/docs/intercom-for-ios) package documentation for more information.

### Android

Make sure that your app's `MainActivity` extends `FlutterFragmentActivity` (you can check the example).

Permissions:
```xml
<uses-permission android:name="android.permission.INTERNET"/>
```

Optional permissions:

```xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
```

Enable AndroidX + Jetifier support in your android/gradle.properties file (see example app):

```
android.useAndroidX=true
android.enableJetifier=true
```

According to the documentation, Intercom must be initialized in the Application onCreate. So follow the below steps to achieve the same:
- Setup custom application class if you don't have any.
- Create a custom `android.app.Application` class named `MyApp`.
- Add an `onCreate()` override. The class should look like this:
```kotlin
import android.app.Application

class MyApp: Application() {

override fun onCreate() {
super.onCreate()
}
}
```
- Open your `AndroidManifest.xml` and find the `application` tag. In it, add an `android:name` attribute, and set the value to your class' name, prefixed by a dot (.).
```xml
<application
android:name=".MyApp" >
```
- Now initialize the Intercom SDK inside the `onCreate()` of custom application class according to the following:
```kotlin
import android.app.Application
import io.maido.intercom.IntercomFlutterPlugin
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
// Add this line with your keys
IntercomFlutterPlugin.initSdk(this, appId = "appId", androidApiKey = "androidApiKey")
}
}
```
### iOS
Make sure that you have a `NSPhotoLibraryUsageDescription` entry in your `Info.plist`.
### Push notifications setup
This plugin works in combination with the [`firebase_messaging`](https://pub.dev/packages/firebase_messaging) plugin to receive Push Notifications. To set this up:
* First, implement [`firebase_messaging`](https://pub.dev/packages/firebase_messaging)
* Then, add the Firebase server key to Intercom, as described [here](https://developers.intercom.com/installing-intercom/docs/android-fcm-push-notifications#section-step-3-add-your-server-key-to-intercom-for-android-settings) (you can skip 1 and 2 as you have probably done them while configuring `firebase_messaging`)
* Follow the steps as described [here](https://developers.intercom.com/installing-intercom/docs/ios-push-notifications) to enable push notification in iOS.
* Starting from Android 13 you may need to ask for notification permissions (as of version 13 `firebase_messaging` should support that)
* Ask FirebaseMessaging for the token that we need to send to Intercom, and give it to Intercom (so Intercom can send push messages to the correct device), please note that in order to receive push notifications in your iOS app, you have to send the APNS token to Intercom. The example below uses [`firebase_messaging`](https://pub.dev/packages/firebase_messaging) to get either the FCM or APNS token based on the platform:
```dart
final firebaseMessaging = FirebaseMessaging.instance;
final intercomToken = Platform.isIOS ? await firebaseMessaging.getAPNSToken() : await firebaseMessaging.getToken();
Intercom.instance.sendTokenToIntercom(intercomToken);
```
Now, if either Firebase direct (e.g. by your own backend server) or Intercom sends you a message, it will be delivered to your app.
### Web
You don't need to do any extra steps for the web. Intercom script will be automatically injected.
But you can pre-define some Intercom settings, if you want (optional).
```html
<script>
window.intercomSettings = {
hide_default_launcher: true, // hide the default launcher
};
</script>
```
#### Following functions are not yet supported on Web:

- [ ] unreadConversationCount
- [ ] setInAppMessagesVisibility
- [ ] sendTokenToIntercom
- [ ] handlePushMessage
- [ ] isIntercomPush
- [ ] handlePush
- [ ] displayCarousel
- [ ] displayHelpCenterCollections

## Using Intercom keys with `--dart-define`

Use `--dart-define` variables to avoid hardcoding Intercom keys.

### Pass the Intercom keys with `flutter run` or `flutter build` command using `--dart-define`.
```dart
flutter run --dart-define="INTERCOM_APP_ID=appID" --dart-define="INTERCOM_ANDROID_KEY=androidKey" --dart-define="INTERCOM_IOS_KEY=iosKey"
```
Note: You can also use `--dart-define-from-file` which is introduced in Flutter 3.7.

### Reading keys in Dart side and initialize the SDK.
```dart
String appId = String.fromEnvironment("INTERCOM_APP_ID", "");
String androidKey = String.fromEnvironment("INTERCOM_ANDROID_KEY", "");
String iOSKey = String.fromEnvironment("INTERCOM_IOS_KEY", "");
Intercom.instance.initialize(appId, iosApiKey: iOSKey, androidApiKey: androidKey);
```

### Reading keys in Android native side and initialize the SDK.

* Add the following code to `build.gradle`.
```
def dartEnvironmentVariables = []
if (project.hasProperty('dart-defines')) {
dartEnvironmentVariables = project.property('dart-defines')
.split(',')
.collectEntries { entry ->
def pair = new String(entry.decodeBase64(), 'UTF-8').split('=')
[(pair.first()): pair.last()]
}
}
```

* Place `dartEnvironmentVariables` inside the build config
```
defaultConfig {
...
buildConfigField 'String', 'INTERCOM_APP_ID', "\"${dartEnvironmentVariables.INTERCOM_APP_ID}\""
buildConfigField 'String', 'INTERCOM_ANDROID_KEY', "\"${dartEnvironmentVariables.INTERCOM_ANDROID_KEY}\""
}
```

* Read the build config fields
```kotlin
import android.app.Application
import android.os.Build
import io.maido.intercom.IntercomFlutterPlugin

class MyApp : Application() {
override fun onCreate() {
super.onCreate()

// Add this line with your keys
IntercomFlutterPlugin.initSdk(this,
appId = BuildConfig.INTERCOM_APP_ID,
androidApiKey = BuildConfig.INTERCOM_ANDROID_KEY)
}
}
```
13 changes: 13 additions & 0 deletions packages/intercom_flutter/intercom_flutter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
.dart_tool/

.packages
.pub/
pubspec.lock

build/
.idea/*
!.idea/runConfigurations
android/bin/
example/.flutter-plugins-dependencies
example/ios/Flutter/flutter_export_environment.sh
Loading

0 comments on commit a384bae

Please sign in to comment.