Commit 0d503a05 by Daniel Dahan

aligned NavigationBarView and fixed fault in callback for timer update

parent d3b4ccc1
...@@ -36,8 +36,8 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg ...@@ -36,8 +36,8 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
} }
private func prepareCameraView() { private func prepareCameraView() {
cameraView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(cameraView) view.addSubview(cameraView)
cameraView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: cameraView) MaterialLayout.alignToParent(view, child: cameraView)
} }
......
...@@ -40,15 +40,18 @@ public class CameraView : CaptureView, CaptureViewDelegate, CaptureSessionDelega ...@@ -40,15 +40,18 @@ public class CameraView : CaptureView, CaptureViewDelegate, CaptureSessionDelega
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
prepareNavigationBarView()
prepareCaptureButton() prepareCaptureButton()
prepareCameraButton() prepareCameraButton()
prepareVideoButton() prepareVideoButton()
prepareCloseButton() prepareCloseButton()
prepareSwitchCameraButton() prepareSwitchCameraButton()
prepareFlashButton() prepareFlashButton()
prepareNavigationBarView()
} }
/**
:name: captureViewDidUpdateRecordTimer
*/
public func captureViewDidUpdateRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) { public func captureViewDidUpdateRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) {
MaterialAnimation.animationDisabled { MaterialAnimation.animationDisabled {
self.navigationBarView.titleLabel!.text = String(format: "%02i:%02i:%02i", arguments: [hours, minutes, seconds]) self.navigationBarView.titleLabel!.text = String(format: "%02i:%02i:%02i", arguments: [hours, minutes, seconds])
...@@ -56,6 +59,9 @@ public class CameraView : CaptureView, CaptureViewDelegate, CaptureSessionDelega ...@@ -56,6 +59,9 @@ public class CameraView : CaptureView, CaptureViewDelegate, CaptureSessionDelega
} }
/**
:name: captureViewDidStopRecordTimer
*/
public func captureViewDidStopRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) { public func captureViewDidStopRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) {
navigationBarView.titleLabel!.hidden = true navigationBarView.titleLabel!.hidden = true
navigationBarView.detailLabel!.hidden = true navigationBarView.detailLabel!.hidden = true
...@@ -236,6 +242,7 @@ public class CameraView : CaptureView, CaptureViewDelegate, CaptureSessionDelega ...@@ -236,6 +242,7 @@ public class CameraView : CaptureView, CaptureViewDelegate, CaptureSessionDelega
addSubview(navigationBarView) addSubview(navigationBarView)
navigationBarView.translatesAutoresizingMaskIntoConstraints = false navigationBarView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(self, child: navigationBarView)
MaterialLayout.alignToParentHorizontally(self, child: navigationBarView) MaterialLayout.alignToParentHorizontally(self, child: navigationBarView)
MaterialLayout.height(self, child: navigationBarView, height: 70) MaterialLayout.height(self, child: navigationBarView, height: 70)
} }
......
...@@ -29,12 +29,12 @@ public protocol CaptureViewDelegate : MaterialDelegate { ...@@ -29,12 +29,12 @@ public protocol CaptureViewDelegate : MaterialDelegate {
/** /**
:name: captureViewDidUpdateRecordTimer :name: captureViewDidUpdateRecordTimer
*/ */
optional func captureViewDidUpdateRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) optional func captureViewDidUpdateRecordTimer(captureView: CaptureView, hours: Int, minutes: Int, seconds: Int)
/** /**
:name: captureViewDidStopRecordTimer :name: captureViewDidStopRecordTimer
*/ */
optional func captureViewDidStopRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) optional func captureViewDidStopRecordTimer(captureView: CaptureView, hours: Int, minutes: Int, seconds: Int)
/** /**
:name: captureViewDidTapToFocusAtPoint :name: captureViewDidTapToFocusAtPoint
...@@ -195,7 +195,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate { ...@@ -195,7 +195,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
let hours: Int = Int(time / 3600) let hours: Int = Int(time / 3600)
let minutes: Int = Int((time / 60) % 60) let minutes: Int = Int((time / 60) % 60)
let seconds: Int = Int(time % 60) let seconds: Int = Int(time % 60)
(delegate as? CaptureViewDelegate)?.captureViewDidUpdateRecordTimer?(self, duration: duration, time: time, hours: hours, minutes: minutes, seconds: seconds) (delegate as? CaptureViewDelegate)?.captureViewDidUpdateRecordTimer?(self, hours: hours, minutes: minutes, seconds: seconds)
} }
/** /**
...@@ -209,7 +209,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate { ...@@ -209,7 +209,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
let seconds: Int = Int(time % 60) let seconds: Int = Int(time % 60)
timer?.invalidate() timer?.invalidate()
timer = nil timer = nil
(delegate as? CaptureViewDelegate)?.captureViewDidStopRecordTimer?(self, duration: duration, time: time, hours: hours, minutes: minutes, seconds: seconds) (delegate as? CaptureViewDelegate)?.captureViewDidStopRecordTimer?(self, hours: hours, minutes: minutes, seconds: seconds)
} }
/** /**
......
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