Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
leandroalonso committed Feb 6, 2020
2 parents 67ad2f7 + d18c499 commit 06a8550
Show file tree
Hide file tree
Showing 49 changed files with 1,920 additions and 167 deletions.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Expected behavior


### Actual behavior


### Steps to reproduce the behavior


##### Tested on [device], iOS [version], WPiOS [version]

9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Fixes #

To test:

PR submission checklist:

- [ ] I have considered adding unit tests where possible.
- [ ] I have considered adding accessibility improvements for my changes.
- [ ] I have considered if this change warrants user-facing release notes and have added them to `RELEASE-NOTES.txt` if necessary.
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# How to Contribute

First off, thank you for contributing! We're excited to collaborate with you! 🎉

The following is a set of guidelines for the many ways you can join our collective effort.

Before anything else, please take a moment to read our [Code of Conduct](https://github.com/wordpress-mobile/WordPress-iOS/blob/develop/CODE-OF-CONDUCT.md). We expect all participants, from full-timers to occasional tinkerers, to uphold it.

## Reporting Bugs, Asking Questions, and Suggesting Features

Have a suggestion or feedback? Please go to [Issues](https://github.com/wordpress-mobile/MediaEditor-iOS/issues) and [open a new issue](https://github.com/wordpress-mobile/MediaEditor-iOS/issues/new). Prefix the title with a category like _"Bug:"_, _"Question:"_, or _"Feature Request:"_. Screenshots help us resolve issues and answer questions faster, so thanks for including some if you can.

## Submitting Code Changes

If you're just getting started and want to familiarize yourself with the app’s code, we suggest looking at [these issues](https://github.com/wordpress-mobile/MediaEditor-iOS/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) with the **good first issue** label. But if you’d like to tackle something different, you're more than welcome to visit the [Issues](https://github.com/wordpress-mobile/MediaEditor-iOS/issues) page and pick an item that interests you.

We always try to avoid duplicating efforts, so if you decide to work on an issue, leave a comment to state your intent. If you choose to focus on a new feature or the change you’re proposing is significant, we recommend waiting for a response before proceeding. The issue may no longer align with project goals.

If the change is trivial, feel free to send a pull request without notifying us.

### Pull Requests and Code Reviews

All code contributions pass through pull requests. If you haven't created a pull request before, we recommend this free video series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github).

The core team monitors and reviews all pull requests. Depending on the changes, we will either approve them or close them with an explanation. We might also work with you to improve a pull request before approval.

We do our best to respond quickly to all pull requests. If you don't get a response from us after a week, feel free to reach out to us via Slack.

## Getting in Touch

If you have questions or just want to say hi, join the [WordPress Slack](https://make.wordpress.org/chat/) and drop a message on the `#mobile` channel.
1 change: 0 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github "TimOliver/TOCropViewController"
github "Quick/Nimble"
1 change: 1 addition & 0 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "Quick/Nimble"
24 changes: 0 additions & 24 deletions Example/Base.lproj/Main.storyboard

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import UIKit
import MediaEditor

class AdditionalCapabilityViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()

// Append Brightness to the list of capabilities
MediaEditor.capabilities.append(BrightnessViewController.self)

// Add tap gesture in the image
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(tapGestureRecognizer)
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if isMovingFromParent {
MediaEditor.capabilities.removeLast()
}
}

@objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) {
guard let image = imageView.image else {
return
}

// Give the image to the MediaEditor (you can also pass an array of UIImage)
let mediaEditor = MediaEditor(image)
mediaEditor.edit(from: self, onFinishEditing: { images, action in
// Display the edited image
guard let images = images as? [UIImage] else {
return
}

self.imageView.image = images.first
}, onCancel: {
// User canceled
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Brightness View Controller-->
<scene sceneID="c1B-7t-CTr">
<objects>
<viewController storyboardIdentifier="brightnessViewController" id="uy1-xE-iLe" customClass="BrightnessViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="4Jy-bd-2Ao">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="AlG-Gr-6cY">
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xoj-Wy-HEs">
<rect key="frame" x="0.0" y="0.0" width="414" height="690"/>
</imageView>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="3mI-zc-Nf4">
<rect key="frame" x="-2" y="700" width="418" height="65"/>
<constraints>
<constraint firstAttribute="height" constant="64" id="W9Z-ah-6ez"/>
</constraints>
<connections>
<action selector="sliderValueChanged:" destination="uy1-xE-iLe" eventType="valueChanged" id="uWJ-Om-meK"/>
</connections>
</slider>
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="BwS-ar-kTV">
<rect key="frame" x="0.0" y="774" width="414" height="44"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IFy-2Y-4OM">
<rect key="frame" x="0.0" y="0.0" width="101" height="44"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="53" id="FTj-uO-CKq"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="tintColor" red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Cancel">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="cancel:" destination="uy1-xE-iLe" eventType="touchUpInside" id="EVw-1E-pxR"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LYk-87-uUE">
<rect key="frame" x="111" y="0.0" width="240" height="44"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="egE-uW-K1q">
<rect key="frame" x="361" y="0.0" width="53" height="44"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="53" id="Bay-oh-sXZ"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="tintColor" red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<inset key="contentEdgeInsets" minX="0.0" minY="0.0" maxX="10" maxY="0.0"/>
<state key="normal" title="Done"/>
<connections>
<action selector="done:" destination="uy1-xE-iLe" eventType="touchUpInside" id="Y5v-RX-dgh"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="44" id="Ald-u2-JqT"/>
</constraints>
</stackView>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" white="0.12" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="AlG-Gr-6cY" firstAttribute="top" secondItem="sGv-Ig-jBp" secondAttribute="top" id="LbP-L3-IdF"/>
<constraint firstItem="sGv-Ig-jBp" firstAttribute="bottom" secondItem="AlG-Gr-6cY" secondAttribute="bottom" id="a35-7A-fOc"/>
<constraint firstItem="sGv-Ig-jBp" firstAttribute="trailing" secondItem="AlG-Gr-6cY" secondAttribute="trailing" symbolic="YES" id="kjm-l6-Ik3"/>
<constraint firstItem="AlG-Gr-6cY" firstAttribute="leading" secondItem="sGv-Ig-jBp" secondAttribute="leading" id="n9m-6v-EBP"/>
</constraints>
<viewLayoutGuide key="safeArea" id="sGv-Ig-jBp"/>
</view>
<connections>
<outlet property="brightnessSlider" destination="3mI-zc-Nf4" id="tlV-Nj-FEN"/>
<outlet property="imageView" destination="xoj-Wy-HEs" id="dXa-s3-C5T"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Q24-RM-atn" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="73.913043478260875" y="-76.339285714285708"/>
</scene>
</scenes>
</document>
89 changes: 89 additions & 0 deletions Example/Extending/BrightnessCapability/BrightnessCapability.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import UIKit
import MediaEditor

// MARK: - BrightnessViewController

class BrightnessViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var brightnessSlider: UISlider!

let context = MediaEditor.ciContext

var onFinishEditing: ((UIImage, [MediaEditorOperation]) -> ())?

var onCancel: (() -> ())?

var image: UIImage!

lazy var ciImage: CIImage? = {
return CIImage(image: image)
}()

lazy var brightnessFilter: CIFilter? = {
guard let ciImage = ciImage else {
return nil
}

let ciFilter = CIFilter(name: "CIColorControls")
ciFilter?.setValue(ciImage, forKey: "inputImage")

return ciFilter
}()

override func viewDidLoad() {
super.viewDidLoad()
imageView.image = image
}


@IBAction func cancel(_ sender: Any) {
onCancel?()
}

@IBAction func done(_ sender: Any) {
// Check if the user changed the brightness
guard brightnessSlider.value > 0 else {
onCancel?()
return
}

// Get the UIImage
guard let ciImage = imageView.image?.ciImage, let cgImage = context.createCGImage(ciImage, from: ciImage.extent) else {
onCancel?()
return
}

onFinishEditing?(UIImage(cgImage: cgImage), [])
}

// When the slider changes, apply the brightness value
@IBAction func sliderValueChanged(_ sender: UISlider) {
brightnessFilter?.setValue(sender.value, forKey: "inputBrightness")
if let outputImage = brightnessFilter?.outputImage {
imageView.image = UIImage(ciImage: outputImage)
}
}

// Load it from storyboard
static func fromStoryboard() -> BrightnessViewController {
return UIStoryboard(name: "BrightnessCapability", bundle: .main).instantiateViewController(withIdentifier: "brightnessViewController") as! BrightnessViewController
}
}

extension BrightnessViewController: MediaEditorCapability {
static var name = "Brightness"

static var icon = UIImage(named: "ink")!

static func initialize(_ image: UIImage, onFinishEditing: @escaping (UIImage, [MediaEditorOperation]) -> (), onCancel: @escaping () -> ()) -> CapabilityViewController {
let viewController = BrightnessViewController.fromStoryboard()
viewController.onFinishEditing = onFinishEditing
viewController.onCancel = onCancel
viewController.image = image
return viewController
}

func apply(styles: MediaEditorStyles) {
// Apply styles here
}
}
Loading

0 comments on commit 06a8550

Please sign in to comment.