Skip to content

Commit

Permalink
Merge pull request hyperoslo#83 from hyperoslo/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
zenangst committed Jan 4, 2016
2 parents 37e3ebd + 33a26ff commit 65f995b
Show file tree
Hide file tree
Showing 39 changed files with 48 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -330,7 +330,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -345,7 +345,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.ImagePicker.hyper;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -359,7 +359,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.ImagePicker.hyper;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="15B30a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
Expand All @@ -14,20 +13,17 @@
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 Ramon Gilabert Llop. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ImagePickerDemo" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<animations/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
Expand All @@ -40,17 +41,19 @@
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "iTunesArtwork@2x copy.png",
"filename" : "Icon-60@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-Small.png",
"scale" : "1x"
},
{
Expand All @@ -59,8 +62,9 @@
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-40.png",
"scale" : "1x"
},
{
Expand Down Expand Up @@ -96,93 +100,34 @@
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "iTunesArtwork@2x copy-1.png",
"filename" : "Icon-76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "iTunesArtwork@2x copy-2.png",
"filename" : "Icon-76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "iTunesArtwork@2x copy-3.png",
"filename" : "Icon-83.5@2x.png",
"scale" : "2x"
},
{
"size" : "24x24",
"idiom" : "watch",
"filename" : "[email protected]",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "38mm"
},
{
"size" : "27.5x27.5",
"idiom" : "watch",
"filename" : "[email protected]",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "42mm"
},
{
"size" : "29x29",
"idiom" : "watch",
"filename" : "Icon-29@2x.png",
"filename" : "Icon-Small@2x.png",
"role" : "companionSettings",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "watch",
"filename" : "Icon-29@3x.png",
"filename" : "Icon-Small@3x.png",
"role" : "companionSettings",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "watch",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "38mm"
},
{
"size" : "44x44",
"idiom" : "watch",
"filename" : "[email protected]",
"scale" : "2x",
"role" : "longLook",
"subtype" : "42mm"
},
{
"size" : "86x86",
"idiom" : "watch",
"filename" : "[email protected]",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "38mm"
},
{
"size" : "98x98",
"idiom" : "watch",
"filename" : "[email protected]",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "42mm"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "iTunesArtwork.png",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
2 changes: 1 addition & 1 deletion Demo/ImagePickerDemo/ImagePickerDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<string>1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
21 changes: 11 additions & 10 deletions Source/CameraView/CameraView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit
import AVFoundation
import AssetsLibrary
import PhotosUI

protocol CameraViewDelegate: class {

Expand Down Expand Up @@ -43,7 +43,7 @@ class CameraView: UIViewController {
view.alpha = 0

return view
}()
}()

lazy var noCameraLabel: UILabel = { [unowned self] in
let label = UILabel()
Expand Down Expand Up @@ -90,7 +90,7 @@ class CameraView: UIViewController {
super.viewDidLoad()

initializeCamera()

view.backgroundColor = Configuration.mainColor
previewLayer?.backgroundColor = Configuration.mainColor.CGColor
}
Expand Down Expand Up @@ -215,7 +215,6 @@ class CameraView: UIViewController {
captureDevice?.flashMode = .Off
default:
captureDevice?.flashMode = .Auto

}
}

Expand Down Expand Up @@ -245,14 +244,16 @@ class CameraView: UIViewController {
guard let imageFromData = UIImage(data: imageData) else { return }
let image = self.cropImage(imageFromData)
let orientation = self.pictureOrientation()
let assetsLibrary = ALAssetsLibrary()
assetsLibrary.writeImageToSavedPhotosAlbum(image.CGImage, orientation: orientation) { url, error in
self.delegate?.imageToLibrary()
}
guard let imageCG = image.CGImage else { return }
UIImageWriteToSavedPhotosAlbum(UIImage(CGImage: imageCG, scale: 1.0, orientation: orientation), self, "saveImage:error:context:", nil)
})
})
}

func saveImage(image: UIImage, error: NSErrorPointer, context:UnsafePointer<Void>) {
delegate?.imageToLibrary()
}

func cropImage(image: UIImage) -> UIImage {
guard let imageReference = CGImageCreateWithImageInRect(image.CGImage,
CGRect(x: 0, y: 0, width: image.size.height - 285, height: image.size.width)) else { return UIImage() }
Expand All @@ -261,7 +262,7 @@ class CameraView: UIViewController {
return normalizedImage
}

func pictureOrientation() -> ALAssetOrientation {
func pictureOrientation() -> UIImageOrientation {
switch UIDevice.currentDevice().orientation {
case .LandscapeLeft:
return .Up
Expand Down Expand Up @@ -363,7 +364,7 @@ class CameraView: UIViewController {
func getImage(name: String) -> UIImage {
guard let bundlePath = NSBundle(forClass: self.classForCoder).resourcePath?.stringByAppendingString("/ImagePicker.bundle")
else { return UIImage() }

let bundle = NSBundle(path: bundlePath)
let traitCollection = UITraitCollection(displayScale: 3)

Expand Down
10 changes: 5 additions & 5 deletions Source/ImageGallery/ImageGalleryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ public class ImageGalleryView: UIView {
return gesture
}()

lazy var selectedStack = ImageStack()

lazy var assets = [PHAsset]()

public lazy var noImagesLabel: UILabel = { [unowned self] in
let label = UILabel()
label.font = Configuration.noImagesFont
Expand All @@ -82,12 +78,16 @@ public class ImageGalleryView: UIView {
return label
}()

public lazy var selectedStack = ImageStack()
lazy var assets = [PHAsset]()

weak var delegate: ImageGalleryPanGestureDelegate?
var collectionSize: CGSize?
var shouldTransform = false
var imagesBeforeLoading = 0
var fetchResult: PHFetchResult?
var canFetchImages = false
var imageLimit = 0

// MARK: - Initializers

Expand Down Expand Up @@ -260,7 +260,7 @@ extension ImageGalleryView: UICollectionViewDelegate {
cell.selectedImageView.image = nil
}
self.selectedStack.dropAsset(asset)
} else {
} else if self.imageLimit == 0 || self.imageLimit > self.selectedStack.assets.count {
cell.selectedImageView.image = self.getImage("selectedImageGallery")
cell.selectedImageView.transform = CGAffineTransformMakeScale(0, 0)
UIView.animateWithDuration(0.2) { _ in
Expand Down
4 changes: 4 additions & 0 deletions Source/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ImagePickerController: UIViewController {
galleryView.delegate = self
galleryView.selectedStack = self.stack
galleryView.collectionView.layer.anchorPoint = CGPoint(x: 0, y: 0)
galleryView.imageLimit = self.imageLimit

return galleryView
}()
Expand Down Expand Up @@ -60,6 +61,7 @@ public class ImagePickerController: UIViewController {

public weak var delegate: ImagePickerDelegate?
public var stack = ImageStack()
public var imageLimit = 0
let totalSize = UIScreen.mainScreen().bounds.size
var initialFrame: CGRect?
var initialContentOffset: CGPoint?
Expand Down Expand Up @@ -217,6 +219,8 @@ public class ImagePickerController: UIViewController {
extension ImagePickerController: BottomContainerViewDelegate {

func pickerButtonDidPress() {
guard imageLimit == 0 || imageLimit > galleryView.selectedStack.assets.count else { return }

bottomContainer.pickerButton.enabled = false
bottomContainer.stackView.startLoader()
collapseGalleryView { [unowned self] in
Expand Down
3 changes: 1 addition & 2 deletions Source/Photos.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Photos
import AssetsLibrary

public struct ImagePicker {

public static func fetch(completion: (assets: [PHAsset]) -> Void) {
let fetchOptions = PHFetchOptions()
let authorizationStatus = ALAssetsLibrary.authorizationStatus()
let authorizationStatus = PHPhotoLibrary.authorizationStatus()
var fetchResult: PHFetchResult?

guard authorizationStatus == .Authorized else { return }
Expand Down

0 comments on commit 65f995b

Please sign in to comment.