Skip to content

Commit

Permalink
Add version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leontobias committed Apr 27, 2023
1 parent 60e9203 commit cd38dd8
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 67 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [3.0.0]

### Changed

* Changed and aligned the error codes for the plugins.
* [imgly_sdk] Removed custom `Color` class and replaced its usage with the `dart:ui` `Color` class.
* [video_editor_sdk] Unlocking the license via `VESDK.unlockWithLicense` is now executing asynchronously.
* [photo_editor_sdk] Unlocking the license via `PESDK.unlockWithLicense` is now executing asynchronously.

### Fixed

* [video_editor_sdk] Fixed tint color of the toolbar would not be applied correctly in the trim tool on iOS.

## [2.9.0]

### Added
Expand Down
14 changes: 11 additions & 3 deletions android/src/main/kotlin/ly/img/flutter/imgly_sdk/FlutterIMGLY.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ open class FlutterIMGLY: FlutterPlugin, MethodChannel.MethodCallHandler, Activit
/** The currently used *Configuration*. */
var currentConfig: Configuration? = null

/** IMGLY constants for the plugin use. */
object IMGLYConstants {
const val K_ERROR_UNABLE_TO_UNLOCK = "E_UNABLE_TO_UNLOCK"
const val K_ERROR_UNABLE_TO_LOAD = "E_UNABLE_TO_LOAD"
const val K_ERROR_MULTIPLE_REQUESTS = "E_MULTIPLE_REQUESTS"
const val K_ERROR_UNABLE_TO_RELEASE = "E_UNABLE_TO_RELEASE"
}

/** The currently used *FlutterPluginBinding*. */
private var binding: FlutterPlugin.FlutterPluginBinding? = null

Expand Down Expand Up @@ -137,15 +145,15 @@ open class FlutterIMGLY: FlutterPlugin, MethodChannel.MethodCallHandler, Activit
licenseContent?.also {
this.unlockWithLicense(it)
} ?: run {
result?.error("Invalid license.", "The license content can not be empty.", null)
result?.error(IMGLYConstants.K_ERROR_UNABLE_TO_UNLOCK, "The license content can not be empty.", null)
result = null
}
} ?: run {
result?.error("Invalid license.", "The license can not be found..", null)
result?.error(IMGLYConstants.K_ERROR_UNABLE_TO_UNLOCK, "The license can not be found..", null)
result = null
}
} else {
result?.error("Invalid license.", "The license can not be nil.", null)
result?.error(IMGLYConstants.K_ERROR_UNABLE_TO_UNLOCK, "The license can not be nil.", null)
result = null
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Flutter (1.0.0)
- imgly_sdk (2.9.0):
- imgly_sdk (3.0.0):
- Flutter
- imglyKit (~> 11.4)
- imglyKit (11.5.1)
Expand All @@ -21,7 +21,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
imgly_sdk: a1937f3cd410756297d87d15086a37f24466d288
imgly_sdk: a114555e1d98e4a4fa5cc8f2b258353198c64e8b
imglyKit: b1b3b827799a50b090433ca7c61f90b078944898

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
Expand Down
42 changes: 11 additions & 31 deletions ios/Classes/FlutterIMGLY.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ open class FlutterIMGLY: NSObject {
/// The configuration defined in Dart is already applied to the provided `ConfigurationBuilder` object.
public static var configureWithBuilder: IMGLYConfigurationBlock?

/// The `Error` thrown in case that the license is invalid.
private var licenseError: NSError?

/// The currently presented `MediaEditViewController`.
private var mediaEditViewController: MediaEditViewController?

Expand Down Expand Up @@ -76,6 +73,7 @@ open class FlutterIMGLY: NSObject {
public static let kErrorUnableToUnlock = "E_UNABLE_TO_UNLOCK"
public static let kErrorUnableToLoad = "E_UNABLE_TO_LOAD"
public static let kErrorUnableToExport = "E_UNABLE_TO_EXPORT"
public static let kErrorMultipleRequests = "E_MULTIPLE_REQUESTS"

public static let kExportTypeFileURL = "file-url"
public static let kExportTypeDataURL = "data-url"
Expand Down Expand Up @@ -120,13 +118,6 @@ open class FlutterIMGLY: NSObject {

// Run on the main queue in order to align with the license validation.
DispatchQueue.main.async {
// Check if the license could be validated.
if let error_ = self.licenseError {
self.result?(FlutterError(code: "License validation error.", message: "The license could not be validated.", details: error_.localizedDescription))
self.result = nil
return
}

// Retrieve the configuration.
let assetCatalog = AssetCatalog.defaultItems
let configurationDictionary = configurationData ?? [String: Any]()
Expand Down Expand Up @@ -260,6 +251,14 @@ open class FlutterIMGLY: NSObject {
options.applyButtonConfigurationClosure = toolbarButtonClosure
options.discardButtonConfigurationClosure = toolbarButtonClosure
}
builder.configureTrimToolController { options in
options.applyButtonConfigurationClosure = toolbarButtonClosure
options.discardButtonConfigurationClosure = toolbarButtonClosure
}
builder.configureClipTrimToolController { options in
options.applyButtonConfigurationClosure = toolbarButtonClosure
options.discardButtonConfigurationClosure = toolbarButtonClosure
}
builder.configureAudioToolController { options in
options.applyButtonConfigurationClosure = toolbarButtonClosure
options.discardButtonConfigurationClosure = toolbarButtonClosure
Expand Down Expand Up @@ -366,7 +365,8 @@ open class FlutterIMGLY: NSObject {
let validLicensePath = licensePath + ".ios"
guard let key = FlutterIMGLY.registrar?.lookupKey(forAsset: validLicensePath),
let url = Bundle.main.url(forResource: key, withExtension: nil) else {
self.handleLicenseError(with: nil)
self.result?(FlutterError(code: "License validation failed.", message: "Unlocking the SDK failed due to:", details: "The license file could not be found in the bundle."))
self.result = nil
return
}
self.unlockWithLicenseFile(at: url)
Expand All @@ -375,26 +375,6 @@ open class FlutterIMGLY: NSObject {
/// Unlocks the SDK witha license from a given file.
/// - Parameter url: The url where the file is located.
open func unlockWithLicenseFile(at url: URL) {}

/// Handles any error that occurs while unlocking the license.
/// - Parameter error: The `NSError` of the unlocking process.
public func handleLicenseError(with error: NSError?) {
self.result = nil
self.licenseError = nil
if let error_ = error {
if error_.domain == "ImglyKit.IMGLY.Error" {
switch error_.code {
case 3:
return
default:
self.licenseError = error_
return
}
} else {
self.licenseError = error_
}
}
}
}

/// Extension for converting wrappers.
Expand Down
41 changes: 11 additions & 30 deletions lib/imgly_sdk.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:ui' as dart_ui;
import 'dart:ui';

/// Configuration options and asset definitions for image and
/// video editing tasks.
Expand Down Expand Up @@ -272,38 +272,38 @@ class Theme {
/// items, the sliders' thumb outline and filled track, and selected fonts
/// in the editor.
/// If `null` the default system's `tintColor` is used.
final dart_ui.Color? tintColor;
final Color? tintColor;

/// The primary tint color used for texts, buttons, icons, and control
/// elements with static background colors in the editor.
/// ```
/// // Defaults to:
/// Colors.white
/// ```
final dart_ui.Color? primaryColor;
final Color? primaryColor;

/// The background color used for the background of the canvas in the editor.
/// ```
/// // Defaults to:
/// Colors.black
/// ```
final dart_ui.Color? backgroundColor;
final Color? backgroundColor;

/// The background color of the menu and accesory controls above the menu
/// in the editor.
/// ```
/// // Defaults to:
/// Color(0xff1c1c1c)
/// ```
final dart_ui.Color? menuBackgroundColor;
final Color? menuBackgroundColor;

/// The background color of the toolbar that hosts the title of the active
/// tool, the discard, and the apply button in the editor.
/// ```
/// // Defaults to:
/// Color(0xff212121)
/// ```
final dart_ui.Color? toolbarBackgroundColor;
final Color? toolbarBackgroundColor;

/// Converts a [Theme] for JSON parsing.
Map<String, dynamic> _toJson() => {
Expand Down Expand Up @@ -900,7 +900,7 @@ class BrushOptions {
: List<dynamic>.from(
_canvasActions.map((x) => _brushCanvasActionValues.reverse[x])),
"colors": colors?._toJson(),
"defaultColor": defaultColor?._toJson(),
"defaultColor": defaultColor?.value,
"defaultHardness": defaultHardness,
"defaultSize": defaultSize,
"maximumHardness": maximumHardness,
Expand Down Expand Up @@ -953,25 +953,6 @@ final _brushCanvasActionValues = _EnumValues({
"undo": BrushCanvasAction.undo
});
/// A color.
class Color {
/// Creates a new [Color].
Color(this.color);
/// A color can be represented as:
/// - `List<double>`: which encodes a single gray value or a RGB(A)
/// tuple of floating point values where
/// each channel is defined in the range of `[0, 1]`.
/// - `String`: which is a hex color code string of a 12-bit RGB,
/// 24-bit RGB, or 32-bit ARGB color value.
/// - `double`: which is the the binary representation of a 32-bit
/// ARGB color value.
final dynamic color;
/// Converts a [Color] for JSON parsing.
dynamic _toJson() => color;
}
/// A named color.
class NamedColor {
/// Creates a new [NamedColor].
Expand All @@ -984,7 +965,7 @@ class NamedColor {
final String name;
/// Converts a [NamedColor] for JSON parsing.
Map<String, dynamic> _toJson() => {"color": color._toJson(), "name": name};
Map<String, dynamic> _toJson() => {"color": color.value, "name": name};
}
/// A color palette of named colors.
Expand Down Expand Up @@ -2611,7 +2592,7 @@ class TextOptions {
? null
: List<dynamic>.from(
_canvasActions.map((x) => _textCanvasActionValues.reverse[x])),
"defaultTextColor": defaultTextColor?._toJson(),
"defaultTextColor": defaultTextColor?.value,
"fonts": _fonts == null
? null
: List<dynamic>.from(_fonts.map((x) => x._toJson())),
Expand Down Expand Up @@ -3174,9 +3155,9 @@ class DuoToneFilter extends Filter {
/// Converts a [DuoToneFilter] for JSON parsing.
@override
Map<String, dynamic> _toJson() => {
"darkColor": darkColor._toJson(),
"darkColor": darkColor.value,
"identifier": identifier,
"lightColor": lightColor._toJson(),
"lightColor": lightColor.value,
"name": name,
}..removeWhere((key, value) => value == null);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: imgly_sdk
description: The official base plugin for the photo_editor_sdk and video_editor_sdk Flutter plugins.
version: 2.9.0
version: 3.0.0
homepage: https://img.ly
repository: https://github.com/imgly/imgly-flutter

Expand Down

0 comments on commit cd38dd8

Please sign in to comment.