Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Start on ImageEditor for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Mar 30, 2016
1 parent 138e756 commit b07bc28
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
.idea
.DS_Store
/node_modules/
src/ios/AdobeCreativeSDKFrameworks/*
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -22,6 +22,18 @@
phonegap-plugin-csdk-image-editor
------------------------

# Prerequisites

Before you can work with the Creative SDK, you must register your application and get Client ID and Client Secret values. For details, see [Registering Your Application](https://creativesdk.adobe.com/docs/ios/#/articles/gettingstarted/index.html).

To get the iOS SDK, go to the [Downloads page](https://creativesdk.adobe.com/downloads.html), download the ZIP files, and extract them to the src/ios folder of this plugin. It should create a AdobeCreativeSDKFrameworks folder. The ZIP files contain all the frameworks in the Creative SDK but for this plugin we will only be using the AdobeCreativeSDKCore.framework.

The following software is required:
- Xcode 7 or higher
- iOS 8.2 or higher

# Installation

To add to your app:

```
Expand Down
17 changes: 17 additions & 0 deletions plugin.xml
Expand Up @@ -48,7 +48,24 @@
<param name="ios-package" value="CDVImageEditor"/>
</feature>
</config-file>
<header-file src="src/ios/CDVImageEditor.h" />
<source-file src="src/ios/CDVImageEditor.m" />

<resource-file src="src/ios/AdobeCreativeSDKFrameworks/AdobeCreativeSDKImage.framework/Versions/A/Resources/AdobeCreativeSDKImageResources.bundle" />
<framework src="src/ios/AdobeCreativeSDKFrameworks/AdobeCreativeSDKImage.framework" custom="true" />

<framework src="MobileCoreServices.framework" />
<framework src="libc++.dylib" />
<framework src="libz.dylib" />
<framework src="Accelerate.framework" />
<framework src="CoreData.framework" />
<framework src="libsqlite3.0.dylib" />
<framework src="Foundation.framework" />
<framework src="MessageUI.framework" />
<framework src="OpenGLES.framework" />
<framework src="QuartzCore.framework" />
<framework src="StoreKit.framework" />
<framework src="UIKit.framework" />
</platform>

</plugin>
12 changes: 12 additions & 0 deletions src/ios/CDVImageEditor.h
@@ -0,0 +1,12 @@
#import <Cordova/CDVPlugin.h>

@interface CDVImageEditor : CDVPlugin
{
NSString *callbackId;
}

@property (nonatomic, retain) NSString *callbackId;

- (void)edit:(CDVInvokedUrlCommand*)command;

@end
37 changes: 22 additions & 15 deletions src/ios/CDVImageEditor.m
Expand Up @@ -17,32 +17,39 @@ Licensed to the Apache Software Foundation (ASF) under one
under the License.
*/

#import <Cordova/CDV.h>
#import <AdobeCreativeSDKImage/AdobeCreativeSDKImage.h>
#import "CDVImageEditor.h"

@interface CDVEcho : CDVPlugin
@end
@implementation CDVImageEditor

@implementation CDVEcho
@synthesize callbackId;

- (void)echo:(CDVInvokedUrlCommand*)command
- (void)edit:(CDVInvokedUrlCommand*)command
{
id message = [command.arguments objectAtIndex:0];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
self.callbackId = command.callbackId;

NSString *imageUri = [command.arguments objectAtIndex:0];
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUri]];
UIImage *image = [UIImage imageWithData:imageData];

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
AdobeUXImageEditorViewController *editorController =
[[AdobeUXImageEditorViewController alloc] initWithImage:image];
[editorController setDelegate:self];
[self.viewController presentViewController:editorController animated:YES completion:nil];
}

- (void)echoAsyncHelper:(NSArray*)args
- (void)photoEditor:(AdobeUXImageEditorViewController *)editor finishedWithImage:(UIImage *)image
{
[self.commandDelegate sendPluginResult:[args objectAtIndex:0] callbackId:[args objectAtIndex:1]];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
[self.viewController dismissViewControllerAnimated:YES completion:nil];
}

- (void)echoAsync:(CDVInvokedUrlCommand*)command
- (void)photoEditorCanceled:(AdobeUXImageEditorViewController *)editor
{
id message = [command.arguments objectAtIndex:0];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];

[self performSelector:@selector(echoAsyncHelper:) withObject:[NSArray arrayWithObjects:pluginResult, command.callbackId, nil] afterDelay:0];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
[self.viewController dismissViewControllerAnimated:YES completion:nil];
}

@end

0 comments on commit b07bc28

Please sign in to comment.