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 19d8382 commit 67365c1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 29 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Add the plugin package to the `pubspec.yaml` file in your project:

```yaml
dependencies:
photo_editor_sdk: ^2.9.0
photo_editor_sdk: ^3.0.0
```
Install the new dependency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class FlutterPESDK: FlutterIMGLY() {

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
if (this.result != null) {
result.error("Multiple requests.", "Cancelled due to multiple requests.", null)
result.error(IMGLYConstants.K_ERROR_MULTIPLE_REQUESTS, "Cancelled due to multiple requests.", null)
return
}

Expand Down Expand Up @@ -93,11 +93,11 @@ class FlutterPESDK: FlutterIMGLY() {
this.result = result
this.present(imageData, config, serialization)
} else {
result.error("PE.SDK", "The specified serialization did not include a photo.", null)
result.error(IMGLYConstants.K_ERROR_UNABLE_TO_LOAD, "The specified serialization did not include a photo.", null)
return
}
} else {
result.error("PE.SDK", "No image has been specified or included in the serialization.", null)
result.error(IMGLYConstants.K_ERROR_UNABLE_TO_LOAD, "No image has been specified or included in the serialization.", null)
return
}
}
Expand Down Expand Up @@ -156,7 +156,7 @@ class FlutterPESDK: FlutterIMGLY() {
this.result?.success(null)
this.result = null
} catch (e: AuthorizationException) {
this.result?.error("PE.SDK", "The license is invalid.", e.message)
this.result?.error(IMGLYConstants.K_ERROR_UNABLE_TO_UNLOCK, "The license is invalid.", e.message)
this.result = null
}
}
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PODS:
- Flutter (1.0.0)
- imgly_sdk (2.9.0):
- imgly_sdk (3.0.0):
- Flutter
- imglyKit (~> 11.4)
- imglyKit (11.5.1)
- photo_editor_sdk (2.9.0):
- photo_editor_sdk (3.0.0):
- Flutter
- imgly_sdk (= 2.9.0)
- imgly_sdk (= 3.0.0)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -27,9 +27,9 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
imgly_sdk: a1937f3cd410756297d87d15086a37f24466d288
imgly_sdk: a114555e1d98e4a4fa5cc8f2b258353198c64e8b
imglyKit: b1b3b827799a50b090433ca7c61f90b078944898
photo_editor_sdk: 5e72294f9947007ff0918717f74a1186c1210f6d
photo_editor_sdk: d5eea1abfd23930ec45163f95d92e2570434e4cc

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

Expand Down
26 changes: 14 additions & 12 deletions ios/Classes/FlutterPESDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD
guard let arguments = call.arguments as? IMGLYDictionary else { return }

if self.result != nil {
result(FlutterError(code: "Multiple requests.", message: "Cancelled due to multiple requests.", details: nil))
result(FlutterError(code: IMGLYConstants.kErrorMultipleRequests, message: "Cancelled due to multiple requests.", details: nil))
return
}

Expand Down Expand Up @@ -83,7 +83,7 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD
if let serializationPhoto = deserializationResult?.photo {
finalPhotoAsset = Photo.from(photoRepresentation: serializationPhoto)
} else {
self.result?(FlutterError(code: "Photo must not be nil.", message: "The specified serialization did not include a photo.", details: nil))
self.result?(FlutterError(code: IMGLYConstants.kErrorUnableToLoad, message: "The specified serialization did not include a photo.", details: nil))
self.result = nil
return nil
}
Expand All @@ -92,7 +92,7 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD
}

guard let finalPhoto = finalPhotoAsset else {
self.result?(FlutterError(code: "Photo must not be nil.", message: "No image has been specified or included in the serialization.", details: nil))
self.result?(FlutterError(code: IMGLYConstants.kErrorUnableToLoad, message: "No image has been specified or included in the serialization.", details: nil))
self.result = nil
return nil
}
Expand Down Expand Up @@ -121,9 +121,11 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD
DispatchQueue.main.async {
do {
try PESDK.unlockWithLicense(from: url)
self.result?(nil)
self.result = nil
} catch let error {
self.handleLicenseError(with: error as NSError)
self.result?(FlutterError(code: IMGLYConstants.kErrorUnableToUnlock, message: "Unlocking the SDK failed due to:", details: error.localizedDescription))
self.result = nil
}
}
}
Expand Down Expand Up @@ -153,7 +155,7 @@ extension FlutterPESDK {
/// - Parameter result: The `PhotoEditorResult` from the editor.
public func photoEditViewControllerDidFinish(_ photoEditViewController: PhotoEditViewController, result: PhotoEditorResult) {
guard let uti = result.output.uti else {
self.handleError(photoEditViewController, code: "Image could not be saved.", message: nil, details: nil)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "Failed to retrieve the output UTI.", details: nil)
return
}

Expand All @@ -164,21 +166,21 @@ extension FlutterPESDK {
if imageData.isEmpty == false {
if self.exportType == IMGLYConstants.kExportTypeFileURL {
guard let fileURL = self.exportFile else {
self.handleError(photoEditViewController, code: "Export type must not be nil.", message: "No valid export type has been specified.", details: self.exportFile?.absoluteString)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "No valid export type has been specified.", details: self.exportFile?.absoluteString)
return
}
do {
try imageData.IMGLYwriteToUrl(fileURL, andCreateDirectoryIfNeeded: true)
imageString = fileURL.absoluteString
} catch let error {
self.handleError(photoEditViewController, code: "Image could not be saved.", message: "Error message: \(error.localizedDescription)", details: error.localizedDescription)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: error.localizedDescription, details: error.localizedDescription)
return
}
} else if self.exportType == IMGLYConstants.kExportTypeDataURL {
if let mediaType = UTTypeCopyPreferredTagWithClass(uti as CFString, kUTTagClassMIMEType)?.takeRetainedValue() as? NSString {
imageString = String(format: "data:%@;base64,%@", mediaType, imageData.base64EncodedString())
} else {
self.handleError(photoEditViewController, code: "Image could not be saved.", message: "The output UTI could not be read.", details: nil)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "The output UTI could not be read.", details: nil)
return
}
}
Expand All @@ -190,21 +192,21 @@ extension FlutterPESDK {
}
if self.serializationType == IMGLYConstants.kExportTypeFileURL {
guard let exportURL = self.serializationFile else {
self.handleError(photoEditViewController, code: "Serialization failed.", message: "The URL must not be nil.", details: nil)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "The URL must not be nil.", details: nil)
return
}
do {
try serializationData.IMGLYwriteToUrl(exportURL, andCreateDirectoryIfNeeded: true)
serialization = self.serializationFile?.absoluteString
} catch let error {
self.handleError(photoEditViewController, code: "Serialization failed.", message: error.localizedDescription, details: error.localizedDescription)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: error.localizedDescription, details: error.localizedDescription)
return
}
} else if self.serializationType == IMGLYConstants.kExportTypeObject {
do {
serialization = try JSONSerialization.jsonObject(with: serializationData, options: .init(rawValue: 0))
} catch let error {
self.handleError(photoEditViewController, code: "Serialization failed.", message: error.localizedDescription, details: error.localizedDescription)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: error.localizedDescription, details: error.localizedDescription)
return
}
}
Expand All @@ -223,7 +225,7 @@ extension FlutterPESDK {
/// - Parameter photoEditViewController: The editor that failed to export.
/// - Parameter error: The `PhotoEditorError` that caused the failure.
public func photoEditViewControllerDidFail(_ photoEditViewController: PhotoEditViewController, error: PhotoEditorError) {
self.handleError(photoEditViewController, code: "Editor failed", message: "The editor did fail to generate the image.", details: error.localizedDescription)
self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "The editor did fail to generate the image.", details: error.localizedDescription)
}

/// Delegate function that is called if the `PhotoEditViewController` has
Expand Down
4 changes: 2 additions & 2 deletions lib/photo_editor_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class PESDK {
/// to include one license for each platform with the same name, but where
/// the iOS license has `.ios` as its file extension and the
/// Android license has `.android` as its file extension.
static void unlockWithLicense(String path) async {
await _channel.invokeMethod('unlock', <String, dynamic>{'license': path});
static Future<void> unlockWithLicense(String path) async {
return _channel.invokeMethod('unlock', <String, dynamic>{'license': path});
}

/// Opens a new photo editor.
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: photo_editor_sdk
description: The official Flutter plugin for PhotoEditor SDK. Integrate the photo editor into your own iOS or Android app - in minutes!
version: 2.9.0
homepage: https://www.photoeditorsdk.com
version: 3.0.0
homepage: https://img.ly/products/photo-sdk
repository: https://github.com/imgly/pesdk-flutter

environment:
Expand All @@ -11,7 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
imgly_sdk: 2.9.0
imgly_sdk: 3.0.0

dev_dependencies:
flutter_test:
Expand Down
6 changes: 4 additions & 2 deletions test/photo_editor_sdk_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
const MethodChannel channel = MethodChannel('photo_editor_sdk');
const channel = MethodChannel('photo_editor_sdk');

TestWidgetsFlutterBinding.ensureInitialized();

setUp(() {});

tearDown(() {});
tearDown(() {
channel.setMockMethodCallHandler(null);
});
}

0 comments on commit 67365c1

Please sign in to comment.