Commit d9ed5cb8 by Daniel Dahan

development: additional updates to Capture

parent efd0aea4
{
"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
...@@ -270,7 +270,7 @@ open class Capture: View { ...@@ -270,7 +270,7 @@ open class Capture: View {
open var isAnimating = false open var isAnimating = false
/// A reference to the capture mode. /// A reference to the capture mode.
open var mode = CaptureMode.video open var mode = CaptureMode.photo
/// Delegation handler. /// Delegation handler.
open weak var delegate: CaptureDelegate? open weak var delegate: CaptureDelegate?
...@@ -281,9 +281,6 @@ open class Capture: View { ...@@ -281,9 +281,6 @@ open class Capture: View {
/// A Timer reference for when recording is enabled. /// A Timer reference for when recording is enabled.
internal var timer: Timer? internal var timer: Timer?
/// A reference to the visualEffect .
internal var visualEffect: UIView!
/// A tap gesture reference for focus events. /// A tap gesture reference for focus events.
internal var tapToFocusGesture: UITapGestureRecognizer? internal var tapToFocusGesture: UITapGestureRecognizer?
...@@ -606,7 +603,6 @@ open class Capture: View { ...@@ -606,7 +603,6 @@ open class Capture: View {
super.prepare() super.prepare()
backgroundColor = .black backgroundColor = .black
prepareVisualEffect()
prepareSession() prepareSession()
prepareSessionQueue() prepareSessionQueue()
prepareActiveVideoInput() prepareActiveVideoInput()
...@@ -621,19 +617,10 @@ open class Capture: View { ...@@ -621,19 +617,10 @@ open class Capture: View {
} }
extension Capture { extension Capture {
/// Prepares the visualEffect.
internal func prepareVisualEffect() {
let blurEffect = UIVisualEffectView(effect: UIBlurEffect(style: .light))
visualEffect = UIView()
visualEffect.backgroundColor = nil
visualEffect.layout(blurEffect).edges()
}
/// Prepares the preview. /// Prepares the preview.
internal func preparePreview() { internal func preparePreview() {
preview = CapturePreview() preview = CapturePreview()
layout(preview).edges() layout(preview).edges()
bringSubview(toFront: visualEffect)
(preview.layer as! AVCaptureVideoPreviewLayer).session = session (preview.layer as! AVCaptureVideoPreviewLayer).session = session
startSession() startSession()
...@@ -777,25 +764,7 @@ extension Capture { ...@@ -777,25 +764,7 @@ extension Capture {
session.commitConfiguration() session.commitConfiguration()
isAnimating = true delegate?.captureDidSwitchCameras?(capture: self, device: devicePosition!)
Motion.delay(time: 0.15) { [weak self] in
guard let s = self else {
return
}
s.delegate?.captureDidSwitchCameras?(capture: s, device: s.devicePosition!)
UIView.animate(withDuration: 0.15, animations: { [weak self] in
self?.visualEffect.alpha = 0
}, completion: { [weak self] _ in
guard let s = self else {
return
}
s.visualEffect.removeFromSuperview()
s.isAnimating = false
})
}
} catch let e as NSError { } catch let e as NSError {
delegate?.captureFailedWithError?(capture: self, error: e) delegate?.captureFailedWithError?(capture: self, error: e)
} }
...@@ -1107,12 +1076,13 @@ extension Capture { ...@@ -1107,12 +1076,13 @@ extension Capture {
} }
/** /**
Handler for the flashButton. Handler for the videoButton.
- Parameter button: A UIButton that is associated with the event. - Parameter button: A UIButton that is associated with the event.
*/ */
@objc @objc
internal func handleFlashButton(button: UIButton) { internal func handleVideoButton(button: UIButton) {
delegate?.captureDidPressFlashButton?(capture: self, button: button) mode = .video
delegate?.captureDidPressVideoButton?(capture: self, button: button)
} }
/** /**
...@@ -1121,26 +1091,17 @@ extension Capture { ...@@ -1121,26 +1091,17 @@ extension Capture {
*/ */
@objc @objc
internal func handleSwitchCamerasButton(button: UIButton) { internal func handleSwitchCamerasButton(button: UIButton) {
visualEffect.alpha = 0 switchCameras()
layout(visualEffect).edges()
UIView.animate(withDuration: 0.15, animations: { [weak self] in
self?.visualEffect.alpha = 1
}) { [weak self] _ in
self?.switchCameras()
}
delegate?.captureDidPressSwitchCamerasButton?(capture: self, button: button) delegate?.captureDidPressSwitchCamerasButton?(capture: self, button: button)
} }
/** /**
Handler for the videoButton. Handler for the flashButton.
- Parameter button: A UIButton that is associated with the event. - Parameter button: A UIButton that is associated with the event.
*/ */
@objc @objc
internal func handleVideoButton(button: UIButton) { internal func handleFlashButton(button: UIButton) {
mode = .video delegate?.captureDidPressFlashButton?(capture: self, button: button)
delegate?.captureDidPressVideoButton?(capture: self, button: button)
} }
/** /**
......
...@@ -43,8 +43,6 @@ open class FabButton: Button { ...@@ -43,8 +43,6 @@ open class FabButton: Button {
depthPreset = .depth1 depthPreset = .depth1
shapePreset = .circle shapePreset = .circle
pulseAnimation = .centerWithBacking pulseAnimation = .centerWithBacking
tintColor = .white backgroundColor = .white
pulseColor = .white
backgroundColor = Color.red.base
} }
} }
...@@ -40,4 +40,5 @@ public enum HeightPreset: Int { ...@@ -40,4 +40,5 @@ public enum HeightPreset: Int {
case medium = 52 case medium = 52
case large = 60 case large = 60
case xlarge = 68 case xlarge = 68
case xxlarge = 104
} }
...@@ -86,7 +86,6 @@ public struct Icon { ...@@ -86,7 +86,6 @@ public struct Icon {
public static let place = Icon.icon("ic_place_white") public static let place = Icon.icon("ic_place_white")
public static let phone = Icon.icon("ic_phone_white") public static let phone = Icon.icon("ic_phone_white")
public static let photoCamera = Icon.icon("ic_photo_camera_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 photoLibrary = Icon.icon("ic_photo_library_white")
public static let search = Icon.icon("ic_search_white") public static let search = Icon.icon("ic_search_white")
public static let settings = Icon.icon("ic_settings_white") public static let settings = Icon.icon("ic_settings_white")
...@@ -95,7 +94,6 @@ public struct Icon { ...@@ -95,7 +94,6 @@ public struct Icon {
public static let starBorder = Icon.icon("ic_star_border_white") public static let starBorder = Icon.icon("ic_star_border_white")
public static let starHalf = Icon.icon("ic_star_half_white") public static let starHalf = Icon.icon("ic_star_half_white")
public static let videocam = Icon.icon("ic_videocam_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") public static let visibility = Icon.icon("ic_visibility_white")
/// CosmicMind icons. /// CosmicMind icons.
......
...@@ -215,6 +215,7 @@ open class NavigationBar: UINavigationBar { ...@@ -215,6 +215,7 @@ open class NavigationBar: UINavigationBar {
} }
item.contentView.grid.begin() item.contentView.grid.begin()
item.contentView.grid.offset.columns = 0
var l: CGFloat = 0 var l: CGFloat = 0
var r: CGFloat = 0 var r: CGFloat = 0
...@@ -232,7 +233,7 @@ open class NavigationBar: UINavigationBar { ...@@ -232,7 +233,7 @@ open class NavigationBar: UINavigationBar {
let p = width - l - r - contentEdgeInsets.left - contentEdgeInsets.right let p = width - l - r - contentEdgeInsets.left - contentEdgeInsets.right
let columns = Int(ceil(p / gridFactor)) let columns = Int(ceil(p / gridFactor))
if .center == contentViewAlignment { if .center == item.contentViewAlignment {
if lc < rc { if lc < rc {
item.contentView.grid.columns = columns - 2 * rc item.contentView.grid.columns = columns - 2 * rc
item.contentView.grid.offset.columns = rc - lc item.contentView.grid.offset.columns = rc - lc
......
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