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

General Cleanup For Cocoapods #57

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .DS_Store
Binary file not shown.
71 changes: 71 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# OS
.DS_Store

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata

## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

# fastlane specific
fastlane/report.xml

# deliver temporary files
fastlane/Preview.html

# snapshot generated screenshots
fastlane/screenshots

# scan temporary files
fastlane/test_output

# in case someone is using AppCode
.idea
2 changes: 1 addition & 1 deletion ExampleApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
12 changes: 6 additions & 6 deletions ExampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Camera is used by Image picker when taking new photos or recording videos</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone is used by Image picker when recording videos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App uses access to Photos when picking images</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -34,11 +40,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSPhotoLibraryUsageDescription</key>
<string>App uses access to Photos when picking images</string>
<key>NSCameraUsageDescription</key>
<string>Camera is used by Image picker when taking new photos or recording videos</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone is used by Image picker when recording videos</string>
</dict>
</plist>
118 changes: 70 additions & 48 deletions ImagePicker.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:ImagePicker.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ExampleApp.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>ImagePicker.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ExampleApp.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>ExampleApp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>ImagePicker.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ExampleApp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>ImagePicker.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ExampleApp.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>ImagePicker.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file added ImagePicker/.DS_Store
Binary file not shown.
30 changes: 15 additions & 15 deletions ImagePicker/AVPreviewView.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,51 @@ enum VideoDisplayMode {
/// output from a capture session.
///
final class AVPreviewView: UIView {

deinit {
log("deinit: \(String(describing: self))")
}

var previewLayer: AVCaptureVideoPreviewLayer {
return layer as! AVCaptureVideoPreviewLayer
}

var session: AVCaptureSession? {
get { return previewLayer.session }
set {
if previewLayer.session === newValue {
return
}
previewLayer.session = newValue

}
}

var displayMode: VideoDisplayMode = .aspectFill {
didSet { applyVideoDisplayMode() }
}

override class var layerClass: AnyClass {
return AVCaptureVideoPreviewLayer.self
}

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

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
applyVideoDisplayMode()
}

// MARK: Private Methods

private func applyVideoDisplayMode() {
switch displayMode {
case .aspectFill: previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
case .aspectFit: previewLayer.videoGravity = AVLayerVideoGravity.resizeAspect
case .resize: previewLayer.videoGravity = AVLayerVideoGravity.resize

private func applyVideoDisplayMode() { switch displayMode {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix alignment

case .aspectFill: previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
case .aspectFit: previewLayer.videoGravity = AVLayerVideoGravity.resizeAspect
case .resize: previewLayer.videoGravity = AVLayerVideoGravity.resize
}
}
}

40 changes: 25 additions & 15 deletions ImagePicker/ActionCell.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,38 @@
import Foundation
import UIKit

final class ActionCell : UICollectionViewCell {

@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var imageView: UIImageView!

public final class ActionCell : UICollectionViewCell {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use extra opening lines

@IBOutlet public weak var backgroundImageView: UIImageView!
@IBOutlet public weak var titleLabel: UILabel!
@IBOutlet public weak var imageView: UIImageView!

@IBOutlet var leadingOffset: NSLayoutConstraint!
@IBOutlet var trailingOffset: NSLayoutConstraint!
@IBOutlet var topOffset: NSLayoutConstraint!
@IBOutlet var bottomOffset: NSLayoutConstraint!
override func awakeFromNib() {

override public func awakeFromNib() {
super.awakeFromNib()
imageView.backgroundColor = UIColor.clear
}

}

extension ActionCell {


public func setupOffsets() {
topOffset.constant = 5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY, keep 5 to a constant

bottomOffset.constant = 5
leadingOffset.constant = 5
trailingOffset.constant = 5
}

func update(withIndex index: Int, layoutConfiguration: LayoutConfiguration) {

let layoutModel = LayoutModel(configuration: layoutConfiguration, assets: 0)
let actionCount = layoutModel.numberOfItems(in: layoutConfiguration.sectionIndexForActions)

titleLabel.textColor = UIColor.black
switch index {
case 0:
Expand All @@ -43,10 +51,10 @@ extension ActionCell {
imageView.image = UIImage(named: "button-photo-library", in: Bundle(for: type(of: self)), compatibleWith: nil)
default: break
}

let isFirst = index == 0
let isLast = index == actionCount - 1

switch layoutConfiguration.scrollDirection {
case .horizontal:
topOffset.constant = isFirst ? 10 : 5
Expand All @@ -58,8 +66,10 @@ extension ActionCell {
bottomOffset.constant = 5
leadingOffset.constant = isFirst ? 10 : 5
trailingOffset.constant = isLast ? 10 : 5
@unknown default: break
}

}

}

1 change: 1 addition & 0 deletions ImagePicker/Appearance.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ public class Appearance {
///
public var backgroundColor: UIColor = UIColor(red: 208/255, green: 213/255, blue: 218/255, alpha: 1)
}

Loading