mirror of
https://github.com/ish-app/ish.git
synced 2026-01-25 14:06:40 +00:00
consistent brace style
This commit is contained in:
parent
37d22fa634
commit
e217786d2f
@ -25,8 +25,7 @@
|
||||
[self _updatePreferenceUI];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
- (void)dealloc {
|
||||
[self _removeObservers];
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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";
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user