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

Commit

Permalink
Merge branch 'release/3.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLittlejohn authored and Guillaume Bellut committed Oct 16, 2019
2 parents 848775c + fa37fbd commit 2cd2215
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 91 deletions.
2 changes: 1 addition & 1 deletion ALCameraViewController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "ALCameraViewController"
spec.version = "3.0.2"
spec.version = "3.0.3"
spec.summary = "A camera view controller with custom image picker and image cropping."
spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s }
spec.requires_arc = true
Expand Down
10 changes: 6 additions & 4 deletions ALCameraViewController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
1F3C56291F701CA7009667E9 /* CroppingParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */; };
7AC96FA21F5B5166003E53F4 /* CroppingParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */; };
7C6AF41F1FB340CA006CB4ED /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7C6AF41E1FB340CA006CB4ED /* LaunchScreen.xib */; };
C40665441C73A47C00EB9751 /* SingleImageSaver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665431C73A47C00EB9751 /* SingleImageSaver.swift */; };
C40665461C73A94100EB9751 /* CameraGlobals.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665451C73A94100EB9751 /* CameraGlobals.swift */; };
C40665481C73B72D00EB9751 /* SingleImageFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */; };
Expand Down Expand Up @@ -61,6 +62,7 @@

/* Begin PBXFileReference section */
7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CroppingParameters.swift; sourceTree = "<group>"; };
7C6AF41E1FB340CA006CB4ED /* LaunchScreen.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = "<group>"; };
C40665431C73A47C00EB9751 /* SingleImageSaver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageSaver.swift; sourceTree = "<group>"; };
C40665451C73A94100EB9751 /* CameraGlobals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraGlobals.swift; sourceTree = "<group>"; };
C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageFetcher.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -196,6 +198,7 @@
FAF058421B31618D008E5592 /* Supporting Files */ = {
isa = PBXGroup;
children = (
7C6AF41E1FB340CA006CB4ED /* LaunchScreen.xib */,
FAF0584B1B31618D008E5592 /* Images.xcassets */,
FAF058431B31618D008E5592 /* Info.plist */,
);
Expand Down Expand Up @@ -322,6 +325,7 @@
files = (
FA52EE0B1B44129B00E16B6F /* ViewController.xib in Resources */,
FA8231381B3BF8F700A837BE /* CameraView.strings in Resources */,
7C6AF41F1FB340CA006CB4ED /* LaunchScreen.xib in Resources */,
FA5FA3451B3AFEB300497C62 /* CameraViewAssets.xcassets in Resources */,
FAF0584C1B31618D008E5592 /* Images.xcassets in Resources */,
FA778A411B8319D8005807E7 /* image.jpg in Resources */,
Expand Down Expand Up @@ -543,11 +547,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 2466624KEK;
INFOPLIST_FILE = "Example/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -560,11 +563,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 2466624KEK;
INFOPLIST_FILE = "Example/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ extension CameraViewController {

let attribute : NSLayoutAttribute = {
switch statusBarOrientation {
case .portrait: return .bottom
case .landscapeRight: return .right
case .landscapeLeft: return .left
default: return .top
case .portrait: return .bottomMargin
case .landscapeRight: return .rightMargin
case .landscapeLeft: return .leftMargin
default: return .topMargin
}
}()

Expand All @@ -60,7 +60,7 @@ extension CameraViewController {
toItem: view,
attribute: attribute,
multiplier: 1.0,
constant: attribute == .right || attribute == .bottom ? -8 : 8)
constant: -8)
view.addConstraint(cameraButtonEdgeConstraint!)
}

Expand Down Expand Up @@ -401,7 +401,7 @@ extension CameraViewController {
view.autoRemoveConstraint(flashButtonEdgeConstraint)

let constraintRight = statusBarOrientation == .portrait || statusBarOrientation == .landscapeRight
let attribute : NSLayoutAttribute = constraintRight ? .top : .bottom
let attribute : NSLayoutAttribute = constraintRight ? .topMargin : .bottomMargin

flashButtonEdgeConstraint = NSLayoutConstraint(
item: flashButton,
Expand Down
34 changes: 14 additions & 20 deletions ALCameraViewController/ViewController/ConfirmViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate {
scrollView.minimumZoomScale = scale
scrollView.zoomScale = scale
centerScrollViewContents()
centerImageViewOnRotate()
}

public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
Expand Down Expand Up @@ -163,21 +162,13 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate {
}

guard let image = imageView.image else {
return 1
return 1
}

let scaleWidth = _size.width / image.size.width
let scaleHeight = _size.height / image.size.height

var scale: CGFloat

if croppingParameters.isEnabled {
scale = max(scaleWidth, scaleHeight)
} else {
scale = min(scaleWidth, scaleHeight)
}

return scale

return min(scaleWidth, scaleHeight)
}

private func calculateScrollViewInsets(_ frame: CGRect) -> UIEdgeInsets {
Expand Down Expand Up @@ -318,14 +309,17 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate {
y: cropOverlay.frame.origin.y + cropOverlay.outterGap,
width: cropOverlay.frame.size.width - 2 * cropOverlay.outterGap,
height: cropOverlay.frame.size.height - 2 * cropOverlay.outterGap)
cropRect.origin.x += scrollView.contentOffset.x
cropRect.origin.y += scrollView.contentOffset.y

let normalizedX = cropRect.origin.x / imageView.frame.width
let normalizedY = cropRect.origin.y / imageView.frame.height

let normalizedWidth = cropRect.width / imageView.frame.width
let normalizedHeight = cropRect.height / imageView.frame.height
cropRect.origin.x += scrollView.contentOffset.x - imageView.frame.origin.x
cropRect.origin.y += scrollView.contentOffset.y - imageView.frame.origin.y

let normalizedX = max(0, cropRect.origin.x / imageView.frame.width)
let normalizedY = max(0, cropRect.origin.y / imageView.frame.height)

let extraWidth = min(0, cropRect.origin.x)
let extraHeight = min(0, cropRect.origin.y)

let normalizedWidth = min(1, (cropRect.width + extraWidth) / imageView.frame.width)
let normalizedHeight = min(1, (cropRect.height + extraHeight) / imageView.frame.height)

return CGRect(x: normalizedX, y: normalizedY, width: normalizedWidth, height: normalizedHeight)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
Expand All @@ -25,8 +35,8 @@
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
},
Expand All @@ -35,10 +45,15 @@
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
6 changes: 6 additions & 0 deletions Example/Supporting Files/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions Example/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<string>For Science</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>For Science</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
34 changes: 34 additions & 0 deletions Example/Supporting Files/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Icon" translatesAutoresizingMaskIntoConstraints="NO" id="qT0-hI-WW6">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
</imageView>
</subviews>
<color key="backgroundColor" red="0.89411764705882346" green="0.44313725490196076" blue="0.36470588235294116" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="qT0-hI-WW6" secondAttribute="trailing" id="8eE-l4-Nl8"/>
<constraint firstItem="qT0-hI-WW6" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="RPR-Lb-YTg"/>
<constraint firstItem="qT0-hI-WW6" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="Xh6-yC-K4f"/>
<constraint firstAttribute="bottom" secondItem="qT0-hI-WW6" secondAttribute="bottom" id="ZKg-1P-IMr"/>
</constraints>
</view>
</objects>
<resources>
<image name="Icon" width="90" height="90"/>
</resources>
</document>
Loading

0 comments on commit 2cd2215

Please sign in to comment.