From e217786d2fe30788d33483bf9e770cae071aaa75 Mon Sep 17 00:00:00 2001 From: Charlie Melbye Date: Mon, 12 Nov 2018 21:34:12 -0800 Subject: [PATCH] consistent brace style --- app/AboutViewController.m | 3 +-- app/TerminalViewController.m | 6 ++---- app/ThemeViewController.m | 9 +++------ app/UserPreferences.m | 33 +++++++++++---------------------- 4 files changed, 17 insertions(+), 34 deletions(-) diff --git a/app/AboutViewController.m b/app/AboutViewController.m index 1de51727..21a368a3 100644 --- a/app/AboutViewController.m +++ b/app/AboutViewController.m @@ -25,8 +25,7 @@ [self _updatePreferenceUI]; } -- (void)dealloc -{ +- (void)dealloc { [self _removeObservers]; } diff --git a/app/TerminalViewController.m b/app/TerminalViewController.m index 2d22e72f..d54cdb3b 100644 --- a/app/TerminalViewController.m +++ b/app/TerminalViewController.m @@ -70,15 +70,13 @@ } } -- (void)dealloc -{ +- (void)dealloc { @try { [[UserPreferences shared] removeObserver:self forKeyPath:@"theme"]; } @catch (NSException * __unused exception) {} } -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (object == [UserPreferences shared]) { [UIView animateWithDuration:0.1 animations:^{ self.view.backgroundColor = ThemeBackgroundColor([UserPreferences shared].theme); diff --git a/app/ThemeViewController.m b/app/ThemeViewController.m index 2687a2b4..5427d361 100644 --- a/app/ThemeViewController.m +++ b/app/ThemeViewController.m @@ -26,15 +26,13 @@ static NSString *const ThemeNameCellIdentifier = @"ThemeNameCell"; [[UserPreferences shared] addObserver:self forKeyPath:@"theme" options:NSKeyValueObservingOptionNew context:nil]; } -- (void)dealloc -{ +- (void)dealloc { @try { [[UserPreferences shared] removeObserver:self forKeyPath:@"theme"]; } @catch (NSException * __unused exception) {} } -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { [self.tableView reloadData]; } @@ -56,8 +54,7 @@ static NSString *const ThemeNameCellIdentifier = @"ThemeNameCell"; return 0; } -- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section -{ +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (section == 1) { return @"Preview"; } diff --git a/app/UserPreferences.m b/app/UserPreferences.m index 102fce85..75b9d8f0 100644 --- a/app/UserPreferences.m +++ b/app/UserPreferences.m @@ -60,13 +60,11 @@ NSString *ThemeName(UserPreferenceTheme theme) { } } -@implementation UserPreferences -{ +@implementation UserPreferences { NSUserDefaults *_defaults; } -+ (instancetype)shared -{ ++ (instancetype)shared { static UserPreferences *shared = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -75,8 +73,7 @@ NSString *ThemeName(UserPreferenceTheme theme) { return shared; } -- (instancetype)init -{ +- (instancetype)init { self = [super init]; if (self) { _defaults = [NSUserDefaults standardUserDefaults]; @@ -84,38 +81,31 @@ NSString *ThemeName(UserPreferenceTheme theme) { return self; } -- (BOOL)mapCapsLockAsControl -{ +- (BOOL)mapCapsLockAsControl { return [_defaults boolForKey:kPreferenceMapCapsLockAsControlKey] ?: NO; } -- (void)setMapCapsLockAsControl:(BOOL)mapCapsLockAsControl -{ +- (void)setMapCapsLockAsControl:(BOOL)mapCapsLockAsControl { [_defaults setBool:mapCapsLockAsControl forKey:kPreferenceMapCapsLockAsControlKey]; } -- (NSNumber *)fontSize -{ +- (NSNumber *)fontSize { return [_defaults objectForKey:kPreferenceFontSizeKey] ?: @(12); } -- (void)setFontSize:(NSNumber *)fontSize -{ +- (void)setFontSize:(NSNumber *)fontSize { [_defaults setObject:fontSize forKey:kPreferenceFontSizeKey]; } -- (UserPreferenceTheme)theme -{ +- (UserPreferenceTheme)theme { return [_defaults integerForKey:kPreferenceThemeKey] ?: UserPreferenceThemeLight; } -- (void)setTheme:(UserPreferenceTheme)theme -{ +- (void)setTheme:(UserPreferenceTheme)theme { [_defaults setInteger:theme forKey:kPreferenceThemeKey]; } -- (NSString *)JSONDictionary -{ +- (NSString *)JSONDictionary { NSDictionary *dict = @{ @"mapCapsLockAsControl": @(self.mapCapsLockAsControl), @"fontSize": self.fontSize, @@ -125,8 +115,7 @@ NSString *ThemeName(UserPreferenceTheme theme) { return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:dict options:0 error:nil] encoding:NSUTF8StringEncoding]; } --(NSString *)_hexFromUIColor:(UIColor *)color -{ +-(NSString *)_hexFromUIColor:(UIColor *)color { const CGFloat *components = CGColorGetComponents(color.CGColor); size_t count = CGColorGetNumberOfComponents(color.CGColor);