Merge pull request #199 from TerekhovAnton/master

Adds possibility to configure colour of LiveCameraCell, also providing default option
This commit is contained in:
Diego Sánchez 2016-08-12 13:02:27 +01:00 committed by GitHub
commit 0184efc4e3
3 changed files with 33 additions and 4 deletions

View File

@ -27,6 +27,10 @@ import Foundation
import UIKit
import Chatto
public struct LiveCameraCellAppearance {
public var backgroundColor: UIColor
}
class LiveCameraCell: UICollectionViewCell {
private struct Constants {
@ -37,6 +41,12 @@ class LiveCameraCell: UICollectionViewCell {
private var iconImageView: UIImageView!
var appearance: LiveCameraCellAppearance = LiveCameraCellAppearance(backgroundColor: Constants.backgroundColor) {
didSet {
self.contentView.backgroundColor = self.appearance.backgroundColor
}
}
override init(frame: CGRect) {
super.init(frame: frame)
self.commonInit()
@ -49,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? {

View File

@ -33,9 +33,13 @@ public class PhotosChatInputItem: ChatInputItemProtocol {
public weak var presentingController: UIViewController?
let buttonAppearance: TabInputButtonAppearance
public init(presentingController: UIViewController?, tabInputButtonAppearance: TabInputButtonAppearance = Class.createDefaultButtonAppearance()) {
let inputViewAppearance: PhotosInputViewAppearance
public init(presentingController: UIViewController?,
tabInputButtonAppearance: TabInputButtonAppearance = Class.createDefaultButtonAppearance(),
inputViewAppearance: PhotosInputViewAppearance = Class.createDefaultInputViewAppearance()) {
self.presentingController = presentingController
self.buttonAppearance = tabInputButtonAppearance
self.inputViewAppearance = inputViewAppearance
}
public class func createDefaultButtonAppearance() -> TabInputButtonAppearance {
@ -47,12 +51,18 @@ public class PhotosChatInputItem: ChatInputItemProtocol {
return TabInputButtonAppearance(images: images, size: nil)
}
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)
let liveCameraCellAppearence = LiveCameraCellAppearance(backgroundColor: defaultColor)
return PhotosInputViewAppearance(liveCameraCellAppearence: liveCameraCellAppearence)
}
lazy private var internalTabView: UIButton = {
return TabInputButton.makeInputButton(withAppearance: self.buttonAppearance)
}()
lazy var photosInputView: PhotosInputViewProtocol = {
let photosInputView = PhotosInputView(presentingController: self.presentingController)
let photosInputView = PhotosInputView(presentingController: self.presentingController, appearance: self.inputViewAppearance)
photosInputView.delegate = self
return photosInputView
}()

View File

@ -26,6 +26,10 @@ import UIKit
import Photos
import Chatto
public struct PhotosInputViewAppearance {
public var liveCameraCellAppearence: LiveCameraCellAppearance
}
protocol PhotosInputViewProtocol {
weak var delegate: PhotosInputViewDelegate? { get set }
weak var presentingController: UIViewController? { get }
@ -70,9 +74,11 @@ class PhotosInputView: UIView, PhotosInputViewProtocol {
}
weak var presentingController: UIViewController?
init(presentingController: UIViewController?) {
var appearance: PhotosInputViewAppearance?
init(presentingController: UIViewController?, appearance: PhotosInputViewAppearance) {
super.init(frame: CGRect.zero)
self.presentingController = presentingController
self.appearance = appearance
self.commonInit()
}
@ -189,6 +195,9 @@ extension PhotosInputView: UICollectionViewDataSource {
var cell: UICollectionViewCell
if indexPath.item == Constants.liveCameraItemIndex {
let liveCameraCell = collectionView.dequeueReusableCellWithReuseIdentifier("LiveCameraCell", forIndexPath: indexPath) as! LiveCameraCell
if let liveCameraCellAppearence = self.appearance?.liveCameraCellAppearence {
liveCameraCell.appearance = liveCameraCellAppearence
}
self.liveCameraPresenter.cameraAuthorizationStatus = self.cameraAuthorizationStatus
cell = liveCameraCell
} else {