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

First implementation #1

Merged
merged 44 commits into from
Aug 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1025ff6
Added the button class
RamonGilabert Aug 4, 2015
97ae3ee
Added those buttons
RamonGilabert Aug 4, 2015
65ea000
Added new configuration file
RamonGilabert Aug 4, 2015
b08ee5c
Added handlers
RamonGilabert Aug 4, 2015
1b369a0
Calculations
RamonGilabert Aug 4, 2015
df35ce1
Configured different views
RamonGilabert Aug 4, 2015
6421a29
Added different thingys
RamonGilabert Aug 4, 2015
c2398df
Deleted and removed files
RamonGilabert Aug 4, 2015
752f964
Added different constraints
RamonGilabert Aug 4, 2015
84f04ea
Added that tap gesture recognizer
RamonGilabert Aug 4, 2015
e019526
Added code for the ImageGalleryView
RamonGilabert Aug 4, 2015
5d40edb
Adding the dataSource
RamonGilabert Aug 4, 2015
e0132f1
You can see your images now
RamonGilabert Aug 4, 2015
de1cfe2
Added images from the library
RamonGilabert Aug 4, 2015
d5245dc
Added the animation
RamonGilabert Aug 5, 2015
9d00590
Finished the animation
RamonGilabert Aug 5, 2015
391c330
Finished the animation here
RamonGilabert Aug 5, 2015
c5ea9a5
Make it like a swipe
RamonGilabert Aug 5, 2015
0509f37
Changed folders
RamonGilabert Aug 5, 2015
35dc3f5
Added all the code to fetch all the photos
RamonGilabert Aug 5, 2015
b9bd72f
Added two more files
RamonGilabert Aug 5, 2015
9df26fd
Added those constraints
RamonGilabert Aug 5, 2015
3eb609a
Updated layout
RamonGilabert Aug 5, 2015
77dd042
Added images
RamonGilabert Aug 5, 2015
b957edd
Added new images
RamonGilabert Aug 5, 2015
aa7c699
We have the camera almost ready!
RamonGilabert Aug 5, 2015
92fa2d4
Handle the pan gesture in another place
RamonGilabert Aug 5, 2015
6a43e01
We have flash button already
RamonGilabert Aug 5, 2015
3c244cf
Added more icons, now, logic
RamonGilabert Aug 5, 2015
1604519
It works!
RamonGilabert Aug 5, 2015
cc7647f
Improved the animation
RamonGilabert Aug 5, 2015
1d6f0db
The wrapper is working gnow
RamonGilabert Aug 5, 2015
f73bfeb
Better gestures
RamonGilabert Aug 5, 2015
69a4888
Now the buttons are working
RamonGilabert Aug 5, 2015
ae5f6c4
Added configuration to send to lightbox
RamonGilabert Aug 5, 2015
ca9d2b5
Changed that thingy again
RamonGilabert Aug 5, 2015
7176424
Added the icon image
RamonGilabert Aug 5, 2015
dbe5b28
Added a switch
RamonGilabert Aug 5, 2015
56250ad
Refactoring
RamonGilabert Aug 5, 2015
049a821
Replace UIColor with .color()
richardtop Aug 5, 2015
0955662
Changed colors
RamonGilabert Aug 5, 2015
c17f10d
Merge pull request #3 from hyperoslo/refactor/remove-UIColor
RamonGilabert Aug 5, 2015
a098570
Stuff
RamonGilabert Aug 5, 2015
f3ceb13
Merge remote-tracking branch 'origin/feature/first-implementation' in…
RamonGilabert Aug 5, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
TargetAttributes = {
29D699D81B70ABFC0021FA73 = {
CreatedOnToolsVersion = 6.4;
DevelopmentTeam = SGM42FXP52;
};
29D699ED1B70ABFC0021FA73 = {
CreatedOnToolsVersion = 6.4;
Expand Down Expand Up @@ -406,7 +407,9 @@
baseConfigurationReference = 51FD9E3875E02B0489658272 /* Pods.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -417,7 +420,9 @@
baseConfigurationReference = 0F514C1F72DEB3C2416C8948 /* Pods.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
5 changes: 4 additions & 1 deletion Demo/ImagePickerDemo/ImagePickerDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return imagePickerController
}()

var window: UIWindow?
lazy var window: UIWindow? = {
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
return window
}()

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window?.rootViewController = imagePickerController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand All @@ -20,6 +25,17 @@
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "57x57",
"scale" : "1x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "iphone-oldAppicon-@1x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
Expand Down Expand Up @@ -59,6 +75,61 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"size" : "24x24",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "38mm"
},
{
"size" : "27.5x27.5",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "42mm"
},
{
"size" : "29x29",
"idiom" : "watch",
"filename" : "iphone-settings-@1x.png",
"role" : "companionSettings",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "watch",
"role" : "companionSettings",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "watch",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "38mm"
},
{
"size" : "44x44",
"idiom" : "watch",
"scale" : "2x",
"role" : "longLook",
"subtype" : "42mm"
},
{
"size" : "86x86",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "38mm"
},
{
"size" : "98x98",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "42mm"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Demo/ImagePickerDemo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ EXTERNAL SOURCES:
:path: ../../

SPEC CHECKSUMS:
ImagePicker: 1ed5022e28822e85d18c5de7e68bb56851c8bd7a
ImagePicker: 32becfa25b8e9179e60c45411b577340d35e3e32

COCOAPODS: 0.37.2
3 changes: 2 additions & 1 deletion ImagePicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Pod::Spec.new do |s|
s.platform = :ios, '8.0'
s.requires_arc = true
s.source_files = 'Source/**/*'
# s.frameworks = 'UIKit', 'MapKit'
s.resource_bundles = { 'ImagePicker' => ['Images/*.{png}'] }
s.frameworks = 'AVFoundation'
# s.dependency 'AFNetworking', '~> 2.3'
end
Binary file added Images/cameraIcon.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/cameraIcon@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/cameraIcon@3x.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/flashIcon.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/flashIcon@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/flashIcon@3x.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/flashIconOff.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/flashIconOff@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/flashIconOff@3x.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/flashIconOn.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/flashIconOn@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/flashIconOn@3x.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/selectedImageGallery.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/selectedImageGallery@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/selectedImageGallery@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
188 changes: 188 additions & 0 deletions Source/BottomView/BottomContainerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import UIKit

protocol BottomContainerViewDelegate {

func pickerButtonDidPress()
func doneButtonDidPress()
func cancelButtonDidPress()
func imageWrapperDidPress()
}

class BottomContainerView: UIView {

lazy var pickerButton: ButtonPicker = {
let pickerButton = ButtonPicker()
pickerButton.setTitleColor(UIColor.whiteColor(), forState: .Normal)
pickerButton.setTranslatesAutoresizingMaskIntoConstraints(false)

return pickerButton
}()

lazy var borderPickerButton: UIView = {
let view = UIView()
view.backgroundColor = .clearColor()
view.layer.borderColor = UIColor.whiteColor().CGColor
view.layer.borderWidth = ButtonPicker.Dimensions.borderWidth
view.layer.cornerRadius = ButtonPicker.Dimensions.buttonBorderSize / 2
view.setTranslatesAutoresizingMaskIntoConstraints(false)

return view
}()

lazy var doneButton: UIButton = { [unowned self] in
let button = UIButton()
button.setTitle(self.configuration.cancelButtonTitle, forState: .Normal)
button.titleLabel!.font = self.configuration.doneButton
button.addTarget(self, action: "doneButtonDidPress:", forControlEvents: .TouchUpInside)
button.setTranslatesAutoresizingMaskIntoConstraints(false)

return button
}()

lazy var imageWrapper: ImageWrapper = {
let view = ImageWrapper()
view.setTranslatesAutoresizingMaskIntoConstraints(false)

return view
}()

lazy var configuration: PickerConfiguration = {
let configuration = PickerConfiguration()
return configuration
}()

var delegate: BottomContainerViewDelegate?

// MARK: Initializers

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

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

setupConstraints()
}

required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Autolayout

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

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

addConstraint(NSLayoutConstraint(item: pickerButton, attribute: .Width,
relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,
multiplier: 1, constant: ButtonPicker.Dimensions.buttonSize))

addConstraint(NSLayoutConstraint(item: pickerButton, attribute: .Height,
relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,
multiplier: 1, constant: ButtonPicker.Dimensions.buttonSize))

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

addConstraint(NSLayoutConstraint(item: borderPickerButton, attribute: .Width,
relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,
multiplier: 1, constant: ButtonPicker.Dimensions.buttonBorderSize))

addConstraint(NSLayoutConstraint(item: borderPickerButton, attribute: .Height,
relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,
multiplier: 1, constant: ButtonPicker.Dimensions.buttonBorderSize))

addConstraint(NSLayoutConstraint(item: doneButton, attribute: .CenterY,
relatedBy: .Equal, toItem: self, attribute: .CenterY,
multiplier: 1, constant: 0))

addConstraint(NSLayoutConstraint(item: doneButton, attribute: .CenterX,
relatedBy: .Equal, toItem: self, attribute: .Right,
multiplier: 1, constant: -(UIScreen.mainScreen().bounds.width - (ButtonPicker.Dimensions.buttonBorderSize + UIScreen.mainScreen().bounds.width)/2)/2))

addConstraint(NSLayoutConstraint(item: imageWrapper, attribute: .Width,
relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,
multiplier: 1, constant: ImageWrapper.Dimensions.imageSize))

addConstraint(NSLayoutConstraint(item: imageWrapper, attribute: .Height,
relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,
multiplier: 1, constant: ImageWrapper.Dimensions.imageSize))

addConstraint(NSLayoutConstraint(item: imageWrapper, attribute: .CenterY,
relatedBy: .Equal, toItem: self, attribute: .CenterY,
multiplier: 1, constant: 0))

addConstraint(NSLayoutConstraint(item: imageWrapper, attribute: .CenterX,
relatedBy: .Equal, toItem: self, attribute: .Left,
multiplier: 1, constant: UIScreen.mainScreen().bounds.width/4 - ButtonPicker.Dimensions.buttonBorderSize/4))
}

// MARK: - Action methods

func doneButtonDidPress(button: UIButton) {
if button.currentTitle == configuration.cancelButtonTitle {
delegate?.cancelButtonDidPress()
} else {
delegate?.doneButtonDidPress()
}
}

// MARK: - Wrapper methods

func updateWrapperImages(array: NSMutableArray) {
switch array.count {
case 1:
imageWrapper.firstImageView.image = array.firstObject as? UIImage
imageWrapper.secondImageView.image = nil
imageWrapper.secondImageView.alpha = 0
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.secondImageView.alpha = 1
imageWrapper.thirdImageView.alpha = 0
case 3:
imageWrapper.firstImageView.image = array[0] as? UIImage
imageWrapper.secondImageView.image = array[1] as? UIImage
imageWrapper.thirdImageView.image = array[2] as? UIImage
imageWrapper.thirdImageView.alpha = 1
imageWrapper.fourthImageView.alpha = 0
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
}

pickerButton.photoNumber = array.count
}
}

// MARK: - ButtonPickerDelegate methods

extension BottomContainerView: ButtonPickerDelegate {

func buttonDidPress() {
delegate?.pickerButtonDidPress()
}
}

// MARK: - ImageWrapperDelegate methods

extension BottomContainerView: ImageWrapperDelegate {

func imageWrapperDidPress() {
delegate?.imageWrapperDidPress()
}
}
Loading