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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Master

* Adds setPrimaryColor API mapping.
* Adds setSessionProfilerEnabled API mapping.

## Version 0.0.3 (2019-03-21)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The section below contains the APIs we're planning to implement for our 1.0 rele
| `logUserEventWithName(String name)` | `logUserEvent(String name)`<br>`+ logUserEventWithName:` |
| `show()` | `show()`<br>`+ show` |
| `setSessionProfilerEnabled(bool sessionProfilerEnabled)` | `setSessionProfilerState(Feature.State state)`<br>`sessionProfilerEnabled` |
| | `setPrimaryColor(@ColorInt int primaryColorValue)`<br>`tintColor` |
|`setPrimaryColor(Color color)` | `setPrimaryColor(@ColorInt int primaryColorValue)`<br>`tintColor` |
| | `onReportSubmitHandler(Report.OnReportCreatedListener listener)`<br>`willSendReportHandler`. |
| | `setUserData(String userData)`<br>`userData` |
| | `addFileAttachment(Uri fileUri, String fileNameWithExtension)`<br>`+ addFileAttachmentWithURL:` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,18 @@ public void setSessionProfilerEnabled(boolean sessionProfilerEnabled) {
Instabug.setSessionProfilerState(Feature.State.DISABLED);
}
}

/**
* Set the primary color that the SDK will use to tint certain UI elements in the SDK
*
* @param primaryColor The value of the primary color
*/
public void setPrimaryColor(final long primaryColor) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Instabug.setPrimaryColor((int)primaryColor);
}
});
}
}
3 changes: 3 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class _MyAppState extends State<MyApp> {
Instabug.setValueForStringWithKey('What\'s the problem', IBGCustomTextPlaceHolderKey.REPORT_BUG);
Instabug.setValueForStringWithKey('Send some ideas', IBGCustomTextPlaceHolderKey.REPORT_FEEDBACK);
Instabug.setSessionProfilerEnabled(false);
Color c = const Color.fromRGBO(255, 0, 255, 1.0);
Color c = const Color.fromRGBO(255, 0, 0, 1.0);
Instabug.setPrimaryColor(c);
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
Expand Down
12 changes: 12 additions & 0 deletions ios/Classes/InstabugFlutterPlugin.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#import "InstabugFlutterPlugin.h"
#import "Instabug.h"

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:((float)((rgbValue & 0xFF000000) >> 24))/255.0 ];

@implementation InstabugFlutterPlugin


Expand Down Expand Up @@ -299,6 +301,16 @@ + (void) setSessionProfilerEnabled:(NSString*) sessionProfilerEnabled {
[Instabug setSessionProfilerEnabled:boolValue];
}

/**
* Set the primary color that the SDK will use to tint certain UI elements in the SDK
*
* @param color The value of the primary color
*/
+ (void) setPrimaryColor:(NSString*) color {
Instabug.tintColor = UIColorFromRGB([color longLongValue]);
}


+ (NSDictionary *)constants {
return @{
@"InvocationEvent.shake": @(IBGInvocationEventShake),
Expand Down
10 changes: 10 additions & 0 deletions lib/Instabug.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:ui';
import 'package:flutter/services.dart';

enum InvocationEvent {
Expand Down Expand Up @@ -210,6 +211,15 @@ class Instabug {
final List<dynamic> params = <dynamic>[sessionProfilerEnabled];
await _channel.invokeMethod<Object>('setSessionProfilerEnabled:', params);
}

/// Sets the primary color of the SDK's UI.
/// Sets the color of UI elements indicating interactivity or call to action.
/// [color] primaryColor A color to set the UI elements of the SDK to.
static void setPrimaryColor(Color color) async {
final List<dynamic> params = <dynamic>[color.value];
await _channel.invokeMethod<Object>('setPrimaryColor:', params);
}

}


Expand Down
12 changes: 12 additions & 0 deletions test/instabug_flutter_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:ui';

import 'package:instabug_flutter/Instabug.dart';
import 'package:instabug_flutter/BugReporting.dart';
Expand Down Expand Up @@ -294,6 +295,17 @@ test('startWithToken:invocationEvents: Test', () async {
]);
});

test('setPrimaryColor: Test', () async {
Color c = const Color.fromRGBO(255, 0, 255, 1.0);
final List<dynamic> args = <dynamic>[c.value];
Instabug.setPrimaryColor(c);
expect(log, <Matcher>[
isMethodCall('setPrimaryColor:',
arguments: args,
)
]);
});

}