Compare commits

...
8 Commits
Author SHA1 Message Date
Alex.k 3aa04958d3 added docs 2016-06-07 11:27:32 +03:00
Alex.k 43808c6d33 items count 2016-06-07 10:44:59 +03:00
Alex.k 84f19193e3 removed print 2016-06-07 10:44:01 +03:00
Alex.k a2c6b4afbf Merge branch 'master' of https://github.com/Ramotion/expanding-collection 2016-06-07 10:42:10 +03:00
Alex.k 2f74142383 small fixing 2016-06-07 10:42:05 +03:00
Alex a4df164649 Merge pull request #13 from Dershowitz011/master
Readme fixed..
2016-06-06 19:24:12 +00:00
Shantanu R Desai 729f3b7c5b Readme fixed.. 2016-06-06 23:40:40 +05:30
Alex.k 959f922708 update podspec 2016-06-06 16:33:01 +03:00
9 changed files with 89 additions and 45 deletions
@@ -493,6 +493,7 @@
TargetAttributes = {
848596271CF585F3000BCC74 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = LEAZS7L33U;
};
8485963B1CF585F3000BCC74 = {
CreatedOnToolsVersion = 7.3.1;
@@ -500,6 +501,7 @@
};
8499D8131D001B82004B5B37 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = LEAZS7L33U;
};
};
};
@@ -810,7 +812,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.ExpandingCollection;
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -833,7 +835,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.ExpandingCollection;
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -879,6 +881,7 @@
8499D81E1D001B82004B5B37 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -1,33 +1,34 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen
import UIKit.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"
var image: UIImage {
return UIImage(asset: self)
}
}
import Foundation
import UIKit
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"
var image: UIImage {
return UIImage(asset: self)
}
}
convenience init!(asset: Asset) {
self.init(named: asset.rawValue)
}
@@ -14,7 +14,7 @@ class DemoTableViewController: ExpandingTableViewController {
override func viewDidLoad() {
super.viewDidLoad()
configureNavBar()
let image1 = Asset.BackgroundImage.image
let image1 = UIImage.Asset.BackgroundImage.image
tableView.backgroundView = UIImageView(image: image1)
}
}
@@ -76,7 +76,6 @@ extension DemoViewController {
func swipeHandler(sender: UISwipeGestureRecognizer) {
let indexPath = NSIndexPath(forRow: currentIndex, inSection: 0)
guard let cell = collectionView?.cellForItemAtIndexPath(indexPath) as? DemoCollectionViewCell else { return }
// double swipe Up transition
if cell.isOpened == true && sender.direction == .Up {
pushToViewController(getViewController())
@@ -108,11 +107,11 @@ extension DemoViewController {
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
guard let cell = cell as? DemoCollectionViewCell else { return }
let index = indexPath.row % 4
let index = indexPath.row % items.count
let info = items[index]
cell.backgroundImageView?.image = UIImage(named: info.imageName)
cell.customTitle.text = info.title
cell.cellIsOpen(cellsIsOpen[indexPath.row], animated: false)
cell.cellIsOpen(cellsIsOpen[index], animated: false)
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
+1 -1
View File
@@ -52,7 +52,7 @@ import expanding_collection
- add any desired uiviews to frontView
3) Adding BackView
- repeat step 3 (connect outlets to `@IBOutlet weak var backContainerView: UIView!`, `@IBOutlet weak var backConstraintY: NSLayoutConstraint!`)
- repeat step 2 (connect outlets to `@IBOutlet weak var backContainerView: UIView!`, `@IBOutlet weak var backConstraintY: NSLayoutConstraint!`)
4) Cell example [DemoCell](https://github.com/Ramotion/expanding-collection/tree/master/DemoExpandingCollection/DemoExpandingCollection/ViewControllers/DemoViewController/Cells)
@@ -8,16 +8,14 @@
import UIKit
/// Base class for UITableViewcontroller which have back transition method
public class ExpandingTableViewController: UITableViewController {
// MARK: Vars
/// The height of the table view header
public var headerHeight: CGFloat = 236
var transitionDriver: TransitionDriver?
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
var transitionDriver: TransitionDriver?
}
// MARK: Helpers
@@ -31,10 +29,14 @@ extension ExpandingTableViewController {
return view.takeSnapshot(CGRect(origin: backImageOrigin, size: backImageSize))
}
}
// MARK: Public
// MARK: Methods
extension ExpandingTableViewController {
/**
Pops the top view controller from the navigation stack and updates the display with custom animation.
*/
public func popTransitionAnimation() {
guard let transitionDriver = self.transitionDriver else {
return
@@ -8,9 +8,11 @@
import UIKit
/// Base class for UICollectionViewCell
public class BasePageCollectionCell: UICollectionViewCell {
@IBInspectable public var openSize: CGFloat = 40
/// Animation oposition offset when cell is open
@IBInspectable public var yOffset: CGFloat = 40
// MARK: Constants
@@ -25,23 +27,43 @@ public class BasePageCollectionCell: UICollectionViewCell {
// MARK: Vars
/// The view used as the face of the cell must connectid from xib or storyboard.
@IBOutlet public weak var frontContainerView: UIView!
/// The view used as the back of the cell must connectid from xib or storyboard.
@IBOutlet public weak var backContainerView: UIView!
/// constraints for backContainerView must connectid from xib or storyboard
@IBOutlet public weak var backConstraintY: NSLayoutConstraint!
/// constraints for frontContainerView must connectid from xib or storyboard
@IBOutlet public weak var frontConstraintY: NSLayoutConstraint!
var shadowView: UIView?
/// A Boolean value that indicates whether the cell is opened.
public var isOpened = false
// MARK: inits
/**
Initializes a UICollectionViewCell from data in a given unarchiver.
- parameter aDecoder: An unarchiver object.
- returns: An initialized UICollectionViewCell object.
*/
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configureOutletFromDecoder(aDecoder)
}
/**
Initializes and returns a newly allocated view object with the specified frame rectangle.
- parameter frame: The frame rectangle for the view
- returns: An initialized UICollectionViewCell object.
*/
override init(frame: CGRect) {
super.init(frame: frame)
@@ -70,18 +92,24 @@ extension BasePageCollectionCell {
extension BasePageCollectionCell {
/**
Open or close cell.
- parameter isOpen: Contains the value true if the cell should display open state, if false should display close state.
- parameter animated: Set to true if the change in selection state is animated.
*/
public func cellIsOpen(isOpen: Bool, animated: Bool = true) {
if isOpen == isOpened { return }
frontConstraintY.constant = isOpen == true ? -bounds.size.height / 5 : 0
backConstraintY.constant = isOpen == true ? bounds.size.height / 5 - openSize / 2 : 0
backConstraintY.constant = isOpen == true ? bounds.size.height / 5 - yOffset / 2 : 0
if let widthConstant = backContainerView.getConstraint(.Width) {
widthConstant.constant = isOpen == true ? contentView.bounds.size.width + openSize : contentView.bounds.size.width
widthConstant.constant = isOpen == true ? contentView.bounds.size.width + yOffset : contentView.bounds.size.width
}
if let heightConstant = backContainerView.getConstraint(.Height) {
heightConstant.constant = isOpen == true ? contentView.bounds.size.height + openSize : contentView.bounds.size.height
heightConstant.constant = isOpen == true ? contentView.bounds.size.height + yOffset : contentView.bounds.size.height
}
if animated == true {
@@ -8,16 +8,22 @@
import UIKit
/// UIViewController with UICollectionView with custom transition method
public class ExpandingViewController: UIViewController {
/// The default size to use for cells.
public var itemSize = CGSize(width: 256, height: 335)
/// The collection view object managed by this view controller.
public var collectionView: UICollectionView?
private var transitionDriver: TransitionDriver?
/// Index of current cell
public var currentIndex: Int {
guard let collectionView = self.collectionView else { return 0 }
let startOffset = (collectionView.bounds.size.width - itemSize.width) / 2
let startOffset = (collectionView.bounds.size.width - itemSize.width) / 2
guard let collectionLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else {
return 0
}
@@ -41,6 +47,11 @@ extension ExpandingViewController {
public extension ExpandingViewController {
/**
Pushes a view controller onto the receiver’s stack and updates the display with custom animation.
- parameter viewController: The table view controller to push onto the stack.
*/
func pushToViewController(viewController: ExpandingTableViewController) {
guard let collectionView = self.collectionView else {
return
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'expanding-collection'
s.version = '0.0.5'
s.version = '0.0.6'
s.summary = 'Transition animtion from CollectionView to TableView'
s.license = 'MIT'
s.homepage = 'https://github.com/Ramotion/expanding-collection'