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.
		
		
		
		
		
			
		
			
	
	
		
			61 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			61 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Swift
		
	
| 
											5 years ago
										 | import Foundation | ||
| 
											6 years ago
										 | 
 | ||
| 
											5 years ago
										 | @objc(LKAppModeManager) | ||
|  | public final class AppModeManager : NSObject { | ||
|  |     private let delegate: AppModeManagerDelegate | ||
|  | 
 | ||
|  |     public var currentAppMode: AppMode { | ||
|  |         return delegate.getCurrentAppMode() | ||
|  |     } | ||
|  | 
 | ||
|  |     public static var shared: AppModeManager! | ||
|  | 
 | ||
|  |     @objc(configureWithDelegate:) | ||
|  |     public static func configure(delegate: AppModeManagerDelegate) { | ||
|  |         shared = AppModeManager(delegate: delegate) | ||
|  |     } | ||
|  | 
 | ||
|  |     private init(delegate: AppModeManagerDelegate) { | ||
|  |         self.delegate = delegate | ||
|  |         super.init() | ||
|  |     } | ||
|  | 
 | ||
|  |     private override init() { preconditionFailure("Use init(delegate:) instead.") } | ||
|  | 
 | ||
|  |     public func setCurrentAppMode(to appMode: AppMode) { | ||
|  |         delegate.setCurrentAppMode(to: appMode) | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | @objc(LKAppModeManagerDelegate) | ||
|  | public protocol AppModeManagerDelegate { | ||
|  | 
 | ||
|  |     func getCurrentAppMode() -> AppMode | ||
| 
											5 years ago
										 |     @objc(setCurrentAppMode:) | ||
| 
											5 years ago
										 |     func setCurrentAppMode(to appMode: AppMode) | ||
|  | } | ||
|  | 
 | ||
|  | @objc(LKAppMode) | ||
|  | public enum AppMode : Int { | ||
| 
											6 years ago
										 |     case light, dark | ||
|  | } | ||
|  | 
 | ||
|  | public var isLightMode: Bool { | ||
| 
											5 years ago
										 |     return AppModeManager.shared.currentAppMode == .light | ||
| 
											6 years ago
										 | } | ||
| 
											6 years ago
										 | 
 | ||
|  | public var isDarkMode: Bool { | ||
| 
											5 years ago
										 |     return AppModeManager.shared.currentAppMode == .dark | ||
| 
											6 years ago
										 | } | ||
| 
											6 years ago
										 | 
 | ||
|  | @objc public final class LKAppModeUtilities : NSObject { | ||
|  | 
 | ||
| 
											6 years ago
										 |     @objc public static var isLightMode: Bool { | ||
| 
											5 years ago
										 |         return AppModeManager.shared.currentAppMode == .light | ||
| 
											6 years ago
										 |     } | ||
|  | 
 | ||
|  |     @objc public static var isDarkMode: Bool { | ||
| 
											5 years ago
										 |         return AppModeManager.shared.currentAppMode == .dark | ||
| 
											6 years ago
										 |     } | ||
| 
											6 years ago
										 | } |