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