mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
Swift
36 lines
1.0 KiB
Swift
5 years ago
|
|
||
|
@objc(LKGradient)
|
||
|
public final class Gradient : NSObject {
|
||
|
public let start: UIColor
|
||
|
public let end: UIColor
|
||
|
|
||
|
private override init() { preconditionFailure("Use init(start:end:) instead.") }
|
||
|
|
||
|
@objc public init(start: UIColor, end: UIColor) {
|
||
|
self.start = start
|
||
|
self.end = end
|
||
|
super.init()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@objc public extension UIView {
|
||
|
|
||
|
@objc public func setGradient(_ gradient: Gradient) {
|
||
|
let layer = CAGradientLayer()
|
||
|
layer.frame = UIScreen.main.bounds
|
||
|
layer.colors = [ gradient.start.cgColor, gradient.end.cgColor ]
|
||
|
self.layer.insertSublayer(layer, at: 0)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@objc(LKGradients)
|
||
|
final public class Gradients : NSObject {
|
||
|
|
||
|
@objc public static var defaultLokiBackground: Gradient {
|
||
|
switch AppMode.current {
|
||
|
case .light: return Gradient(start: UIColor(hex: 0xFCFCFC), end: UIColor(hex: 0xFFFFFF))
|
||
|
case .dark: return Gradient(start: UIColor(hex: 0x171717), end: UIColor(hex: 0x121212))
|
||
|
}
|
||
|
}
|
||
|
}
|