From ed76fe6336f1c560b0cd45a93bd6cb5e951f85ad Mon Sep 17 00:00:00 2001 From: Anton Terehov Date: Fri, 12 Aug 2016 12:00:32 +0100 Subject: [PATCH] Code review comments --- .../Source/Input/Photos/LiveCameraCell.swift | 10 +++++++--- .../Source/Input/Photos/PhotosChatInputItem.swift | 3 ++- .../Source/Input/Photos/PhotosInputView.swift | 9 ++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ChattoAdditions/Source/Input/Photos/LiveCameraCell.swift b/ChattoAdditions/Source/Input/Photos/LiveCameraCell.swift index 1614c37..1b9497a 100644 --- a/ChattoAdditions/Source/Input/Photos/LiveCameraCell.swift +++ b/ChattoAdditions/Source/Input/Photos/LiveCameraCell.swift @@ -27,6 +27,10 @@ import Foundation import UIKit import Chatto +public struct LiveCameraCellAppearance { + public var backgroundColor: UIColor +} + class LiveCameraCell: UICollectionViewCell { private struct Constants { @@ -37,9 +41,9 @@ class LiveCameraCell: UICollectionViewCell { private var iconImageView: UIImageView! - override var backgroundColor: UIColor? { + var appearance: LiveCameraCellAppearance = LiveCameraCellAppearance(backgroundColor: Constants.backgroundColor) { didSet { - self.contentView.backgroundColor = backgroundColor + self.contentView.backgroundColor = self.appearance.backgroundColor } } @@ -55,7 +59,7 @@ class LiveCameraCell: UICollectionViewCell { private func commonInit() { self.configureIcon() - self.contentView.backgroundColor = Constants.backgroundColor + self.contentView.backgroundColor = self.appearance.backgroundColor } var captureLayer: CALayer? { diff --git a/ChattoAdditions/Source/Input/Photos/PhotosChatInputItem.swift b/ChattoAdditions/Source/Input/Photos/PhotosChatInputItem.swift index 6dd8059..a4a1404 100644 --- a/ChattoAdditions/Source/Input/Photos/PhotosChatInputItem.swift +++ b/ChattoAdditions/Source/Input/Photos/PhotosChatInputItem.swift @@ -53,7 +53,8 @@ public class PhotosChatInputItem: ChatInputItemProtocol { public class func createDefaultInputViewAppearance() -> PhotosInputViewAppearance { let defaultColor = UIColor(red: 24.0/255.0, green: 101.0/255.0, blue: 245.0/255.0, alpha: 1) - return PhotosInputViewAppearance(color: defaultColor) + let liveCameraCellAppearence = LiveCameraCellAppearance(backgroundColor: defaultColor) + return PhotosInputViewAppearance(liveCameraCellAppearence: liveCameraCellAppearence) } lazy private var internalTabView: UIButton = { diff --git a/ChattoAdditions/Source/Input/Photos/PhotosInputView.swift b/ChattoAdditions/Source/Input/Photos/PhotosInputView.swift index 2324b24..c7cee75 100644 --- a/ChattoAdditions/Source/Input/Photos/PhotosInputView.swift +++ b/ChattoAdditions/Source/Input/Photos/PhotosInputView.swift @@ -27,10 +27,7 @@ import Photos import Chatto public struct PhotosInputViewAppearance { - public var color: UIColor - public init(color: UIColor) { - self.color = color - } + public var liveCameraCellAppearence: LiveCameraCellAppearance } protocol PhotosInputViewProtocol { @@ -198,7 +195,9 @@ extension PhotosInputView: UICollectionViewDataSource { var cell: UICollectionViewCell if indexPath.item == Constants.liveCameraItemIndex { let liveCameraCell = collectionView.dequeueReusableCellWithReuseIdentifier("LiveCameraCell", forIndexPath: indexPath) as! LiveCameraCell - liveCameraCell.backgroundColor = self.appearance?.color + if let liveCameraCellAppearence = self.appearance?.liveCameraCellAppearence { + liveCameraCell.appearance = liveCameraCellAppearence + } self.liveCameraPresenter.cameraAuthorizationStatus = self.cameraAuthorizationStatus cell = liveCameraCell } else {