Skip to content

Instantly share code, notes, and snippets.

@DGh0st
Last active May 3, 2019 04:49
Show Gist options
  • Save DGh0st/e263bc54ef07b92f1238532680afdc9b to your computer and use it in GitHub Desktop.
Save DGh0st/e263bc54ef07b92f1238532680afdc9b to your computer and use it in GitHub Desktop.
SBLockscreenDateViewController implementation for iOS 12 (generated using a disassembler)
@interface SBLockScreenDateViewController : UIViewController <SBDateTimeOverrideObserver, _UISettingsKeyObserver> {
NSNumber* _timerToken;
BOOL _isScreenOn;
BOOL _isVisible;
BOOL _disablesUpdates;
_UILegibilitySettings* _legibilitySettings;
}
@property (assign,getter=isSubtitleHidden,nonatomic) BOOL subtitleHidden;
@property (nonatomic,retain) _UILegibilitySettings * legibilitySettings;
@property (readonly) unsigned long long hash;
@property (readonly) Class superclass;
@property (copy,readonly) NSString * description;
@property (copy,readonly) NSString * debugDescription;
-(void)controller:(id)arg1 didChangeOverrideDateFromDate:(id)arg2 ;
-(void)_backlightChanged:(id)arg1 ;
-(id)dateViewIfExists;
-(void)updateTimeNow;
-(void)_updateLegibilityStrength;
-(void)_updateFormatIfEnabled;
-(void)_updateFormat;
-(BOOL)isSubtitleHidden;
-(void)setSubtitleHidden:(BOOL)arg1 ;
-(void)setContentAlpha:(double)arg1 withSubtitleVisible:(BOOL)arg2 ;
-(void)setCustomSubtitleView:(id)arg1 ;
-(void)_addObservers;
-(void)_stopUpdateTimer;
-(void)_startUpdateTimer;
-(void)dealloc;
-(NSString *)description;
-(void)setView:(id)arg1 ;
-(id)initWithNibName:(id)arg1 bundle:(id)arg2 ;
-(void)viewWillAppear:(BOOL)arg1 ;
-(void)loadView;
-(void)willMoveToParentViewController:(id)arg1 ;
-(void)viewDidDisappear:(BOOL)arg1 ;
-(void)_updateView;
-(void)_updateState;
-(_UILegibilitySettings *)legibilitySettings;
-(void)setLegibilitySettings:(_UILegibilitySettings *)arg1 ;
-(void)settings:(id)arg1 changedValueForKey:(id)arg2 ;
-(id)dateView;
@end
@implementation SBLockscreenDateViewController
-(id)dateViewIfExists {
if ([self isViewLoaded])
return [self dateView];
return nil;
}
-(id)dateView {
return self.view;
}
-(void)setContentAlpha:(CGFloat)arg1 withSubtitleVisible:(BOOL)arg2 {
[[self dateViewIfExists] setContentAlpha:arg1 withSubtitleVisible:arg2];
}
-(void)setCustomSubtitleView:(id)arg1 {
[[self dateViewIfExists] setCustomSubtitleView:arg1];
}
-(void)setLegibilitySettings:(id)arg1 {
if (self->_legibilitySettings != arg1) {
[self->_legibilitySettings release];
self->_legibilitySettings = [arg1 retain];
[self _updateLegibilityStrength];
[[self dateView] setLegibilitySettings:self->_legibilitySettings];
}
}
-(void)_updateLegibilityStrength {
SBFLockscreenDateView *dateView = [self dateViewIfExists];
SBLegibilitySettings *settings = [[[SBPrototypeController sharedInstance] rootSettings] legibilitySettings];
CGFloat style = [[self legibilitySettings] style];
[dateView setTimeLegibilityStrength:[settings timeStrengthForStyle:style]];
[dateView setSubtitleLegibilityStrength:[settings dateStrengthForStyle:style]];
}
-(id)legibilitySettings {
return self->_legibilitySettings;
}
-(void)viewWillAppear:(BOOL)arg1 {
[super viewWillAppear:arg1];
self->_isVisible = YES;
[self _updateState];
}
-(void)_updateState {
BOOL shouldDisableUpdates = self->_isVisible ? !self->_isScreenOn : YES;
if (self->_disablesUpdates != shouldDisableUpdates) {
self->_disablesUpdates = shouldDisableUpdates;
// bunch of logging using SBLogDashboard and oslog
[self _updateFormatIfEnabled];
if (self->_disablesUpdates) {
[self _stopUpdateTimer];
} else {
NSDate *overrideDate = [[SBDateTimeController sharedInstance] overrideDate];
if (overrideDate == nil) {
[self _startUpdateTimer];
}
}
}
}
-(void)_updateFormatIfEnabled {
if (!self->_disablesUpdates)
[self _updateFormat];
}
-(void)_updateFormat {
[[self dateViewIfExists] updateFormat];
[self _updateView];
}
-(void)_updateView {
if (self->_disablesUpdates) {
[self _stopUpdateTimer];
} else {
NSDate *overrideDate = [[SBDateTimeController sharedInstance] overrideDate];
if (overrideDate != nil) {
[[self dateViewIfExists] setDate:overrideDate];
} else {
[[self dateViewIfExists] setDate:[SBUIPreciseClockTimer now]];
[self _startUpdateTimer];
}
}
}
-(void)_startUpdateTimer {
if (self->_timerToken == nil) {
self->_timerToken = (NSNumber *)[[[SBUIPreciseClockTimer sharedInstance] startMinuteUpdatesWithHandler:^{
[self _updateView];
}] retain];
}
}
-(void)viewDidDisappear:(BOOL)arg1 {
[super viewDidDisappear:arg1];
self->_isVisible = NO;
[self _updateState];
}
-(void)_stopUpdateTimer {
if (self->_timerToken != nil) {
[[SBUIPreciseClockTimer sharedInstance] stopMinuteUpdatesForToken:self->_timerToken];
[self->_timerToken release];
self->_timerToken = nil;
}
}
-(void)_backlightChanged:(id)arg1 {
CGFloat newBacklightValue = [[[arg1 userInfo] objectForKey:SBBacklightNewFactorKey] floatValue];
BOOL newIsScreenOn = newBacklightValue > 0.0;
if (self->_isScreenOn != newIsScreenOn) {
self->_isScreenOn = newIsScreenOn;
[self _updateState];
}
}
-(void)updateTimeNow {
NSDate *overrideDate = [[SBDateTimeController sharedInstance] overrideDate];
if (overrideDate != nil) {
[[self dateViewIfExists] setDate:overrideDate];
} else {
[[self dateViewIfExists] setDate:[SBUIPreciseClockTimer now]];
}
}
-(id)initWithNibName:(id)arg1 bundle:(id)arg2 {
self = [super initWithNibName:arg1 bundle:arg2];
if (self != nil)
[self _addObservers];
return self;
}
-(void)dealloc {
[[SBDateTimeController sharedInstance] removeObserver:self];
[self _stopUpdateTimer];
[[[[SBPrototypeController sharedInstance] rootSettings] legibilitySettings] removeKeyObserver:self];
[super dealloc];
}
-(BOOL)isSubtitleHidden {
return [[self dateViewIfExists] isSubtitleHidden];
}
-(void)setSubtitleHidden:(BOOL)arg1 {
[[self dateView] setSubtitleHidden:arg1];
}
-(void)loadView {
SBDateTimeController *dateTimeController = [SBDateTimeController sharedInstance];
[dateTimeController addObserver:self];
SBFLockscreenDateView *lockscreenDateView = [[SBFLockscreenDateView alloc] initWithFrame:CGRectZero];
[lockscreenDateView setUserInteractionEnabled:NO];
[lockscreenDateView setLegibilitySettings:self->_legibilitySettings];
self.view = lockscreenDateView;
[self _updateLegibilityStrength];
NSDate *overrideDate = [dateTimeController overrideDate];
if (overrideDate != nil) {
[lockscreenDateView setDate:overrideDate];
} else {
[lockscreenDateView setDate:[SBUIPreciseClockTimer now]];
}
}
-(void)setView:(id)arg1 {
[super setView:arg1];
if (arg1 == nil)
[self _stopUpdateTimer];
}
-(void)willMoveToParentViewController:(id)arg1 {
if (arg1 == nil)
[self setView:nil];
}
-(void)controller:(SBDateTimeController *)arg1 didChangeOverrideDateFromDate:(NSDate *)arg2 {
NSDate *overrideDate = [arg1 overrideDate];
if (overrideDate != nil)
[self _stopUpdateTimer];
else if (!self->_disablesUpdates)
[self _startUpdateTimer];
[self _updateFormatIfEnabled];
}
-(void)settings:(id)arg1 changedValueForKey:(id)arg2 {
if ([arg1 isMemberOfClass:[SBLegibilitySettings class]])
[self _updateLegibilityStrength];
}
-(void)_addObservers {
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self selector:@selector(_updateFormat) name:BSDateTimeCacheChangedNotification object:nil];
[defaultCenter addObserver:self selector:@selector(_backlightChanged:) name:SBBacklightLevelChangedNotification object:nil];
[defaultCenter addObserver:self selector:@selector(_updateView) name:UIContentSizeCategoryDidChangeNotification object:nil];
[defaultCenter addObserver:self selector:@selector(_updateView) name:UIAccessibilityLargeTextChangedNotification object:nil];
[[[[SBPrototypeController sharedInstance] rootSettings] legibilitySettings] addKeyObserverIfPrototyping:self];
}
@end
@DGh0st
Copy link
Author

DGh0st commented May 2, 2019

Remember this was generated using a disassembler so it may not be 100% accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment