Commit 6840f013 by Daniel Dahan

development: initial addition of CaptureController, updated default tint and…

development: initial addition of CaptureController, updated default tint and title color to match pulse, added Display class
parent 0b16cde6
...@@ -67,7 +67,7 @@ class ViewController: UIViewController { ...@@ -67,7 +67,7 @@ class ViewController: UIViewController {
} }
private func prepareFlatButton() { private func prepareFlatButton() {
let button = FlatButton(title: "Flat Button", titleColor: Color.blue.base) let button = FlatButton(title: "Flat Button")
view.layout(button) view.layout(button)
.width(ButtonLayout.Flat.width) .width(ButtonLayout.Flat.width)
...@@ -95,7 +95,7 @@ class ViewController: UIViewController { ...@@ -95,7 +95,7 @@ class ViewController: UIViewController {
} }
private func prepareIconButton() { private func prepareIconButton() {
let button = IconButton(image: Icon.cm.search, tintColor: Color.blue.base) let button = IconButton(image: Icon.cm.search)
view.layout(button) view.layout(button)
.width(ButtonLayout.Icon.width) .width(ButtonLayout.Icon.width)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
9626CA9C1DAB5588003E2611 /* AppCaptureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626CA9B1DAB5588003E2611 /* AppCaptureController.swift */; };
96784F741D901FB90061C06C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F731D901FB90061C06C /* AppDelegate.swift */; }; 96784F741D901FB90061C06C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F731D901FB90061C06C /* AppDelegate.swift */; };
96784F761D901FB90061C06C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F751D901FB90061C06C /* ViewController.swift */; }; 96784F761D901FB90061C06C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784F751D901FB90061C06C /* ViewController.swift */; };
96784F7B1D901FB90061C06C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96784F7A1D901FB90061C06C /* Assets.xcassets */; }; 96784F7B1D901FB90061C06C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96784F7A1D901FB90061C06C /* Assets.xcassets */; };
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
9626CA9B1DAB5588003E2611 /* AppCaptureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppCaptureController.swift; sourceTree = "<group>"; };
96784F701D901FB90061C06C /* CaptureController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CaptureController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 96784F701D901FB90061C06C /* CaptureController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CaptureController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96784F731D901FB90061C06C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 96784F731D901FB90061C06C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96784F751D901FB90061C06C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 96784F751D901FB90061C06C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -66,6 +68,7 @@ ...@@ -66,6 +68,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96784F731D901FB90061C06C /* AppDelegate.swift */, 96784F731D901FB90061C06C /* AppDelegate.swift */,
9626CA9B1DAB5588003E2611 /* AppCaptureController.swift */,
96784F751D901FB90061C06C /* ViewController.swift */, 96784F751D901FB90061C06C /* ViewController.swift */,
96784F7A1D901FB90061C06C /* Assets.xcassets */, 96784F7A1D901FB90061C06C /* Assets.xcassets */,
96784F7C1D901FB90061C06C /* LaunchScreen.storyboard */, 96784F7C1D901FB90061C06C /* LaunchScreen.storyboard */,
...@@ -147,6 +150,7 @@ ...@@ -147,6 +150,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96784F761D901FB90061C06C /* ViewController.swift in Sources */, 96784F761D901FB90061C06C /* ViewController.swift in Sources */,
9626CA9C1DAB5588003E2611 /* AppCaptureController.swift in Sources */,
96784F741D901FB90061C06C /* AppDelegate.swift in Sources */, 96784F741D901FB90061C06C /* AppDelegate.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
class AppCaptureController: CaptureController {
open override func prepare() {
super.prepare()
prepareCaptureButton()
prepareCameraButton()
prepareVideoButton()
prepareToolbar()
}
private func prepareToolbar() {
toolbar.titleLabel.isHidden = true
toolbar.titleLabel.textColor = Color.white
toolbar.detailLabel.isHidden = true
toolbar.detail = "Recording"
toolbar.detailLabel.textColor = Color.red.accent1
toolbar.leftViews = [switchCamerasButton]
toolbar.rightViews = [flashButton]
}
private func prepareCaptureButton() {
captureButton.width = 72
captureButton.height = 72
captureButton.backgroundColor = Color.red.darken1.withAlphaComponent(0.3)
captureButton.borderColor = Color.white
captureButton.borderWidthPreset = .border3
captureButton.depthPreset = .none
}
private func prepareCameraButton() {
cameraButton.width = 72
cameraButton.height = 72
cameraButton.pulseAnimation = .centerRadialBeyondBounds
}
private func prepareVideoButton() {
videoButton.width = 72
videoButton.height = 72
videoButton.pulseAnimation = .centerRadialBeyondBounds
}
}
...@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationDidFinishLaunching(_ application: UIApplication) { func applicationDidFinishLaunching(_ application: UIApplication) {
window = UIWindow(frame: Device.bounds) window = UIWindow(frame: Device.bounds)
window!.rootViewController = ViewController() window!.rootViewController = AppCaptureController(rootViewController: ViewController())
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
} }
} }
......
...@@ -32,97 +32,20 @@ import UIKit ...@@ -32,97 +32,20 @@ import UIKit
import AVFoundation import AVFoundation
import Material import Material
public class ViewController: UIViewController { class ViewController: UIViewController {
internal lazy var capture: Capture = Capture() open override func viewWillAppear(_ animated: Bool) {
internal var toolbar: Toolbar! super.viewWillAppear(animated)
internal var cameraButton: IconButton!
internal var videoButton: IconButton!
internal var switchCamerasButton: IconButton!
internal var flashButton: IconButton!
internal var captureButton: FabButton!
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.black
prepareCaptureButton()
prepareCameraButton()
prepareVideoButton()
prepareSwitchCamerasButton()
prepareFlashButton()
prepareCapture() prepareCapture()
prepareToolbar()
} }
private func prepareCapture() { open func prepareCapture() {
capture.enableTapToFocus = true guard let cc = captureController else {
capture.enableTapToExpose = true return
capture.delegate = self }
capture.captureSession.delegate = self
view.layout(capture).edges()
}
private func prepareToolbar() {
toolbar = Toolbar()
toolbar.backgroundColor = Color.clear
toolbar.depthPreset = .none
toolbar.titleLabel.isHidden = true
toolbar.titleLabel.textColor = Color.white
toolbar.detailLabel.isHidden = true
toolbar.detail = "Recording"
toolbar.detailLabel.textColor = Color.red.accent1
toolbar.leftViews = [switchCamerasButton]
toolbar.rightViews = [flashButton]
view.layout(toolbar).horizontally().top(20)
}
private func prepareCaptureButton() {
captureButton = FabButton()
captureButton.width = 72
captureButton.height = 72
captureButton.backgroundColor = Color.red.darken1.withAlphaComponent(0.3)
captureButton.borderColor = Color.white
captureButton.borderWidthPreset = .border3
captureButton.depthPreset = .none
capture.captureButton = captureButton
}
private func prepareCameraButton() {
cameraButton = IconButton(image: Icon.cm.photoCamera, tintColor: Color.white)
cameraButton.width = 72
cameraButton.height = 72
cameraButton.pulseAnimation = .centerRadialBeyondBounds
cameraButton.shapePreset = .circle
capture.cameraButton = cameraButton
}
private func prepareVideoButton() {
videoButton = IconButton(image: Icon.cm.videocam, tintColor: Color.white)
videoButton.width = 72
videoButton.height = 72
videoButton.pulseAnimation = .centerRadialBeyondBounds
videoButton.shapePreset = .circle
capture.videoButton = videoButton
}
private func prepareSwitchCamerasButton() {
switchCamerasButton = IconButton(image: UIImage(named: "ic_camera_front_white"))
capture.switchCamerasButton = switchCamerasButton
}
private func prepareFlashButton() {
flashButton = IconButton(image: UIImage(named: "ic_flash_auto_white"))
capture.flashButton = flashButton cc.capture.delegate = self
capture.captureSession.flashMode = .auto cc.capture.captureSession.delegate = self
view.layout(cc.capture).edges()
} }
} }
...@@ -142,33 +65,33 @@ extension ViewController: CaptureSessionDelegate { ...@@ -142,33 +65,33 @@ extension ViewController: CaptureSessionDelegate {
public func captureSessionDidStartRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, fileURL: NSURL, fromConnections connections: [Any]) { public func captureSessionDidStartRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, fileURL: NSURL, fromConnections connections: [Any]) {
print("Capture Started Recording \(fileURL)") print("Capture Started Recording \(fileURL)")
cameraButton.isHidden = true // cameraButton.isHidden = true
videoButton.isHidden = true // videoButton.isHidden = true
switchCamerasButton.isHidden = true // switchCamerasButton.isHidden = true
flashButton.isHidden = true // flashButton.isHidden = true
} }
public func captureSessionDidFinishRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, outputFileURL: NSURL, fromConnections connections: [Any], error: Error!) { public func captureSessionDidFinishRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, outputFileURL: NSURL, fromConnections connections: [Any], error: Error!) {
print("Capture Stopped Recording \(outputFileURL)") print("Capture Stopped Recording \(outputFileURL)")
cameraButton.isHidden = false // cameraButton.isHidden = false
videoButton.isHidden = false // videoButton.isHidden = false
switchCamerasButton.isHidden = false // switchCamerasButton.isHidden = false
flashButton.isHidden = false // flashButton.isHidden = false
} }
public func captureDidStartRecordTimer(capture: Capture) { public func captureDidStartRecordTimer(capture: Capture) {
toolbar.titleLabel.text = "00:00:00" // toolbar.titleLabel.text = "00:00:00"
toolbar.titleLabel.isHidden = false // toolbar.titleLabel.isHidden = false
toolbar.detailLabel.isHidden = false // toolbar.detailLabel.isHidden = false
} }
public func captureDidUpdateRecordTimer(capture: Capture, hours: Int, minutes: Int, seconds: Int) { public func captureDidUpdateRecordTimer(capture: Capture, hours: Int, minutes: Int, seconds: Int) {
toolbar.title = String(format: "%02i:%02i:%02i", arguments: [hours, minutes, seconds]) // toolbar.title = String(format: "%02i:%02i:%02i", arguments: [hours, minutes, seconds])
} }
public func captureDidStopRecordTimer(capture: Capture, hours: Int, minutes: Int, seconds: Int) { public func captureDidStopRecordTimer(capture: Capture, hours: Int, minutes: Int, seconds: Int) {
toolbar.titleLabel.isHidden = true // toolbar.titleLabel.isHidden = true
toolbar.detailLabel.isHidden = true // toolbar.detailLabel.isHidden = true
} }
public func captureSessionWillSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) { public func captureSessionWillSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) {
...@@ -176,56 +99,56 @@ extension ViewController: CaptureSessionDelegate { ...@@ -176,56 +99,56 @@ extension ViewController: CaptureSessionDelegate {
} }
public func captureSessionDidSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) { public func captureSessionDidSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) {
if .back == position { // if .back == position {
capture.captureSession.flashMode = .auto // capture.captureSession.flashMode = .auto
flashButton.image = UIImage(named: "ic_flash_auto_white") // flashButton.image = UIImage(named: "ic_flash_auto_white")
switchCamerasButton.image = UIImage(named: "ic_camera_front_white") // switchCamerasButton.image = UIImage(named: "ic_camera_front_white")
} else { // } else {
capture.captureSession.flashMode = .off // capture.captureSession.flashMode = .off
flashButton.image = UIImage(named: "ic_flash_off_white") // flashButton.image = UIImage(named: "ic_flash_off_white")
switchCamerasButton.image = UIImage(named: "ic_camera_rear_white") // switchCamerasButton.image = UIImage(named: "ic_camera_rear_white")
} // }
} }
} }
/// CaptureDelegate. /// CaptureDelegate.
extension ViewController: CaptureDelegate { extension ViewController: CaptureDelegate {
public func captureDidPressFlashButton(capture: Capture, button: UIButton) { public func captureDidPressFlashButton(capture: Capture, button: UIButton) {
guard .back == capture.captureSession.position else { // guard .back == capture.captureSession.position else {
return // return
} // }
//
guard let b = button as? Button else { // guard let b = button as? Button else {
return // return
} // }
//
switch capture.captureSession.flashMode { // switch capture.captureSession.flashMode {
case .off: // case .off:
b.image = UIImage(named: "ic_flash_on_white") // b.image = UIImage(named: "ic_flash_on_white")
capture.captureSession.flashMode = .on // capture.captureSession.flashMode = .on
case .on: // case .on:
b.image = UIImage(named: "ic_flash_auto_white") // b.image = UIImage(named: "ic_flash_auto_white")
capture.captureSession.flashMode = .auto // capture.captureSession.flashMode = .auto
case .auto: // case .auto:
b.image = UIImage(named: "ic_flash_off_white") // b.image = UIImage(named: "ic_flash_off_white")
capture.captureSession.flashMode = .off // capture.captureSession.flashMode = .off
} // }
} }
public func captureDidPressCameraButton(capture: Capture, button: UIButton) { public func captureDidPressCameraButton(capture: Capture, button: UIButton) {
captureButton.backgroundColor = Color.blue.darken1.withAlphaComponent(0.3) // captureButton.backgroundColor = Color.blue.darken1.withAlphaComponent(0.3)
} }
public func captureDidPressVideoButton(capture: Capture, button: UIButton) { public func captureDidPressVideoButton(capture: Capture, button: UIButton) {
captureButton.backgroundColor = Color.red.darken1.withAlphaComponent(0.3) // captureButton.backgroundColor = Color.red.darken1.withAlphaComponent(0.3)
} }
public func captureDidPressCaptureButton(capture: Capture, button: UIButton) { public func captureDidPressCaptureButton(capture: Capture, button: UIButton) {
if .photo == capture.captureMode { // if .photo == capture.captureMode {
// ... do something // // ... do something
} else if .video == capture.captureMode { // } else if .video == capture.captureMode {
// ... do something // // ... do something
} // }
} }
public func captureDidPressSwitchCamerasButton(capture: Capture, button: UIButton) { public func captureDidPressSwitchCamerasButton(capture: Capture, button: UIButton) {
......
...@@ -57,7 +57,7 @@ class AppToolbarController: ToolbarController { ...@@ -57,7 +57,7 @@ class AppToolbarController: ToolbarController {
} }
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base) menuButton = IconButton(image: Icon.cm.menu)
menuButton.addTarget(self, action: #selector(handleMenuButton), for: .touchUpInside) menuButton.addTarget(self, action: #selector(handleMenuButton), for: .touchUpInside)
} }
...@@ -66,7 +66,7 @@ class AppToolbarController: ToolbarController { ...@@ -66,7 +66,7 @@ class AppToolbarController: ToolbarController {
} }
private func prepareMoreButton() { private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blue.base) moreButton = IconButton(image: Icon.cm.moreVertical)
moreButton.addTarget(self, action: #selector(handleMoreButton), for: .touchUpInside) moreButton.addTarget(self, action: #selector(handleMoreButton), for: .touchUpInside)
} }
......
...@@ -49,11 +49,11 @@ class RootViewController: UIViewController { ...@@ -49,11 +49,11 @@ class RootViewController: UIViewController {
} }
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base) menuButton = IconButton(image: Icon.cm.menu)
} }
private func prepareMoreButton() { private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blue.base) moreButton = IconButton(image: Icon.cm.moreVertical)
} }
private func prepareSearchBar() { private func prepareSearchBar() {
......
...@@ -51,15 +51,15 @@ class RootViewController: UIViewController { ...@@ -51,15 +51,15 @@ class RootViewController: UIViewController {
} }
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base) menuButton = IconButton(image: Icon.cm.menu)
} }
private func prepareStarButton() { private func prepareStarButton() {
starButton = IconButton(image: Icon.cm.star, tintColor: Color.blue.base) starButton = IconButton(image: Icon.cm.star)
} }
private func prepareSearchButton() { private func prepareSearchButton() {
searchButton = IconButton(image: Icon.cm.search, tintColor: Color.blue.base) searchButton = IconButton(image: Icon.cm.search)
} }
private func prepareToolbar() { private func prepareToolbar() {
......
...@@ -56,15 +56,15 @@ class RootViewController: UIViewController { ...@@ -56,15 +56,15 @@ class RootViewController: UIViewController {
} }
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base) menuButton = IconButton(image: Icon.cm.menu)
} }
private func prepareStarButton() { private func prepareStarButton() {
starButton = IconButton(image: Icon.cm.star, tintColor: Color.blue.base) starButton = IconButton(image: Icon.cm.star)
} }
private func prepareSearchButton() { private func prepareSearchButton() {
searchButton = IconButton(image: Icon.cm.search, tintColor: Color.blue.base) searchButton = IconButton(image: Icon.cm.search)
} }
private func prepareNavigationItem() { private func prepareNavigationItem() {
......
...@@ -49,11 +49,11 @@ class RootViewController: UIViewController { ...@@ -49,11 +49,11 @@ class RootViewController: UIViewController {
} }
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base) menuButton = IconButton(image: Icon.cm.menu)
} }
private func prepareMoreButton() { private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blue.base) moreButton = IconButton(image: Icon.cm.moreVertical)
} }
private func prepareSearchBar() { private func prepareSearchBar() {
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
961EFC581D738FF600E84652 /* SnackbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961EFC571D738FF600E84652 /* SnackbarController.swift */; }; 961EFC581D738FF600E84652 /* SnackbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961EFC571D738FF600E84652 /* SnackbarController.swift */; };
961F18E81CD93E3E008927C5 /* ErrorTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961F18E71CD93E3E008927C5 /* ErrorTextField.swift */; }; 961F18E81CD93E3E008927C5 /* ErrorTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961F18E71CD93E3E008927C5 /* ErrorTextField.swift */; };
96230AB81D6A520C00AF47DC /* Divider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96230AB71D6A520C00AF47DC /* Divider.swift */; }; 96230AB81D6A520C00AF47DC /* Divider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96230AB71D6A520C00AF47DC /* Divider.swift */; };
9626CA971DAB53A8003E2611 /* Display.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* Display.swift */; };
9626CA9E1DAB55B8003E2611 /* CaptureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626CA9D1DAB55B8003E2611 /* CaptureController.swift */; };
9628645A1D53FE3E00690B69 /* Material+UIWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864591D53FE3E00690B69 /* Material+UIWindow.swift */; }; 9628645A1D53FE3E00690B69 /* Material+UIWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864591D53FE3E00690B69 /* Material+UIWindow.swift */; };
9628645F1D540AF300690B69 /* DynamicFontType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9628645E1D540AF300690B69 /* DynamicFontType.swift */; }; 9628645F1D540AF300690B69 /* DynamicFontType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9628645E1D540AF300690B69 /* DynamicFontType.swift */; };
9631A7C11D95E3AC00CFB109 /* PresenterCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */; }; 9631A7C11D95E3AC00CFB109 /* PresenterCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */; };
...@@ -209,6 +211,8 @@ ...@@ -209,6 +211,8 @@
961EFC571D738FF600E84652 /* SnackbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnackbarController.swift; sourceTree = "<group>"; }; 961EFC571D738FF600E84652 /* SnackbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnackbarController.swift; sourceTree = "<group>"; };
961F18E71CD93E3E008927C5 /* ErrorTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorTextField.swift; sourceTree = "<group>"; }; 961F18E71CD93E3E008927C5 /* ErrorTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorTextField.swift; sourceTree = "<group>"; };
96230AB71D6A520C00AF47DC /* Divider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Divider.swift; sourceTree = "<group>"; }; 96230AB71D6A520C00AF47DC /* Divider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Divider.swift; sourceTree = "<group>"; };
9626CA961DAB53A8003E2611 /* Display.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Display.swift; sourceTree = "<group>"; };
9626CA9D1DAB55B8003E2611 /* CaptureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureController.swift; sourceTree = "<group>"; };
962864591D53FE3E00690B69 /* Material+UIWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIWindow.swift"; sourceTree = "<group>"; }; 962864591D53FE3E00690B69 /* Material+UIWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIWindow.swift"; sourceTree = "<group>"; };
9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; }; 9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; };
9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresenterCard.swift; sourceTree = "<group>"; }; 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresenterCard.swift; sourceTree = "<group>"; };
...@@ -372,6 +376,15 @@ ...@@ -372,6 +376,15 @@
name = Bar; name = Bar;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9626CA951DAB5370003E2611 /* Root */ = {
isa = PBXGroup;
children = (
9626CA961DAB53A8003E2611 /* Display.swift */,
96BCB7991CB40DC500C806FE /* RootController.swift */,
);
name = Root;
sourceTree = "<group>";
};
962DDD071D6FBBB7001C307C /* Page */ = { 962DDD071D6FBBB7001C307C /* Page */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -537,6 +550,7 @@ ...@@ -537,6 +550,7 @@
962DDD071D6FBBB7001C307C /* Page */, 962DDD071D6FBBB7001C307C /* Page */,
96EA9A411D4E68E60052C74D /* PhotoLibrary */, 96EA9A411D4E68E60052C74D /* PhotoLibrary */,
9631A7C51D95E5C400CFB109 /* Pulse */, 9631A7C51D95E5C400CFB109 /* Pulse */,
9626CA951DAB5370003E2611 /* Root */,
963FBF031D6696EF008F8512 /* SearchBar */, 963FBF031D6696EF008F8512 /* SearchBar */,
963FBEFB1D6694E8008F8512 /* Snackbar */, 963FBEFB1D6694E8008F8512 /* Snackbar */,
967A48171D0F424B00B8CEB7 /* StatusBar */, 967A48171D0F424B00B8CEB7 /* StatusBar */,
...@@ -578,6 +592,7 @@ ...@@ -578,6 +592,7 @@
96BCB75A1CB40DC500C806FE /* CapturePreview.swift */, 96BCB75A1CB40DC500C806FE /* CapturePreview.swift */,
96BCB75B1CB40DC500C806FE /* CaptureSession.swift */, 96BCB75B1CB40DC500C806FE /* CaptureSession.swift */,
96BCB75C1CB40DC500C806FE /* Capture.swift */, 96BCB75C1CB40DC500C806FE /* Capture.swift */,
9626CA9D1DAB55B8003E2611 /* CaptureController.swift */,
); );
name = Capture; name = Capture;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -593,7 +608,6 @@ ...@@ -593,7 +608,6 @@
96BCB8011CB40F1700C806FE /* Navigation */ = { 96BCB8011CB40F1700C806FE /* Navigation */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96BCB7991CB40DC500C806FE /* RootController.swift */,
96BCB7901CB40DC500C806FE /* NavigationBar.swift */, 96BCB7901CB40DC500C806FE /* NavigationBar.swift */,
96BCB7911CB40DC500C806FE /* NavigationController.swift */, 96BCB7911CB40DC500C806FE /* NavigationController.swift */,
96BCB7921CB40DC500C806FE /* NavigationItem.swift */, 96BCB7921CB40DC500C806FE /* NavigationItem.swift */,
...@@ -1066,6 +1080,7 @@ ...@@ -1066,6 +1080,7 @@
96BCB7A21CB40DC500C806FE /* BottomTabBar.swift in Sources */, 96BCB7A21CB40DC500C806FE /* BottomTabBar.swift in Sources */,
96BCB7BD1CB40DC500C806FE /* CollectionViewDelegate.swift in Sources */, 96BCB7BD1CB40DC500C806FE /* CollectionViewDelegate.swift in Sources */,
9631A7C71D95E5D900CFB109 /* Pulse.swift in Sources */, 9631A7C71D95E5D900CFB109 /* Pulse.swift in Sources */,
9626CA971DAB53A8003E2611 /* Display.swift in Sources */,
961F18E81CD93E3E008927C5 /* ErrorTextField.swift in Sources */, 961F18E81CD93E3E008927C5 /* ErrorTextField.swift in Sources */,
96BCB7D01CB40DC500C806FE /* InterimSpace.swift in Sources */, 96BCB7D01CB40DC500C806FE /* InterimSpace.swift in Sources */,
96BCB7E81CB40DC500C806FE /* Toolbar.swift in Sources */, 96BCB7E81CB40DC500C806FE /* Toolbar.swift in Sources */,
...@@ -1099,6 +1114,7 @@ ...@@ -1099,6 +1114,7 @@
96BCB7D71CB40DC500C806FE /* Menu.swift in Sources */, 96BCB7D71CB40DC500C806FE /* Menu.swift in Sources */,
966ECF2A1CF4C20100BB0BDF /* CollectionReusableView.swift in Sources */, 966ECF2A1CF4C20100BB0BDF /* CollectionReusableView.swift in Sources */,
96BCB7E51CB40DC500C806FE /* TextField.swift in Sources */, 96BCB7E51CB40DC500C806FE /* TextField.swift in Sources */,
9626CA9E1DAB55B8003E2611 /* CaptureController.swift in Sources */,
96BCB7D21CB40DC500C806FE /* TableViewCell.swift in Sources */, 96BCB7D21CB40DC500C806FE /* TableViewCell.swift in Sources */,
96F1DC881D654FDF0025F925 /* Material+CALayer.swift in Sources */, 96F1DC881D654FDF0025F925 /* Material+CALayer.swift in Sources */,
96BCB7B61CB40DC500C806FE /* Animation.swift in Sources */, 96BCB7B61CB40DC500C806FE /* Animation.swift in Sources */,
......
...@@ -143,39 +143,21 @@ open class Button: UIButton { ...@@ -143,39 +143,21 @@ open class Button: UIButton {
} }
/** /**
A convenience initializer that acceps an image.
- Parameter image: A UIImage.
*/
public convenience init(image: UIImage?) {
self.init()
prepare(with: image, tintColor: nil)
}
/**
A convenience initializer that acceps an image and tintColor. A convenience initializer that acceps an image and tintColor.
- Parameter image: A UIImage. - Parameter image: A UIImage.
- Parameter tintColor: A UIColor. - Parameter tintColor: A UIColor.
*/ */
public convenience init(image: UIImage?, tintColor: UIColor?) { public convenience init(image: UIImage?, tintColor: UIColor = Color.blue.base) {
self.init() self.init()
prepare(with: image, tintColor: tintColor) prepare(with: image, tintColor: tintColor)
} }
/** /**
A convenience initializer that acceps a title.
- Parameter title: A String.
*/
public convenience init(title: String?) {
self.init()
prepare(with: title, titleColor: nil)
}
/**
A convenience initializer that acceps a title and titleColor. A convenience initializer that acceps a title and titleColor.
- Parameter title: A String. - Parameter title: A String.
- Parameter titleColor: A UIColor. - Parameter titleColor: A UIColor.
*/ */
public convenience init(title: String?, titleColor: UIColor?) { public convenience init(title: String?, titleColor: UIColor = Color.blue.base) {
self.init() self.init()
prepare(with: title, titleColor: titleColor) prepare(with: title, titleColor: titleColor)
} }
...@@ -274,9 +256,10 @@ open class Button: UIButton { ...@@ -274,9 +256,10 @@ open class Button: UIButton {
- Parameter image: A UIImage. - Parameter image: A UIImage.
- Parameter tintColor: A UIColor. - Parameter tintColor: A UIColor.
*/ */
private func prepare(with image: UIImage?, tintColor: UIColor?) { private func prepare(with image: UIImage?, tintColor: UIColor) {
self.image = image self.image = image
self.tintColor = tintColor self.tintColor = tintColor
pulseColor = tintColor
} }
/** /**
...@@ -284,8 +267,9 @@ open class Button: UIButton { ...@@ -284,8 +267,9 @@ open class Button: UIButton {
- Parameter title: A String. - Parameter title: A String.
- Parameter titleColor: A UIColor. - Parameter titleColor: A UIColor.
*/ */
private func prepare(with title: String?, titleColor: UIColor?) { private func prepare(with title: String?, titleColor: UIColor) {
self.title = title self.title = title
self.titleColor = titleColor self.titleColor = titleColor
pulseColor = titleColor
} }
} }
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
extension UIViewController {
/**
A convenience property that provides access to the CaptureController.
This is the recommended method of accessing the CaptureController
through child UIViewControllers.
*/
public var captureController: CaptureController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is CaptureController {
return viewController as? CaptureController
}
viewController = viewController?.parent
}
return nil
}
}
open class CaptureController: ToolbarController, CaptureDelegate, CaptureSessionDelegate {
open private(set) lazy var capture: Capture = Capture()
open private(set) var cameraButton: IconButton!
open private(set) var videoButton: IconButton!
open private(set) var switchCamerasButton: IconButton!
open private(set) var flashButton: IconButton!
open private(set) var captureButton: FabButton!
open override func prepare() {
super.prepare()
view.backgroundColor = Color.black
display = .full
prepareToolbar()
prepareCaptureButton()
prepareCameraButton()
prepareVideoButton()
prepareSwitchCamerasButton()
prepareFlashButton()
prepareCapture()
}
/// Prepares the Toolbar.
private func prepareToolbar() {
toolbar.backgroundColor = Color.clear
toolbar.depthPreset = .none
}
/// Prepares the captureButton.
private func prepareCaptureButton() {
captureButton = FabButton()
capture.captureButton = captureButton
}
/// Prepares the cameraButton.
private func prepareCameraButton() {
cameraButton = IconButton(image: Icon.cm.photoCamera, tintColor: Color.white)
capture.cameraButton = cameraButton
}
/// Preapres the videoButton.
private func prepareVideoButton() {
videoButton = IconButton(image: Icon.cm.videocam, tintColor: Color.white)
capture.videoButton = videoButton
}
/// Prepares the switchCameraButton.
private func prepareSwitchCamerasButton() {
switchCamerasButton = IconButton(image: UIImage(named: "ic_camera_front_white"), tintColor: Color.white)
capture.switchCamerasButton = switchCamerasButton
}
/// Prepares the flashButton.
private func prepareFlashButton() {
flashButton = IconButton(image: UIImage(named: "ic_flash_auto_white"), tintColor: Color.white)
capture.flashButton = flashButton
capture.captureSession.flashMode = .auto
}
/// Prepares capture.
private func prepareCapture() {
capture.enableTapToFocus = true
capture.enableTapToExpose = true
capture.delegate = self
capture.captureSession.delegate = self
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
@objc(Display)
public enum Display: Int {
case partial
case full
}
...@@ -44,6 +44,7 @@ open class FabButton: Button { ...@@ -44,6 +44,7 @@ open class FabButton: Button {
shapePreset = .circle shapePreset = .circle
pulseAnimation = .centerWithBacking pulseAnimation = .centerWithBacking
tintColor = Color.white tintColor = Color.white
backgroundColor = Color.red.base pulseColor = Color.white
backgroundColor = Color.red.base
} }
} }
...@@ -35,7 +35,7 @@ internal struct Pulse { ...@@ -35,7 +35,7 @@ internal struct Pulse {
internal lazy var layers = [CAShapeLayer]() internal lazy var layers = [CAShapeLayer]()
/// A UIColor. /// A UIColor.
internal var color = Color.white internal var color = Color.blueGrey.base
/// A reference to the PulseAnimation. /// A reference to the PulseAnimation.
internal var animation = PulseAnimation.pointWithBacking internal var animation = PulseAnimation.pointWithBacking
......
...@@ -69,6 +69,12 @@ public protocol ToolbarControllerDelegate { ...@@ -69,6 +69,12 @@ public protocol ToolbarControllerDelegate {
@objc(ToolbarController) @objc(ToolbarController)
open class ToolbarController: RootController { open class ToolbarController: RootController {
open var display = Display.partial {
didSet {
layoutSubviews()
}
}
/// Reference to the Toolbar. /// Reference to the Toolbar.
open private(set) lazy var toolbar: Toolbar = Toolbar() open private(set) lazy var toolbar: Toolbar = Toolbar()
...@@ -168,8 +174,13 @@ open class ToolbarController: RootController { ...@@ -168,8 +174,13 @@ open class ToolbarController: RootController {
toolbar.width = view.width + toolbar.grid.layoutEdgeInsets.left + toolbar.grid.layoutEdgeInsets.right toolbar.width = view.width + toolbar.grid.layoutEdgeInsets.left + toolbar.grid.layoutEdgeInsets.right
toolbar.height = p toolbar.height = p
rootViewController.view.y = p switch display {
rootViewController.view.height = view.height - p case .partial:
rootViewController.view.y = p
rootViewController.view.height = view.height - p
case .full:
rootViewController.view.frame = view.bounds
}
} }
/** /**
......
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