Commit 3386efad by Daniel Dahan

development: Color is now a subclass of UIColor

parent 6840f013
...@@ -47,7 +47,7 @@ class ViewController: UIViewController { ...@@ -47,7 +47,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = .white
prepareMenuButton() prepareMenuButton()
prepareFavoriteButton() prepareFavoriteButton()
...@@ -56,23 +56,23 @@ class ViewController: UIViewController { ...@@ -56,23 +56,23 @@ class ViewController: UIViewController {
} }
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.white) menuButton = IconButton(image: Icon.cm.menu, tintColor: .white)
} }
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.white) favoriteButton = IconButton(image: Icon.favorite, tintColor: .white)
} }
private func prepareShareButton() { private func prepareShareButton() {
shareButton = IconButton(image: Icon.cm.share, tintColor: Color.white) shareButton = IconButton(image: Icon.cm.share, tintColor: .white)
} }
private func prepareBar() { private func prepareBar() {
bar = Bar(leftViews: [menuButton], rightViews: [favoriteButton, shareButton]) bar = Bar(leftViews: [menuButton], rightViews: [favoriteButton, shareButton])
bar.backgroundColor = Color.blue.base bar.backgroundColor = .blue.base
bar.contentView.cornerRadiusPreset = .cornerRadius1 bar.contentView.cornerRadiusPreset = .cornerRadius1
bar.contentView.backgroundColor = Color.blue.lighten3 bar.contentView.backgroundColor = .blue.lighten3
view.layout(bar).horizontally().center() view.layout(bar).horizontally().center()
} }
......
...@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController { ...@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController {
private func prepareTabBar() { private func prepareTabBar() {
tabBar.depthPreset = .none tabBar.depthPreset = .none
tabBar.dividerColor = Color.grey.lighten3 tabBar.dividerColor = .grey.lighten3
} }
} }
...@@ -39,12 +39,12 @@ class AudioViewController: UIViewController { ...@@ -39,12 +39,12 @@ class AudioViewController: UIViewController {
/// Prepare tabBarItem. /// Prepare tabBarItem.
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.image = Icon.cm.audioLibrary?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.audioLibrary?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.audioLibrary?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.audioLibrary?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = .blue.base
} }
} }
...@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController { ...@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController {
/// Prepare tabBarItem. /// Prepare tabBarItem.
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.image = Icon.cm.photoCamera?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.photoCamera?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.photoCamera?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.photoCamera?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.red.base view.backgroundColor = .red.base
} }
} }
...@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController { ...@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController {
/// Prepare tabBarItem. /// Prepare tabBarItem.
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.image = Icon.cm.bell?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.bell?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.bell?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.bell?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.yellow.base view.backgroundColor = .yellow.base
} }
} }
...@@ -39,12 +39,12 @@ class SearchViewController: UIViewController { ...@@ -39,12 +39,12 @@ class SearchViewController: UIViewController {
/// Prepare tabBarItem. /// Prepare tabBarItem.
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.image = Icon.cm.search?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.search?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.search?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.search?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blueGrey.base view.backgroundColor = .blueGrey.base
} }
} }
...@@ -39,12 +39,12 @@ class VideoViewController: UIViewController { ...@@ -39,12 +39,12 @@ class VideoViewController: UIViewController {
/// Prepare tabBarItem. /// Prepare tabBarItem.
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.image = Icon.cm.videocam?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.videocam?.tint(with: blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.videocam?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.videocam?.tint(with: blue.base)?.withRenderingMode(.alwaysOriginal)
} }
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.green.base view.backgroundColor = green.base
} }
} }
...@@ -58,7 +58,7 @@ struct ButtonLayout { ...@@ -58,7 +58,7 @@ struct ButtonLayout {
class ViewController: UIViewController { class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareFlatButton() prepareFlatButton()
prepareRaisedButton() prepareRaisedButton()
...@@ -76,8 +76,8 @@ class ViewController: UIViewController { ...@@ -76,8 +76,8 @@ class ViewController: UIViewController {
} }
private func prepareRaisedButton() { private func prepareRaisedButton() {
let button = RaisedButton(title: "Raised Button", titleColor: Color.white) let button = RaisedButton(title: "Raised Button", titleColor: white)
button.backgroundColor = Color.blue.base button.backgroundColor = blue.base
view.layout(button) view.layout(button)
.width(ButtonLayout.Raised.width) .width(ButtonLayout.Raised.width)
...@@ -86,7 +86,7 @@ class ViewController: UIViewController { ...@@ -86,7 +86,7 @@ class ViewController: UIViewController {
} }
private func prepareFabButton() { private func prepareFabButton() {
let button = FabButton(image: Icon.cm.add, tintColor: Color.white) let button = FabButton(image: Icon.cm.add, tintColor: white)
view.layout(button) view.layout(button)
.width(ButtonLayout.Fab.diameter) .width(ButtonLayout.Fab.diameter)
......
...@@ -42,11 +42,11 @@ class AppCaptureController: CaptureController { ...@@ -42,11 +42,11 @@ class AppCaptureController: CaptureController {
private func prepareToolbar() { private func prepareToolbar() {
toolbar.titleLabel.isHidden = true toolbar.titleLabel.isHidden = true
toolbar.titleLabel.textColor = Color.white toolbar.titleLabel.textColor = white
toolbar.detailLabel.isHidden = true toolbar.detailLabel.isHidden = true
toolbar.detail = "Recording" toolbar.detail = "Recording"
toolbar.detailLabel.textColor = Color.red.accent1 toolbar.detailLabel.textColor = red.accent1
toolbar.leftViews = [switchCamerasButton] toolbar.leftViews = [switchCamerasButton]
toolbar.rightViews = [flashButton] toolbar.rightViews = [flashButton]
...@@ -55,8 +55,8 @@ class AppCaptureController: CaptureController { ...@@ -55,8 +55,8 @@ class AppCaptureController: CaptureController {
private func prepareCaptureButton() { private func prepareCaptureButton() {
captureButton.width = 72 captureButton.width = 72
captureButton.height = 72 captureButton.height = 72
captureButton.backgroundColor = Color.red.darken1.withAlphaComponent(0.3) captureButton.backgroundColor = red.darken1.withAlphaComponent(0.3)
captureButton.borderColor = Color.white captureButton.borderColor = white
captureButton.borderWidthPreset = .border3 captureButton.borderWidthPreset = .border3
captureButton.depthPreset = .none captureButton.depthPreset = .none
} }
......
...@@ -44,26 +44,26 @@ class ViewController: UIViewController { ...@@ -44,26 +44,26 @@ class ViewController: UIViewController {
} }
cc.capture.delegate = self cc.capture.delegate = self
cc.capture.captureSession.delegate = self cc.capture.session.delegate = self
view.layout(cc.capture).edges() view.layout(cc.capture).edges()
} }
} }
/// CaptureSessionDelegate. /// CaptureSessionDelegate.
extension ViewController: CaptureSessionDelegate { extension ViewController: CaptureSessionDelegate {
public func captureSessionFailedWithError(captureSession: CaptureSession, error: Error) { public func sessionFailedWithError(session: CaptureSession, error: Error) {
print(error) print(error)
} }
public func captureSessionStillImageAsynchronously(captureSession: CaptureSession, image: UIImage) { public func sessionStillImageAsynchronously(session: CaptureSession, image: UIImage) {
print("captureStillImageAsynchronously") print("captureStillImageAsynchronously")
} }
public func captureSessionCreateMovieFileFailedWithError(captureSession: CaptureSession, error: Error) { public func sessionCreateMovieFileFailedWithError(session: CaptureSession, error: Error) {
print("Capture Failed \(error)") print("Capture Failed \(error)")
} }
public func captureSessionDidStartRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, fileURL: NSURL, fromConnections connections: [Any]) { public func sessionDidStartRecordingToOutputFileAtURL(session: 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
...@@ -71,7 +71,7 @@ extension ViewController: CaptureSessionDelegate { ...@@ -71,7 +71,7 @@ extension ViewController: CaptureSessionDelegate {
// flashButton.isHidden = true // flashButton.isHidden = true
} }
public func captureSessionDidFinishRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, outputFileURL: NSURL, fromConnections connections: [Any], error: Error!) { public func sessionDidFinishRecordingToOutputFileAtURL(session: 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
...@@ -94,17 +94,17 @@ extension ViewController: CaptureSessionDelegate { ...@@ -94,17 +94,17 @@ extension ViewController: CaptureSessionDelegate {
// toolbar.detailLabel.isHidden = true // toolbar.detailLabel.isHidden = true
} }
public func captureSessionWillSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) { public func sessionWillSwitchCameras(session: CaptureSession, position: AVCaptureDevicePosition) {
// ... do something // ... do something
} }
public func captureSessionDidSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) { public func sessionDidSwitchCameras(session: CaptureSession, position: AVCaptureDevicePosition) {
// if .back == position { // if .back == position {
// capture.captureSession.flashMode = .auto // capture.session.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.session.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")
// } // }
...@@ -114,7 +114,7 @@ extension ViewController: CaptureSessionDelegate { ...@@ -114,7 +114,7 @@ extension ViewController: CaptureSessionDelegate {
/// 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.session.position else {
// return // return
// } // }
// //
...@@ -122,25 +122,25 @@ extension ViewController: CaptureDelegate { ...@@ -122,25 +122,25 @@ extension ViewController: CaptureDelegate {
// return // return
// } // }
// //
// switch capture.captureSession.flashMode { // switch capture.session.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.session.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.session.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.session.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 = 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 = red.darken1.withAlphaComponent(0.3)
} }
public func captureDidPressCaptureButton(capture: Capture, button: UIButton) { public func captureDidPressCaptureButton(capture: Capture, button: UIButton) {
......
...@@ -50,7 +50,7 @@ class ViewController: UIViewController { ...@@ -50,7 +50,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
prepareDateFormatter() prepareDateFormatter()
prepareDateLabel() prepareDateLabel()
...@@ -71,16 +71,16 @@ class ViewController: UIViewController { ...@@ -71,16 +71,16 @@ class ViewController: UIViewController {
private func prepareDateLabel() { private func prepareDateLabel() {
dateLabel = UILabel() dateLabel = UILabel()
dateLabel.font = RobotoFont.regular(with: 12) dateLabel.font = RobotoFont.regular(with: 12)
dateLabel.textColor = Color.blueGrey.base dateLabel.textColor = blueGrey.base
dateLabel.text = dateFormatter.string(from: Date.distantFuture) dateLabel.text = dateFormatter.string(from: Date.distantFuture)
} }
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.red.base) favoriteButton = IconButton(image: Icon.favorite, tintColor: red.base)
} }
private func prepareMoreButton() { private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blueGrey.base) moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: blueGrey.base)
} }
private func prepareAuthorView() { private func prepareAuthorView() {
...@@ -97,7 +97,7 @@ class ViewController: UIViewController { ...@@ -97,7 +97,7 @@ class ViewController: UIViewController {
toolbar.detail = "Build Beautiful Software" toolbar.detail = "Build Beautiful Software"
toolbar.detailLabel.textAlignment = .left toolbar.detailLabel.textAlignment = .left
toolbar.detailLabel.textColor = Color.blueGrey.base toolbar.detailLabel.textColor = blueGrey.base
} }
private func prepareContentView() { private func prepareContentView() {
......
...@@ -50,7 +50,7 @@ class ViewController: UIViewController { ...@@ -50,7 +50,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
prepareImageView() prepareImageView()
prepareFavoriteButton() prepareFavoriteButton()
...@@ -70,19 +70,19 @@ class ViewController: UIViewController { ...@@ -70,19 +70,19 @@ class ViewController: UIViewController {
} }
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = FlatButton(image: Icon.favorite, tintColor: Color.blueGrey.base) favoriteButton = FlatButton(image: Icon.favorite, tintColor: blueGrey.base)
} }
private func prepareShareButton() { private func prepareShareButton() {
shareButton = FlatButton(image: Icon.cm.share, tintColor: Color.blueGrey.base) shareButton = FlatButton(image: Icon.cm.share, tintColor: blueGrey.base)
} }
private func prepareStarButton() { private func prepareStarButton() {
starButton = FlatButton(image: Icon.cm.star, tintColor: Color.blueGrey.base) starButton = FlatButton(image: Icon.cm.star, tintColor: blueGrey.base)
} }
private func prepareMoreButton() { private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreHorizontal, tintColor: Color.white) moreButton = IconButton(image: Icon.cm.moreHorizontal, tintColor: white)
} }
private func prepareToolbar() { private func prepareToolbar() {
...@@ -90,10 +90,10 @@ class ViewController: UIViewController { ...@@ -90,10 +90,10 @@ class ViewController: UIViewController {
toolbar.backgroundColor = nil toolbar.backgroundColor = nil
toolbar.title = "CosmicMind" toolbar.title = "CosmicMind"
toolbar.titleLabel.textColor = Color.white toolbar.titleLabel.textColor = white
toolbar.detail = "Build Beautiful Software" toolbar.detail = "Build Beautiful Software"
toolbar.detailLabel.textColor = Color.white toolbar.detailLabel.textColor = white
} }
private func prepareContentView() { private func prepareContentView() {
......
...@@ -37,7 +37,7 @@ class ViewController: UIViewController { ...@@ -37,7 +37,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareLayer() prepareLayer()
} }
...@@ -50,7 +50,7 @@ class ViewController: UIViewController { ...@@ -50,7 +50,7 @@ class ViewController: UIViewController {
layer = Layer(frame: CGRect(x: (w - d) / 2, y: (h - d) / 2, width: d, height: d)) layer = Layer(frame: CGRect(x: (w - d) / 2, y: (h - d) / 2, width: d, height: d))
layer.depthPreset = .depth3 layer.depthPreset = .depth3
layer.shapePreset = .circle layer.shapePreset = .circle
layer.backgroundColor = Color.white.cgColor layer.backgroundColor = white.cgColor
layer.image = UIImage(named: "CosmicMind") layer.image = UIImage(named: "CosmicMind")
view.layer.addSublayer(layer) view.layer.addSublayer(layer)
......
...@@ -38,7 +38,7 @@ class AppMenuController: MenuController { ...@@ -38,7 +38,7 @@ class AppMenuController: MenuController {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
prepareMenu() prepareMenu()
} }
......
...@@ -38,7 +38,7 @@ class RootViewController: UIViewController { ...@@ -38,7 +38,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
prepareAddButton() prepareAddButton()
prepareAudioLibraryButton() prepareAudioLibraryButton()
...@@ -69,14 +69,14 @@ class RootViewController: UIViewController { ...@@ -69,14 +69,14 @@ class RootViewController: UIViewController {
} }
private func prepareAddButton() { private func prepareAddButton() {
addButton = FabButton(image: Icon.cm.add, tintColor: Color.white) addButton = FabButton(image: Icon.cm.add, tintColor: white)
addButton.addTarget(self, action: #selector(handleToggleMenu), for: .touchUpInside) addButton.addTarget(self, action: #selector(handleToggleMenu), for: .touchUpInside)
} }
private func prepareAudioLibraryButton() { private func prepareAudioLibraryButton() {
audioLibraryMenuItem = MenuItem() audioLibraryMenuItem = MenuItem()
audioLibraryMenuItem.button.image = Icon.cm.audioLibrary audioLibraryMenuItem.button.image = Icon.cm.audioLibrary
audioLibraryMenuItem.button.backgroundColor = Color.green.base audioLibraryMenuItem.button.backgroundColor = green.base
audioLibraryMenuItem.button.depthPreset = .depth1 audioLibraryMenuItem.button.depthPreset = .depth1
audioLibraryMenuItem.title = "Audio Library" audioLibraryMenuItem.title = "Audio Library"
} }
...@@ -84,7 +84,7 @@ class RootViewController: UIViewController { ...@@ -84,7 +84,7 @@ class RootViewController: UIViewController {
private func prepareBellButton() { private func prepareBellButton() {
reminderMenuItem = MenuItem() reminderMenuItem = MenuItem()
reminderMenuItem.button.image = Icon.cm.bell reminderMenuItem.button.image = Icon.cm.bell
reminderMenuItem.button.backgroundColor = Color.blue.base reminderMenuItem.button.backgroundColor = blue.base
reminderMenuItem.title = "Reminders" reminderMenuItem.title = "Reminders"
} }
......
...@@ -35,7 +35,7 @@ class AppNavigationController: NavigationController { ...@@ -35,7 +35,7 @@ class AppNavigationController: NavigationController {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
statusBarStyle = .lightContent statusBarStyle = .lightContent
(navigationBar as? NavigationBar)?.backgroundColor = Color.blue.base (navigationBar as? NavigationBar)?.backgroundColor = blue.base
} }
} }
...@@ -34,19 +34,19 @@ import Material ...@@ -34,19 +34,19 @@ import Material
class NextViewController: UIViewController { class NextViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareNavigationItem() prepareNavigationItem()
} }
private func prepareNavigationItem() { private func prepareNavigationItem() {
navigationItem.title = "Title" navigationItem.title = "Title"
navigationItem.titleLabel.textColor = Color.white navigationItem.titleLabel.textColor = white
navigationItem.detail = "Detail Description" navigationItem.detail = "Detail Description"
navigationItem.detailLabel.textColor = Color.lightBlue.lighten5 navigationItem.detailLabel.textColor = lightBlue.lighten5
navigationItem.backButton.tintColor = Color.white navigationItem.backButton.tintColor = white
} }
} }
...@@ -42,7 +42,7 @@ class RootViewController: UIViewController { ...@@ -42,7 +42,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
prepareMenuButton() prepareMenuButton()
prepareStarButton() prepareStarButton()
...@@ -56,23 +56,23 @@ class RootViewController: UIViewController { ...@@ -56,23 +56,23 @@ class RootViewController: UIViewController {
} }
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.white) menuButton = IconButton(image: Icon.cm.menu, tintColor: white)
} }
private func prepareStarButton() { private func prepareStarButton() {
starButton = IconButton(image: Icon.cm.star, tintColor: Color.white) starButton = IconButton(image: Icon.cm.star, tintColor: white)
} }
private func prepareSearchButton() { private func prepareSearchButton() {
searchButton = IconButton(image: Icon.cm.search, tintColor: Color.white) searchButton = IconButton(image: Icon.cm.search, tintColor: white)
} }
private func prepareNavigationItem() { private func prepareNavigationItem() {
navigationItem.title = "Material" navigationItem.title = "Material"
navigationItem.titleLabel.textColor = Color.white navigationItem.titleLabel.textColor = white
navigationItem.detail = "Build Beautiful Software" navigationItem.detail = "Build Beautiful Software"
navigationItem.detailLabel.textColor = Color.lightBlue.lighten5 navigationItem.detailLabel.textColor = lightBlue.lighten5
navigationItem.leftViews = [menuButton] navigationItem.leftViews = [menuButton]
navigationItem.rightViews = [starButton, searchButton] navigationItem.rightViews = [starButton, searchButton]
......
...@@ -36,7 +36,7 @@ class LeftViewController: UIViewController { ...@@ -36,7 +36,7 @@ class LeftViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = blue.base
prepareTransitionButton() prepareTransitionButton()
} }
...@@ -55,7 +55,7 @@ class LeftViewController: UIViewController { ...@@ -55,7 +55,7 @@ class LeftViewController: UIViewController {
} }
private func prepareTransitionButton() { private func prepareTransitionButton() {
transitionButton = FlatButton(title: "Transition VC", titleColor: Color.white) transitionButton = FlatButton(title: "Transition VC", titleColor: white)
transitionButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside) transitionButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
view.layout(transitionButton).horizontally().center() view.layout(transitionButton).horizontally().center()
......
...@@ -36,7 +36,7 @@ class RightViewController: UIViewController { ...@@ -36,7 +36,7 @@ class RightViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = blue.base
prepareRootButton() prepareRootButton()
} }
...@@ -55,7 +55,7 @@ class RightViewController: UIViewController { ...@@ -55,7 +55,7 @@ class RightViewController: UIViewController {
} }
private func prepareRootButton() { private func prepareRootButton() {
rootButton = FlatButton(title: "Root VC", titleColor: Color.white) rootButton = FlatButton(title: "Root VC", titleColor: white)
rootButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside) rootButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
view.layout(rootButton).horizontally().center() view.layout(rootButton).horizontally().center()
......
...@@ -34,7 +34,7 @@ import Material ...@@ -34,7 +34,7 @@ import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareToolbar() prepareToolbar()
} }
......
...@@ -34,7 +34,7 @@ import Material ...@@ -34,7 +34,7 @@ import Material
class TransitionedViewController: UIViewController { class TransitionedViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.purple.base view.backgroundColor = purple.base
prepareToolbar() prepareToolbar()
} }
......
...@@ -40,8 +40,8 @@ class AppPageTabBarController: PageTabBarController { ...@@ -40,8 +40,8 @@ class AppPageTabBarController: PageTabBarController {
} }
private func preparePageTabBar() { private func preparePageTabBar() {
pageTabBar.lineColor = Color.blueGrey.base pageTabBar.lineColor = blueGrey.base
pageTabBar.dividerColor = Color.blueGrey.lighten5 pageTabBar.dividerColor = blueGrey.lighten5
} }
} }
......
...@@ -44,12 +44,12 @@ class BlueViewController: UIViewController { ...@@ -44,12 +44,12 @@ class BlueViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = blue.base
} }
private func preparePageTabBarItem() { private func preparePageTabBarItem() {
pageTabBarItem.title = "Blue" pageTabBarItem.title = "Blue"
pageTabBarItem.titleColor = Color.blueGrey.base pageTabBarItem.titleColor = blueGrey.base
} }
} }
...@@ -44,12 +44,12 @@ class GreenViewController: UIViewController { ...@@ -44,12 +44,12 @@ class GreenViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.green.base view.backgroundColor = green.base
} }
private func preparePageTabBarItem() { private func preparePageTabBarItem() {
pageTabBarItem.title = "Green" pageTabBarItem.title = "Green"
pageTabBarItem.titleColor = Color.blueGrey.base pageTabBarItem.titleColor = blueGrey.base
} }
} }
...@@ -44,12 +44,12 @@ class RedViewController: UIViewController { ...@@ -44,12 +44,12 @@ class RedViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.red.base view.backgroundColor = red.base
} }
private func preparePageTabBarItem() { private func preparePageTabBarItem() {
pageTabBarItem.title = "Red" pageTabBarItem.title = "Red"
pageTabBarItem.titleColor = Color.blueGrey.base pageTabBarItem.titleColor = blueGrey.base
} }
} }
...@@ -42,6 +42,6 @@ class AppToolbarController: ToolbarController { ...@@ -42,6 +42,6 @@ class AppToolbarController: ToolbarController {
private func prepareToolbar() { private func prepareToolbar() {
toolbar.title = "Photo Library" toolbar.title = "Photo Library"
toolbar.depthPreset = .none toolbar.depthPreset = .none
toolbar.dividerColor = Color.grey.lighten3 toolbar.dividerColor = grey.lighten3
} }
} }
...@@ -50,7 +50,7 @@ class PhotoLibraryCollectionReusableView: CollectionReusableView { ...@@ -50,7 +50,7 @@ class PhotoLibraryCollectionReusableView: CollectionReusableView {
toolbar.contentEdgeInsets.left = 16 toolbar.contentEdgeInsets.left = 16
toolbar.contentEdgeInsets.right = 16 toolbar.contentEdgeInsets.right = 16
toolbar.depthPreset = .none toolbar.depthPreset = .none
toolbar.dividerColor = Color.grey.lighten3 toolbar.dividerColor = grey.lighten3
layout(toolbar).edges() layout(toolbar).edges()
} }
} }
...@@ -73,7 +73,7 @@ class PhotoLibraryViewController: PhotoLibraryController { ...@@ -73,7 +73,7 @@ class PhotoLibraryViewController: PhotoLibraryController {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
prepareCollectionView() prepareCollectionView()
...@@ -141,7 +141,7 @@ class PhotoLibraryViewController: PhotoLibraryController { ...@@ -141,7 +141,7 @@ class PhotoLibraryViewController: PhotoLibraryController {
layout.sectionHeadersPinToVisibleBounds = true layout.sectionHeadersPinToVisibleBounds = true
collectionView = PhotoLibraryCollectionView(frame: .zero, collectionViewLayout: layout) collectionView = PhotoLibraryCollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.backgroundColor = Color.clear collectionView.backgroundColor = clear
collectionView.delegate = self collectionView.delegate = self
collectionView.dataSource = self collectionView.dataSource = self
view.layout(collectionView).edges() view.layout(collectionView).edges()
......
...@@ -51,7 +51,7 @@ class ViewController: UIViewController { ...@@ -51,7 +51,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
preparePresenterView() preparePresenterView()
prepareDateFormatter() prepareDateFormatter()
...@@ -79,21 +79,21 @@ class ViewController: UIViewController { ...@@ -79,21 +79,21 @@ class ViewController: UIViewController {
private func prepareDateLabel() { private func prepareDateLabel() {
dateLabel = UILabel() dateLabel = UILabel()
dateLabel.font = RobotoFont.regular(with: 12) dateLabel.font = RobotoFont.regular(with: 12)
dateLabel.textColor = Color.blueGrey.base dateLabel.textColor = blueGrey.base
dateLabel.textAlignment = .center dateLabel.textAlignment = .center
dateLabel.text = dateFormatter.string(from: Date.distantFuture) dateLabel.text = dateFormatter.string(from: Date.distantFuture)
} }
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.red.base) favoriteButton = IconButton(image: Icon.favorite, tintColor: red.base)
} }
private func prepareShareButton() { private func prepareShareButton() {
shareButton = IconButton(image: Icon.cm.share, tintColor: Color.blueGrey.base) shareButton = IconButton(image: Icon.cm.share, tintColor: blueGrey.base)
} }
private func prepareMoreButton() { private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreHorizontal, tintColor: Color.blueGrey.base) moreButton = IconButton(image: Icon.cm.moreHorizontal, tintColor: blueGrey.base)
} }
private func prepareToolbar() { private func prepareToolbar() {
...@@ -104,7 +104,7 @@ class ViewController: UIViewController { ...@@ -104,7 +104,7 @@ class ViewController: UIViewController {
toolbar.detail = "Build Beautiful Software" toolbar.detail = "Build Beautiful Software"
toolbar.detailLabel.textAlignment = .left toolbar.detailLabel.textAlignment = .left
toolbar.detailLabel.textColor = Color.blueGrey.base toolbar.detailLabel.textColor = blueGrey.base
} }
private func prepareContentView() { private func prepareContentView() {
......
...@@ -37,7 +37,7 @@ class RootViewController: UIViewController { ...@@ -37,7 +37,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = grey.lighten1
} }
open override func viewWillAppear(_ animated: Bool) { open override func viewWillAppear(_ animated: Bool) {
......
...@@ -36,7 +36,7 @@ class RootViewController: UIViewController { ...@@ -36,7 +36,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
} }
open override func viewDidAppear(_ animated: Bool) { open override func viewDidAppear(_ animated: Bool) {
...@@ -49,7 +49,7 @@ class RootViewController: UIViewController { ...@@ -49,7 +49,7 @@ class RootViewController: UIViewController {
} }
private func prepareUndoButton() { private func prepareUndoButton() {
undoButton = FlatButton(title: "Undo", titleColor: Color.yellow.base) undoButton = FlatButton(title: "Undo", titleColor: yellow.base)
undoButton.pulseAnimation = .backing undoButton.pulseAnimation = .backing
undoButton.titleLabel?.font = snackbarController?.snackbar.textLabel.font undoButton.titleLabel?.font = snackbarController?.snackbar.textLabel.font
} }
......
...@@ -34,7 +34,7 @@ import Material ...@@ -34,7 +34,7 @@ import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = grey.lighten1
} }
} }
...@@ -35,7 +35,7 @@ class ViewController: UIViewController { ...@@ -35,7 +35,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareSwitch() prepareSwitch()
} }
......
...@@ -40,22 +40,22 @@ class ViewController: UIViewController { ...@@ -40,22 +40,22 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareButtons() prepareButtons()
prepareTabBar() prepareTabBar()
} }
private func prepareButtons() { private func prepareButtons() {
let btn1 = FlatButton(title: "Library", titleColor: Color.blueGrey.base) let btn1 = FlatButton(title: "Library", titleColor: blueGrey.base)
btn1.pulseAnimation = .none btn1.pulseAnimation = .none
buttons.append(btn1) buttons.append(btn1)
let btn2 = FlatButton(title: "Photo", titleColor: Color.blueGrey.base) let btn2 = FlatButton(title: "Photo", titleColor: blueGrey.base)
btn2.pulseAnimation = .none btn2.pulseAnimation = .none
buttons.append(btn2) buttons.append(btn2)
let btn3 = FlatButton(title: "Video", titleColor: Color.blueGrey.base) let btn3 = FlatButton(title: "Video", titleColor: blueGrey.base)
btn3.pulseAnimation = .none btn3.pulseAnimation = .none
buttons.append(btn3) buttons.append(btn3)
} }
...@@ -63,13 +63,13 @@ class ViewController: UIViewController { ...@@ -63,13 +63,13 @@ class ViewController: UIViewController {
private func prepareTabBar() { private func prepareTabBar() {
tabBar = TabBar() tabBar = TabBar()
tabBar.dividerColor = Color.grey.lighten3 tabBar.dividerColor = grey.lighten3
tabBar.dividerAlignment = .top tabBar.dividerAlignment = .top
tabBar.lineColor = Color.blue.base tabBar.lineColor = blue.base
tabBar.lineAlignment = .top tabBar.lineAlignment = .top
tabBar.backgroundColor = Color.grey.lighten5 tabBar.backgroundColor = grey.lighten5
tabBar.buttons = buttons tabBar.buttons = buttons
view.layout(tabBar).horizontally().bottom() view.layout(tabBar).horizontally().bottom()
......
...@@ -38,7 +38,7 @@ class ViewController: UIViewController { ...@@ -38,7 +38,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareNameField() prepareNameField()
prepareEmailField() prepareEmailField()
...@@ -53,7 +53,7 @@ class ViewController: UIViewController { ...@@ -53,7 +53,7 @@ class ViewController: UIViewController {
/// Prepares the resign responder button. /// Prepares the resign responder button.
private func prepareResignResponderButton() { private func prepareResignResponderButton() {
let btn = RaisedButton(title: "Resign", titleColor: Color.blue.base) let btn = RaisedButton(title: "Resign", titleColor: blue.base)
btn.addTarget(self, action: #selector(handleResignResponderButton(button:)), for: .touchUpInside) btn.addTarget(self, action: #selector(handleResignResponderButton(button:)), for: .touchUpInside)
view.layout(btn).width(100).height(50).bottom(24).right(24) view.layout(btn).width(100).height(50).bottom(24).right(24)
...@@ -87,9 +87,9 @@ class ViewController: UIViewController { ...@@ -87,9 +87,9 @@ class ViewController: UIViewController {
emailField.isClearIconButtonEnabled = true emailField.isClearIconButtonEnabled = true
emailField.delegate = self emailField.delegate = self
emailField.placeholderNormalColor = Color.amber.darken4 emailField.placeholderNormalColor = amber.darken4
emailField.placeholderActiveColor = Color.pink.base emailField.placeholderActiveColor = pink.base
emailField.dividerNormalColor = Color.cyan.base emailField.dividerNormalColor = cyan.base
view.addSubview(emailField) view.addSubview(emailField)
} }
...@@ -102,7 +102,7 @@ class ViewController: UIViewController { ...@@ -102,7 +102,7 @@ class ViewController: UIViewController {
passwordField.isVisibilityIconButtonEnabled = true passwordField.isVisibilityIconButtonEnabled = true
// Setting the visibilityIconButton color. // Setting the visibilityIconButton color.
passwordField.visibilityIconButton?.tintColor = Color.green.base.withAlphaComponent(passwordField.isSecureTextEntry ? 0.38 : 0.54) passwordField.visibilityIconButton?.tintColor = green.base.withAlphaComponent(passwordField.isSecureTextEntry ? 0.38 : 0.54)
// Size the TextField to the maximum width, less 40 pixels on either side // Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 200 pixels. // with a top margin of 200 pixels.
......
...@@ -38,7 +38,7 @@ class RootViewController: UIViewController { ...@@ -38,7 +38,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
} }
open override func viewWillAppear(_ animated: Bool) { open override func viewWillAppear(_ animated: Bool) {
......
...@@ -37,7 +37,7 @@ class ViewController: UIViewController { ...@@ -37,7 +37,7 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = white
prepareLogo() prepareLogo()
} }
...@@ -48,7 +48,7 @@ class ViewController: UIViewController { ...@@ -48,7 +48,7 @@ class ViewController: UIViewController {
logo = View() logo = View()
logo.depthPreset = .depth3 logo.depthPreset = .depth3
logo.shapePreset = .circle logo.shapePreset = .circle
logo.backgroundColor = Color.white logo.backgroundColor = white
logo.image = UIImage(named: "CosmicMind") logo.image = UIImage(named: "CosmicMind")
view.layout(logo).width(d).height(d).center() view.layout(logo).width(d).height(d).center()
......
...@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController { ...@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController {
private func prepareTabBar() { private func prepareTabBar() {
tabBar.depthPreset = .none tabBar.depthPreset = .none
tabBar.divider.color = Color.grey.lighten3 tabBar.dividerColor = .grey.lighten3
} }
} }
...@@ -39,12 +39,12 @@ class AudioViewController: UIViewController { ...@@ -39,12 +39,12 @@ class AudioViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = .blue.base
} }
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.title = nil tabBarItem.title = nil
tabBarItem.image = Icon.cm.audioLibrary?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.audioLibrary?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.audioLibrary?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.audioLibrary?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
} }
...@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController { ...@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.red.base view.backgroundColor = .red.base
} }
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.title = nil tabBarItem.title = nil
tabBarItem.image = Icon.cm.photoCamera?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.photoCamera?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.photoCamera?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.photoCamera?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
} }
...@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController { ...@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.yellow.base view.backgroundColor = .yellow.base
} }
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.title = nil tabBarItem.title = nil
tabBarItem.image = Icon.cm.bell?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.bell?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.bell?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.bell?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
} }
...@@ -39,12 +39,12 @@ class SearchViewController: UIViewController { ...@@ -39,12 +39,12 @@ class SearchViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blueGrey.base view.backgroundColor = .blueGrey.base
} }
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.title = nil tabBarItem.title = nil
tabBarItem.image = Icon.cm.search?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.search?.tint(with: .blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.search?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.search?.tint(with: .blue.base)?.withRenderingMode(.alwaysOriginal)
} }
} }
...@@ -39,12 +39,12 @@ class VideoViewController: UIViewController { ...@@ -39,12 +39,12 @@ class VideoViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.green.base view.backgroundColor = green.base
} }
private func prepareTabBarItem() { private func prepareTabBarItem() {
tabBarItem.title = nil tabBarItem.title = nil
tabBarItem.image = Icon.cm.videocam?.tintWithColor(color: Color.blueGrey.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.image = Icon.cm.videocam?.tint(with: blueGrey.base)?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = Icon.cm.videocam?.tintWithColor(color: Color.blue.base)?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = Icon.cm.videocam?.tint(with: blue.base)?.withRenderingMode(.alwaysOriginal)
} }
} }
...@@ -47,7 +47,7 @@ class ViewController: UIViewController { ...@@ -47,7 +47,7 @@ class ViewController: UIViewController {
private func prepareIconButton() { private func prepareIconButton() {
iconButton.image = Icon.search iconButton.image = Icon.search
iconButton.pulseColor = Color.blue.base iconButton.pulseColor = blue.base
} }
} }
......
...@@ -34,7 +34,7 @@ import Material ...@@ -34,7 +34,7 @@ import Material
class NextViewController: UIViewController { class NextViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.base view.backgroundColor = grey.base
prepareNavigationItem() prepareNavigationItem()
} }
...@@ -43,7 +43,7 @@ class NextViewController: UIViewController { ...@@ -43,7 +43,7 @@ class NextViewController: UIViewController {
navigationItem.title = "Title" navigationItem.title = "Title"
navigationItem.detail = "Detail Description" navigationItem.detail = "Detail Description"
navigationItem.backButton.tintColor = Color.blue.base navigationItem.backButton.tintColor = blue.base
} }
} }
...@@ -42,7 +42,7 @@ class RootViewController: UIViewController { ...@@ -42,7 +42,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = grey.lighten1
prepareMenuButton() prepareMenuButton()
prepareStarButton() prepareStarButton()
......
...@@ -34,6 +34,6 @@ import Material ...@@ -34,6 +34,6 @@ import Material
class LeftViewController: UIViewController { class LeftViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = blue.base
} }
} }
...@@ -34,6 +34,6 @@ import Material ...@@ -34,6 +34,6 @@ import Material
class RightViewController: UIViewController { class RightViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = blue.base
} }
} }
...@@ -40,7 +40,7 @@ class AppPageTabBarController: PageTabBarController { ...@@ -40,7 +40,7 @@ class AppPageTabBarController: PageTabBarController {
} }
private func preparePageTabBar() { private func preparePageTabBar() {
pageTabBar.lineColor = Color.grey.darken1 pageTabBar.lineColor = grey.darken1
} }
} }
......
...@@ -44,12 +44,12 @@ class BlueViewController: UIViewController { ...@@ -44,12 +44,12 @@ class BlueViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = blue.base
} }
private func preparePageTabBarItem() { private func preparePageTabBarItem() {
pageTabBarItem.title = "Blue" pageTabBarItem.title = "Blue"
pageTabBarItem.titleColor = Color.blueGrey.base pageTabBarItem.titleColor = blueGrey.base
} }
} }
...@@ -44,12 +44,12 @@ class GreenViewController: UIViewController { ...@@ -44,12 +44,12 @@ class GreenViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.green.base view.backgroundColor = green.base
} }
private func preparePageTabBarItem() { private func preparePageTabBarItem() {
pageTabBarItem.title = "Green" pageTabBarItem.title = "Green"
pageTabBarItem.titleColor = Color.blueGrey.base pageTabBarItem.titleColor = blueGrey.base
} }
} }
...@@ -44,12 +44,12 @@ class RedViewController: UIViewController { ...@@ -44,12 +44,12 @@ class RedViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.red.base view.backgroundColor = red.base
} }
private func preparePageTabBarItem() { private func preparePageTabBarItem() {
pageTabBarItem.title = "Red" pageTabBarItem.title = "Red"
pageTabBarItem.titleColor = Color.blueGrey.base pageTabBarItem.titleColor = blueGrey.base
} }
} }
...@@ -37,7 +37,7 @@ class RootViewController: UIViewController { ...@@ -37,7 +37,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1 view.backgroundColor = grey.lighten1
} }
open override func viewWillAppear(_ animated: Bool) { open override func viewWillAppear(_ animated: Bool) {
......
...@@ -36,7 +36,7 @@ class RootViewController: UIViewController { ...@@ -36,7 +36,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
} }
open override func viewDidAppear(_ animated: Bool) { open override func viewDidAppear(_ animated: Bool) {
...@@ -49,7 +49,7 @@ class RootViewController: UIViewController { ...@@ -49,7 +49,7 @@ class RootViewController: UIViewController {
} }
private func prepareUndoButton() { private func prepareUndoButton() {
undoButton = FlatButton(title: "Undo", titleColor: Color.yellow.base) undoButton = FlatButton(title: "Undo", titleColor: yellow.base)
undoButton.pulseAnimation = .backing undoButton.pulseAnimation = .backing
undoButton.titleLabel?.font = snackbarController?.snackbar.textLabel.font undoButton.titleLabel?.font = snackbarController?.snackbar.textLabel.font
} }
......
...@@ -34,7 +34,7 @@ import Material ...@@ -34,7 +34,7 @@ import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5 view.backgroundColor = grey.lighten5
} }
} }
...@@ -160,7 +160,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel ...@@ -160,7 +160,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel
private func prepareTabBar() { private func prepareTabBar() {
tabBar.depthPreset = .depth1 tabBar.depthPreset = .depth1
tabBar.dividerAlignment = .top tabBar.dividerAlignment = .top
let image = UIImage.imageWithColor(color: Color.clear, size: CGSize(width: 1, height: 1)) let image = UIImage.image(with: Color.clear, size: CGSize(width: 1, height: 1))
tabBar.shadowImage = image tabBar.shadowImage = image
tabBar.backgroundImage = image tabBar.backgroundImage = image
tabBar.backgroundColor = Color.white tabBar.backgroundColor = Color.white
......
...@@ -41,7 +41,7 @@ open class BottomTabBar: UITabBar { ...@@ -41,7 +41,7 @@ open class BottomTabBar: UITabBar {
/// Automatically aligns the BottomNavigationBar to the superview. /// Automatically aligns the BottomNavigationBar to the superview.
open var isAlignedToParentAutomatically = true open var isAlignedToParentAutomatically = true
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable @IBInspectable
open override var backgroundColor: UIColor? { open override var backgroundColor: UIColor? {
didSet { didSet {
...@@ -127,8 +127,8 @@ open class BottomTabBar: UITabBar { ...@@ -127,8 +127,8 @@ open class BottomTabBar: UITabBar {
depthPreset = .depth1 depthPreset = .depth1
dividerAlignment = .top dividerAlignment = .top
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
backgroundColor = Color.white backgroundColor = .white
let image = UIImage.imageWithColor(color: Color.clear, size: CGSize(width: 1, height: 1)) let image = UIImage.image(with: .clear, size: CGSize(width: 1, height: 1))
shadowImage = image shadowImage = image
backgroundImage = image backgroundImage = image
} }
......
...@@ -75,7 +75,7 @@ open class Button: UIButton { ...@@ -75,7 +75,7 @@ open class Button: UIButton {
} }
} }
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable @IBInspectable
open override var backgroundColor: UIColor? { open override var backgroundColor: UIColor? {
didSet { didSet {
...@@ -143,9 +143,9 @@ open class Button: UIButton { ...@@ -143,9 +143,9 @@ open class Button: UIButton {
} }
/** /**
A convenience initializer that acceps an image and tintColor. A convenience initializer that acceps an image and tint
- Parameter image: A UIImage. - Parameter image: A UIImage.
- Parameter tintColor: A UIColor. - Parameter tintColor: A UI
*/ */
public convenience init(image: UIImage?, tintColor: UIColor = Color.blue.base) { public convenience init(image: UIImage?, tintColor: UIColor = Color.blue.base) {
self.init() self.init()
...@@ -153,9 +153,9 @@ open class Button: UIButton { ...@@ -153,9 +153,9 @@ open class Button: UIButton {
} }
/** /**
A convenience initializer that acceps a title and titleColor. A convenience initializer that acceps a title and title
- Parameter title: A String. - Parameter title: A String.
- Parameter titleColor: A UIColor. - Parameter titleColor: A UI
*/ */
public convenience init(title: String?, titleColor: UIColor = Color.blue.base) { public convenience init(title: String?, titleColor: UIColor = Color.blue.base) {
self.init() self.init()
...@@ -252,9 +252,9 @@ open class Button: UIButton { ...@@ -252,9 +252,9 @@ open class Button: UIButton {
} }
/** /**
Prepares the Button with an image and tintColor. Prepares the Button with an image and tint
- Parameter image: A UIImage. - Parameter image: A UIImage.
- Parameter tintColor: A UIColor. - Parameter tintColor: A UI
*/ */
private func prepare(with image: UIImage?, tintColor: UIColor) { private func prepare(with image: UIImage?, tintColor: UIColor) {
self.image = image self.image = image
...@@ -263,9 +263,9 @@ open class Button: UIButton { ...@@ -263,9 +263,9 @@ open class Button: UIButton {
} }
/** /**
Prepares the Button with a title and titleColor. Prepares the Button with a title and title
- Parameter title: A String. - Parameter title: A String.
- Parameter titleColor: A UIColor. - Parameter titleColor: A UI
*/ */
private func prepare(with title: String?, titleColor: UIColor) { private func prepare(with title: String?, titleColor: UIColor) {
self.title = title self.title = title
......
...@@ -151,10 +151,11 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -151,10 +151,11 @@ open class Capture: View, UIGestureRecognizerDelegate {
open lazy var captureMode: CaptureMode = .video open lazy var captureMode: CaptureMode = .video
/// A boolean indicating whether to enable tap to focus. /// A boolean indicating whether to enable tap to focus.
@IBInspectable open var enableTapToFocus = false { @IBInspectable
open var isTapToFocusEnabled = false {
didSet { didSet {
if enableTapToFocus { if isTapToFocusEnabled {
enableTapToReset = true isTapToResetEnabled = true
prepareFocusLayer() prepareFocusLayer()
prepareTapGesture(gesture: &tapToFocusGesture, numberOfTapsRequired: 1, numberOfTouchesRequired: 1, selector: #selector(handleTapToFocusGesture)) prepareTapGesture(gesture: &tapToFocusGesture, numberOfTapsRequired: 1, numberOfTouchesRequired: 1, selector: #selector(handleTapToFocusGesture))
if let v: UITapGestureRecognizer = tapToExposeGesture { if let v: UITapGestureRecognizer = tapToExposeGesture {
...@@ -169,10 +170,11 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -169,10 +170,11 @@ open class Capture: View, UIGestureRecognizerDelegate {
} }
/// A boolean indicating whether to enable tap to expose. /// A boolean indicating whether to enable tap to expose.
@IBInspectable open var enableTapToExpose = false { @IBInspectable
open var isTapToExposeEnabled = false {
didSet { didSet {
if enableTapToExpose { if isTapToExposeEnabled {
enableTapToReset = true isTapToResetEnabled = true
prepareExposureLayer() prepareExposureLayer()
prepareTapGesture(gesture: &tapToExposeGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 1, selector: #selector(handleTapToExposeGesture)) prepareTapGesture(gesture: &tapToExposeGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 1, selector: #selector(handleTapToExposeGesture))
if let v: UITapGestureRecognizer = tapToFocusGesture { if let v: UITapGestureRecognizer = tapToFocusGesture {
...@@ -187,9 +189,10 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -187,9 +189,10 @@ open class Capture: View, UIGestureRecognizerDelegate {
} }
/// A boolean indicating whether to enable tap to reset. /// A boolean indicating whether to enable tap to reset.
@IBInspectable open var enableTapToReset = false { @IBInspectable
open var isTapToResetEnabled = false {
didSet { didSet {
if enableTapToReset { if isTapToResetEnabled {
prepareResetLayer() prepareResetLayer()
prepareTapGesture(gesture: &tapToResetGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 2, selector: #selector(handleTapToResetGesture)) prepareTapGesture(gesture: &tapToResetGesture, numberOfTapsRequired: 2, numberOfTouchesRequired: 2, selector: #selector(handleTapToResetGesture))
if let v: UITapGestureRecognizer = tapToFocusGesture { if let v: UITapGestureRecognizer = tapToFocusGesture {
...@@ -207,24 +210,25 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -207,24 +210,25 @@ open class Capture: View, UIGestureRecognizerDelegate {
} }
/// Insets preset value for content. /// Insets preset value for content.
open var contentEdgeInsetsPreset: EdgeInsetsPreset = .none { open var contentEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet { didSet {
contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset) contentEdgeInsets = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/// Content insert value. /// Content insert value.
open var contentInset = EdgeInsetsPresetToValue(preset: .square4) { @IBInspectable
open var contentEdgeInsets = EdgeInsets.zero {
didSet { didSet {
reloadView() reloadView()
} }
} }
/// A reference to the CapturePreview view. /// A reference to the CapturePreview view.
open internal(set) var previewView: CapturePreview! open internal(set) var preview: CapturePreview!
/// A reference to the CaptureSession. /// A reference to the CaptureSession.
open internal(set) var captureSession: CaptureSession! open internal(set) var session: CaptureSession!
/// A reference to the focus layer used in focus animations. /// A reference to the focus layer used in focus animations.
open internal(set) var focusLayer: Layer? open internal(set) var focusLayer: Layer?
...@@ -236,9 +240,9 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -236,9 +240,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
open internal(set) var resetLayer: Layer? open internal(set) var resetLayer: Layer?
/// A reference to the cameraButton. /// A reference to the cameraButton.
open var cameraButton: UIButton? { open var cameraButton: IconButton! {
didSet { didSet {
if let v: UIButton = cameraButton { if let v = cameraButton {
v.addTarget(self, action: #selector(handleCameraButton), for: .touchUpInside) v.addTarget(self, action: #selector(handleCameraButton), for: .touchUpInside)
} }
reloadView() reloadView()
...@@ -246,9 +250,9 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -246,9 +250,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
} }
/// A reference to the captureButton. /// A reference to the captureButton.
open var captureButton: UIButton? { open var captureButton: FabButton! {
didSet { didSet {
if let v: UIButton = captureButton { if let v = captureButton {
v.addTarget(self, action: #selector(handleCaptureButton), for: .touchUpInside) v.addTarget(self, action: #selector(handleCaptureButton), for: .touchUpInside)
} }
reloadView() reloadView()
...@@ -257,9 +261,9 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -257,9 +261,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
/// A reference to the videoButton. /// A reference to the videoButton.
open var videoButton: UIButton? { open var videoButton: IconButton! {
didSet { didSet {
if let v: UIButton = videoButton { if let v = videoButton {
v.addTarget(self, action: #selector(handleVideoButton), for: .touchUpInside) v.addTarget(self, action: #selector(handleVideoButton), for: .touchUpInside)
} }
reloadView() reloadView()
...@@ -267,18 +271,18 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -267,18 +271,18 @@ open class Capture: View, UIGestureRecognizerDelegate {
} }
/// A reference to the switchCameraButton. /// A reference to the switchCameraButton.
open var switchCamerasButton: UIButton? { open var switchCamerasButton: IconButton! {
didSet { didSet {
if let v: UIButton = switchCamerasButton { if let v = switchCamerasButton {
v.addTarget(self, action: #selector(handleSwitchCamerasButton), for: .touchUpInside) v.addTarget(self, action: #selector(handleSwitchCamerasButton), for: .touchUpInside)
} }
} }
} }
/// A reference to the flashButton. /// A reference to the flashButton.
open var flashButton: UIButton? { open var flashButton: IconButton! {
didSet { didSet {
if let v: UIButton = flashButton { if let v = flashButton {
v.addTarget(self, action: #selector(handleFlashButton), for: .touchUpInside) v.addTarget(self, action: #selector(handleFlashButton), for: .touchUpInside)
} }
} }
...@@ -291,22 +295,22 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -291,22 +295,22 @@ open class Capture: View, UIGestureRecognizerDelegate {
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
previewView.frame = bounds preview.frame = bounds
if let v: UIButton = cameraButton { if let v = cameraButton {
v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height v.frame.origin.y = bounds.height - contentEdgeInsets.bottom - v.bounds.height
v.frame.origin.x = contentInset.left v.frame.origin.x = contentEdgeInsets.left
} }
if let v: UIButton = captureButton { if let v = captureButton {
v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height v.frame.origin.y = bounds.height - contentEdgeInsets.bottom - v.bounds.height
v.frame.origin.x = (bounds.width - v.bounds.width) / 2 v.frame.origin.x = (bounds.width - v.bounds.width) / 2
} }
if let v: UIButton = videoButton { if let v = videoButton {
v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height v.frame.origin.y = bounds.height - contentEdgeInsets.bottom - v.bounds.height
v.frame.origin.x = bounds.width - v.bounds.width - contentInset.right v.frame.origin.x = bounds.width - v.bounds.width - contentEdgeInsets.right
} }
if let v: AVCaptureConnection = (previewView.layer as! AVCaptureVideoPreviewLayer).connection { if let v: AVCaptureConnection = (preview.layer as! AVCaptureVideoPreviewLayer).connection {
v.videoOrientation = captureSession.videoOrientation v.videoOrientation = session.videoOrientation
} }
} }
...@@ -319,9 +323,17 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -319,9 +323,17 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/ */
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
backgroundColor = Color.black backgroundColor = .black
isTapToFocusEnabled = true
isTapToExposeEnabled = true
prepareCaptureSession() prepareCaptureSession()
preparePreviewView() preparePreviewView()
prepareCaptureButton()
prepareCameraButton()
prepareVideoButton()
prepareSwitchCamerasButton()
prepareFlashButton()
} }
/// Reloads the view. /// Reloads the view.
...@@ -332,17 +344,17 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -332,17 +344,17 @@ open class Capture: View, UIGestureRecognizerDelegate {
v.removeFromSuperview() v.removeFromSuperview()
} }
insertSubview(previewView, at: 0) insertSubview(preview, at: 0)
if let v: UIButton = captureButton { if let v = captureButton {
insertSubview(v, at: 1) insertSubview(v, at: 1)
} }
if let v: UIButton = cameraButton { if let v = cameraButton {
insertSubview(v, at: 2) insertSubview(v, at: 2)
} }
if let v: UIButton = videoButton { if let v = videoButton {
insertSubview(v, at: 3) insertSubview(v, at: 3)
} }
} }
...@@ -357,7 +369,7 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -357,7 +369,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
/// Updates the timer when recording. /// Updates the timer when recording.
internal func updateTimer() { internal func updateTimer() {
let duration: CMTime = captureSession.recordedDuration let duration: CMTime = session.recordedDuration
let time: Double = CMTimeGetSeconds(duration) let time: Double = CMTimeGetSeconds(duration)
let hours: Int = Int(time / 3600) let hours: Int = Int(time / 3600)
let minutes: Int = Int((time / 60).truncatingRemainder(dividingBy: 60)) let minutes: Int = Int((time / 60).truncatingRemainder(dividingBy: 60))
...@@ -367,7 +379,7 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -367,7 +379,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
/// Stops the timer when recording. /// Stops the timer when recording.
internal func stopTimer() { internal func stopTimer() {
let duration: CMTime = captureSession.recordedDuration let duration: CMTime = session.recordedDuration
let time: Double = CMTimeGetSeconds(duration) let time: Double = CMTimeGetSeconds(duration)
let hours: Int = Int(time / 3600) let hours: Int = Int(time / 3600)
let minutes: Int = Int((time / 60).truncatingRemainder(dividingBy: 60)) let minutes: Int = Int((time / 60).truncatingRemainder(dividingBy: 60))
...@@ -392,7 +404,7 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -392,7 +404,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/ */
@objc @objc
internal func handleSwitchCamerasButton(button: UIButton) { internal func handleSwitchCamerasButton(button: UIButton) {
captureSession.switchCameras() session.switchCameras()
delegate?.captureDidPressSwitchCamerasButton?(capture: self, button: button) delegate?.captureDidPressSwitchCamerasButton?(capture: self, button: button)
} }
...@@ -403,13 +415,13 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -403,13 +415,13 @@ open class Capture: View, UIGestureRecognizerDelegate {
@objc @objc
internal func handleCaptureButton(button: UIButton) { internal func handleCaptureButton(button: UIButton) {
if .photo == captureMode { if .photo == captureMode {
captureSession.captureStillImage() session.captureStillImage()
} else if .video == captureMode { } else if .video == captureMode {
if captureSession.isRecording { if session.isRecording {
captureSession.stopRecording() session.stopRecording()
stopTimer() stopTimer()
} else { } else {
captureSession.startRecording() session.startRecording()
startTimer() startTimer()
} }
} }
...@@ -442,9 +454,9 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -442,9 +454,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/ */
@objc @objc
internal func handleTapToFocusGesture(recognizer: UITapGestureRecognizer) { internal func handleTapToFocusGesture(recognizer: UITapGestureRecognizer) {
if enableTapToFocus && captureSession.isFocusPointOfInterestSupported { if isTapToFocusEnabled && session.isFocusPointOfInterestSupported {
let point: CGPoint = recognizer.location(in: self) let point: CGPoint = recognizer.location(in: self)
captureSession.focus(at: previewView.captureDevicePointOfInterestForPoint(point: point)) session.focus(at: preview.captureDevicePointOfInterestForPoint(point: point))
animateTapLayer(layer: focusLayer!, point: point) animateTapLayer(layer: focusLayer!, point: point)
delegate?.captureDidTapToFocusAtPoint?(capture: self, point: point) delegate?.captureDidTapToFocusAtPoint?(capture: self, point: point)
} }
...@@ -456,9 +468,9 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -456,9 +468,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/ */
@objc @objc
internal func handleTapToExposeGesture(recognizer: UITapGestureRecognizer) { internal func handleTapToExposeGesture(recognizer: UITapGestureRecognizer) {
if enableTapToExpose && captureSession.isExposurePointOfInterestSupported { if isTapToExposeEnabled && session.isExposurePointOfInterestSupported {
let point: CGPoint = recognizer.location(in: self) let point: CGPoint = recognizer.location(in: self)
captureSession.expose(at: previewView.captureDevicePointOfInterestForPoint(point: point)) session.expose(at: preview.captureDevicePointOfInterestForPoint(point: point))
animateTapLayer(layer: exposureLayer!, point: point) animateTapLayer(layer: exposureLayer!, point: point)
delegate?.captureDidTapToExposeAtPoint?(capture: self, point: point) delegate?.captureDidTapToExposeAtPoint?(capture: self, point: point)
} }
...@@ -470,9 +482,9 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -470,9 +482,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/ */
@objc @objc
internal func handleTapToResetGesture(recognizer: UITapGestureRecognizer) { internal func handleTapToResetGesture(recognizer: UITapGestureRecognizer) {
if enableTapToReset { if isTapToResetEnabled {
captureSession.reset() session.reset()
let point: CGPoint = previewView.pointForCaptureDevicePointOfInterest(point: CGPoint(x: 0.5, y: 0.5)) let point: CGPoint = preview.pointForCaptureDevicePointOfInterest(point: CGPoint(x: 0.5, y: 0.5))
animateTapLayer(layer: resetLayer!, point: point) animateTapLayer(layer: resetLayer!, point: point)
delegate?.captureDidTapToResetAtPoint?(capture: self, point: point) delegate?.captureDidTapToResetAtPoint?(capture: self, point: point)
} }
...@@ -507,17 +519,43 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -507,17 +519,43 @@ open class Capture: View, UIGestureRecognizerDelegate {
} }
} }
/// Prepare the captureSession. /// Prepare the session.
private func prepareCaptureSession() { private func prepareCaptureSession() {
captureSession = CaptureSession() session = CaptureSession()
} }
/// Prepares the previewView. /// Prepares the preview.
private func preparePreviewView() { private func preparePreviewView() {
previewView = CapturePreview() preview = CapturePreview()
(previewView.layer as! AVCaptureVideoPreviewLayer).session = captureSession.session (preview.layer as! AVCaptureVideoPreviewLayer).session = session.session
captureSession.startSession() session.startSession()
} }
/// Prepares the captureButton.
private func prepareCaptureButton() {
captureButton = FabButton()
}
/// Prepares the cameraButton.
private func prepareCameraButton() {
cameraButton = IconButton(image: Icon.cm.photoCamera, tintColor: .white)
}
/// Preapres the videoButton.
private func prepareVideoButton() {
videoButton = IconButton(image: Icon.cm.videocam, tintColor: .white)
}
/// Prepares the switchCameraButton.
private func prepareSwitchCamerasButton() {
switchCamerasButton = IconButton(image: UIImage(named: "ic_camera_front_white"), tintColor: .white)
}
/// Prepares the flashButton.
private func prepareFlashButton() {
flashButton = IconButton(image: UIImage(named: "ic_flash_auto_white"), tintColor: .white)
session.flashMode = .auto
}
/// Prepares the focusLayer. /// Prepares the focusLayer.
private func prepareFocusLayer() { private func prepareFocusLayer() {
...@@ -526,7 +564,7 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -526,7 +564,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
focusLayer!.isHidden = true focusLayer!.isHidden = true
focusLayer!.borderWidth = 2 focusLayer!.borderWidth = 2
focusLayer!.borderColor = Color.white.cgColor focusLayer!.borderColor = Color.white.cgColor
previewView.layer.addSublayer(focusLayer!) preview.layer.addSublayer(focusLayer!)
} }
} }
...@@ -537,7 +575,7 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -537,7 +575,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
exposureLayer!.isHidden = true exposureLayer!.isHidden = true
exposureLayer!.borderWidth = 2 exposureLayer!.borderWidth = 2
exposureLayer!.borderColor = Color.yellow.darken1.cgColor exposureLayer!.borderColor = Color.yellow.darken1.cgColor
previewView.layer.addSublayer(exposureLayer!) preview.layer.addSublayer(exposureLayer!)
} }
} }
...@@ -548,7 +586,7 @@ open class Capture: View, UIGestureRecognizerDelegate { ...@@ -548,7 +586,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
resetLayer!.isHidden = true resetLayer!.isHidden = true
resetLayer!.borderWidth = 2 resetLayer!.borderWidth = 2
resetLayer!.borderColor = Color.red.accent1.cgColor resetLayer!.borderColor = Color.red.accent1.cgColor
previewView.layer.addSublayer(resetLayer!) preview.layer.addSublayer(resetLayer!)
} }
} }
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
*/ */
import UIKit import UIKit
import Material
extension UIViewController { extension UIViewController {
/** /**
...@@ -50,69 +49,59 @@ extension UIViewController { ...@@ -50,69 +49,59 @@ extension UIViewController {
} }
open class CaptureController: ToolbarController, CaptureDelegate, CaptureSessionDelegate { open class CaptureController: ToolbarController, CaptureDelegate, CaptureSessionDelegate {
/// A reference to the Capture instance.
open private(set) lazy var capture: Capture = Capture() 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() { /// A reference to capture's cameraButton.
super.prepare() open var cameraButton: IconButton {
view.backgroundColor = Color.black return capture.cameraButton
display = .full
prepareToolbar()
prepareCaptureButton()
prepareCameraButton()
prepareVideoButton()
prepareSwitchCamerasButton()
prepareFlashButton()
prepareCapture()
} }
/// Prepares the Toolbar. /// A reference to capture's videoButton.
private func prepareToolbar() { open var videoButton: IconButton {
toolbar.backgroundColor = Color.clear return capture.videoButton
toolbar.depthPreset = .none
} }
/// Prepares the captureButton. /// A reference to capture's switchCamerasButton.
private func prepareCaptureButton() { open var switchCamerasButton: IconButton {
captureButton = FabButton() return capture.switchCamerasButton
capture.captureButton = captureButton
} }
/// Prepares the cameraButton. /// A reference to capture's flashButton.
private func prepareCameraButton() { open var flashButton: IconButton {
cameraButton = IconButton(image: Icon.cm.photoCamera, tintColor: Color.white) return capture.flashButton
capture.cameraButton = cameraButton
} }
/// Preapres the videoButton. /// A reference to capture's captureButton.
private func prepareVideoButton() { open var captureButton: FabButton {
videoButton = IconButton(image: Icon.cm.videocam, tintColor: Color.white) return capture.captureButton
capture.videoButton = videoButton
} }
/// Prepares the switchCameraButton. /**
private func prepareSwitchCamerasButton() { Prepares the view instance when intialized. When subclassing,
switchCamerasButton = IconButton(image: UIImage(named: "ic_camera_front_white"), tintColor: Color.white) it is recommended to override the prepare method
capture.switchCamerasButton = switchCamerasButton to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
view.backgroundColor = .black
display = .full
prepareToolbar()
prepareCapture()
} }
/// Prepares the flashButton. /// Prepares the Toolbar.
private func prepareFlashButton() { private func prepareToolbar() {
flashButton = IconButton(image: UIImage(named: "ic_flash_auto_white"), tintColor: Color.white) toolbar.backgroundColor = .clear
capture.flashButton = flashButton toolbar.depthPreset = .none
capture.captureSession.flashMode = .auto
} }
/// Prepares capture. /// Prepares capture.
private func prepareCapture() { private func prepareCapture() {
capture.enableTapToFocus = true
capture.enableTapToExpose = true
capture.delegate = self capture.delegate = self
capture.captureSession.delegate = self capture.session.delegate = self
} }
} }
...@@ -90,82 +90,82 @@ public func CaptureSessionPresetToString(preset: CaptureSessionPreset) -> String ...@@ -90,82 +90,82 @@ public func CaptureSessionPresetToString(preset: CaptureSessionPreset) -> String
public protocol CaptureSessionDelegate { public protocol CaptureSessionDelegate {
/** /**
A delegation method that is fired when the captureSesstion failes with an error. A delegation method that is fired when the captureSesstion failes with an error.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error. - Parameter error: A Error corresponding to the error.
*/ */
@objc @objc
optional func captureSessionFailedWithError(captureSession: CaptureSession, error: Error) optional func sessionFailedWithError(session: CaptureSession, error: Error)
/** /**
A delegation method that is fired when the camera has been switched to another. A delegation method that is fired when the camera has been switched to another.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter position: An AVCaptureDevicePosition that the camera has switched to. - Parameter position: An AVCaptureDevicePosition that the camera has switched to.
*/ */
@objc @objc
optional func captureSessionDidSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) optional func sessionDidSwitchCameras(session: CaptureSession, position: AVCaptureDevicePosition)
/** /**
A delegation method that is fired before the camera has been switched to another. A delegation method that is fired before the camera has been switched to another.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter position: An AVCaptureDevicePosition that the camera will switch to. - Parameter position: An AVCaptureDevicePosition that the camera will switch to.
*/ */
@objc @objc
optional func captureSessionWillSwitchCameras(captureSession: CaptureSession, position: AVCaptureDevicePosition) optional func sessionWillSwitchCameras(session: CaptureSession, position: AVCaptureDevicePosition)
/** /**
A delegation method that is fired when an image has been captured asynchronously. A delegation method that is fired when an image has been captured asynchronously.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter image: An image that has been captured. - Parameter image: An image that has been captured.
*/ */
@objc @objc
optional func captureSessionStillImageAsynchronously(captureSession: CaptureSession, image: UIImage) optional func sessionStillImageAsynchronously(session: CaptureSession, image: UIImage)
/** /**
A delegation method that is fired when capturing an image asynchronously has failed. A delegation method that is fired when capturing an image asynchronously has failed.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error. - Parameter error: A Error corresponding to the error.
*/ */
@objc @objc
optional func captureSessionStillImageAsynchronouslyFailedWithError(captureSession: CaptureSession, error: Error) optional func sessionStillImageAsynchronouslyFailedWithError(session: CaptureSession, error: Error)
/** /**
A delegation method that is fired when creating a movie file has failed. A delegation method that is fired when creating a movie file has failed.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error. - Parameter error: A Error corresponding to the error.
*/ */
@objc @objc
optional func captureSessionCreateMovieFileFailedWithError(captureSession: CaptureSession, error: Error) optional func sessionCreateMovieFileFailedWithError(session: CaptureSession, error: Error)
/** /**
A delegation method that is fired when capturing a movie has failed. A delegation method that is fired when capturing a movie has failed.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error. - Parameter error: A Error corresponding to the error.
*/ */
@objc @objc
optional func captureSessionMovieFailedWithError(captureSession: CaptureSession, error: Error) optional func sessionMovieFailedWithError(session: CaptureSession, error: Error)
/** /**
A delegation method that is fired when a session started recording and writing A delegation method that is fired when a session started recording and writing
to a file. to a file.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter captureOut: An AVCaptureFileOutput. - Parameter captureOut: An AVCaptureFileOutput.
- Parameter fileURL: A file URL. - Parameter fileURL: A file URL.
- Parameter fromConnections: An array of Anys. - Parameter fromConnections: An array of Anys.
*/ */
@objc @objc
optional func captureSessionDidStartRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, fileURL: NSURL, fromConnections connections: [Any]) optional func sessionDidStartRecordingToOutputFileAtURL(session: CaptureSession, captureOutput: AVCaptureFileOutput, fileURL: NSURL, fromConnections connections: [Any])
/** /**
A delegation method that is fired when a session finished recording and writing A delegation method that is fired when a session finished recording and writing
to a file. to a file.
- Parameter captureSession: A reference to the calling CaptureSession. - Parameter session: A reference to the calling CaptureSession.
- Parameter captureOut: An AVCaptureFileOutput. - Parameter captureOut: An AVCaptureFileOutput.
- Parameter fileURL: A file URL. - Parameter fileURL: A file URL.
- Parameter fromConnections: An array of Anys. - Parameter fromConnections: An array of Anys.
- Parameter error: A Error corresponding to an error. - Parameter error: A Error corresponding to an error.
*/ */
@objc @objc
optional func captureSessionDidFinishRecordingToOutputFileAtURL(captureSession: CaptureSession, captureOutput: AVCaptureFileOutput, outputFileURL: NSURL, fromConnections connections: [Any], error: Error!) optional func sessionDidFinishRecordingToOutputFileAtURL(session: CaptureSession, captureOutput: AVCaptureFileOutput, outputFileURL: NSURL, fromConnections connections: [Any], error: Error!)
} }
@objc(CaptureSession) @objc(CaptureSession)
...@@ -279,7 +279,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -279,7 +279,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo[NSUnderlyingErrorKey] = error userInfo[NSUnderlyingErrorKey] = error
} }
if let e = error { if let e = error {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
} }
...@@ -308,7 +308,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -308,7 +308,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo[NSUnderlyingErrorKey] = error userInfo[NSUnderlyingErrorKey] = error
} }
if let e = error { if let e = error {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
} }
...@@ -337,7 +337,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -337,7 +337,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo[NSUnderlyingErrorKey] = error userInfo[NSUnderlyingErrorKey] = error
} }
if let e: NSError = error { if let e: NSError = error {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
} }
...@@ -403,7 +403,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -403,7 +403,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
if canSwitchCameras { if canSwitchCameras {
do { do {
if let v: AVCaptureDevicePosition = position { if let v: AVCaptureDevicePosition = position {
delegate?.captureSessionWillSwitchCameras?(captureSession: self, position: v) delegate?.sessionWillSwitchCameras?(session: self, position: v)
let videoInput: AVCaptureDeviceInput? = try AVCaptureDeviceInput(device: inactiveCamera!) let videoInput: AVCaptureDeviceInput? = try AVCaptureDeviceInput(device: inactiveCamera!)
session.beginConfiguration() session.beginConfiguration()
session.removeInput(activeVideoInput) session.removeInput(activeVideoInput)
...@@ -415,10 +415,10 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -415,10 +415,10 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
session.addInput(activeVideoInput) session.addInput(activeVideoInput)
} }
session.commitConfiguration() session.commitConfiguration()
delegate?.captureSessionDidSwitchCameras?(captureSession: self, position: position!) delegate?.sessionDidSwitchCameras?(session: self, position: position!)
} }
} catch let e as NSError { } catch let e as NSError {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
} }
...@@ -483,7 +483,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -483,7 +483,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo[NSUnderlyingErrorKey] = error userInfo[NSUnderlyingErrorKey] = error
} }
if let e = error { if let e = error {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
...@@ -514,7 +514,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -514,7 +514,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo[NSUnderlyingErrorKey] = error userInfo[NSUnderlyingErrorKey] = error
} }
if let e = error { if let e = error {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
...@@ -529,7 +529,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -529,7 +529,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
device.exposureMode = .locked device.exposureMode = .locked
device.unlockForConfiguration() device.unlockForConfiguration()
} catch let e as NSError { } catch let e as NSError {
self.delegate?.captureSessionFailedWithError?(captureSession: self, error: e) self.delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
} }
...@@ -560,7 +560,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -560,7 +560,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
} }
device.unlockForConfiguration() device.unlockForConfiguration()
} catch let e as NSError { } catch let e as NSError {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
...@@ -577,7 +577,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -577,7 +577,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
let data = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)! let data = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)!
if let image1 = UIImage(data: data) { if let image1 = UIImage(data: data) {
if let image2 = image1.adjustOrientation() { if let image2 = image1.adjustOrientation() {
s.delegate?.captureSessionStillImageAsynchronously?(captureSession: s, image: image2) s.delegate?.sessionStillImageAsynchronously?(session: s, image: image2)
} else { } else {
var userInfo = [String: Any]() var userInfo = [String: Any]()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Cannot fix image orientation.]" userInfo[NSLocalizedDescriptionKey] = "[Material Error: Cannot fix image orientation.]"
...@@ -595,7 +595,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -595,7 +595,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
} }
if let e: Error = captureError { if let e: Error = captureError {
s.delegate?.captureSessionStillImageAsynchronouslyFailedWithError?(captureSession: s, error: e) s.delegate?.sessionStillImageAsynchronouslyFailedWithError?(session: s, error: e)
} }
} }
} }
...@@ -620,7 +620,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -620,7 +620,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
v.isSmoothAutoFocusEnabled = true v.isSmoothAutoFocusEnabled = true
v.unlockForConfiguration() v.unlockForConfiguration()
} catch let e as NSError { } catch let e as NSError {
s.delegate?.captureSessionFailedWithError?(captureSession: s, error: e) s.delegate?.sessionFailedWithError?(session: s, error: e)
} }
} }
...@@ -643,12 +643,12 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -643,12 +643,12 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
public func capture(_ captureOutput: AVCaptureFileOutput!, didStartRecordingToOutputFileAt fileURL: URL!, fromConnections connections: [Any]!) { public func capture(_ captureOutput: AVCaptureFileOutput!, didStartRecordingToOutputFileAt fileURL: URL!, fromConnections connections: [Any]!) {
isRecording = true isRecording = true
delegate?.captureSessionDidStartRecordingToOutputFileAtURL?(captureSession: self, captureOutput: captureOutput, fileURL: fileURL as NSURL, fromConnections: connections) delegate?.sessionDidStartRecordingToOutputFileAtURL?(session: self, captureOutput: captureOutput, fileURL: fileURL as NSURL, fromConnections: connections)
} }
public func capture(_ captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAt outputFileURL: URL!, fromConnections connections: [Any]!, error: Error!) { public func capture(_ captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAt outputFileURL: URL!, fromConnections connections: [Any]!, error: Error!) {
isRecording = false isRecording = false
delegate?.captureSessionDidFinishRecordingToOutputFileAtURL?(captureSession: self, captureOutput: captureOutput, outputFileURL: outputFileURL as NSURL, fromConnections: connections, error: error) delegate?.sessionDidFinishRecordingToOutputFileAtURL?(session: self, captureOutput: captureOutput, outputFileURL: outputFileURL as NSURL, fromConnections: connections, error: error)
} }
/// Prepares the sessionQueue. /// Prepares the sessionQueue.
...@@ -669,7 +669,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -669,7 +669,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
session.addInput(activeVideoInput) session.addInput(activeVideoInput)
} }
} catch let e as NSError { } catch let e as NSError {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
...@@ -681,7 +681,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -681,7 +681,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
session.addInput(activeAudioInput) session.addInput(activeAudioInput)
} }
} catch let e as NSError { } catch let e as NSError {
delegate?.captureSessionFailedWithError?(captureSession: self, error: e) delegate?.sessionFailedWithError?(session: self, error: e)
} }
} }
...@@ -729,7 +729,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -729,7 +729,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
dateFormatter.timeStyle = .full dateFormatter.timeStyle = .full
return directory.appendingPathComponent(dateFormatter.string(from: NSDate() as Date) + ".mov") return directory.appendingPathComponent(dateFormatter.string(from: NSDate() as Date) + ".mov")
} catch let e as NSError { } catch let e as NSError {
delegate?.captureSessionCreateMovieFileFailedWithError?(captureSession: self, error: e) delegate?.sessionCreateMovieFileFailedWithError?(session: self, error: e)
} }
return nil return nil
} }
......
...@@ -157,7 +157,7 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -157,7 +157,7 @@ open class CollectionReusableView: UICollectionReusableView {
} }
/// A reference to EdgeInsets. /// A reference to EdgeInsets.
@IBInspectable open var contentInset: UIEdgeInsets { @IBInspectable open var contentEdgeInsets: UIEdgeInsets {
get { get {
return grid.contentEdgeInsets return grid.contentEdgeInsets
} }
...@@ -183,7 +183,7 @@ open class CollectionReusableView: UICollectionReusableView { ...@@ -183,7 +183,7 @@ open class CollectionReusableView: UICollectionReusableView {
} }
} }
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable open override var backgroundColor: UIColor? { @IBInspectable open override var backgroundColor: UIColor? {
didSet { didSet {
layer.backgroundColor = backgroundColor?.cgColor layer.backgroundColor = backgroundColor?.cgColor
......
...@@ -41,7 +41,7 @@ open class CollectionView: UICollectionView { ...@@ -41,7 +41,7 @@ open class CollectionView: UICollectionView {
} }
} }
open override var contentInset: UIEdgeInsets { open var contentEdgeInsets: EdgeInsets {
get { get {
return (collectionViewLayout as? CollectionViewLayout)!.contentEdgeInsets return (collectionViewLayout as? CollectionViewLayout)!.contentEdgeInsets
} }
...@@ -68,7 +68,8 @@ open class CollectionView: UICollectionView { ...@@ -68,7 +68,8 @@ open class CollectionView: UICollectionView {
} }
/// Spacing between items. /// Spacing between items.
@IBInspectable open var interimSpace: InterimSpace { @IBInspectable
open var interimSpace: InterimSpace {
get { get {
return (collectionViewLayout as? CollectionViewLayout)!.interimSpace return (collectionViewLayout as? CollectionViewLayout)!.interimSpace
} }
...@@ -119,7 +120,7 @@ open class CollectionView: UICollectionView { ...@@ -119,7 +120,7 @@ open class CollectionView: UICollectionView {
*/ */
open func prepare() { open func prepare() {
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
backgroundColor = Color.clear backgroundColor = .clear
contentInset = .zero contentEdgeInsets = .zero
} }
} }
...@@ -162,7 +162,7 @@ open class CollectionViewCell: UICollectionViewCell { ...@@ -162,7 +162,7 @@ open class CollectionViewCell: UICollectionViewCell {
/// A reference to EdgeInsets. /// A reference to EdgeInsets.
@IBInspectable @IBInspectable
open var contentInset: EdgeInsets { open var contentEdgeInsets: EdgeInsets {
get { get {
return contentView.grid.contentEdgeInsets return contentView.grid.contentEdgeInsets
} }
...@@ -189,7 +189,7 @@ open class CollectionViewCell: UICollectionViewCell { ...@@ -189,7 +189,7 @@ open class CollectionViewCell: UICollectionViewCell {
} }
} }
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable @IBInspectable
open override var backgroundColor: UIColor? { open override var backgroundColor: UIColor? {
didSet { didSet {
......
...@@ -56,30 +56,21 @@ public protocol ColorPalette { ...@@ -56,30 +56,21 @@ public protocol ColorPalette {
optional static var accent4: UIColor { get } optional static var accent4: UIColor { get }
} }
open class Color { open class Color: UIColor {
// clear
open static let clear = UIColor.clear
// white
open static let white = UIColor.white
// black
open static let black = UIColor.black
// dark text // dark text
open class darkText { open class darkText {
open static let primary = Color.black.withAlphaComponent(0.87) open static let primary = black.withAlphaComponent(0.87)
open static let secondary = Color.black.withAlphaComponent(0.54) open static let secondary = black.withAlphaComponent(0.54)
open static let others = Color.black.withAlphaComponent(0.38) open static let others = black.withAlphaComponent(0.38)
open static let dividers = Color.black.withAlphaComponent(0.12) open static let dividers = black.withAlphaComponent(0.12)
} }
// light text // light text
open class lightText { open class lightText {
open static let primary = Color.white open static let primary = white
open static let secondary = Color.white.withAlphaComponent(0.7) open static let secondary = white.withAlphaComponent(0.7)
open static let others = Color.white.withAlphaComponent(0.5) open static let others = white.withAlphaComponent(0.5)
open static let dividers = Color.white.withAlphaComponent(0.12) open static let dividers = white.withAlphaComponent(0.12)
} }
// red // red
......
...@@ -48,7 +48,7 @@ open class Divider { ...@@ -48,7 +48,7 @@ open class Divider {
/// A reference to the height. /// A reference to the height.
public var height: CGFloat public var height: CGFloat
/// A UIColor. /// A UI
open var color: UIColor? { open var color: UIColor? {
get { get {
return line?.backgroundColor return line?.backgroundColor
......
...@@ -43,8 +43,8 @@ open class FabButton: Button { ...@@ -43,8 +43,8 @@ open class FabButton: Button {
depthPreset = .depth1 depthPreset = .depth1
shapePreset = .circle shapePreset = .circle
pulseAnimation = .centerWithBacking pulseAnimation = .centerWithBacking
tintColor = Color.white tintColor = .white
pulseColor = Color.white pulseColor = .white
backgroundColor = Color.red.base backgroundColor = Color.red.base
} }
} }
...@@ -239,7 +239,7 @@ extension CALayer { ...@@ -239,7 +239,7 @@ extension CALayer {
} }
} }
/// A UIColor reference to the `backgroundColor.cgColor`. /// A UIColor reference to the `backgroundcgColor`.
open var color: UIColor? { open var color: UIColor? {
get { get {
return nil == backgroundColor ? nil : UIColor(cgColor: backgroundColor!) return nil == backgroundColor ? nil : UIColor(cgColor: backgroundColor!)
......
...@@ -100,7 +100,7 @@ extension UIImage { ...@@ -100,7 +100,7 @@ extension UIImage {
- Parameter color: The UIColor to create the image from. - Parameter color: The UIColor to create the image from.
- Returns: A UIImage that is the color passed in. - Returns: A UIImage that is the color passed in.
*/ */
open func tintWithColor(color: UIColor) -> UIImage? { open func tint(with color: UIColor) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, Device.scale) UIGraphicsBeginImageContextWithOptions(size, false, Device.scale)
guard let context = UIGraphicsGetCurrentContext() else { guard let context = UIGraphicsGetCurrentContext() else {
return nil return nil
...@@ -129,7 +129,7 @@ extension UIImage { ...@@ -129,7 +129,7 @@ extension UIImage {
- Parameter size: The size of the image to create. - Parameter size: The size of the image to create.
- Returns: A UIImage that is the color passed in. - Returns: A UIImage that is the color passed in.
*/ */
open class func imageWithColor(color: UIColor, size: CGSize) -> UIImage? { open class func image(with color: UIColor, size: CGSize) -> UIImage? {
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
UIGraphicsBeginImageContextWithOptions(size, false, 0) UIGraphicsBeginImageContextWithOptions(size, false, 0)
color.setFill() color.setFill()
......
...@@ -110,7 +110,7 @@ extension UIView { ...@@ -110,7 +110,7 @@ extension UIView {
} }
} }
/// A property that accesses the backing layer's shadowColor. /// A property that accesses the backing layer's shadow
@IBInspectable @IBInspectable
open var shadowColor: UIColor? { open var shadowColor: UIColor? {
get { get {
......
...@@ -98,7 +98,7 @@ open class MenuItem: View { ...@@ -98,7 +98,7 @@ open class MenuItem: View {
private func prepareTitleLabel() { private func prepareTitleLabel() {
titleLabel.font = RobotoFont.regular(with: 14) titleLabel.font = RobotoFont.regular(with: 14)
titleLabel.textAlignment = .center titleLabel.textAlignment = .center
titleLabel.backgroundColor = Color.white titleLabel.backgroundColor = .white
titleLabel.depthPreset = button.depthPreset titleLabel.depthPreset = button.depthPreset
titleLabel.cornerRadiusPreset = .cornerRadius1 titleLabel.cornerRadiusPreset = .cornerRadius1
addSubview(titleLabel) addSubview(titleLabel)
......
...@@ -115,7 +115,7 @@ open class NavigationBar: UINavigationBar { ...@@ -115,7 +115,7 @@ open class NavigationBar: UINavigationBar {
} }
} }
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable @IBInspectable
open override var backgroundColor: UIColor? { open override var backgroundColor: UIColor? {
didSet { didSet {
...@@ -300,7 +300,7 @@ open class NavigationBar: UINavigationBar { ...@@ -300,7 +300,7 @@ open class NavigationBar: UINavigationBar {
The super.prepare method should always be called immediately The super.prepare method should always be called immediately
when subclassing. when subclassing.
*/ */
public func prepare() { open func prepare() {
barStyle = .black barStyle = .black
isTranslucent = false isTranslucent = false
depthPreset = .depth1 depthPreset = .depth1
...@@ -308,10 +308,10 @@ open class NavigationBar: UINavigationBar { ...@@ -308,10 +308,10 @@ open class NavigationBar: UINavigationBar {
contentEdgeInsetsPreset = .square1 contentEdgeInsetsPreset = .square1
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
backButtonImage = Icon.cm.arrowBack backButtonImage = Icon.cm.arrowBack
let image = UIImage.imageWithColor(color: Color.clear, size: CGSize(width: 1, height: 1)) let image = UIImage.image(with: .clear, size: CGSize(width: 1, height: 1))
shadowImage = image shadowImage = image
setBackgroundImage(image, for: .default) setBackgroundImage(image, for: .default)
backgroundColor = Color.white backgroundColor = .white
} }
/** /**
......
...@@ -112,7 +112,7 @@ open class NavigationController: UINavigationController { ...@@ -112,7 +112,7 @@ open class NavigationController: UINavigationController {
*/ */
open func prepare() { open func prepare() {
view.clipsToBounds = true view.clipsToBounds = true
view.backgroundColor = Color.white view.backgroundColor = .white
view.contentScaleFactor = Device.scale view.contentScaleFactor = Device.scale
// This ensures the panning gesture is available when going back between views. // This ensures the panning gesture is available when going back between views.
......
...@@ -975,7 +975,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega ...@@ -975,7 +975,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Prepares the contentViewController. /// Prepares the contentViewController.
private func prepareContentViewController() { private func prepareContentViewController() {
contentViewController.view.backgroundColor = Color.black contentViewController.view.backgroundColor = .black
prepare(viewController: contentViewController, withContainer: view) prepare(viewController: contentViewController, withContainer: view)
view.sendSubview(toBack: contentViewController.view) view.sendSubview(toBack: contentViewController.view)
} }
......
...@@ -48,7 +48,7 @@ open class PhotoLibraryController: UIViewController { ...@@ -48,7 +48,7 @@ open class PhotoLibraryController: UIViewController {
*/ */
open func prepare() { open func prepare() {
view.clipsToBounds = true view.clipsToBounds = true
view.backgroundColor = Color.white view.backgroundColor = .white
view.contentScaleFactor = Device.scale view.contentScaleFactor = Device.scale
preparePhotoLibrary() preparePhotoLibrary()
} }
......
...@@ -34,7 +34,7 @@ internal struct Pulse { ...@@ -34,7 +34,7 @@ internal struct Pulse {
/// An Array of layers. /// An Array of layers.
internal lazy var layers = [CAShapeLayer]() internal lazy var layers = [CAShapeLayer]()
/// A UIColor. /// A UI
internal var color = Color.blueGrey.base internal var color = Color.blueGrey.base
/// A reference to the PulseAnimation. /// A reference to the PulseAnimation.
......
...@@ -42,6 +42,6 @@ open class RaisedButton: Button { ...@@ -42,6 +42,6 @@ open class RaisedButton: Button {
super.prepare() super.prepare()
depthPreset = .depth1 depthPreset = .depth1
cornerRadiusPreset = .cornerRadius1 cornerRadiusPreset = .cornerRadius1
backgroundColor = Color.white backgroundColor = .white
} }
} }
...@@ -152,7 +152,7 @@ open class RootController: UIViewController { ...@@ -152,7 +152,7 @@ open class RootController: UIViewController {
*/ */
open func prepare() { open func prepare() {
view.clipsToBounds = true view.clipsToBounds = true
view.backgroundColor = Color.white view.backgroundColor = .white
view.contentScaleFactor = Device.scale view.contentScaleFactor = Device.scale
prepareRootViewController() prepareRootViewController()
} }
......
...@@ -74,17 +74,17 @@ open class SearchBar: Bar { ...@@ -74,17 +74,17 @@ open class SearchBar: Bar {
@IBInspectable @IBInspectable
open var placeholder: String? { open var placeholder: String? {
didSet { didSet {
if let v: String = placeholder { if let v = placeholder {
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: placeholderColor]) textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: placeholderColor])
} }
} }
} }
/// Placeholder textColor. /// Placeholder text
@IBInspectable @IBInspectable
open var placeholderColor = Color.darkText.others { open var placeholderColor = Color.darkText.others {
didSet { didSet {
if let v: String = placeholder { if let v = placeholder {
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: placeholderColor]) textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: placeholderColor])
} }
} }
......
...@@ -89,7 +89,7 @@ open class Switch: UIControl { ...@@ -89,7 +89,7 @@ open class Switch: UIControl {
/// Indicates if the animation should bounce. /// Indicates if the animation should bounce.
@IBInspectable @IBInspectable
public var bounceable = true { open var bounceable = true {
didSet { didSet {
bounceOffset = bounceable ? 3 : 0 bounceOffset = bounceable ? 3 : 0
} }
...@@ -97,7 +97,7 @@ open class Switch: UIControl { ...@@ -97,7 +97,7 @@ open class Switch: UIControl {
/// Button on color. /// Button on color.
@IBInspectable @IBInspectable
public var buttonOnColor = Color.clear { open var buttonOnColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
...@@ -105,7 +105,7 @@ open class Switch: UIControl { ...@@ -105,7 +105,7 @@ open class Switch: UIControl {
/// Button off color. /// Button off color.
@IBInspectable @IBInspectable
public var buttonOffColor = Color.clear { open var buttonOffColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
...@@ -113,7 +113,7 @@ open class Switch: UIControl { ...@@ -113,7 +113,7 @@ open class Switch: UIControl {
/// Track on color. /// Track on color.
@IBInspectable @IBInspectable
public var trackOnColor = Color.clear { open var trackOnColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
...@@ -121,7 +121,7 @@ open class Switch: UIControl { ...@@ -121,7 +121,7 @@ open class Switch: UIControl {
/// Track off color. /// Track off color.
@IBInspectable @IBInspectable
public var trackOffColor = Color.clear { open var trackOffColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
...@@ -129,7 +129,7 @@ open class Switch: UIControl { ...@@ -129,7 +129,7 @@ open class Switch: UIControl {
/// Button on disabled color. /// Button on disabled color.
@IBInspectable @IBInspectable
public var buttonOnDisabledColor = Color.clear { open var buttonOnDisabledColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
...@@ -137,7 +137,7 @@ open class Switch: UIControl { ...@@ -137,7 +137,7 @@ open class Switch: UIControl {
/// Track on disabled color. /// Track on disabled color.
@IBInspectable @IBInspectable
public var trackOnDisabledColor = Color.clear { open var trackOnDisabledColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
...@@ -145,7 +145,7 @@ open class Switch: UIControl { ...@@ -145,7 +145,7 @@ open class Switch: UIControl {
/// Button off disabled color. /// Button off disabled color.
@IBInspectable @IBInspectable
public var buttonOffDisabledColor = Color.clear { open var buttonOffDisabledColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
...@@ -153,21 +153,21 @@ open class Switch: UIControl { ...@@ -153,21 +153,21 @@ open class Switch: UIControl {
/// Track off disabled color. /// Track off disabled color.
@IBInspectable @IBInspectable
public var trackOffDisabledColor = Color.clear { open var trackOffDisabledColor = Color.clear {
didSet { didSet {
styleForState(state: switchState) styleForState(state: switchState)
} }
} }
/// Track view reference. /// Track view reference.
public private(set) var track: UIView { open private(set) var track: UIView {
didSet { didSet {
prepareTrack() prepareTrack()
} }
} }
/// Button view reference. /// Button view reference.
public private(set) var button: FabButton { open private(set) var button: FabButton {
didSet { didSet {
prepareButton() prepareButton()
} }
......
...@@ -74,7 +74,7 @@ open class TableViewCell: UITableViewCell { ...@@ -74,7 +74,7 @@ open class TableViewCell: UITableViewCell {
} }
} }
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable @IBInspectable
open override var backgroundColor: UIColor? { open override var backgroundColor: UIColor? {
didSet { didSet {
......
...@@ -125,7 +125,7 @@ open class TextField: UITextField { ...@@ -125,7 +125,7 @@ open class TextField: UITextField {
@IBInspectable @IBInspectable
open private(set) var placeholderLabel: UILabel! open private(set) var placeholderLabel: UILabel!
/// Placeholder normal textColor. /// Placeholder normal text
@IBInspectable @IBInspectable
open var placeholderNormalColor = Color.darkText.others { open var placeholderNormalColor = Color.darkText.others {
didSet { didSet {
...@@ -141,7 +141,7 @@ open class TextField: UITextField { ...@@ -141,7 +141,7 @@ open class TextField: UITextField {
} }
} }
/// Placeholder active textColor. /// Placeholder active text
@IBInspectable @IBInspectable
open var placeholderActiveColor = Color.blue.base { open var placeholderActiveColor = Color.blue.base {
didSet { didSet {
...@@ -178,7 +178,7 @@ open class TextField: UITextField { ...@@ -178,7 +178,7 @@ open class TextField: UITextField {
} }
} }
/// Detail textColor. /// Detail text
@IBInspectable @IBInspectable
open var detailColor = Color.darkText.others { open var detailColor = Color.darkText.others {
didSet { didSet {
......
...@@ -35,7 +35,7 @@ public protocol TextViewDelegate : UITextViewDelegate {} ...@@ -35,7 +35,7 @@ public protocol TextViewDelegate : UITextViewDelegate {}
@objc(TextView) @objc(TextView)
public class TextView: UITextView { public class TextView: UITextView {
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable public override var backgroundColor: UIColor? { @IBInspectable public override var backgroundColor: UIColor? {
didSet { didSet {
layer.backgroundColor = backgroundColor?.cgColor layer.backgroundColor = backgroundColor?.cgColor
...@@ -223,7 +223,7 @@ public class TextView: UITextView { ...@@ -223,7 +223,7 @@ public class TextView: UITextView {
public func prepare() { public func prepare() {
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
textContainerInset = .zero textContainerInset = .zero
backgroundColor = Color.white backgroundColor = .white
clipsToBounds = false clipsToBounds = false
removeNotificationHandlers() removeNotificationHandlers()
prepareNotificationHandlers() prepareNotificationHandlers()
...@@ -236,7 +236,7 @@ public class TextView: UITextView { ...@@ -236,7 +236,7 @@ public class TextView: UITextView {
v.font = font v.font = font
v.textAlignment = textAlignment v.textAlignment = textAlignment
v.numberOfLines = 0 v.numberOfLines = 0
v.backgroundColor = Color.clear v.backgroundColor = .clear
addSubview(v) addSubview(v)
reloadView() reloadView()
handleTextViewTextDidChange() handleTextViewTextDidChange()
......
...@@ -116,7 +116,7 @@ open class View: UIView { ...@@ -116,7 +116,7 @@ open class View: UIView {
} }
} }
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's background
@IBInspectable @IBInspectable
open override var backgroundColor: UIColor? { open override var backgroundColor: UIColor? {
didSet { didSet {
......
...@@ -58,28 +58,28 @@ public protocol ColorPalette { ...@@ -58,28 +58,28 @@ public protocol ColorPalette {
open class Color { open class Color {
// clear // clear
open static let clear = NSColor.clear open static let clear = NSclear
// white // white
open static let white = NSColor.white open static let white = NSwhite
// black // black
open static let black = NSColor.black open static let black = NSblack
// dark text // dark text
open class darkText { open class darkText {
open static let primary = Color.black.withAlphaComponent(0.87) open static let primary = black.withAlphaComponent(0.87)
open static let secondary = Color.black.withAlphaComponent(0.54) open static let secondary = black.withAlphaComponent(0.54)
open static let others = Color.black.withAlphaComponent(0.38) open static let others = black.withAlphaComponent(0.38)
open static let dividers = Color.black.withAlphaComponent(0.12) open static let dividers = black.withAlphaComponent(0.12)
} }
// light text // light text
open class lightText { open class lightText {
open static let primary = Color.white open static let primary = white
open static let secondary = Color.white.withAlphaComponent(0.7) open static let secondary = white.withAlphaComponent(0.7)
open static let others = Color.white.withAlphaComponent(0.5) open static let others = white.withAlphaComponent(0.5)
open static let dividers = Color.white.withAlphaComponent(0.12) open static let dividers = white.withAlphaComponent(0.12)
} }
// red // red
......
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