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.
		
		
		
		
		
			
		
			
	
	
		
			48 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			48 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Swift
		
	
| 
											5 years ago
										 | import UIKit | ||
| 
											6 years ago
										 | 
 | ||
|  | @objc(LKGradient) | ||
|  | public final class Gradient : NSObject { | ||
|  |     public let start: UIColor | ||
|  |     public let end: UIColor | ||
| 
											6 years ago
										 | 
 | ||
| 
											6 years ago
										 |     private override init() { preconditionFailure("Use init(start:end:) instead.") } | ||
| 
											6 years ago
										 | 
 | ||
| 
											6 years ago
										 |     @objc public init(start: UIColor, end: UIColor) { | ||
|  |         self.start = start | ||
|  |         self.end = end | ||
|  |         super.init() | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | @objc public extension UIView { | ||
| 
											6 years ago
										 | 
 | ||
| 
											6 years ago
										 |     @objc func setGradient(_ gradient: Gradient) { | ||
| 
											6 years ago
										 |         let layer = CAGradientLayer() | ||
|  |         layer.frame = UIScreen.main.bounds | ||
|  |         layer.colors = [ gradient.start.cgColor, gradient.end.cgColor ] | ||
| 
											5 years ago
										 |         if let existingSublayer = self.layer.sublayers?[0], existingSublayer is CAGradientLayer { | ||
| 
											5 years ago
										 |             self.layer.replaceSublayer(existingSublayer, with: layer) | ||
|  |         } else { | ||
|  |             self.layer.insertSublayer(layer, at: 0) | ||
|  |         } | ||
| 
											6 years ago
										 |     } | ||
|  | } | ||
|  | 
 | ||
|  | @objc(LKGradients) | ||
|  | final public class Gradients : NSObject { | ||
| 
											6 years ago
										 | 
 | ||
| 
											6 years ago
										 |     @objc public static var defaultLokiBackground: Gradient { | ||
| 
											5 years ago
										 |         switch AppModeManager.shared.currentAppMode { | ||
| 
											6 years ago
										 |         case .light: return Gradient(start: UIColor(hex: 0xFCFCFC), end: UIColor(hex: 0xFFFFFF)) | ||
|  |         case .dark: return Gradient(start: UIColor(hex: 0x171717), end: UIColor(hex: 0x121212)) | ||
|  |         } | ||
|  |     } | ||
| 
											6 years ago
										 | 
 | ||
| 
											6 years ago
										 |     @objc public static var homeVCFade: Gradient { | ||
| 
											5 years ago
										 |         switch AppModeManager.shared.currentAppMode { | ||
| 
											6 years ago
										 |         case .light: return Gradient(start: UIColor(hex: 0xFFFFFF).withAlphaComponent(0), end: UIColor(hex: 0xFFFFFF)) | ||
|  |         case .dark: return Gradient(start: UIColor(hex: 0x000000).withAlphaComponent(0), end: UIColor(hex: 0x000000)) | ||
|  |         } | ||
|  |     } | ||
| 
											6 years ago
										 | } |