Skip to content

Commit 06a8550

Browse files
committed
Merge branch 'develop'
2 parents 67ad2f7 + d18c499 commit 06a8550

File tree

49 files changed

+1920
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1920
-167
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Expected behavior
2+
3+
4+
### Actual behavior
5+
6+
7+
### Steps to reproduce the behavior
8+
9+
10+
##### Tested on [device], iOS [version], WPiOS [version]
11+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Fixes #
2+
3+
To test:
4+
5+
PR submission checklist:
6+
7+
- [ ] I have considered adding unit tests where possible.
8+
- [ ] I have considered adding accessibility improvements for my changes.
9+
- [ ] I have considered if this change warrants user-facing release notes and have added them to `RELEASE-NOTES.txt` if necessary.

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# How to Contribute
2+
3+
First off, thank you for contributing! We're excited to collaborate with you! 🎉
4+
5+
The following is a set of guidelines for the many ways you can join our collective effort.
6+
7+
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.
8+
9+
## Reporting Bugs, Asking Questions, and Suggesting Features
10+
11+
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.
12+
13+
## Submitting Code Changes
14+
15+
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.
16+
17+
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.
18+
19+
If the change is trivial, feel free to send a pull request without notifying us.
20+
21+
### Pull Requests and Code Reviews
22+
23+
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).
24+
25+
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.
26+
27+
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.
28+
29+
## Getting in Touch
30+
31+
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.

Cartfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
github "TimOliver/TOCropViewController"
2-
github "Quick/Nimble"

Cartfile.private

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github "Quick/Nimble"

Example/Base.lproj/Main.storyboard

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import UIKit
2+
import MediaEditor
3+
4+
class AdditionalCapabilityViewController: UIViewController {
5+
@IBOutlet weak var imageView: UIImageView!
6+
7+
override func viewDidLoad() {
8+
super.viewDidLoad()
9+
10+
// Append Brightness to the list of capabilities
11+
MediaEditor.capabilities.append(BrightnessViewController.self)
12+
13+
// Add tap gesture in the image
14+
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
15+
imageView.isUserInteractionEnabled = true
16+
imageView.addGestureRecognizer(tapGestureRecognizer)
17+
}
18+
19+
override func viewDidAppear(_ animated: Bool) {
20+
super.viewDidAppear(animated)
21+
}
22+
23+
override func viewWillDisappear(_ animated: Bool) {
24+
super.viewWillDisappear(animated)
25+
if isMovingFromParent {
26+
MediaEditor.capabilities.removeLast()
27+
}
28+
}
29+
30+
@objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) {
31+
guard let image = imageView.image else {
32+
return
33+
}
34+
35+
// Give the image to the MediaEditor (you can also pass an array of UIImage)
36+
let mediaEditor = MediaEditor(image)
37+
mediaEditor.edit(from: self, onFinishEditing: { images, action in
38+
// Display the edited image
39+
guard let images = images as? [UIImage] else {
40+
return
41+
}
42+
43+
self.imageView.image = images.first
44+
}, onCancel: {
45+
// User canceled
46+
})
47+
}
48+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
7+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<scenes>
11+
<!--Brightness View Controller-->
12+
<scene sceneID="c1B-7t-CTr">
13+
<objects>
14+
<viewController storyboardIdentifier="brightnessViewController" id="uy1-xE-iLe" customClass="BrightnessViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
15+
<view key="view" contentMode="scaleToFill" id="4Jy-bd-2Ao">
16+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
17+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18+
<subviews>
19+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="AlG-Gr-6cY">
20+
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
21+
<subviews>
22+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xoj-Wy-HEs">
23+
<rect key="frame" x="0.0" y="0.0" width="414" height="690"/>
24+
</imageView>
25+
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="3mI-zc-Nf4">
26+
<rect key="frame" x="-2" y="700" width="418" height="65"/>
27+
<constraints>
28+
<constraint firstAttribute="height" constant="64" id="W9Z-ah-6ez"/>
29+
</constraints>
30+
<connections>
31+
<action selector="sliderValueChanged:" destination="uy1-xE-iLe" eventType="valueChanged" id="uWJ-Om-meK"/>
32+
</connections>
33+
</slider>
34+
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="BwS-ar-kTV">
35+
<rect key="frame" x="0.0" y="774" width="414" height="44"/>
36+
<subviews>
37+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IFy-2Y-4OM">
38+
<rect key="frame" x="0.0" y="0.0" width="101" height="44"/>
39+
<constraints>
40+
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="53" id="FTj-uO-CKq"/>
41+
</constraints>
42+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
43+
<color key="tintColor" red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
44+
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
45+
<state key="normal" title="Cancel">
46+
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
47+
</state>
48+
<connections>
49+
<action selector="cancel:" destination="uy1-xE-iLe" eventType="touchUpInside" id="EVw-1E-pxR"/>
50+
</connections>
51+
</button>
52+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LYk-87-uUE">
53+
<rect key="frame" x="111" y="0.0" width="240" height="44"/>
54+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
55+
</view>
56+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="egE-uW-K1q">
57+
<rect key="frame" x="361" y="0.0" width="53" height="44"/>
58+
<constraints>
59+
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="53" id="Bay-oh-sXZ"/>
60+
</constraints>
61+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
62+
<color key="tintColor" red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
63+
<inset key="contentEdgeInsets" minX="0.0" minY="0.0" maxX="10" maxY="0.0"/>
64+
<state key="normal" title="Done"/>
65+
<connections>
66+
<action selector="done:" destination="uy1-xE-iLe" eventType="touchUpInside" id="Y5v-RX-dgh"/>
67+
</connections>
68+
</button>
69+
</subviews>
70+
<constraints>
71+
<constraint firstAttribute="height" constant="44" id="Ald-u2-JqT"/>
72+
</constraints>
73+
</stackView>
74+
</subviews>
75+
</stackView>
76+
</subviews>
77+
<color key="backgroundColor" white="0.12" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
78+
<constraints>
79+
<constraint firstItem="AlG-Gr-6cY" firstAttribute="top" secondItem="sGv-Ig-jBp" secondAttribute="top" id="LbP-L3-IdF"/>
80+
<constraint firstItem="sGv-Ig-jBp" firstAttribute="bottom" secondItem="AlG-Gr-6cY" secondAttribute="bottom" id="a35-7A-fOc"/>
81+
<constraint firstItem="sGv-Ig-jBp" firstAttribute="trailing" secondItem="AlG-Gr-6cY" secondAttribute="trailing" symbolic="YES" id="kjm-l6-Ik3"/>
82+
<constraint firstItem="AlG-Gr-6cY" firstAttribute="leading" secondItem="sGv-Ig-jBp" secondAttribute="leading" id="n9m-6v-EBP"/>
83+
</constraints>
84+
<viewLayoutGuide key="safeArea" id="sGv-Ig-jBp"/>
85+
</view>
86+
<connections>
87+
<outlet property="brightnessSlider" destination="3mI-zc-Nf4" id="tlV-Nj-FEN"/>
88+
<outlet property="imageView" destination="xoj-Wy-HEs" id="dXa-s3-C5T"/>
89+
</connections>
90+
</viewController>
91+
<placeholder placeholderIdentifier="IBFirstResponder" id="Q24-RM-atn" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
92+
</objects>
93+
<point key="canvasLocation" x="73.913043478260875" y="-76.339285714285708"/>
94+
</scene>
95+
</scenes>
96+
</document>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import UIKit
2+
import MediaEditor
3+
4+
// MARK: - BrightnessViewController
5+
6+
class BrightnessViewController: UIViewController {
7+
@IBOutlet weak var imageView: UIImageView!
8+
@IBOutlet weak var brightnessSlider: UISlider!
9+
10+
let context = MediaEditor.ciContext
11+
12+
var onFinishEditing: ((UIImage, [MediaEditorOperation]) -> ())?
13+
14+
var onCancel: (() -> ())?
15+
16+
var image: UIImage!
17+
18+
lazy var ciImage: CIImage? = {
19+
return CIImage(image: image)
20+
}()
21+
22+
lazy var brightnessFilter: CIFilter? = {
23+
guard let ciImage = ciImage else {
24+
return nil
25+
}
26+
27+
let ciFilter = CIFilter(name: "CIColorControls")
28+
ciFilter?.setValue(ciImage, forKey: "inputImage")
29+
30+
return ciFilter
31+
}()
32+
33+
override func viewDidLoad() {
34+
super.viewDidLoad()
35+
imageView.image = image
36+
}
37+
38+
39+
@IBAction func cancel(_ sender: Any) {
40+
onCancel?()
41+
}
42+
43+
@IBAction func done(_ sender: Any) {
44+
// Check if the user changed the brightness
45+
guard brightnessSlider.value > 0 else {
46+
onCancel?()
47+
return
48+
}
49+
50+
// Get the UIImage
51+
guard let ciImage = imageView.image?.ciImage, let cgImage = context.createCGImage(ciImage, from: ciImage.extent) else {
52+
onCancel?()
53+
return
54+
}
55+
56+
onFinishEditing?(UIImage(cgImage: cgImage), [])
57+
}
58+
59+
// When the slider changes, apply the brightness value
60+
@IBAction func sliderValueChanged(_ sender: UISlider) {
61+
brightnessFilter?.setValue(sender.value, forKey: "inputBrightness")
62+
if let outputImage = brightnessFilter?.outputImage {
63+
imageView.image = UIImage(ciImage: outputImage)
64+
}
65+
}
66+
67+
// Load it from storyboard
68+
static func fromStoryboard() -> BrightnessViewController {
69+
return UIStoryboard(name: "BrightnessCapability", bundle: .main).instantiateViewController(withIdentifier: "brightnessViewController") as! BrightnessViewController
70+
}
71+
}
72+
73+
extension BrightnessViewController: MediaEditorCapability {
74+
static var name = "Brightness"
75+
76+
static var icon = UIImage(named: "ink")!
77+
78+
static func initialize(_ image: UIImage, onFinishEditing: @escaping (UIImage, [MediaEditorOperation]) -> (), onCancel: @escaping () -> ()) -> CapabilityViewController {
79+
let viewController = BrightnessViewController.fromStoryboard()
80+
viewController.onFinishEditing = onFinishEditing
81+
viewController.onCancel = onCancel
82+
viewController.image = image
83+
return viewController
84+
}
85+
86+
func apply(styles: MediaEditorStyles) {
87+
// Apply styles here
88+
}
89+
}

0 commit comments

Comments
 (0)