diff --git a/CHANGELOG.md b/CHANGELOG.md index 9501109..4a8e3b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/android/src/main/kotlin/ly/img/flutter/imgly_sdk/FlutterIMGLY.kt b/android/src/main/kotlin/ly/img/flutter/imgly_sdk/FlutterIMGLY.kt index d2ec376..70ef16a 100644 --- a/android/src/main/kotlin/ly/img/flutter/imgly_sdk/FlutterIMGLY.kt +++ b/android/src/main/kotlin/ly/img/flutter/imgly_sdk/FlutterIMGLY.kt @@ -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 @@ -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 } } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 05502bd..c0caa6e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -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) @@ -21,7 +21,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - imgly_sdk: a1937f3cd410756297d87d15086a37f24466d288 + imgly_sdk: a114555e1d98e4a4fa5cc8f2b258353198c64e8b imglyKit: b1b3b827799a50b090433ca7c61f90b078944898 PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 diff --git a/ios/Classes/FlutterIMGLY.swift b/ios/Classes/FlutterIMGLY.swift index 53e0269..fd5fede 100644 --- a/ios/Classes/FlutterIMGLY.swift +++ b/ios/Classes/FlutterIMGLY.swift @@ -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? @@ -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" @@ -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]() @@ -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 @@ -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) @@ -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. diff --git a/lib/imgly_sdk.dart b/lib/imgly_sdk.dart index d158dd1..5134047 100644 --- a/lib/imgly_sdk.dart +++ b/lib/imgly_sdk.dart @@ -1,4 +1,4 @@ -import 'dart:ui' as dart_ui; +import 'dart:ui'; /// Configuration options and asset definitions for image and /// video editing tasks. @@ -272,7 +272,7 @@ 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. @@ -280,14 +280,14 @@ class Theme { /// // 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. @@ -295,7 +295,7 @@ class Theme { /// // 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. @@ -303,7 +303,7 @@ class Theme { /// // Defaults to: /// Color(0xff212121) /// ``` - final dart_ui.Color? toolbarBackgroundColor; + final Color? toolbarBackgroundColor; /// Converts a [Theme] for JSON parsing. Map _toJson() => { @@ -900,7 +900,7 @@ class BrushOptions { : List.from( _canvasActions.map((x) => _brushCanvasActionValues.reverse[x])), "colors": colors?._toJson(), - "defaultColor": defaultColor?._toJson(), + "defaultColor": defaultColor?.value, "defaultHardness": defaultHardness, "defaultSize": defaultSize, "maximumHardness": maximumHardness, @@ -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`: 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]. @@ -984,7 +965,7 @@ class NamedColor { final String name; /// Converts a [NamedColor] for JSON parsing. - Map _toJson() => {"color": color._toJson(), "name": name}; + Map _toJson() => {"color": color.value, "name": name}; } /// A color palette of named colors. @@ -2611,7 +2592,7 @@ class TextOptions { ? null : List.from( _canvasActions.map((x) => _textCanvasActionValues.reverse[x])), - "defaultTextColor": defaultTextColor?._toJson(), + "defaultTextColor": defaultTextColor?.value, "fonts": _fonts == null ? null : List.from(_fonts.map((x) => x._toJson())), @@ -3174,9 +3155,9 @@ class DuoToneFilter extends Filter { /// Converts a [DuoToneFilter] for JSON parsing. @override Map _toJson() => { - "darkColor": darkColor._toJson(), + "darkColor": darkColor.value, "identifier": identifier, - "lightColor": lightColor._toJson(), + "lightColor": lightColor.value, "name": name, }..removeWhere((key, value) => value == null); } diff --git a/pubspec.yaml b/pubspec.yaml index bc08e69..5b0a8e7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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