mirror of https://github.com/oxen-io/session-ios
Merge branch 'charlesmchen/tweakColors'
commit
1a7cc3acb4
@ -0,0 +1,71 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SignalServiceKit
|
||||||
|
|
||||||
|
// TODO: Possibly pull this into Conversation Style.
|
||||||
|
@objc
|
||||||
|
public class OWSMessagesBubbleColors: NSObject {
|
||||||
|
|
||||||
|
override private init() {
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public static let shared = OWSMessagesBubbleColors()
|
||||||
|
|
||||||
|
// TODO: Remove this! Incoming bubble colors are now dynamic.
|
||||||
|
@objc
|
||||||
|
public static let bubbleColorIncoming = UIColor.ows_messageBubbleLightGray
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
@objc
|
||||||
|
public static let bubbleColorOutgoingUnsent = UIColor.ows_red
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
@objc
|
||||||
|
public static let bubbleColorOutgoingSending = UIColor.ows_light35
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public static let bubbleColorOutgoingSent = UIColor.ows_light10
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public static func bubbleColor(message: TSMessage) -> UIColor {
|
||||||
|
if message is TSIncomingMessage {
|
||||||
|
return OWSMessagesBubbleColors.bubbleColorIncoming
|
||||||
|
} else if let outgoingMessage = message as? TSOutgoingMessage {
|
||||||
|
switch outgoingMessage.messageState {
|
||||||
|
case .failed:
|
||||||
|
return OWSMessagesBubbleColors.bubbleColorOutgoingUnsent
|
||||||
|
case .sending:
|
||||||
|
return OWSMessagesBubbleColors.bubbleColorOutgoingSending
|
||||||
|
default:
|
||||||
|
return OWSMessagesBubbleColors.bubbleColorOutgoingSent
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
owsFail("Unexpected message type: \(message)")
|
||||||
|
return UIColor.ows_materialBlue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public static func bubbleTextColor(message: TSMessage) -> UIColor {
|
||||||
|
if message is TSIncomingMessage {
|
||||||
|
return UIColor.ows_white
|
||||||
|
} else if let outgoingMessage = message as? TSOutgoingMessage {
|
||||||
|
switch outgoingMessage.messageState {
|
||||||
|
case .failed:
|
||||||
|
return UIColor.ows_black
|
||||||
|
case .sending:
|
||||||
|
return UIColor.ows_black
|
||||||
|
default:
|
||||||
|
return UIColor.ows_black
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
owsFail("Unexpected message type: \(message)")
|
||||||
|
return UIColor.ows_materialBlue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import SignalServiceKit
|
|
||||||
|
|
||||||
@objc
|
|
||||||
public class OWSMessagesBubbleImageFactory: NSObject {
|
|
||||||
|
|
||||||
@objc
|
|
||||||
public static let shared = OWSMessagesBubbleImageFactory()
|
|
||||||
|
|
||||||
// TODO: UIView is a little bit expensive to instantiate.
|
|
||||||
// Can we cache this value?
|
|
||||||
private lazy var isRTL: Bool = {
|
|
||||||
return UIView().isRTL()
|
|
||||||
}()
|
|
||||||
|
|
||||||
@objc
|
|
||||||
public static let bubbleColorIncoming = UIColor.ows_messageBubbleLightGray
|
|
||||||
|
|
||||||
@objc
|
|
||||||
public static let bubbleColorOutgoingUnsent = UIColor.gray
|
|
||||||
|
|
||||||
@objc
|
|
||||||
public static let bubbleColorOutgoingSending = UIColor.ows_fadedBlue
|
|
||||||
|
|
||||||
@objc
|
|
||||||
public static let bubbleColorOutgoingSent = UIColor.ows_materialBlue
|
|
||||||
|
|
||||||
@objc
|
|
||||||
public func bubbleColor(message: TSMessage) -> UIColor {
|
|
||||||
if message is TSIncomingMessage {
|
|
||||||
return OWSMessagesBubbleImageFactory.bubbleColorIncoming
|
|
||||||
} else if let outgoingMessage = message as? TSOutgoingMessage {
|
|
||||||
switch outgoingMessage.messageState {
|
|
||||||
case .failed:
|
|
||||||
return OWSMessagesBubbleImageFactory.bubbleColorOutgoingUnsent
|
|
||||||
case .sending:
|
|
||||||
return OWSMessagesBubbleImageFactory.bubbleColorOutgoingSending
|
|
||||||
default:
|
|
||||||
return OWSMessagesBubbleImageFactory.bubbleColorOutgoingSent
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
owsFail("Unexpected message type: \(message)")
|
|
||||||
return UIColor.ows_materialBlue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue