Skip to content

Commit

Permalink
Merge pull request #7 from hyperoslo/feature/actual-camera
Browse files Browse the repository at this point in the history
Feature/actual camera
  • Loading branch information
richardtop committed Aug 6, 2015
2 parents 12148de + a7f96f0 commit 6c96fdc
Show file tree
Hide file tree
Showing 10 changed files with 470 additions and 72 deletions.
Binary file added Images/focusIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/focusIcon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/focusIcon@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 56 additions & 10 deletions Source/BottomView/BottomContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class BottomContainerView: UIView {
let pickerButton = ButtonPicker()
pickerButton.setTitleColor(UIColor.whiteColor(), forState: .Normal)
pickerButton.setTranslatesAutoresizingMaskIntoConstraints(false)
pickerButton.delegate = self

return pickerButton
}()
Expand Down Expand Up @@ -51,14 +52,24 @@ class BottomContainerView: UIView {
return configuration
}()

lazy var topSeparator: UIView = { [unowned self] in
let view = UIView()
view.setTranslatesAutoresizingMaskIntoConstraints(false)
view.backgroundColor = self.configuration.backgroundColor

return view
}()

var delegate: BottomContainerViewDelegate?
var pastCount = 0

// MARK: Initializers

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

[borderPickerButton, pickerButton, doneButton, imageWrapper].map { self.addSubview($0) }
[borderPickerButton, pickerButton, doneButton, imageWrapper, topSeparator].map { self.addSubview($0) }
backgroundColor = self.configuration.backgroundColor

setupConstraints()
}
Expand All @@ -71,6 +82,7 @@ class BottomContainerView: UIView {

func setupConstraints() {
let attributesBorder: [NSLayoutAttribute] = [.CenterX, .CenterY]
let attributesSeparator: [NSLayoutAttribute] = [.Width, .Left, .Top]

attributesBorder.map {
self.addConstraint(NSLayoutConstraint(item: self.pickerButton, attribute: $0,
Expand Down Expand Up @@ -123,6 +135,16 @@ class BottomContainerView: UIView {
addConstraint(NSLayoutConstraint(item: imageWrapper, attribute: .CenterX,
relatedBy: .Equal, toItem: self, attribute: .Left,
multiplier: 1, constant: UIScreen.mainScreen().bounds.width/4 - ButtonPicker.Dimensions.buttonBorderSize/4))

attributesSeparator.map {
self.addConstraint(NSLayoutConstraint(item: self.topSeparator, attribute: $0,
relatedBy: .Equal, toItem: self, attribute: $0,
multiplier: 1, constant: 0))
}

addConstraint(NSLayoutConstraint(item: topSeparator, attribute: .Height,
relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,
multiplier: 1, constant: 1))
}

// MARK: - Action methods
Expand All @@ -143,30 +165,54 @@ class BottomContainerView: UIView {
imageWrapper.firstImageView.image = array.firstObject as? UIImage
imageWrapper.secondImageView.image = nil
imageWrapper.secondImageView.alpha = 0
if pastCount < 1 {
animateImageView(imageWrapper.firstImageView)
}
case 0:
imageWrapper.firstImageView.image = nil
imageWrapper.secondImageView.image = nil
case 2:
imageWrapper.firstImageView.image = array[0] as? UIImage
imageWrapper.secondImageView.image = array[1] as? UIImage
imageWrapper.firstImageView.image = array[1] as? UIImage
imageWrapper.secondImageView.image = array.firstObject as? UIImage
imageWrapper.secondImageView.alpha = 1
imageWrapper.thirdImageView.alpha = 0
if pastCount < 2 {
animateImageView(imageWrapper.secondImageView)
}
case 3:
imageWrapper.firstImageView.image = array[0] as? UIImage
imageWrapper.firstImageView.image = array[2] as? UIImage
imageWrapper.secondImageView.image = array[1] as? UIImage
imageWrapper.thirdImageView.image = array[2] as? UIImage
imageWrapper.thirdImageView.image = array.firstObject as? UIImage
imageWrapper.thirdImageView.alpha = 1
imageWrapper.fourthImageView.alpha = 0
if pastCount < 3 {
animateImageView(imageWrapper.thirdImageView)
}
default:
imageWrapper.fourthImageView.alpha = 1
imageWrapper.firstImageView.image = array[array.count - 4] as? UIImage
imageWrapper.secondImageView.image = array[array.count - 3] as? UIImage
imageWrapper.thirdImageView.image = array[array.count - 2] as? UIImage
imageWrapper.fourthImageView.image = array.lastObject as? UIImage
imageWrapper.firstImageView.image = array.lastObject as? UIImage
imageWrapper.secondImageView.image = array[array.count - 2] as? UIImage
imageWrapper.thirdImageView.image = array[array.count - 3] as? UIImage
imageWrapper.fourthImageView.image = array[array.count - 4] as? UIImage
if pastCount < array.count {
animateImageView(imageWrapper.fourthImageView)
}
}

pastCount = array.count
pickerButton.photoNumber = array.count
}

private func animateImageView(imageView: UIImageView) {
imageView.transform = CGAffineTransformMakeScale(0, 0)

UIView.animateWithDuration(0.3, animations: { [unowned self] in
imageView.transform = CGAffineTransformMakeScale(1.05, 1.05)
}, completion: { _ in
UIView.animateWithDuration(0.2, animations: { _ in
imageView.transform = CGAffineTransformIdentity
})
})
}
}

// MARK: - ButtonPickerDelegate methods
Expand Down
8 changes: 8 additions & 0 deletions Source/BottomView/ButtonPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ButtonPicker: UIButton {
backgroundColor = .whiteColor()
layer.cornerRadius = Dimensions.buttonSize / 2
addTarget(self, action: "pickerButtonDidPress:", forControlEvents: .TouchUpInside)
addTarget(self, action: "pickerButtonDidHighlight:", forControlEvents: .TouchDown)
}

// MARK: - Layout
Expand All @@ -73,8 +74,15 @@ class ButtonPicker: UIButton {
// MARK: - Actions

func pickerButtonDidPress(button: UIButton) {
backgroundColor = .whiteColor()
numberLabel.textColor = .blackColor()
photoNumber = photoNumber + 1
numberLabel.sizeToFit()
delegate?.buttonDidPress()
}

func pickerButtonDidHighlight(button: UIButton) {
numberLabel.textColor = .whiteColor()
backgroundColor = UIColor(red:0.3, green:0.3, blue:0.3, alpha:1)
}
}
Loading

0 comments on commit 6c96fdc

Please sign in to comment.