Skip to content

Commit

Permalink
Merge pull request #1 from richardoti/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
richardtop committed Aug 10, 2015
2 parents be91562 + 1c14032 commit cfbf8fb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
28 changes: 28 additions & 0 deletions Source/BottomView/ImageStack.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import UIKit

class ImageStack: UIView {

var images: NSMutableArray = NSMutableArray()
var views: NSMutableArray = NSMutableArray()

override init(frame: CGRect) {
super.init(frame: frame)

}

func pushImage(image: UIImage) {
images.insertObject(image, atIndex: 0)
println("Image pushed")
println(images)
}

func dropImage(image: UIImage) {
images.removeObject(image)
println("Image dropped")
println(images)
}

required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
6 changes: 4 additions & 2 deletions Source/ImageGallery/ImageGalleryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ImageGalleryView: UIView {
static let indicatorHeight: CGFloat = 8
}

var stack: ImageStack = ImageStack()

lazy var collectionView: UICollectionView = { [unowned self] in
let collectionView = UICollectionView(frame: CGRectMake(0, 0, 0, 0),
collectionViewLayout: self.collectionViewLayout)
Expand Down Expand Up @@ -263,14 +265,14 @@ extension ImageGalleryView: UICollectionViewDelegate {
}, completion: { _ in
cell.selectedImageView.image = nil
})
selectedImages.removeObject(image)
stack.dropImage(image)
} else {
cell.selectedImageView.image = getImage("selectedImageGallery")
cell.selectedImageView.transform = CGAffineTransformMakeScale(0, 0)
UIView.animateWithDuration(0.2, animations: { _ in
cell.selectedImageView.transform = CGAffineTransformIdentity
})
selectedImages.insertObject(image, atIndex: 0)
stack.pushImage(image)
}

delegate?.imageSelected(selectedImages)
Expand Down

0 comments on commit cfbf8fb

Please sign in to comment.