|  |  |  | @ -7,35 +7,53 @@ import Foundation | 
		
	
		
			
				|  |  |  |  | @objc | 
		
	
		
			
				|  |  |  |  | class OWSMessagesBubbleImageFactory: NSObject { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     let jsqFactory = JSQMessagesBubbleImageFactory()! | 
		
	
		
			
				|  |  |  |  |     private let jsqFactory = JSQMessagesBubbleImageFactory()! | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // TODO: UIView is a little bit expensive to instantiate. | 
		
	
		
			
				|  |  |  |  |     //       Can we cache this value? | 
		
	
		
			
				|  |  |  |  |     var isRTL: Bool { | 
		
	
		
			
				|  |  |  |  |     private var isRTL: Bool { | 
		
	
		
			
				|  |  |  |  |         return UIView().isRTL() | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     var incoming: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |     public var incoming: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |         let color = UIColor.jsq_messageBubbleLightGray()! | 
		
	
		
			
				|  |  |  |  |         return incoming(color: color) | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     var outgoing: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |     public var outgoing: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |         let color = UIColor.ows_materialBlue() | 
		
	
		
			
				|  |  |  |  |         return outgoing(color: color) | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     var currentlyOutgoing: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |     public var currentlyOutgoing: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |         let color = UIColor.ows_fadedBlue() | 
		
	
		
			
				|  |  |  |  |         return outgoing(color: color) | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     var outgoingFailed: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |     public var outgoingFailed: JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |         let color = UIColor.gray | 
		
	
		
			
				|  |  |  |  |         return outgoing(color: color) | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     func outgoing(color: UIColor) -> JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |     public func bubble(message: TSMessage) -> JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |         if message is TSIncomingMessage { | 
		
	
		
			
				|  |  |  |  |             return self.incoming | 
		
	
		
			
				|  |  |  |  |         } else if let outgoingMessage = message as? TSOutgoingMessage { | 
		
	
		
			
				|  |  |  |  |             switch outgoingMessage.messageState { | 
		
	
		
			
				|  |  |  |  |             case .unsent: | 
		
	
		
			
				|  |  |  |  |                 return outgoingFailed | 
		
	
		
			
				|  |  |  |  |             case .attemptingOut: | 
		
	
		
			
				|  |  |  |  |                 return currentlyOutgoing | 
		
	
		
			
				|  |  |  |  |             default: | 
		
	
		
			
				|  |  |  |  |                 return outgoing | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |         } else { | 
		
	
		
			
				|  |  |  |  |             owsFail("Unexpected message type: \(message)") | 
		
	
		
			
				|  |  |  |  |             return outgoing | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     private func outgoing(color: UIColor) -> JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |         if isRTL { | 
		
	
		
			
				|  |  |  |  |             return jsqFactory.incomingMessagesBubbleImage(with: color) | 
		
	
		
			
				|  |  |  |  |         } else { | 
		
	
	
		
			
				
					|  |  |  | @ -43,7 +61,7 @@ class OWSMessagesBubbleImageFactory: NSObject { | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     func incoming(color: UIColor) -> JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |     private func incoming(color: UIColor) -> JSQMessagesBubbleImage { | 
		
	
		
			
				|  |  |  |  |         if isRTL { | 
		
	
		
			
				|  |  |  |  |             return jsqFactory.outgoingMessagesBubbleImage(with: color) | 
		
	
		
			
				|  |  |  |  |         } else { | 
		
	
	
		
			
				
					|  |  |  | 
 |