Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df7777f1dd | ||
|
|
15419f5d6a | ||
|
|
7cfa15526b | ||
|
|
dbc17e3350 | ||
|
|
b0b71a7492 | ||
|
|
698ba6ce3b | ||
|
|
ab039916ca | ||
|
|
184ad73a1d | ||
|
|
0cd732c252 | ||
|
|
a60a161ac8 | ||
|
|
bc6093f4c2 | ||
|
|
61665d8b00 | ||
|
|
c9d69f148c | ||
|
|
e4f0d79eaa | ||
|
|
a44e54d7e9 | ||
|
|
b11b0ce612 | ||
|
|
8976f8e45f | ||
|
|
717cccf841 | ||
|
|
9d7e14d7f5 | ||
|
|
6ac142d507 | ||
|
|
6fb5efd349 | ||
|
|
e0ef4dd95c | ||
|
|
b00bd352c0 | ||
|
|
224131ffc3 | ||
|
|
017a311d93 | ||
|
|
c424208817 | ||
|
|
307d2d8951 | ||
|
|
c2cb27dc85 | ||
|
|
5f30473885 | ||
|
|
0ad7a826d1 | ||
|
|
3e98254fbd | ||
|
|
83090712f9 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
osx_image: xcode7.3
|
||||
osx_image: xcode8
|
||||
language: objective-c
|
||||
|
||||
xcode_project: DemoExpandingCollection/DemoExpandingCollection.xcodeproj
|
||||
|
||||
@@ -569,7 +569,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "if which swiftgen >/dev/null; then\nswiftgen images \"$PROJECT_DIR/DemoExpandingCollection/Assets.xcassets\" --output \"$PROJECT_DIR/DemoExpandingCollection/Constants/Images.swift\"\nelse\necho \"warning: SwiftGen not installed, download it from https://github.com/AliSoftware/SwiftGen\"\nfi";
|
||||
shellScript = "if which swiftgen >/dev/null; then\nswiftgen images \"$PROJECT_DIR/DemoExpandingCollection/Assets.xcassets\" -t swift3 --output \"$PROJECT_DIR/DemoExpandingCollection/Constants/Images.swift\"\nelse\necho \"warning: SwiftGen not installed, download it from https://github.com/AliSoftware/SwiftGen\"\nfi";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@@ -759,7 +759,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
DEVELOPMENT_TEAM = 34MUF9YXTA;
|
||||
INFOPLIST_FILE = DemoExpandingCollection/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev1;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -777,7 +777,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
DEVELOPMENT_TEAM = 34MUF9YXTA;
|
||||
INFOPLIST_FILE = DemoExpandingCollection/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev1;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -824,7 +824,7 @@
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = ExpandingCollection/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -848,7 +848,7 @@
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = ExpandingCollection/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
||||
+10
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="L1n-Ia-Jrw">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
|
||||
@@ -1,35 +1,59 @@
|
||||
// Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
import UIKit.UIImage
|
||||
typealias Image = UIImage
|
||||
#elseif os(OSX)
|
||||
import AppKit.NSImage
|
||||
typealias Image = NSImage
|
||||
#endif
|
||||
|
||||
extension UIImage {
|
||||
enum Asset: String {
|
||||
case BackgroundImage = "BackgroundImage"
|
||||
case CloseButton = "CloseButton"
|
||||
case Dots = "dots"
|
||||
case Face1 = "face1"
|
||||
case Face2 = "face2"
|
||||
case Heand = "heand"
|
||||
case Icons = "icons"
|
||||
case Image = "image"
|
||||
case Item0 = "item0"
|
||||
case Item1 = "item1"
|
||||
case Item2 = "item2"
|
||||
case Item3 = "item3"
|
||||
case LocationButton = "locationButton"
|
||||
case Map = "map"
|
||||
case PinIcon = "pinIcon"
|
||||
case SearchIcon = "searchIcon"
|
||||
case Stars = "stars"
|
||||
case Title = "Title"
|
||||
// swiftlint:disable file_length
|
||||
// swiftlint:disable line_length
|
||||
|
||||
var image: UIImage {
|
||||
return UIImage(asset: self)
|
||||
}
|
||||
}
|
||||
// swiftlint:disable type_body_length
|
||||
enum Asset: String {
|
||||
case backgroundImage = "BackgroundImage"
|
||||
case closeButton = "CloseButton"
|
||||
case dots = "dots"
|
||||
case face1 = "face1"
|
||||
case face2 = "face2"
|
||||
case heand = "heand"
|
||||
case icons = "icons"
|
||||
case image = "image"
|
||||
case item0 = "item0"
|
||||
case item1 = "item1"
|
||||
case item2 = "item2"
|
||||
case item3 = "item3"
|
||||
case locationButton = "locationButton"
|
||||
case map = "map"
|
||||
case pinIcon = "pinIcon"
|
||||
case searchIcon = "searchIcon"
|
||||
case stars = "stars"
|
||||
case title = "Title"
|
||||
|
||||
convenience init!(asset: Asset) {
|
||||
self.init(named: asset.rawValue)
|
||||
var image: Image {
|
||||
let bundle = Bundle(for: BundleToken.self)
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
let image = Image(named: rawValue, in: bundle, compatibleWith: nil)
|
||||
#elseif os(OSX)
|
||||
let image = bundle.image(forResource: rawValue)
|
||||
#endif
|
||||
guard let result = image else { fatalError("Unable to load image \(rawValue).") }
|
||||
return result
|
||||
}
|
||||
}
|
||||
// swiftlint:enable type_body_length
|
||||
|
||||
extension Image {
|
||||
convenience init!(asset: Asset) {
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
let bundle = Bundle(for: BundleToken.self)
|
||||
self.init(named: asset.rawValue, in: bundle, compatibleWith: nil)
|
||||
#elseif os(OSX)
|
||||
self.init(named: asset.rawValue)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private final class BundleToken {}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class DemoTableViewController: ExpandingTableViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
configureNavBar()
|
||||
let image1 = UIImage.Asset.BackgroundImage.image
|
||||
let image1 = Asset.backgroundImage.image
|
||||
tableView.backgroundView = UIImageView(image: image1)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,10 +17,10 @@ extension Rotatable {
|
||||
|
||||
func rotateAnimationFrom(_ fromItem: UIView, toItem: UIView, duration: Double) {
|
||||
|
||||
let fromRotate = animationFrom(0, to: M_PI, key: "transform.rotation", duration: duration)
|
||||
let fromRotate = animationFrom(0, to: Double.pi, key: "transform.rotation", duration: duration)
|
||||
let fromOpacity = animationFrom(1, to: 0, key: "opacity", duration: duration)
|
||||
|
||||
let toRotate = animationFrom(-M_PI, to: 0, key: "transform.rotation", duration: duration)
|
||||
let toRotate = animationFrom(-Double.pi, to: 0, key: "transform.rotation", duration: duration)
|
||||
let toOpacity = animationFrom(0, to: 1, key: "opacity", duration: duration)
|
||||
|
||||
fromItem.layer.add(fromRotate, forKey: nil)
|
||||
|
||||
@@ -8,21 +8,28 @@
|
||||
[](https://cdn.rawgit.com/Ramotion/expanding-collection/master/docs/index.html)
|
||||
|
||||
[](https://github.com/Ramotion/expanding-collection)
|
||||
[](https://travis-ci.org/Ramotion/elastic-pull-to-update)
|
||||
[](https://travis-ci.org/Ramotion/expanding-collection)
|
||||
[](https://codebeat.co/projects/github-com-ramotion-expanding-collection)
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
## About
|
||||
This project is maintained by Ramotion, an agency specialized in building dedicated engineering teams and developing custom software.<br><br> [Contact our team](https://business.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection-contact-us) and we’ll help you work with the best engineers from Eastern Europe.
|
||||
This project is maintained by Ramotion, Inc.<br>
|
||||
We specialize in the designing and coding of custom UI for Mobile Apps and Websites.<br><br>**Looking for developers for your project?**
|
||||
|
||||
<a href="https://business.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection-contact-us/#Get_in_Touch" > <img src="https://github.com/Ramotion/navigation-stack/raw/master/contact_our_team@2x.png" width="150" height="30"></a>
|
||||
|
||||
|
||||
[](https://dribbble.com/shots/2741477-iOS-Expanding-Collection-Open-Source)
|
||||
|
||||
The [iPhone mockup](https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection) available [here](https://store.ramotion.com/product/iphone-6-mockups?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection).
|
||||
The [iPhone mockup](https://store.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection) available [here](https://store.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=expanding-collection).
|
||||
|
||||
## Try this UI control in action
|
||||
|
||||
<a href="https://itunes.apple.com/app/apple-store/id1182360240?pt=550053&ct=gthb-expanding-collection&mt=8" > <img src="https://github.com/Ramotion/navigation-stack/raw/master/Download_on_the_App_Store_Badge_US-UK_135x40.png" width="170" height="58"></a>
|
||||
|
||||
## Requirements
|
||||
|
||||
- iOS 8.0+
|
||||
- Xcode 7.3
|
||||
- iOS 9.0+
|
||||
- Xcode 8
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -30,7 +37,9 @@ Just add the Source folder to your project.
|
||||
|
||||
or use [CocoaPods](https://cocoapods.org) with Podfile:
|
||||
``` ruby
|
||||
pod 'expanding-collection'
|
||||
pod 'expanding-collection', '~> 1.0.3' swift 3
|
||||
|
||||
pod 'expanding-collection', '~> 0.3.2' swift 2
|
||||
```
|
||||
or [Carthage](https://github.com/Carthage/Carthage) users can simply add to their `Cartfile`:
|
||||
```
|
||||
@@ -40,7 +49,7 @@ github "Ramotion/expanding-collection"
|
||||
## Usage
|
||||
|
||||
```swift
|
||||
import ExpandingCollection
|
||||
import expanding_collection
|
||||
```
|
||||
|
||||
#### Create CollectionViewCell
|
||||
|
||||
@@ -11,8 +11,16 @@ import UIKit
|
||||
/// Base class for UICollectionViewCell
|
||||
open class BasePageCollectionCell: UICollectionViewCell {
|
||||
|
||||
/// Animation oposition offset when cell is open
|
||||
/// DEPRECATED! Animation oposition offset when cell is open
|
||||
@IBInspectable open var yOffset: CGFloat = 40
|
||||
/// Spacing between centers of views
|
||||
@IBInspectable open var ySpacing: CGFloat = CGFloat.greatestFiniteMagnitude
|
||||
/// Additional height of back view, when it grows
|
||||
@IBInspectable open var additionalHeight: CGFloat = CGFloat.greatestFiniteMagnitude
|
||||
/// Additional width of back view, when it grows
|
||||
@IBInspectable open var additionalWidth: CGFloat = CGFloat.greatestFiniteMagnitude
|
||||
/// Should front view drow shadow to bottom or not
|
||||
@IBInspectable open var dropShadow: Bool = true
|
||||
|
||||
// MARK: Constants
|
||||
|
||||
@@ -85,7 +93,6 @@ extension BasePageCollectionCell {
|
||||
configurationViews()
|
||||
shadowView = createShadowViewOnView(frontContainerView)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: Control
|
||||
@@ -101,19 +108,32 @@ extension BasePageCollectionCell {
|
||||
public func cellIsOpen(_ isOpen: Bool, animated: Bool = true) {
|
||||
if isOpen == isOpened { return }
|
||||
|
||||
frontConstraintY.constant = isOpen == true ? -frontContainerView.bounds.size.height / 5 : 0
|
||||
backConstraintY.constant = isOpen == true ? frontContainerView.bounds.size.height / 5 - yOffset / 2 : 0
|
||||
if ySpacing == .greatestFiniteMagnitude {
|
||||
frontConstraintY.constant = isOpen == true ? -frontContainerView.bounds.size.height / 5 : 0
|
||||
backConstraintY.constant = isOpen == true ? frontContainerView.bounds.size.height / 5 - yOffset / 2 : 0
|
||||
} else {
|
||||
frontConstraintY.constant = isOpen == true ? -ySpacing / 2 : 0
|
||||
backConstraintY.constant = isOpen == true ? ySpacing / 2 : 0
|
||||
}
|
||||
|
||||
if let widthConstant = backContainerView.getConstraint(.width) {
|
||||
widthConstant.constant = isOpen == true ? frontContainerView.bounds.size.width + yOffset : frontContainerView.bounds.size.width
|
||||
if additionalWidth == .greatestFiniteMagnitude {
|
||||
widthConstant.constant = isOpen == true ? frontContainerView.bounds.size.width + yOffset : frontContainerView.bounds.size.width
|
||||
} else {
|
||||
widthConstant.constant = isOpen == true ? frontContainerView.bounds.size.width + additionalWidth : frontContainerView.bounds.size.width
|
||||
}
|
||||
}
|
||||
|
||||
if let heightConstant = backContainerView.getConstraint(.height) {
|
||||
heightConstant.constant = isOpen == true ? frontContainerView.bounds.size.height + yOffset : frontContainerView.bounds.size.height
|
||||
if additionalHeight == .greatestFiniteMagnitude {
|
||||
heightConstant.constant = isOpen == true ? frontContainerView.bounds.size.height + yOffset : frontContainerView.bounds.size.height
|
||||
} else {
|
||||
heightConstant.constant = isOpen == true ? frontContainerView.bounds.size.height + additionalHeight : frontContainerView.bounds.size.height
|
||||
}
|
||||
}
|
||||
|
||||
isOpened = isOpen
|
||||
configurationCell()
|
||||
|
||||
|
||||
if animated == true {
|
||||
UIView.animate(withDuration: 0.3, delay: 0, options: UIViewAnimationOptions(), animations: {
|
||||
@@ -123,7 +143,6 @@ extension BasePageCollectionCell {
|
||||
self.contentView.layoutIfNeeded()
|
||||
}
|
||||
|
||||
isOpened = isOpen
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,10 +168,12 @@ extension BasePageCollectionCell {
|
||||
$0.backgroundColor = UIColor(white: 0, alpha: 0)
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.layer.masksToBounds = false;
|
||||
$0.layer.shadowColor = UIColor.black.cgColor
|
||||
$0.layer.shadowRadius = 10
|
||||
$0.layer.shadowOpacity = 0.3
|
||||
$0.layer.shadowOffset = CGSize(width: 0, height:0)
|
||||
if dropShadow {
|
||||
$0.layer.shadowColor = UIColor.black.cgColor
|
||||
$0.layer.shadowRadius = 10
|
||||
$0.layer.shadowOpacity = 0.3
|
||||
$0.layer.shadowOffset = CGSize(width: 0, height:0)
|
||||
}
|
||||
}
|
||||
contentView.insertSubview(shadow, belowSubview: view)
|
||||
|
||||
@@ -192,8 +213,13 @@ extension BasePageCollectionCell {
|
||||
|
||||
frame.size.height += i * superHeight
|
||||
frame.origin.y -= i * superHeight / 2
|
||||
frame.origin.x -= i * yOffset / 2
|
||||
frame.size.width += i * yOffset
|
||||
if additionalWidth == .greatestFiniteMagnitude {
|
||||
frame.origin.x -= i * yOffset / 2
|
||||
frame.size.width += i * yOffset
|
||||
} else {
|
||||
frame.origin.x -= i * additionalWidth / 2
|
||||
frame.size.width += i * additionalWidth
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,12 +13,11 @@ class PageCollectionView: UICollectionView {
|
||||
}
|
||||
|
||||
// MARK: init
|
||||
|
||||
extension PageCollectionView {
|
||||
|
||||
class func createOnView(_ view: UIView,
|
||||
layout: UICollectionViewLayout,
|
||||
height:CGFloat,
|
||||
height: CGFloat,
|
||||
dataSource: UICollectionViewDataSource,
|
||||
delegate: UICollectionViewDelegate) -> PageCollectionView {
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ extension ExpandingViewController {
|
||||
height: itemSize.height + itemSize.height / 5 * 2,
|
||||
dataSource: self,
|
||||
delegate: self)
|
||||
if #available(iOS 10.0, *) {
|
||||
collectionView?.isPrefetchingEnabled = false
|
||||
}
|
||||
transitionDriver = TransitionDriver(view: view)
|
||||
}
|
||||
}
|
||||
@@ -109,18 +112,18 @@ extension ExpandingViewController {
|
||||
|
||||
extension ExpandingViewController: UICollectionViewDataSource, UICollectionViewDelegate {
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
open func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
guard case let cell as BasePageCollectionCell = cell else {
|
||||
return
|
||||
}
|
||||
|
||||
cell.configureCellViewConstraintsWithSize(itemSize)
|
||||
}
|
||||
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
fatalError("need emplementation in subclass")
|
||||
}
|
||||
|
||||
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
fatalError("need emplementation in subclass")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'expanding-collection'
|
||||
s.version = '1.0.0'
|
||||
s.version = '1.0.3'
|
||||
s.summary = 'Transition animtion from CollectionView to TableView'
|
||||
s.license = 'MIT'
|
||||
s.homepage = 'https://github.com/Ramotion/expanding-collection'
|
||||
s.author = { 'Juri Vasylenko' => 'juri.v@ramotion.com' }
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.ios.deployment_target = '9.0'
|
||||
s.source = { :git => 'https://github.com/Ramotion/expanding-collection.git', :tag => s.version.to_s }
|
||||
s.source_files = 'Source/**/*.swift'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user