Skip to content

Commit

Permalink
Small Tweaks In Codes Apperance
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadhashemi committed Aug 24, 2016
1 parent 1889119 commit bd1c457
Showing 1 changed file with 37 additions and 48 deletions.
85 changes: 37 additions & 48 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,55 @@ CLLocation *userLocation;

- (void)configureColorPalette {

NSDate *sunrise = [[NSUserDefaults standardUserDefaults] objectForKey:@"Sunrise"];
NSDate *sunset = [[NSUserDefaults standardUserDefaults] objectForKey:@"Sunset"];

if (sunrise && sunset) {

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"H";

NSInteger nowHour = [[formatter stringFromDate:[[NSDate alloc] init]] integerValue];
NSInteger sunriseHour = [[formatter stringFromDate:sunrise] integerValue];
NSInteger sunsetHour = [[formatter stringFromDate:sunset] integerValue];

// NSLog(@"NOWHOUR: %li",(long)nowHour);
// NSLog(@"SUNRISEHOUR: %li",(long)sunriseHour);
// NSLog(@"SUNSETHOUR: %li",(long)sunsetHour);

NSString *palette;

if (nowHour > sunsetHour || nowHour < sunriseHour) {
palette = @"dark";
} else {
palette = @"standard";
}

// NSLog(@"SELECTEDPALETTE: %@",palette);
[[NSUserDefaults standardUserDefaults] setObject:palette forKey:@"TFNTwitterColorSettings.colorPaletteName"];
// [[NSUserDefaults standardUserDefaults] setObject:@"dark" forKey:@"TFNTwitterColorSettings.colorPaletteName"];
NSDate *sunrise = [[NSUserDefaults standardUserDefaults] objectForKey:@"Sunrise"];
NSDate *sunset = [[NSUserDefaults standardUserDefaults] objectForKey:@"Sunset"];

} else {
if (sunrise && sunset) {

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = (id)self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"H";

NSInteger nowHour = [[formatter stringFromDate:[[NSDate alloc] init]] integerValue];
NSInteger sunriseHour = [[formatter stringFromDate:sunrise] integerValue];
NSInteger sunsetHour = [[formatter stringFromDate:sunset] integerValue];

// NSLog(@"NOWHOUR: %li",(long)nowHour);
// NSLog(@"SUNRISEHOUR: %li",(long)sunriseHour);
// NSLog(@"SUNSETHOUR: %li",(long)sunsetHour);

NSString *palette;

if (nowHour > sunsetHour || nowHour < sunriseHour) {
palette = @"dark";
} else {
palette = @"standard";
}

// NSLog(@"SELECTEDPALETTE: %@",palette);
[[NSUserDefaults standardUserDefaults] setObject:palette forKey:@"TFNTwitterColorSettings.colorPaletteName"];

[locationManager requestWhenInUseAuthorization];
} else {

[locationManager startUpdatingLocation];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = (id)self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;

[locationManager requestWhenInUseAuthorization];
[locationManager startUpdatingLocation];

}

}

%orig;

//
// id sharedSettings = [%c(TFNTwitterColorSettings) performSelector:@selector(sharedSettings)];
// NSArray *available = [sharedSettings performSelector:@selector(availableColorPalettes)];
// id current = [sharedSettings performSelector:@selector(currentColorPalette)];
//
// current = available[1];
//
// [sharedSettings performSelector:@selector(applyCurrentColorPalette)];
%orig;

}

%new(v@:)
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {

if (userLocation) {
if (userLocation) {
return;
}
}

userLocation = [locations lastObject];
[manager stopUpdatingLocation];
Expand Down

0 comments on commit bd1c457

Please sign in to comment.