From 2c5b065d5cb62bf792443ae244aaaa07b163194e Mon Sep 17 00:00:00 2001 From: Diego Sanchez Date: Mon, 21 Mar 2016 13:08:07 +0000 Subject: [PATCH 1/4] Improvements for custom styling - Allows reusing default styles by injecting parameters - Insets and fonts for input component --- .../Views/BaseMessageCollectionViewCell.swift | 2 +- ...essageCollectionViewCellDefaultStyle.swift | 157 ++++++++++++++---- ...essageCollectionViewCellDefaultStyle.swift | 72 +++++--- ...essageCollectionViewCellDefaultStyle.swift | 92 ++++++++-- .../Source/Input/ChatInputBar.swift | 5 + ChattoAdditions/Source/Input/ChatInputBar.xib | 19 ++- .../Source/Input/ChatInputBarAppearance.swift | 6 +- .../Source/Input/ChatInputBarPresenter.swift | 5 +- .../Source/Input/ExpandableTextView.swift | 4 +- .../Input/Photos/PhotosChatInputItem.swift | 37 ++++- .../Source/Input/Text/TextChatInputItem.swift | 24 ++- 11 files changed, 332 insertions(+), 91 deletions(-) diff --git a/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCell.swift b/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCell.swift index e5b993c07..cd9de1962 100644 --- a/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCell.swift +++ b/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCell.swift @@ -26,7 +26,7 @@ import UIKit import Chatto public protocol BaseMessageCollectionViewCellStyleProtocol { - func avatarSize(viewModel viewModel: MessageViewModelProtocol) -> CGSize + func avatarSize(viewModel viewModel: MessageViewModelProtocol) -> CGSize // .zero => no avatar func avatarVerticalAlignment(viewModel viewModel: MessageViewModelProtocol) -> VerticalAlignment var failedIcon: UIImage { get } var failedIconHighlighted: UIImage { get } diff --git a/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCellDefaultStyle.swift b/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCellDefaultStyle.swift index cf26e2026..d43b54f90 100644 --- a/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCellDefaultStyle.swift +++ b/ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCellDefaultStyle.swift @@ -26,45 +26,110 @@ import UIKit public class BaseMessageCollectionViewCellDefaultStyle: BaseMessageCollectionViewCellStyleProtocol { - public init () {} + typealias Class = BaseMessageCollectionViewCellDefaultStyle + + public struct Colors { + let incoming: () -> UIColor + let outgoing: () -> UIColor + public init( + @autoclosure(escaping) incoming: () -> UIColor, + @autoclosure(escaping) outgoing: () -> UIColor) { + self.incoming = incoming + self.outgoing = outgoing + } + } - lazy var baseColorIncoming = UIColor.bma_color(rgb: 0xE6ECF2) - lazy var baseColorOutgoing = UIColor.bma_color(rgb: 0x3D68F5) + public struct BubbleBorderImages { + let borderIncomingTail: () -> UIImage + let borderIncomingNoTail: () -> UIImage + let borderOutgoingTail: () -> UIImage + let borderOutgoingNoTail: () -> UIImage + public init( + @autoclosure(escaping) borderIncomingTail: () -> UIImage, + @autoclosure(escaping) borderIncomingNoTail: () -> UIImage, + @autoclosure(escaping) borderOutgoingTail: () -> UIImage, + @autoclosure(escaping) borderOutgoingNoTail: () -> UIImage) { + self.borderIncomingTail = borderIncomingTail + self.borderIncomingNoTail = borderIncomingNoTail + self.borderOutgoingTail = borderOutgoingTail + self.borderOutgoingNoTail = borderOutgoingNoTail + } + } - lazy var borderIncomingTail: UIImage = { - return UIImage(named: "bubble-incoming-border-tail", inBundle: NSBundle(forClass: BaseMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() + public struct FailedIconImages { + let normal: () -> UIImage + let highlighted: () -> UIImage + public init( + @autoclosure(escaping) normal: () -> UIImage, + @autoclosure(escaping) highlighted: () -> UIImage) { + self.normal = normal + self.highlighted = highlighted + } + } - lazy var borderIncomingNoTail: UIImage = { - return UIImage(named: "bubble-incoming-border", inBundle: NSBundle(forClass: BaseMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() + public struct DateTextStyle { + let font: () -> UIFont + let color: () -> UIColor + public init( + @autoclosure(escaping) font: () -> UIFont, + @autoclosure(escaping) color: () -> UIColor) { + self.font = font + self.color = color + } + } - lazy var borderOutgoingTail: UIImage = { - return UIImage(named: "bubble-outgoing-border-tail", inBundle: NSBundle(forClass: BaseMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() + public struct AvatarStyle { + let size: CGSize + let alignment: VerticalAlignment + public init(size: CGSize = .zero, alignment: VerticalAlignment = .Bottom) { + self.size = size + self.alignment = alignment + } + } - lazy var borderOutgoingNoTail: UIImage = { - return UIImage(named: "bubble-outgoing-border", inBundle: NSBundle(forClass: BaseMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() + let colors: Colors + let bubbleBorderImages: BubbleBorderImages + let failedIconImages: FailedIconImages + let layoutConstants: BaseMessageCollectionViewCellLayoutConstants + let dateTextStyle: DateTextStyle + let avatarStyle: AvatarStyle + public init ( + colors: Colors = Class.createDefaultColors(), + bubbleBorderImages: BubbleBorderImages = Class.createDefaultBubbleBorderImages(), + failedIconImages: FailedIconImages = Class.createDefaultFailedIconImages(), + layoutConstants: BaseMessageCollectionViewCellLayoutConstants = Class.createDefaultLayoutConstants(), + dateTextStyle: DateTextStyle = Class.createDefaultDateTextStyle(), + avatarStyle: AvatarStyle = AvatarStyle()) { + self.colors = colors + self.bubbleBorderImages = bubbleBorderImages + self.failedIconImages = failedIconImages + self.layoutConstants = layoutConstants + self.dateTextStyle = dateTextStyle + self.avatarStyle = avatarStyle + } - public lazy var failedIcon: UIImage = { - return UIImage(named: "base-message-failed-icon", inBundle: NSBundle(forClass: BaseMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() + public lazy var baseColorIncoming: UIColor = self.colors.incoming() + public lazy var baseColorOutgoing: UIColor = self.colors.outgoing() - public lazy var failedIconHighlighted: UIImage = { - return self.failedIcon.bma_blendWithColor(UIColor.blackColor().colorWithAlphaComponent(0.10)) - }() + public lazy var borderIncomingTail: UIImage = self.bubbleBorderImages.borderIncomingTail() + public lazy var borderIncomingNoTail: UIImage = self.bubbleBorderImages.borderIncomingNoTail() + public lazy var borderOutgoingTail: UIImage = self.bubbleBorderImages.borderOutgoingTail() + public lazy var borderOutgoingNoTail: UIImage = self.bubbleBorderImages.borderOutgoingNoTail() - private lazy var dateFont = { - return UIFont.systemFontOfSize(12.0) - }() + public lazy var failedIcon: UIImage = self.failedIconImages.normal() + public lazy var failedIconHighlighted: UIImage = self.failedIconImages.highlighted() + private lazy var dateFont: UIFont = self.dateTextStyle.font() + private lazy var dateFontColor: UIColor = self.dateTextStyle.color() public func attributedStringForDate(date: String) -> NSAttributedString { - let attributes = [NSFontAttributeName : self.dateFont] + let attributes = [ + NSFontAttributeName : self.dateFont, + NSForegroundColorAttributeName: self.dateFontColor + ] return NSAttributedString(string: date, attributes: attributes) } - func borderImage(viewModel viewModel: MessageViewModelProtocol) -> UIImage? { + public func borderImage(viewModel viewModel: MessageViewModelProtocol) -> UIImage? { switch (viewModel.isIncoming, viewModel.showsTail) { case (true, true): return self.borderIncomingTail @@ -77,18 +142,48 @@ public class BaseMessageCollectionViewCellDefaultStyle: BaseMessageCollectionVie } } - // Override this method to provide a size of avatarImage, so avatar image will be displayed if there is any in the viewModel - // if no image, then no avatar will be displayed, and a blank space will placehold at the position public func avatarSize(viewModel viewModel: MessageViewModelProtocol) -> CGSize { - return CGSize.zero + return self.avatarStyle.size } - // Specify the vertical alignment of the avatar image in the cell. By Default it is Botton, can go Top or Center public func avatarVerticalAlignment(viewModel viewModel: MessageViewModelProtocol) -> VerticalAlignment { - return VerticalAlignment.Bottom + return self.avatarStyle.alignment } public func layoutConstants(viewModel viewModel: MessageViewModelProtocol) -> BaseMessageCollectionViewCellLayoutConstants { + return self.layoutConstants + } +} + +public extension BaseMessageCollectionViewCellDefaultStyle { // Default values + static public func createDefaultColors() -> Colors { + return Colors(incoming: UIColor.bma_color(rgb: 0xE6ECF2), outgoing: UIColor.bma_color(rgb: 0x3D68F5)) + } + + static public func createDefaultBubbleBorderImages() -> BubbleBorderImages { + return BubbleBorderImages( + borderIncomingTail: UIImage(named: "bubble-incoming-border-tail", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + borderIncomingNoTail: UIImage(named: "bubble-incoming-border", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + borderOutgoingTail: UIImage(named: "bubble-outgoing-border-tail", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + borderOutgoingNoTail: UIImage(named: "bubble-outgoing-border", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)! + ) + } + + static public func createDefaultFailedIconImages() -> FailedIconImages { + let normal = { + return UIImage(named: "base-message-failed-icon", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)! + } + return FailedIconImages( + normal: normal(), + highlighted: normal().bma_blendWithColor(UIColor.blackColor().colorWithAlphaComponent(0.10)) + ) + } + + static public func createDefaultDateTextStyle() -> DateTextStyle { + return DateTextStyle(font: UIFont.systemFontOfSize(12), color: UIColor.bma_color(rgb: 0x9aa3ab)) + } + + static public func createDefaultLayoutConstants() -> BaseMessageCollectionViewCellLayoutConstants { return BaseMessageCollectionViewCellLayoutConstants(horizontalMargin: 11, horizontalInterspacing: 4, maxContainerWidthPercentageForBubbleView: 0.68) } } diff --git a/ChattoAdditions/Source/Chat Items/PhotoMessages/Views/PhotoMessageCollectionViewCellDefaultStyle.swift b/ChattoAdditions/Source/Chat Items/PhotoMessages/Views/PhotoMessageCollectionViewCellDefaultStyle.swift index 30a3057e7..35bed9a07 100644 --- a/ChattoAdditions/Source/Chat Items/PhotoMessages/Views/PhotoMessageCollectionViewCellDefaultStyle.swift +++ b/ChattoAdditions/Source/Chat Items/PhotoMessages/Views/PhotoMessageCollectionViewCellDefaultStyle.swift @@ -25,40 +25,53 @@ import UIKit public class PhotoMessageCollectionViewCellDefaultStyle: PhotoMessageCollectionViewCellStyleProtocol { + typealias Class = PhotoMessageCollectionViewCellDefaultStyle + + public struct BubbleMasks { + let incomingTail: () -> UIImage + let incomingNoTail: () -> UIImage + let outgoingTail: () -> UIImage + let outgoingNoTail: () -> UIImage + let tailWidth: CGFloat + public init( + @autoclosure(escaping) incomingTail: () -> UIImage, + @autoclosure(escaping) incomingNoTail: () -> UIImage, + @autoclosure(escaping) outgoingTail: () -> UIImage, + @autoclosure(escaping) outgoingNoTail: () -> UIImage, + tailWidth: CGFloat) { + self.incomingTail = incomingTail + self.incomingNoTail = incomingNoTail + self.outgoingTail = outgoingTail + self.outgoingNoTail = outgoingNoTail + self.tailWidth = tailWidth + } + } + + let bubbleMasks: BubbleMasks + let baseStyle: BaseMessageCollectionViewCellDefaultStyle + public init(bubbleMasks: BubbleMasks = Class.createDefaultBubbleMasks(), baseStyle: BaseMessageCollectionViewCellDefaultStyle = BaseMessageCollectionViewCellDefaultStyle()) { + self.bubbleMasks = bubbleMasks + self.baseStyle = baseStyle + } - public init() { } - private struct Constants { - let tailWidth: CGFloat = 6.0 let aspectRatioIntervalForSquaredSize: ClosedInterval = 0.90...1.10 let photoSizeLandscape = CGSize(width: 210, height: 136) let photoSizePortratit = CGSize(width: 136, height: 210) let photoSizeSquare = CGSize(width: 210, height: 210) let placeholderIconTintIncoming = UIColor.bma_color(rgb: 0xced6dc) - let placeholderIconTintOugoing = UIColor.bma_color(rgb: 0x508dfc) + let placeholderIconTintOutgoing = UIColor.bma_color(rgb: 0x508dfc) let progressIndicatorColorIncoming = UIColor.bma_color(rgb: 0x98a3ab) let progressIndicatorColorOutgoing = UIColor.whiteColor() let overlayColor = UIColor.blackColor().colorWithAlphaComponent(0.70) } lazy private var styleConstants = Constants() - lazy private var baseStyle = BaseMessageCollectionViewCellDefaultStyle() - lazy private var maskImageIncomingTail: UIImage = { - return UIImage(named: "bubble-incoming-tail", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() - - lazy private var maskImageIncomingNoTail: UIImage = { - return UIImage(named: "bubble-incoming", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() - - lazy private var maskImageOutgoingTail: UIImage = { - return UIImage(named: "bubble-outgoing-tail", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() - - lazy private var maskImageOutgoingNoTail: UIImage = { - return UIImage(named: "bubble-outgoing", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! - }() + lazy private var maskImageIncomingTail: UIImage = self.bubbleMasks.incomingTail() + lazy private var maskImageIncomingNoTail: UIImage = self.bubbleMasks.incomingNoTail() + lazy private var maskImageOutgoingTail: UIImage = self.bubbleMasks.outgoingTail() + lazy private var maskImageOutgoingNoTail: UIImage = self.bubbleMasks.outgoingNoTail() lazy private var placeholderBackgroundIncoming: UIImage = { return UIImage.bma_imageWithColor(self.baseStyle.baseColorIncoming, size: CGSize(width: 1, height: 1)) @@ -69,7 +82,7 @@ public class PhotoMessageCollectionViewCellDefaultStyle: PhotoMessageCollectionV }() lazy private var placeholderIcon: UIImage = { - return UIImage(named: "photo-bubble-placeholder-icon", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)! + return UIImage(named: "photo-bubble-placeholder-icon", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)! }() public func maskingImage(viewModel viewModel: PhotoMessageViewModelProtocol) -> UIImage { @@ -95,14 +108,14 @@ public class PhotoMessageCollectionViewCellDefaultStyle: PhotoMessageCollectionV public func placeholderIconImage(viewModel viewModel: PhotoMessageViewModelProtocol) -> (icon: UIImage?, tintColor: UIColor?) { if viewModel.image.value == nil && viewModel.transferStatus.value == .Failed { - let tintColor = viewModel.isIncoming ? self.styleConstants.placeholderIconTintIncoming : self.styleConstants.placeholderIconTintOugoing + let tintColor = viewModel.isIncoming ? self.styleConstants.placeholderIconTintIncoming : self.styleConstants.placeholderIconTintOutgoing return (self.placeholderIcon, tintColor) } return (nil, nil) } public func tailWidth(viewModel viewModel: PhotoMessageViewModelProtocol) -> CGFloat { - return self.styleConstants.tailWidth + return self.bubbleMasks.tailWidth } public func bubbleSize(viewModel viewModel: PhotoMessageViewModelProtocol) -> CGSize { @@ -127,3 +140,16 @@ public class PhotoMessageCollectionViewCellDefaultStyle: PhotoMessageCollectionV } } + +public extension PhotoMessageCollectionViewCellDefaultStyle { // Default values + + static public func createDefaultBubbleMasks() -> BubbleMasks { + return BubbleMasks( + incomingTail: UIImage(named: "bubble-incoming-tail", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + incomingNoTail: UIImage(named: "bubble-incoming", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + outgoingTail: UIImage(named: "bubble-outgoing-tail", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + outgoingNoTail: UIImage(named: "bubble-outgoing", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + tailWidth: 6 + ) + } +} diff --git a/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift b/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift index 2ee1046a9..d89705dbe 100644 --- a/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift +++ b/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift @@ -25,33 +25,81 @@ import UIKit public class TextMessageCollectionViewCellDefaultStyle: TextMessageCollectionViewCellStyleProtocol { + typealias Class = TextMessageCollectionViewCellDefaultStyle + + public struct BubbleImages { + let incomingTail: () -> UIImage + let incomingNoTail: () -> UIImage + let outgoingTail: () -> UIImage + let outgoingNoTail: () -> UIImage + public init( + @autoclosure(escaping) incomingTail: () -> UIImage, + @autoclosure(escaping) incomingNoTail: () -> UIImage, + @autoclosure(escaping) outgoingTail: () -> UIImage, + @autoclosure(escaping) outgoingNoTail: () -> UIImage) { + self.incomingTail = incomingTail + self.incomingNoTail = incomingNoTail + self.outgoingTail = outgoingTail + self.outgoingNoTail = outgoingNoTail + } + } - public init () {} + public struct TextStyle { + let font: () -> UIFont + let incomingColor: () -> UIColor + let outgoingColor: () -> UIColor + let incomingInsets: UIEdgeInsets + let outgoingInsets: UIEdgeInsets + public init( + @autoclosure(escaping) font: () -> UIFont, + @autoclosure(escaping) incomingColor: () -> UIColor, + @autoclosure(escaping) outgoingColor: () -> UIColor, + incomingInsets: UIEdgeInsets, + outgoingInsets: UIEdgeInsets) { + self.font = font + self.incomingColor = incomingColor + self.outgoingColor = outgoingColor + self.incomingInsets = incomingInsets + self.outgoingInsets = outgoingInsets + } + } + + let bubbleImages: BubbleImages + let textStyle: TextStyle + let baseStyle: BaseMessageCollectionViewCellDefaultStyle + + public init ( + bubbleImages: BubbleImages = Class.createDefaultBubbleImages(), + textStyle: TextStyle = Class.createDefaultTextStyle(), + baseStyle: BaseMessageCollectionViewCellDefaultStyle = BaseMessageCollectionViewCellDefaultStyle()) { + self.bubbleImages = bubbleImages + self.textStyle = textStyle + self.baseStyle = baseStyle + } - lazy var baseStyle = BaseMessageCollectionViewCellDefaultStyle() lazy var images: [String: UIImage] = { return [ - "incoming_tail" : UIImage(named: "bubble-incoming-tail", inBundle: NSBundle(forClass: TextMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!, - "incoming_notail" : UIImage(named: "bubble-incoming", inBundle: NSBundle(forClass: TextMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!, - "outgoing_tail" : UIImage(named: "bubble-outgoing-tail", inBundle: NSBundle(forClass: TextMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!, - "outgoing_notail" : UIImage(named: "bubble-outgoing", inBundle: NSBundle(forClass: TextMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!, + "incoming_tail" : self.bubbleImages.incomingTail(), + "incoming_notail" : self.bubbleImages.incomingNoTail(), + "outgoing_tail" : self.bubbleImages.outgoingTail(), + "outgoing_notail" : self.bubbleImages.outgoingNoTail() ] }() - lazy var font = { - return UIFont.systemFontOfSize(16) - }() + lazy var font: UIFont = self.textStyle.font() + lazy var incomingColor: UIColor = self.textStyle.incomingColor() + lazy var outgoingColor: UIColor = self.textStyle.outgoingColor() public func textFont(viewModel viewModel: TextMessageViewModelProtocol, isSelected: Bool) -> UIFont { return self.font } public func textColor(viewModel viewModel: TextMessageViewModelProtocol, isSelected: Bool) -> UIColor { - return viewModel.isIncoming ? UIColor.blackColor() : UIColor.whiteColor() + return viewModel.isIncoming ? self.incomingColor : self.outgoingColor } public func textInsets(viewModel viewModel: TextMessageViewModelProtocol, isSelected: Bool) -> UIEdgeInsets { - return viewModel.isIncoming ? UIEdgeInsets(top: 10, left: 19, bottom: 10, right: 15) : UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 19) + return viewModel.isIncoming ? self.textStyle.incomingInsets : self.textStyle.outgoingInsets } public func bubbleImageBorder(viewModel viewModel: TextMessageViewModelProtocol, isSelected: Bool) -> UIImage? { @@ -119,3 +167,25 @@ public class TextMessageCollectionViewCellDefaultStyle: TextMessageCollectionVie } } } + +public extension TextMessageCollectionViewCellDefaultStyle { // Default values + + static public func createDefaultBubbleImages() -> BubbleImages { + return BubbleImages( + incomingTail: UIImage(named: "bubble-incoming-tail", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + incomingNoTail: UIImage(named: "bubble-incoming", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + outgoingTail: UIImage(named: "bubble-outgoing-tail", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)!, + outgoingNoTail: UIImage(named: "bubble-outgoing", inBundle: NSBundle(forClass: Class.self), compatibleWithTraitCollection: nil)! + ) + } + + static public func createDefaultTextStyle() -> TextStyle { + return TextStyle( + font: UIFont.systemFontOfSize(16), + incomingColor: UIColor.blackColor(), + outgoingColor: UIColor.whiteColor(), + incomingInsets: UIEdgeInsets(top: 10, left: 19, bottom: 10, right: 15), + outgoingInsets: UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 19) + ) + } +} diff --git a/ChattoAdditions/Source/Input/ChatInputBar.swift b/ChattoAdditions/Source/Input/ChatInputBar.swift index 76e1f6d02..68b20adc9 100644 --- a/ChattoAdditions/Source/Input/ChatInputBar.swift +++ b/ChattoAdditions/Source/Input/ChatInputBar.swift @@ -168,10 +168,15 @@ extension ChatInputBar { public func setAppearance(appearance: ChatInputBarAppearance) { self.textView.font = appearance.textFont self.textView.textColor = appearance.textColor + self.textView.textContainerInset = appearance.textInsets self.textView.setTextPlaceholderFont(appearance.textPlaceholderFont) self.textView.setTextPlaceholderColor(appearance.textPlaceholderColor) self.textView.setTextPlaceholder(appearance.textPlaceholder) + self.tabBarInterItemSpacing = appearance.tabBarInterItemSpacing + self.tabBarContentInsets = appearance.tabBarInsets + self.sendButton.contentEdgeInsets = appearance.sendButtonInsets self.sendButton.setTitle(appearance.sendButtonTitle, forState: .Normal) + self.sendButton.titleLabel?.font = appearance.sendButtonFont } } diff --git a/ChattoAdditions/Source/Input/ChatInputBar.xib b/ChattoAdditions/Source/Input/ChatInputBar.xib index 6877956da..de17f85d6 100644 --- a/ChattoAdditions/Source/Input/ChatInputBar.xib +++ b/ChattoAdditions/Source/Input/ChatInputBar.xib @@ -1,17 +1,17 @@ - + - + - + - + @@ -20,12 +20,13 @@ - + -