Last active
May 12, 2020 00:53
-
-
Save shepgoba/e4697d4c03a129403ad2cd8180c65b3a to your computer and use it in GitHub Desktop.
Incomplete SBIconListView reversal. iOS 13.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "SBIconListView.h" | |
typedef struct SBIconListPredictedVisibleColumn { | |
unsigned long long column; | |
double confidence; | |
} SBIconListPredictedVisibleColumn; | |
typedef struct SBIconCoordinate { | |
NSInteger row; | |
NSInteger col; | |
} SBIconCoordinate; | |
@implementation SBIconListView | |
+(CGRect) defaultFrameForOrientation:(unsigned long long)orientation { | |
return CGRectZero; // probably | |
} | |
+(unsigned long long) defaultIconViewConfigurationOptions { | |
return 0; | |
} | |
+(void)getLayoutMetrics:(SBIconListLayoutMetrics *)metrics forBounds:(CGRect)bounds insets:(UIEdgeInsets)insets | |
orientation:(unsigned long long)orientation numberOfColumns:(unsigned long long)columns numberOfRows:(unsigned long long)rows | |
iconSize:(CGSize)size iconContentScale:(double)scale options:(unsigned long long)options { | |
} | |
-(CGSize)alignmentIconViewSize { | |
Class cls = [self baseIconViewClass]; | |
return [cls defaultIconViewSizeForIconImageSize:self.iconImageSize configurationOptions:self.iconViewConfigurationOptions]; | |
} | |
-(Class)baseIconViewClass { | |
return [SBIconView class]; | |
} | |
-(CGPoint)centerForIcon:(SBIconView *)icon { | |
CGPoint iconCoordinate = [coordinateForIcon: icon]; | |
return [self centerForIconCoordinate: iconCoordinate]; | |
} | |
-(CGPoint)centerForIconAtIndex:(NSUInteger)index { | |
SBIconCoordinate coordinate = [self iconCoordinateForIndex:index forOrentation: self.layoutOrientation]; | |
return [self centerForIconAtCoordinate:coordinate]; | |
} | |
-(SBIconCoordinate)coordinateForIcon:(SBIconView *)icon { | |
long long iconIndex = [_model indexForIcon: icon]; | |
long long layoutOrientation = [self layoutOrientation]; | |
SBIconCoordinate result = [self iconCoordinateForIndex: iconIndex forOrientation:layoutOrientation]; | |
return result; | |
} | |
-(SBIconCoordinate)iconCoordinateForIndex:(unsigned long long)index forOrentation:(long long)orientation { | |
return [[self layout] iconCoordinateForIndex:index forOrientation:orientation inList: self.model]; | |
} | |
-(NSArray *)icons { | |
return self.model.icons; | |
} | |
-(id)initWithModel:(SBIconListModel *)model layoutProvider:(id)arg2 iconLocation:(id)arg3 orientation:(long long)arg4 iconViewProvider:(id)iconViewProvider { | |
if (self = [super initWithFrame:CGRectZero]) { | |
_iconLocation = arg3; | |
_orientation = arg4; | |
_iconContentScale = 1.0f; | |
_iconViewConfigurationOptions = [self defaultIconViewConfigurationOptions]; | |
_alignsIconsOnPixelBoundaries = YES; | |
_iconViewProvider = iconViewProvider; | |
_iconViews = [NSMapTable strongToStrongObjectsMapTable]; | |
[self setAutoresizingMask: 16]; | |
[model addListObserver: self]; | |
_visibleColumnRange = NSRangeMake(0, -1); | |
_predictedVisibleColumn.column = 0x7FFFFFFFFFFFFFFF; | |
_draggingDelegate = [[SBIconListViewDraggingDestinationDelegate alloc] initWithIconListView: self]; | |
} | |
} | |
-(void)layoutAndCreateIcon:(SBIcon *)icon atIndex:(NSUInteger)index { | |
SBIconView *iconView = [self iconViewForIcon:icon]; | |
iconView.alpha = 1.0f; | |
if (iconView) { | |
CGPoint center = [self centerForIconAtIndex: index]; | |
iconView.transform = 0; //unknown | |
iconView.center = UIPointRoundToViewScale(center); // unsure of what this does | |
if (self != self.superview) { | |
if ([self shouldReparentView: iconView]) { | |
[self addSubview: iconView]; | |
} | |
} | |
} | |
NSArray *array = [NSArray arrayWithObjects:iconView count:1]; | |
[self _updateEditingStateForIcons: array animated: 0]; | |
} | |
-(void)removeIconView:(SBIconView *)iconView { | |
id<SBIconViewProviding> iconViewProvider = self.iconViewProvider; | |
if (iconViewProvider) { | |
[iconViewProvider recycleIconView:iconView]; | |
} | |
if ([iconView isDescendantOfView: self]) { | |
[iconView removeFromSuperview]; | |
} | |
} | |
-(NSMutableArray *)removedIcons { | |
if (!_removedIcons) { | |
_removedIcons = [[NSMutableArray alloc] init]; | |
} | |
return _removedIcons; | |
} | |
-(unsigned long long)rowAtPoint:(CGPoint)point { | |
id metrics = [self getLayoutMetrics:nil/*unknown*/]; | |
return [self rowAtPoint:point metrics: metrics]; | |
} | |
-(unsigned long long)rowAtPoint:(CGPoint)point metrics:(SBIconListLayoutMetrics *)metrics { | |
/* unknown struct members, can't be determined */ | |
NSUInteger result; | |
if ( metrics->var1 == 1 ) | |
return 0LL; | |
v4 = metrics->var3.var1 * metrics->var4; | |
v5 = metrics->var2.var1; | |
v6 = metrics->var5.var0 + v4; | |
v7 = v4 + v5; | |
v8 = v5 * 0.5 + v6; | |
result = 0LL; | |
while ( v8 <= point.y ) | |
{ | |
v8 = v8 + v7; | |
if ( ++result >= metrics->var1 - 1 ) | |
return metrics->var1 - 1; | |
} | |
return result; | |
} | |
-(void)setUserInterfaceLayoutDirectionHandling:(unsigned long long)arg1 { | |
if (_userInterfaceLayoutDirectionHandling != arg1) { | |
_userInterfaceLayoutDirectionHandling = arg1; | |
[self setIconsNeedLayout]; | |
} | |
} | |
-(void)setIconsNeedLayout { | |
_needsLayout = 1; | |
if (!_layoutRunLoopObserver) { | |
[self _setupLayoutRunLoopObserver] | |
} | |
} | |
-(void)setIconsNeedLayout:(unsigned long long)newValue { | |
_iconsNeedLayout = newValue; | |
} | |
-(UIColor *)tintColor { | |
return nil; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment