Skip to content

Instantly share code, notes, and snippets.

@imgly-gists
imgly-gists / main.dart
Last active March 8, 2021 11:29
A minimal example showing how to use the configuration dart class.
import 'package:imgly_sdk/imgly_sdk.dart';
import 'package:photo_editor_sdk/photo_editor_sdk.dart';
/// Here, we assign custom stickers to the editor.
///
/// We create a completely custom category
/// containing custom stickers:
/// A custom sticker displaying the Flutter logo:
final flutterSticker = Sticker(
@imgly-gists
imgly-gists / main.dart
Created March 8, 2021 10:23
Minimal example showing how to launch the editor.
import 'package:photo_editor_sdk/photo_editor_sdk.dart';
import 'package:video_editor_sdk/video_editor_sdk.dart';
/// For photo_editor_sdk:
PESDK.openEditor(image: "assets/demo-image.jpg");
/// For video_editor_sdk:
VESDK.openEditor(video: "assets/demo-video.mp4");
@imgly-gists
imgly-gists / App.js
Last active February 20, 2020 15:14
Minimal React Native app which shows how to add custom stickers to PhotoEditor SDK
import React, { Component } from 'react';
import { Configuration, PhotoEditorModal } from 'react-native-photoeditorsdk';
const configuration: Configuration = {
sticker: {
categories: [{
identifier: "demo_sticker_category", name: "Logos",
thumbnailURI: require("./react.png"),
items: [{
identifier: "demo_sticker_react", name: "React",
@imgly-gists
imgly-gists / TextPanel.java
Created February 19, 2018 08:16
Button function for text background and text color.
textFillButton.setOnTextFillStateChangeListener(new TextFillButton.OnTextFillStateChangeListener() {
@Override
public void onTextFillStateChange(boolean isTextFillClicked) {
if (isTextFillClicked) {
if (textColor == DEFAULT_COLOR) {
textBgColor = BLACK_COLOR;
} else {
textBgColor = textColor;
textColor = DEFAULT_COLOR;
}
func stickerSelectionController(_ stickerSelectionController: StickerSelectionController, didSelect sticker: Sticker, with image: UIImage) {
guard let referenceSize = delegate?.stickerViewControllerReferenceSize(self) else { return }
var model = StickerSpriteModel(sticker: sticker)
let aspectRatio = referenceSize.width / referenceSize.height
model.normalizedCenter = CGPoint(x: 0.5, y: 0.5)
model.normalizedSize = CGSize(width: 0.3, height: 0.3 * aspectRatio)
delegate?.stickerViewControllerDidFinish(self, stickerModel: model)
dismiss(animated: true, completion: nil)
}
func spriteEditControllerPreviewView(_ spriteEditController: SpriteEditController) -> UIView? {
return self.previewViewController?.previewView
}
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
PESDK.init(cordova.getActivity().getApplication(), "LICENSE_ANDROID");
}
onDeviceReady: function() {
selectImageBtn = document.getElementById('js-selectImageBtn');
selectImageBtn.addEventListener('click', function() {
window.imagePicker.getPictures(
function(results) {
let imageURI = results[0];
PESDK.present(
function(result){ alert('PESDK result: ' + JSON.stringify(result)); },
function(error){ alert('PESDK error: ' + error); },
{ path: imageURI }
onDeviceReady: function() {
selectImageBtn = document.getElementById('js-selectImageBtn');
selectImageBtn.addEventListener('click', function() {
// TODO: Open PhotoEditor SDK
});
selectImageBtn.disabled = false;
}
+ (void)initialize {
if (self == [PESDKPlugin self]) {
[PESDK unlockWithLicenseAt:[[NSBundle mainBundle] URLForResource:@"LICENSE_IOS" withExtension:nil]];
}
}