Tweak appearance.

This commit is contained in:
Matthew Chen 2018-07-11 17:33:00 -04:00
parent 19173a20b9
commit 750b935122
4 changed files with 43 additions and 6 deletions

View File

@ -195,6 +195,16 @@ NS_ASSUME_NONNULL_BEGIN
}
[contents addSection:censorshipSection];
#ifdef DEBUG
OWSTableSection *themeSection = [OWSTableSection new];
themeSection.headerTitle = NSLocalizedString(@"THEME_SECTION", nil);
[themeSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_THEME", @"")
isOn:[Environment.preferences isThemeEnabled]
target:weakSelf
selector:@selector(didToggleThemeSwitch:)]];
[contents addSection:themeSection];
#endif
self.contents = contents;
}
@ -274,6 +284,13 @@ NS_ASSUME_NONNULL_BEGIN
[self updateTableContents];
}
- (void)didToggleThemeSwitch:(UISwitch *)sender
{
[Environment.preferences setIsThemeEnabled:sender.isOn];
// TODO: Notify and refresh.
}
@end
NS_ASSUME_NONNULL_END

View File

@ -1886,6 +1886,9 @@
/* No comment provided by engineer. */
"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG" = "Submit Debug Log";
/* No comment provided by engineer. */
"SETTINGS_ADVANCED_THEME" = "Theme";
/* No comment provided by engineer. */
"SETTINGS_ADVANCED_TITLE" = "Advanced";
@ -2132,6 +2135,9 @@
/* Label for button to verify a user's safety number. */
"SYSTEM_MESSAGE_ACTION_VERIFY_SAFETY_NUMBER" = "Verify Safety Number";
/* No comment provided by engineer. */
"THEME_SECTION" = "THEME_SECTION";
/* {{number of days}} embedded in strings, e.g. 'Alice updated disappearing messages expiration to {{5 days}}'. See other *_TIME_AMOUNT strings */
"TIME_AMOUNT_DAYS" = "%@ days";

View File

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

View File

@ -31,6 +31,7 @@ NSString *const OWSPreferencesKeyHasGeneratedThumbnails = @"OWSPreferencesKeyHas
NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled";
NSString *const OWSPreferencesKeyEnableTheme = @"OWSPreferencesKeyEnableTheme";
@implementation OWSPreferences
@ -58,7 +59,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
OWSAssert(key != nil);
__block id result;
[OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
[OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
result = [self tryGetValueForKey:key transaction:transaction];
}];
return result;
@ -72,10 +73,9 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
- (void)setValueForKey:(NSString *)key toValue:(nullable id)value
{
[OWSPrimaryStorage.dbReadWriteConnection
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self setValueForKey:key toValue:value transaction:transaction];
}];
[OWSPrimaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self setValueForKey:key toValue:value transaction:transaction];
}];
}
- (void)setValueForKey:(NSString *)key
@ -414,6 +414,19 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
}
}
- (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