Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add album view #240

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
20 changes: 20 additions & 0 deletions Example/FusumaExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
objects = {

/* Begin PBXBuildFile section */
4786CC921FD413FC00B6A97C /* FSAlbumSelectionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC8D1FD413FB00B6A97C /* FSAlbumSelectionTableViewCell.swift */; };
4786CC931FD413FC00B6A97C /* ArrowableTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC8E1FD413FB00B6A97C /* ArrowableTitleView.swift */; };
4786CC941FD413FC00B6A97C /* FSAlbumSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC8F1FD413FC00B6A97C /* FSAlbumSelectionViewController.swift */; };
4786CC951FD413FC00B6A97C /* ArrowImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC901FD413FC00B6A97C /* ArrowImageView.swift */; };
4786CC961FD413FC00B6A97C /* Rotatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC911FD413FC00B6A97C /* Rotatable.swift */; };
17AF1C921FDB81C900427B11 /* FusumaUITesting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17AF1C911FDB81C900427B11 /* FusumaUITesting.swift */; };
52412AC41CA61C9F0073C4BE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52412AC31CA61C9F0073C4BE /* AppDelegate.swift */; };
52412AC61CA61C9F0073C4BE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52412AC51CA61C9F0073C4BE /* ViewController.swift */; };
Expand Down Expand Up @@ -39,6 +44,11 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
4786CC8D1FD413FB00B6A97C /* FSAlbumSelectionTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSAlbumSelectionTableViewCell.swift; sourceTree = "<group>"; };
4786CC8E1FD413FB00B6A97C /* ArrowableTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrowableTitleView.swift; sourceTree = "<group>"; };
4786CC8F1FD413FC00B6A97C /* FSAlbumSelectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSAlbumSelectionViewController.swift; sourceTree = "<group>"; };
4786CC901FD413FC00B6A97C /* ArrowImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrowImageView.swift; sourceTree = "<group>"; };
4786CC911FD413FC00B6A97C /* Rotatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Rotatable.swift; sourceTree = "<group>"; };
17AF1C8F1FDB81C900427B11 /* FusumaUITesting.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FusumaUITesting.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
17AF1C911FDB81C900427B11 /* FusumaUITesting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FusumaUITesting.swift; sourceTree = "<group>"; };
17AF1C931FDB81C900427B11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -136,7 +146,12 @@
D77CA2951CBBDEB300C4BAC4 /* FSConstants.swift */,
D77CA2961CBBDEB300C4BAC4 /* FSImageCropView.swift */,
D77CA2971CBBDEB300C4BAC4 /* FusumaViewController.swift */,
4786CC8E1FD413FB00B6A97C /* ArrowableTitleView.swift */,
D77CA2981CBBDEB300C4BAC4 /* FusumaViewController.xib */,
4786CC901FD413FC00B6A97C /* ArrowImageView.swift */,
4786CC911FD413FC00B6A97C /* Rotatable.swift */,
4786CC8D1FD413FB00B6A97C /* FSAlbumSelectionTableViewCell.swift */,
4786CC8F1FD413FC00B6A97C /* FSAlbumSelectionViewController.swift */,
EDDC0B401D04FA14009135DB /* FSVideoCameraView.swift */,
EDDC0B411D04FA14009135DB /* FSVideoCameraView.xib */,
);
Expand Down Expand Up @@ -264,10 +279,15 @@
files = (
52412AC61CA61C9F0073C4BE /* ViewController.swift in Sources */,
EDDC0B421D04FA14009135DB /* FSVideoCameraView.swift in Sources */,
4786CC951FD413FC00B6A97C /* ArrowImageView.swift in Sources */,
4786CC941FD413FC00B6A97C /* FSAlbumSelectionViewController.swift in Sources */,
D77CA29E1CBBDEB300C4BAC4 /* FSCameraView.swift in Sources */,
4786CC931FD413FC00B6A97C /* ArrowableTitleView.swift in Sources */,
D77CA29C1CBBDEB300C4BAC4 /* FSAlbumViewCell.swift in Sources */,
D77CA29A1CBBDEB300C4BAC4 /* FSAlbumView.swift in Sources */,
4786CC921FD413FC00B6A97C /* FSAlbumSelectionTableViewCell.swift in Sources */,
D77CA2A01CBBDEB300C4BAC4 /* FSConstants.swift in Sources */,
4786CC961FD413FC00B6A97C /* Rotatable.swift in Sources */,
D77CA2A21CBBDEB300C4BAC4 /* FusumaViewController.swift in Sources */,
52412AC41CA61C9F0073C4BE /* AppDelegate.swift in Sources */,
D77CA2A11CBBDEB300C4BAC4 /* FSImageCropView.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions Example/FusumaExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class ViewController: UIViewController, FusumaDelegate {
fusuma.allowMultipleSelection = true
// fusuma.availableModes = [.video]
fusumaSavesImage = true

self.present(fusuma, animated: true, completion: nil)
let nav = UINavigationController(rootViewController: fusuma)
self.present(nav, animated: true, completion: nil)
}

// MARK: FusumaDelegate Protocol
Expand Down
48 changes: 45 additions & 3 deletions Fusuma.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
objects = {

/* Begin PBXBuildFile section */
4786CC771FD1B56900B6A97C /* FSAlbumSelectionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC741FD1B56700B6A97C /* FSAlbumSelectionTableViewCell.swift */; };
4786CC781FD1B56900B6A97C /* ArrowableTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC751FD1B56800B6A97C /* ArrowableTitleView.swift */; };
4786CC791FD1B56900B6A97C /* FSAlbumSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC761FD1B56800B6A97C /* FSAlbumSelectionViewController.swift */; };
4786CC7B1FD1B68800B6A97C /* ArrowImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC7A1FD1B68800B6A97C /* ArrowImageView.swift */; };
4786CC7C1FD1C15800B6A97C /* ArrowableTitleView.swift in Resources */ = {isa = PBXBuildFile; fileRef = 4786CC751FD1B56800B6A97C /* ArrowableTitleView.swift */; };
4786CC7D1FD1C15800B6A97C /* ArrowImageView.swift in Resources */ = {isa = PBXBuildFile; fileRef = 4786CC7A1FD1B68800B6A97C /* ArrowImageView.swift */; };
4786CC7E1FD1C15800B6A97C /* FSAlbumSelectionTableViewCell.swift in Resources */ = {isa = PBXBuildFile; fileRef = 4786CC741FD1B56700B6A97C /* FSAlbumSelectionTableViewCell.swift */; };
4786CC7F1FD1C15800B6A97C /* FSAlbumSelectionViewController.swift in Resources */ = {isa = PBXBuildFile; fileRef = 4786CC761FD1B56800B6A97C /* FSAlbumSelectionViewController.swift */; };
4786CC811FD1C22000B6A97C /* Rotatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4786CC801FD1C22000B6A97C /* Rotatable.swift */; };
4786CC821FD1C37400B6A97C /* Rotatable.swift in Resources */ = {isa = PBXBuildFile; fileRef = 4786CC801FD1C22000B6A97C /* Rotatable.swift */; };
52412A971CA6114A0073C4BE /* Fusuma.h in Headers */ = {isa = PBXBuildFile; fileRef = 52412A961CA6114A0073C4BE /* Fusuma.h */; settings = {ATTRIBUTES = (Public, ); }; };
EDDC0B3E1D04F53E009135DB /* FSVideoCameraView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDDC0B3C1D04F53E009135DB /* FSVideoCameraView.swift */; };
EDDC0B3F1D04F53E009135DB /* FSVideoCameraView.xib in Resources */ = {isa = PBXBuildFile; fileRef = EDDC0B3D1D04F53E009135DB /* FSVideoCameraView.xib */; };
Expand All @@ -24,6 +34,11 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
4786CC741FD1B56700B6A97C /* FSAlbumSelectionTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSAlbumSelectionTableViewCell.swift; sourceTree = "<group>"; };
4786CC751FD1B56800B6A97C /* ArrowableTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrowableTitleView.swift; sourceTree = "<group>"; };
4786CC761FD1B56800B6A97C /* FSAlbumSelectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSAlbumSelectionViewController.swift; sourceTree = "<group>"; };
4786CC7A1FD1B68800B6A97C /* ArrowImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrowImageView.swift; sourceTree = "<group>"; };
4786CC801FD1C22000B6A97C /* Rotatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Rotatable.swift; sourceTree = "<group>"; };
52412A931CA6114A0073C4BE /* Fusuma.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Fusuma.framework; sourceTree = BUILT_PRODUCTS_DIR; };
52412A961CA6114A0073C4BE /* Fusuma.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Fusuma.h; sourceTree = "<group>"; };
52412A981CA6114A0073C4BE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -87,6 +102,11 @@
EDDC0B5C1D051245009135DB /* Assets.xcassets */,
EDDC0B481D0511E7009135DB /* FusumaViewController.swift */,
EDDC0B491D0511E7009135DB /* FusumaViewController.xib */,
4786CC751FD1B56800B6A97C /* ArrowableTitleView.swift */,
4786CC7A1FD1B68800B6A97C /* ArrowImageView.swift */,
4786CC801FD1C22000B6A97C /* Rotatable.swift */,
4786CC741FD1B56700B6A97C /* FSAlbumSelectionTableViewCell.swift */,
4786CC761FD1B56800B6A97C /* FSAlbumSelectionViewController.swift */,
EDDC0B4C1D0511F2009135DB /* FSAlbumView.swift */,
EDDC0B4D1D0511F2009135DB /* FSAlbumView.xib */,
EDDC0B4E1D0511F2009135DB /* FSAlbumViewCell.swift */,
Expand Down Expand Up @@ -139,7 +159,7 @@
52412A8A1CA6114A0073C4BE /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = ytakzk;
TargetAttributes = {
52412A921CA6114A0073C4BE = {
Expand Down Expand Up @@ -171,6 +191,11 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4786CC821FD1C37400B6A97C /* Rotatable.swift in Resources */,
4786CC7C1FD1C15800B6A97C /* ArrowableTitleView.swift in Resources */,
4786CC7D1FD1C15800B6A97C /* ArrowImageView.swift in Resources */,
4786CC7E1FD1C15800B6A97C /* FSAlbumSelectionTableViewCell.swift in Resources */,
4786CC7F1FD1C15800B6A97C /* FSAlbumSelectionViewController.swift in Resources */,
EDDC0B3F1D04F53E009135DB /* FSVideoCameraView.xib in Resources */,
EDDC0B571D0511F2009135DB /* FSAlbumViewCell.xib in Resources */,
EDDC0B591D0511F2009135DB /* FSCameraView.xib in Resources */,
Expand All @@ -188,7 +213,12 @@
buildActionMask = 2147483647;
files = (
EDDC0B3E1D04F53E009135DB /* FSVideoCameraView.swift in Sources */,
4786CC771FD1B56900B6A97C /* FSAlbumSelectionTableViewCell.swift in Sources */,
4786CC791FD1B56900B6A97C /* FSAlbumSelectionViewController.swift in Sources */,
EDDC0B581D0511F2009135DB /* FSCameraView.swift in Sources */,
4786CC811FD1C22000B6A97C /* Rotatable.swift in Sources */,
4786CC781FD1B56900B6A97C /* ArrowableTitleView.swift in Sources */,
4786CC7B1FD1B68800B6A97C /* ArrowImageView.swift in Sources */,
EDDC0B4A1D0511E7009135DB /* FusumaViewController.swift in Sources */,
EDDC0B541D0511F2009135DB /* FSAlbumView.swift in Sources */,
EDDC0B5A1D0511F2009135DB /* FSConstants.swift in Sources */,
Expand All @@ -209,14 +239,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -261,14 +297,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -303,7 +345,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CODE_SIGN_STYLE = Manual;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
Expand All @@ -327,7 +369,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CODE_SIGN_STYLE = Manual;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
Expand Down
78 changes: 78 additions & 0 deletions Sources/ArrowImageView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// ArrowImageView.swift
// Burpple2
//
// Created by Valent Richie on 25/8/16.
// Copyright © 2016 Burpple Pte Ltd. All rights reserved.
//

import UIKit

@objc final class ArrowImageView: UIImageView, Rotatable {

var duration: Double = 0.3

func setup() {
transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi / 2))
translatesAutoresizingMaskIntoConstraints = false
setContentCompressionResistancePriority(UILayoutPriority.required, for: .horizontal)
setContentCompressionResistancePriority(UILayoutPriority.required, for: .horizontal)
setContentHuggingPriority(UILayoutPriority.required, for: .horizontal)
setContentCompressionResistancePriority(UILayoutPriority.required, for: .vertical)
setContentHuggingPriority(UILayoutPriority.required, for: .vertical)

if #available(iOS 9.0, *) {
self.addConstraint(NSLayoutConstraint(item: self, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 12.0))
self.addConstraint(NSLayoutConstraint(item: self, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 6.0))
}
}

init() {
// ic_arrow is right facing
super.init(image: UIImage(named: "ic_arrow"))
setup()
}

init(template: Bool) {
let image = UIImage(named: "ic_arrow")
if template {
image?.withRenderingMode(.alwaysTemplate)
}
super.init(image: image)
setup()
}

required init?(coder _: NSCoder) {
super.init(image: UIImage(named: "ic_arrow"))
setup()
}

public func upsideDown(_ animation: Bool) {
let angle = CGFloat(3 * Double.pi / 2) // Upside down
if animation == false {
transform = CGAffineTransform(rotationAngle: angle)
} else {
UIView.animate(withDuration: duration, animations: {
self.transform = CGAffineTransform(rotationAngle: angle)
})
}
}

public func normal(_ animation: Bool) {
let angle: CGFloat = CGFloat(Double.pi / 2) // Normal direction

// The rotation transform will rotate in the direction of shortest angle change
// If the angle is the same, the default direction is clockwise (which is undesired in this case since the rotation upside down is clockwise)
// Transform the initial angle to be slightly less than M_PI to make the rotation direction counter clockwise
let startAngle = CGFloat(3 * Double.pi / 2 - 0.001)
transform = CGAffineTransform(rotationAngle: startAngle)

if animation == false {
transform = CGAffineTransform(rotationAngle: angle)
} else {
UIView.animate(withDuration: duration, animations: {
self.transform = CGAffineTransform(rotationAngle: angle)
})
}
}
}
Loading