Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
- uses: nanasess/setup-chromedriver@v2
- uses: subosito/flutter-action@v1
with:
channel: 'master'
channel: 'stable'

# Download all Flutter packages
- name: Download dependencies
Expand All @@ -117,5 +117,6 @@ jobs:

# Run all integration tests
- name: Run integration tests
timeout-minutes: 10
run: flutter drive -d web-server --browser-name=chrome --driver=test_driver/integration_test.dart --target=integration_test/intercom_flutter_web_test.dart
working-directory: ${{env.source-directory}}
4 changes: 4 additions & 0 deletions intercom_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 9.4.15

* Added API `setThemeMode`.

## 9.4.14

* Bump Intercom iOS SDK version to [19.3.2](https://github.com/intercom/intercom-ios/releases/tag/19.3.2)
Expand Down
5 changes: 3 additions & 2 deletions intercom_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'io.maido.intercom'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '2.1.21'
ext.kotlin_version = '2.2.21'
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:8.10.1")
classpath("com.android.tools.build:gradle:8.13.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}
Expand Down Expand Up @@ -51,5 +51,6 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'io.intercom.android:intercom-sdk:17.3.0'
implementation 'io.intercom.android:intercom-sdk-ui:17.3.0'
implementation 'com.google.firebase:firebase-messaging:24.1.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.flutter.plugin.common.MethodChannel.Result
import io.intercom.android.sdk.*
import io.intercom.android.sdk.identity.Registration
import io.intercom.android.sdk.push.IntercomPushClient
import io.intercom.android.sdk.ui.theme.ThemeMode

class IntercomFlutterPlugin : FlutterPlugin, MethodCallHandler, EventChannel.StreamHandler, ActivityAware {
companion object {
Expand Down Expand Up @@ -298,6 +299,24 @@ class IntercomFlutterPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Str
})
}
}
"setThemeMode" -> {
val theme = call.argument<String>("theme")
when (theme) {
"dark" -> {
Intercom.client().setThemeMode(ThemeMode.DARK)
}
"light" -> {
Intercom.client().setThemeMode(ThemeMode.LIGHT)
}
"system" -> {
Intercom.client().setThemeMode(ThemeMode.SYSTEM)
}
else -> {
Intercom.client().setThemeMode(null)
}
}
result.success("Theme overridden")
}
else -> result.notImplemented()
}
}
Expand Down
6 changes: 3 additions & 3 deletions intercom_flutter/example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.10.1' apply false
id "org.jetbrains.kotlin.android" version "2.1.21" apply false
id "com.google.gms.google-services" version "4.4.2" apply false
id "com.android.application" version '8.13.0' apply false
id "org.jetbrains.kotlin.android" version "2.2.21" apply false
id "com.google.gms.google-services" version "4.4.4" apply false
}

include ":app"
2 changes: 1 addition & 1 deletion intercom_flutter/example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
2 changes: 2 additions & 0 deletions intercom_flutter/example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
13 changes: 13 additions & 0 deletions intercom_flutter/ios/Classes/IntercomFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,19 @@ - (void) handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
details: [self getIntercomError:errorCode:errorMsg]]);
}];
}
} else if([@"setThemeMode" isEqualToString:call.method]) {
NSString *theme = call.arguments[@"theme"];

if([@"dark" isEqualToString:theme]){
[Intercom setThemeOverride:ICMThemeOverrideDark];
} else if([@"light" isEqualToString:theme]){
[Intercom setThemeOverride:ICMThemeOverrideLight];
} else if([@"system" isEqualToString:theme]){
[Intercom setThemeOverride:ICMThemeOverrideSystem];
} else {
[Intercom setThemeOverride:ICMThemeOverrideNone];
}
result(@"Theme overridden");
}
else {
result(FlutterMethodNotImplemented);
Expand Down
13 changes: 11 additions & 2 deletions intercom_flutter/lib/intercom_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ library intercom_flutter;

import 'dart:async';

import 'package:intercom_flutter_platform_interface/enumeral.dart';
import 'package:intercom_flutter_platform_interface/intercom_flutter_platform_interface.dart';
import 'package:intercom_flutter_platform_interface/intercom_status_callback.dart';

/// export the [IntercomVisibility] enum
export 'package:intercom_flutter_platform_interface/intercom_flutter_platform_interface.dart'
show IntercomVisibility;
export 'package:intercom_flutter_platform_interface/enumeral.dart'
show IntercomVisibility, IntercomTheme;
export 'package:intercom_flutter_platform_interface/intercom_status_callback.dart'
show IntercomStatusCallback, IntercomError;

Expand Down Expand Up @@ -304,4 +305,12 @@ class Intercom {
Future<void> setAuthTokens(Map<String, String> tokens) {
return IntercomFlutterPlatform.instance.setAuthTokens(tokens);
}

/// The theme mode controls whether the SDK displays in light mode, dark mode,
/// or follows the system theme.
/// The theme selection will be reset when the app restarts i.e. You can
/// override the server-provided theme setting for the current session only.
Future<void> setThemeMode(IntercomTheme theme) {
return IntercomFlutterPlatform.instance.setThemeMode(theme);
}
}
6 changes: 3 additions & 3 deletions intercom_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: intercom_flutter
description: Flutter plugin for Intercom integration. Provides in-app messaging
and help-center Intercom services
version: 9.4.14
version: 9.4.15
homepage: https://github.com/v3rm0n/intercom_flutter

dependencies:
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
intercom_flutter_platform_interface: ^2.0.5
intercom_flutter_web: ^1.1.9
intercom_flutter_platform_interface: ^2.0.6
intercom_flutter_web: ^1.1.10

dev_dependencies:
flutter_test:
Expand Down
30 changes: 30 additions & 0 deletions intercom_flutter/test/intercom_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,34 @@ void main() {
'tokens': {'security_token': 'test'},
});
});

group('setThemeMode', () {
test('dark', () {
Intercom.instance.setThemeMode(IntercomTheme.dark);
expectMethodCall('setThemeMode', arguments: {
'theme': 'dark',
});
});

test('light', () {
Intercom.instance.setThemeMode(IntercomTheme.light);
expectMethodCall('setThemeMode', arguments: {
'theme': 'light',
});
});

test('system', () {
Intercom.instance.setThemeMode(IntercomTheme.system);
expectMethodCall('setThemeMode', arguments: {
'theme': 'system',
});
});

test('none', () {
Intercom.instance.setThemeMode(IntercomTheme.none);
expectMethodCall('setThemeMode', arguments: {
'theme': 'none',
});
});
});
}
4 changes: 4 additions & 0 deletions intercom_flutter_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.0.6

* Added method `setThemeMode`.

## 2.0.5

* Deprecated `handlePushMessage`
Expand Down
18 changes: 18 additions & 0 deletions intercom_flutter_platform_interface/lib/enumeral.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
enum IntercomVisibility {
gone,
visible,
}

enum IntercomTheme {
// // Enable dark mode
dark,

// Enable light mode
light,

// Use system preference
system,

// Clear override and use server-provided theme
none,
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'package:intercom_flutter_platform_interface/enumeral.dart';
import 'package:intercom_flutter_platform_interface/intercom_status_callback.dart';
import 'package:intercom_flutter_platform_interface/method_channel_intercom_flutter.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

enum IntercomVisibility { gone, visible }

abstract class IntercomFlutterPlatform extends PlatformInterface {
IntercomFlutterPlatform() : super(token: _token);

Expand Down Expand Up @@ -295,4 +294,12 @@ abstract class IntercomFlutterPlatform extends PlatformInterface {
Future<void> setAuthTokens(Map<String, String> tokens) {
throw UnimplementedError('setAuthTokens() has not been implemented.');
}

/// The theme mode controls whether the SDK displays in light mode, dark mode,
/// or follows the system theme.
/// The theme selection will be reset when the app restarts i.e. You can
/// override the server-provided theme setting for the current session only.
Future<void> setThemeMode(IntercomTheme theme) {
throw UnimplementedError('setThemeMode() has not been implemented.');
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/services.dart';
import 'package:intercom_flutter_platform_interface/enumeral.dart';
import 'package:intercom_flutter_platform_interface/intercom_flutter_platform_interface.dart';
import 'package:intercom_flutter_platform_interface/intercom_status_callback.dart';

Expand Down Expand Up @@ -265,6 +266,11 @@ class MethodChannelIntercomFlutter extends IntercomFlutterPlatform {
await _channel.invokeMethod('setAuthTokens', {'tokens': tokens});
}

@override
Future<void> setThemeMode(IntercomTheme theme) async {
await _channel.invokeMethod('setThemeMode', {'theme': theme.name});
}

/// Convert the [PlatformException] details to [IntercomError].
/// From the Platform side if the intercom operation failed then error details
/// will be sent as details in [PlatformException].
Expand Down
2 changes: 1 addition & 1 deletion intercom_flutter_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: intercom_flutter_platform_interface
description: A common platform interface for the intercom_flutter plugin.
version: 2.0.5
version: 2.0.6
homepage: https://github.com/v3rm0n/intercom_flutter

dependencies:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:intercom_flutter_platform_interface/enumeral.dart';
import 'package:intercom_flutter_platform_interface/intercom_flutter_platform_interface.dart';
import 'package:intercom_flutter_platform_interface/method_channel_intercom_flutter.dart';
import 'package:mockito/mockito.dart';
Expand Down Expand Up @@ -479,6 +480,56 @@ void main() {
],
);
});

group('setThemeMode', () {
test('dark', () async {
await intercom.setThemeMode(IntercomTheme.dark);
expect(
log,
<Matcher>[
isMethodCall('setThemeMode', arguments: {
'theme': 'dark',
})
],
);
});

test('light', () async {
await intercom.setThemeMode(IntercomTheme.light);
expect(
log,
<Matcher>[
isMethodCall('setThemeMode', arguments: {
'theme': 'light',
})
],
);
});

test('system', () async {
await intercom.setThemeMode(IntercomTheme.system);
expect(
log,
<Matcher>[
isMethodCall('setThemeMode', arguments: {
'theme': 'system',
})
],
);
});

test('none', () async {
await intercom.setThemeMode(IntercomTheme.none);
expect(
log,
<Matcher>[
isMethodCall('setThemeMode', arguments: {
'theme': 'none',
})
],
);
});
});
});
}

Expand Down
4 changes: 4 additions & 0 deletions intercom_flutter_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.10

* Implemented method `setThemeMode`.

## 1.1.9

* Removed `auth_tokens` and `intercom_user_jwt` from intercomSettings on logout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,23 @@ void main() {
testWidgets('setAuthTokens', (WidgetTester _) async {
expect(plugin.setAuthTokens({'security_token': 'test'}), completes);
});

group('setThemeMode', () {
testWidgets('dark', (WidgetTester _) async {
expect(plugin.setThemeMode(IntercomTheme.dark), completes);
});

testWidgets('light', (WidgetTester _) async {
expect(plugin.setThemeMode(IntercomTheme.light), completes);
});

testWidgets('system', (WidgetTester _) async {
expect(plugin.setThemeMode(IntercomTheme.system), completes);
});

testWidgets('none', (WidgetTester _) async {
expect(plugin.setThemeMode(IntercomTheme.none), completes);
});
});
});
}
Loading
Loading