mirror of https://github.com/oxen-io/session-ios
Respond to CR.
parent
b2b95597cc
commit
48975eaac8
@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define THEME_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern NSString *const NSNotificationNameThemeDidChange;
|
||||||
|
|
||||||
|
@interface Theme : NSObject
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
+ (BOOL)isDarkThemeEnabled;
|
||||||
|
#ifdef THEME_ENABLED
|
||||||
|
+ (void)setIsDarkThemeEnabled:(BOOL)value;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@property (class, readonly, nonatomic) UIColor *backgroundColor;
|
||||||
|
@property (class, readonly, nonatomic) UIColor *primaryColor;
|
||||||
|
@property (class, readonly, nonatomic) UIColor *secondaryColor;
|
||||||
|
@property (class, readonly, nonatomic) UIColor *boldColor;
|
||||||
|
|
||||||
|
#pragma mark - Global App Colors
|
||||||
|
|
||||||
|
@property (class, readonly, nonatomic) UIColor *navbarBackgroundColor;
|
||||||
|
@property (class, readonly, nonatomic) UIColor *navbarIconColor;
|
||||||
|
@property (class, readonly, nonatomic) UIColor *navbarTitleColor;
|
||||||
|
|
||||||
|
@property (class, readonly, nonatomic) UIColor *toolbarBackgroundColor;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,98 @@
|
|||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
NSString *const NSNotificationNameThemeDidChange = @"NSNotificationNameThemeDidChange";
|
||||||
|
|
||||||
|
NSString *const ThemeCollection = @"ThemeCollection";
|
||||||
|
NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled";
|
||||||
|
|
||||||
|
@implementation Theme
|
||||||
|
|
||||||
|
+ (BOOL)isDarkThemeEnabled
|
||||||
|
{
|
||||||
|
OWSAssertIsOnMainThread();
|
||||||
|
|
||||||
|
#ifndef THEME_ENABLED
|
||||||
|
return NO;
|
||||||
|
#else
|
||||||
|
return [OWSPrimaryStorage.sharedManager.dbReadConnection boolForKey:ThemeKeyThemeEnabled
|
||||||
|
inCollection:ThemeCollection
|
||||||
|
defaultValue:NO];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)setIsDarkThemeEnabled:(BOOL)value
|
||||||
|
{
|
||||||
|
OWSAssertIsOnMainThread();
|
||||||
|
|
||||||
|
[OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value
|
||||||
|
forKey:ThemeKeyThemeEnabled
|
||||||
|
inCollection:ThemeCollection];
|
||||||
|
|
||||||
|
[UIUtil setupSignalAppearence];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:NSNotificationNameThemeDidChange
|
||||||
|
object:nil
|
||||||
|
userInfo:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIColor *)backgroundColor
|
||||||
|
{
|
||||||
|
return (Theme.isDarkThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIColor *)primaryColor
|
||||||
|
{
|
||||||
|
// TODO: Theme, Review with design.
|
||||||
|
return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_light90Color);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIColor *)secondaryColor
|
||||||
|
{
|
||||||
|
// TODO: Theme, Review with design.
|
||||||
|
return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIColor *)boldColor
|
||||||
|
{
|
||||||
|
// TODO: Review with design.
|
||||||
|
return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.blackColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Global App Colors
|
||||||
|
|
||||||
|
+ (UIColor *)navbarBackgroundColor
|
||||||
|
{
|
||||||
|
return (Theme.isDarkThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIColor *)navbarIconColor
|
||||||
|
{
|
||||||
|
// TODO: Theme, Review with design.
|
||||||
|
return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIColor *)navbarTitleColor
|
||||||
|
{
|
||||||
|
// TODO: Theme, Review with design.
|
||||||
|
return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIColor *)toolbarBackgroundColor
|
||||||
|
{
|
||||||
|
return self.navbarBackgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
Loading…
Reference in New Issue