Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c10e3fe
updated for redbooth
alan-yilun-li Jul 30, 2018
1f01011
Updated to swift 4
twof Aug 7, 2018
f67c889
Merge pull request #1 from redbooth/swift4
alan-yilun-li Aug 7, 2018
bb40b29
made changes to add xcode10 and swift 4.2 support
rahuljiresal Sep 18, 2018
ddf71eb
renamed a variable
rahuljiresal Sep 18, 2018
570d335
Merge pull request #2 from redbooth/fix/xcode10
rahuljiresal Sep 18, 2018
f025dec
Merge branch 'om' into fix/iOS12
rahuljiresal Oct 17, 2018
783e2d8
Merge pull request #3 from redbooth/fix/iOS12
rahuljiresal Oct 17, 2018
7d959cd
removed Redbooth remanents
twof Jan 7, 2019
7bb5c31
Merge pull request #4 from redbooth/prepForRelease
twof Jan 7, 2019
9bf399e
cleanup for cocoapods release
twof Jan 7, 2019
df9aaee
Merge pull request #5 from redbooth/prepForRelease
twof Jan 7, 2019
5be6b5b
update podspec to redboothImagePicker
twof Jan 8, 2019
deff9af
podspec passing
twof Jan 8, 2019
597cbdc
- Updated to Swift 5
xavisavvy May 16, 2019
d5b41f5
Updated gitignore, and podspec version
xavisavvy May 16, 2019
d35ab90
Merge pull request #6 from redbooth/swift-5-upgrade
xavisavvy May 16, 2019
6c09618
Added XCode 12 fixes for unknown returns in switches.
xavisavvy Sep 28, 2020
f138ae6
Add Package.swift for SPM support
fernandogcat Jun 1, 2026
d433903
Add UIKit imports and pin to Swift 4.2 language mode for SPM
fernandogcat Jun 1, 2026
6a8636b
Add missing UIKit import in VideoCaptureDelegate
fernandogcat Jun 1, 2026
607ec08
Load nibs and asset images from Bundle.module for SPM
fernandogcat Jun 1, 2026
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
Copy Markdown
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
}
}
}

44 changes: 27 additions & 17 deletions ImagePicker/ActionCell.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,52 @@
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
Copy Markdown
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
Copy Markdown
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:
titleLabel.text = "Camera"
imageView.image = UIImage(named: "button-camera", in: Bundle(for: type(of: self)), compatibleWith: nil)
imageView.image = UIImage(named: "button-camera", in: .module, compatibleWith: nil)
case 1:
titleLabel.text = "Photos"
imageView.image = UIImage(named: "button-photo-library", in: Bundle(for: type(of: self)), compatibleWith: nil)
imageView.image = UIImage(named: "button-photo-library", in: .module, 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
}

}

}

3 changes: 2 additions & 1 deletion ImagePicker/Appearance.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Inloop. All rights reserved.
//

import Foundation
import UIKit

///
/// Provides access to styling attributes of Image Picker.
Expand All @@ -17,3 +17,4 @@ public class Appearance {
///
public var backgroundColor: UIColor = UIColor(red: 208/255, green: 213/255, blue: 218/255, alpha: 1)
}

Loading