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.
		
		
		
		
		
			
		
			
	
	
		
			166 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			166 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Matlab
		
	
| 
											7 years ago
										 | // | ||
|  | //  Copyright (c) 2018 Open Whisper Systems. All rights reserved. | ||
|  | // | ||
|  | 
 | ||
|  | #import "Theme.h" | ||
|  | #import "UIColor+OWS.h" | ||
|  | #import "UIUtil.h" | ||
|  | #import <SignalServiceKit/NSNotificationCenter+OWS.h> | ||
|  | #import <SignalServiceKit/OWSPrimaryStorage.h> | ||
|  | #import <SignalServiceKit/YapDatabaseConnection+OWS.h> | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_BEGIN | ||
|  | 
 | ||
| 
											7 years ago
										 | NSString *const ThemeDidChangeNotification = @"ThemeDidChangeNotification"; | ||
| 
											7 years ago
										 | 
 | ||
|  | NSString *const ThemeCollection = @"ThemeCollection"; | ||
|  | NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; | ||
|  | 
 | ||
|  | @implementation Theme | ||
|  | 
 | ||
|  | + (BOOL)isDarkThemeEnabled | ||
|  | { | ||
|  |     OWSAssertIsOnMainThread(); | ||
|  | 
 | ||
| 
											7 years ago
										 |     if (!CurrentAppContext().isMainApp) { | ||
|  |         // Ignore theme in app extensions. | ||
|  |         return NO; | ||
|  |     } | ||
|  | 
 | ||
| 
											7 years ago
										 |     return [OWSPrimaryStorage.sharedManager.dbReadConnection boolForKey:ThemeKeyThemeEnabled | ||
|  |                                                            inCollection:ThemeCollection | ||
|  |                                                            defaultValue:NO]; | ||
|  | } | ||
|  | 
 | ||
|  | + (void)setIsDarkThemeEnabled:(BOOL)value | ||
|  | { | ||
|  |     OWSAssertIsOnMainThread(); | ||
|  | 
 | ||
|  |     [OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value | ||
|  |                                                             forKey:ThemeKeyThemeEnabled | ||
|  |                                                       inCollection:ThemeCollection]; | ||
|  | 
 | ||
|  |     [UIUtil setupSignalAppearence]; | ||
|  | 
 | ||
| 
											7 years ago
										 |     [UIView performWithoutAnimation:^{ | ||
|  |         [[NSNotificationCenter defaultCenter] postNotificationName:ThemeDidChangeNotification object:nil userInfo:nil]; | ||
|  |     }]; | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
|  | + (UIColor *)backgroundColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray95Color : UIColor.ows_whiteColor); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)offBackgroundColor | ||
|  | { | ||
|  |     return ( | ||
| 
											7 years ago
										 |         Theme.isDarkThemeEnabled ? [UIColor colorWithWhite:0.2f alpha:1.f] : [UIColor colorWithWhite:0.94f alpha:1.f]); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)primaryColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray05Color : UIColor.ows_gray90Color); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
|  | + (UIColor *)secondaryColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray25Color : UIColor.ows_gray60Color); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
|  | + (UIColor *)boldColor | ||
|  | { | ||
|  |     return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.blackColor); | ||
|  | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)middleGrayColor | ||
|  | { | ||
|  |     return [UIColor colorWithWhite:0.5f alpha:1.f]; | ||
|  | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)placeholderColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray45Color : UIColor.ows_gray45Color); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
|  | + (UIColor *)hairlineColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray75Color : UIColor.ows_gray25Color); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
| 
											7 years ago
										 | #pragma mark - Global App Colors | ||
|  | 
 | ||
|  | + (UIColor *)navbarBackgroundColor | ||
|  | { | ||
|  |     return (Theme.isDarkThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor); | ||
|  | } | ||
|  | 
 | ||
|  | + (UIColor *)navbarIconColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray25Color : UIColor.ows_gray60Color); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
|  | + (UIColor *)navbarTitleColor | ||
|  | { | ||
| 
											7 years ago
										 |     return Theme.primaryColor; | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
|  | + (UIColor *)toolbarBackgroundColor | ||
|  | { | ||
|  |     return self.navbarBackgroundColor; | ||
|  | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)cellSelectedColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? [UIColor colorWithWhite:0.2 alpha:1] : [UIColor colorWithWhite:0.92 alpha:1]); | ||
|  | } | ||
|  | 
 | ||
|  | + (UIColor *)cellSeparatorColor | ||
|  | { | ||
| 
											7 years ago
										 |     return Theme.hairlineColor; | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)conversationButtonBackgroundColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? [UIColor colorWithWhite:0.35f alpha:1.f] : UIColor.ows_gray02Color); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIBlurEffect *)barBlurEffect | ||
|  | { | ||
|  |     return Theme.isDarkThemeEnabled ? [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark] | ||
|  |                                     : [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; | ||
|  | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIKeyboardAppearance)keyboardAppearance | ||
|  | { | ||
|  |     return Theme.isDarkThemeEnabled ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault; | ||
|  | } | ||
|  | 
 | ||
| 
											7 years ago
										 | #pragma mark - Search Bar | ||
| 
											7 years ago
										 | 
 | ||
| 
											7 years ago
										 | + (UIBarStyle)barStyle | ||
|  | { | ||
| 
											7 years ago
										 |     return Theme.isDarkThemeEnabled ? UIBarStyleBlack : UIBarStyleDefault; | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)searchFieldBackgroundColor | ||
| 
											7 years ago
										 | { | ||
| 
											7 years ago
										 |     return Theme.isDarkThemeEnabled ? Theme.offBackgroundColor : UIColor.ows_gray05Color; | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
|  | #pragma mark - | ||
|  | 
 | ||
| 
											7 years ago
										 | + (UIColor *)toastForegroundColor | ||
|  | { | ||
|  |     return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_whiteColor); | ||
|  | } | ||
|  | 
 | ||
|  | + (UIColor *)toastBackgroundColor | ||
|  | { | ||
| 
											7 years ago
										 |     return (Theme.isDarkThemeEnabled ? UIColor.ows_gray75Color : UIColor.ows_gray60Color); | ||
| 
											7 years ago
										 | } | ||
|  | 
 | ||
| 
											7 years ago
										 | @end | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_END |