Tweak appearance.

pull/1/head
Matthew Chen 7 years ago
parent 750b935122
commit 0c420ed28a

@ -195,11 +195,11 @@ NS_ASSUME_NONNULL_BEGIN
}
[contents addSection:censorshipSection];
#ifdef DEBUG
#ifdef THEME_ENABLED
OWSTableSection *themeSection = [OWSTableSection new];
themeSection.headerTitle = NSLocalizedString(@"THEME_SECTION", nil);
[themeSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_THEME", @"")
isOn:[Environment.preferences isThemeEnabled]
isOn:[UIColor isThemeEnabled]
target:weakSelf
selector:@selector(didToggleThemeSwitch:)]];
[contents addSection:themeSection];
@ -286,7 +286,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didToggleThemeSwitch:(UISwitch *)sender
{
[Environment.preferences setIsThemeEnabled:sender.isOn];
[UIColor setIsThemeEnabled:sender.isOn];
// TODO: Notify and refresh.
}

@ -6,6 +6,10 @@
NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
#define THEME_ENABLED
#endif
@interface UIColor (OWS)
#pragma mark - Global App Colors
@ -77,6 +81,13 @@ NS_ASSUME_NONNULL_BEGIN
@property (class, readonly, nonatomic) UIColor *ows_grey600Color;
@property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor;
#pragma mark - Theme
#ifdef THEME_ENABLED
+ (BOOL)isThemeEnabled;
+ (void)setIsThemeEnabled:(BOOL)value;
#endif
@end
NS_ASSUME_NONNULL_END

@ -2,12 +2,17 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "UIColor+OWS.h"
#import "OWSMath.h"
#import "UIColor+OWS.h"
#import <SignalServiceKit/Cryptography.h>
#import <SignalServiceKit/OWSPrimaryStorage.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h>
NS_ASSUME_NONNULL_BEGIN
NSString *const UIColorCollection = @"UIColorCollection";
NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled";
@implementation UIColor (OWS)
#pragma mark - Global App Colors
@ -338,6 +343,26 @@ NS_ASSUME_NONNULL_BEGIN
return [self.ows_conversationColorMap allKeysForObject:color].firstObject;
}
#pragma mark - Theme
+ (BOOL)isThemeEnabled
{
OWSAssertIsOnMainThread();
return [OWSPrimaryStorage.sharedManager.dbReadConnection boolForKey:UIColorKeyThemeEnabled
inCollection:UIColorCollection
defaultValue:NO];
}
+ (void)setIsThemeEnabled:(BOOL)value
{
OWSAssertIsOnMainThread();
[OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value
forKey:UIColorKeyThemeEnabled
inCollection:UIColorCollection];
}
@end
NS_ASSUME_NONNULL_END

@ -61,9 +61,6 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
- (BOOL)hasGeneratedThumbnails;
- (void)setHasGeneratedThumbnails:(BOOL)value;
- (BOOL)isThemeEnabled;
- (void)setIsThemeEnabled:(BOOL)flag;
#pragma mark Callkit
- (BOOL)isSystemCallLogEnabled;

@ -31,7 +31,6 @@ NSString *const OWSPreferencesKeyHasGeneratedThumbnails = @"OWSPreferencesKeyHas
NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled";
NSString *const OWSPreferencesKeyEnableTheme = @"OWSPreferencesKeyEnableTheme";
@implementation OWSPreferences
@ -414,19 +413,6 @@ NSString *const OWSPreferencesKeyEnableTheme = @"OWSPreferencesKeyEnableTheme";
}
}
- (BOOL)isThemeEnabled
{
NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyEnableTheme];
return preference ? [preference boolValue] : NO;
}
- (void)setIsThemeEnabled:(BOOL)flag
{
OWSAssert(CurrentAppContext().isMainApp);
[self setValueForKey:OWSPreferencesKeyEnableTheme toValue:@(flag)];
}
#pragma mark - Push Tokens
- (void)setPushToken:(NSString *)value

Loading…
Cancel
Save