Commit baa54bba by Daniel Dahan

development: progression commit for Capture updates

parent d7bea33c
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_camera_front_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_camera_front_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_camera_front_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_camera_rear_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_camera_rear_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_camera_rear_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_flash_auto_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_auto_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_auto_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_flash_off_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_off_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_off_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_flash_on_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_on_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_flash_on_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_photo_camera_white_36pt@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_videocam_white_36pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_videocam_white_36pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_videocam_white_36pt@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -52,6 +52,83 @@ open class CaptureController: ToolbarController, CaptureDelegate, CaptureSession
/// A reference to the Capture instance.
open private(set) lazy var capture: Capture = Capture()
/// A tap gesture reference for focus events.
private var tapToFocusGesture: UITapGestureRecognizer?
/// A tap gesture reference for exposure events.
private var tapToExposeGesture: UITapGestureRecognizer?
/// A tap gesture reference for reset events.
private var tapToResetGesture: UITapGestureRecognizer?
/// A boolean indicating whether to enable tap to focus.
@IBInspectable
open var isTapToFocusEnabled = false {
didSet {
guard isTapToFocusEnabled else {
removeTapGesture(gesture: &tapToFocusGesture)
focusView?.removeFromSuperview()
focusView = nil
return
}
isTapToResetEnabled = true
prepareFocusLayer()
prepareTapGesture(gesture: &tapToFocusGesture, numberOfTapsRequired: 1, numberOfTouchesRequired: 1, selector: #selector(handleTapToFocusGesture))
if let v = tapToExposeGesture {
tapToFocusGesture!.require(toFail: v)
}
}
}
/// A boolean indicating whether to enable tap to expose.
@IBInspectable
open var isTapToExposeEnabled = false {
didSet {
guard isTapToExposeEnabled else {
removeTapGesture(gesture: &tapToExposeGesture)
exposureView?.removeFromSuperview()
exposureView = nil
return
}
isTapToResetEnabled = true
prepareExposureLayer()
prepareTapGesture(gesture: &tapToExposeGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 1, selector: #selector(handleTapToExposeGesture))
if let v = tapToFocusGesture {
v.require(toFail: tapToExposeGesture!)
}
}
}
/// A boolean indicating whether to enable tap to reset.
@IBInspectable
open var isTapToResetEnabled = false {
didSet {
guard isTapToResetEnabled else {
removeTapGesture(gesture: &tapToResetGesture)
resetView?.removeFromSuperview()
resetView = nil
return
}
prepareResetLayer()
prepareTapGesture(gesture: &tapToResetGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 2, selector: #selector(handleTapToResetGesture))
if let v = tapToFocusGesture {
v.require(toFail: tapToResetGesture!)
}
if let v = tapToExposeGesture {
v.require(toFail: tapToResetGesture!)
}
}
}
/// A reference to capture's cameraButton.
open var cameraButton: IconButton {
return capture.cameraButton
......@@ -77,6 +154,29 @@ open class CaptureController: ToolbarController, CaptureDelegate, CaptureSession
return capture.captureButton
}
open override func layoutSubviews() {
super.layoutSubviews()
if let v = cameraButton {
v.y = bounds.height - contentEdgeInsets.bottom - v.bounds.height
v.x = contentEdgeInsets.left
}
if let v = captureButton {
v.y = bounds.height - contentEdgeInsets.bottom - v.bounds.height
v.x = (bounds.width - v.width) / 2
}
if let v = videoButton {
v.y = bounds.height - contentEdgeInsets.bottom - v.bounds.height
v.x = bounds.width - v.width - contentEdgeInsets.right
}
if let v = (preview.layer as! AVCaptureVideoPreviewLayer).connection {
v.videoOrientation = session.videoOrientation
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
......@@ -109,5 +209,59 @@ open class CaptureController: ToolbarController, CaptureDelegate, CaptureSession
private func prepareCapture() {
capture.delegate = self
capture.session.delegate = self
capture.isTapToFocusEnabled = true
capture.isTapToExposeEnabled = true
}
}
extension CaptureController {
/// Starts the timer for recording.
internal func startTimer() {
timer?.invalidate()
timer = Timer(timeInterval: 0.5, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true)
RunLoop.main.add(timer!, forMode: .commonModes)
delegate?.captureDidStartRecordTimer?(capture: self)
}
/// Updates the timer when recording.
internal func updateTimer() {
let duration = session.recordedDuration
let time = CMTimeGetSeconds(duration)
let hours = Int(time / 3600)
let minutes = Int((time / 60).truncatingRemainder(dividingBy: 60))
let seconds = Int(time.truncatingRemainder(dividingBy: 60))
delegate?.captureDidUpdateRecordTimer?(capture: self, hours: hours, minutes: minutes, seconds: seconds)
}
/// Stops the timer when recording.
internal func stopTimer() {
let duration = session.recordedDuration
let time = CMTimeGetSeconds(duration)
let hours = Int(time / 3600)
let minutes = Int((time / 60).truncatingRemainder(dividingBy: 60))
let seconds = Int(time.truncatingRemainder(dividingBy: 60))
timer?.invalidate()
timer = nil
delegate?.captureDidStopRecordTimer?(capture: self, hours: hours, minutes: minutes, seconds: seconds)
}
func captureDidPressCaptureButton(capture: Capture, button: UIButton) {
switch captureMode {
case .photo:
session.captureStillImage()
case .video:
if session.isRecording {
session.stopRecording()
stopTimer()
} else {
session.startRecording()
startTimer()
}
}
}
}
......@@ -40,6 +40,7 @@ open class CapturePreview: View {
Converts a point in layer coordinates to a point of interest
in the coordinate space of the capture device providing input
to the layer.
- Parameter point: A CGPoint.
- Returns: A CGPoint that is converted.
*/
open func captureDevicePointOfInterestForPoint(point: CGPoint) -> CGPoint {
......@@ -50,6 +51,7 @@ open class CapturePreview: View {
Converts a point of interest in the coordinate space of the
capture device providing input to the layer to a point in
layer coordinates.
- Parameter point: A CGPoint.
- Returns: A CGPoint that is converted.
*/
open func pointForCaptureDevicePointOfInterest(point: CGPoint) -> CGPoint {
......
......@@ -63,14 +63,19 @@ public struct Icon {
public static let arrowDownward = Icon.icon("ic_arrow_downward_white")
public static let audio = Icon.icon("ic_audiotrack_white")
public static let bell = Icon.icon("cm_bell_white")
public static let check = Icon.icon("ic_check_white")
public static let cameraFront = Icon.icon("ic_camera_front_white")
public static let cameraRear = Icon.icon("ic_camera_rear_white")
public static let check = Icon.icon("ic_check_white")
public static let clear = Icon.icon("ic_close_white")
public static let close = Icon.icon("ic_close_white")
public static let edit = Icon.icon("ic_edit_white")
public static let email = Icon.icon("ic_email_white")
public static let favorite = Icon.icon("ic_favorite_white")
public static let favoriteBorder = Icon.icon("ic_favorite_border_white")
public static let history = Icon.icon("ic_history_white")
public static let flashAuto = Icon.icon("ic_flash_auto_white")
public static let flashOff = Icon.icon("ic_flash_off_white")
public static let flashOn = Icon.icon("ic_flash_on_white")
public static let history = Icon.icon("ic_history_white")
public static let home = Icon.icon("ic_home_white")
public static let image = Icon.icon("ic_image_white")
public static let menu = Icon.icon("ic_menu_white")
......@@ -81,6 +86,7 @@ public struct Icon {
public static let place = Icon.icon("ic_place_white")
public static let phone = Icon.icon("ic_phone_white")
public static let photoCamera = Icon.icon("ic_photo_camera_white")
public static let photoCameraLarge = Icon.icon("ic_photo_camera_white_36pt")
public static let photoLibrary = Icon.icon("ic_photo_library_white")
public static let search = Icon.icon("ic_search_white")
public static let settings = Icon.icon("ic_settings_white")
......@@ -89,6 +95,7 @@ public struct Icon {
public static let starBorder = Icon.icon("ic_star_border_white")
public static let starHalf = Icon.icon("ic_star_half_white")
public static let videocam = Icon.icon("ic_videocam_white")
public static let videocamLarge = Icon.icon("ic_videocam_white_36pt")
public static let visibility = Icon.icon("ic_visibility_white")
/// CosmicMind icons.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment