-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTBCSAppSwitcherCollectionViewCell.x
More file actions
50 lines (41 loc) · 1.66 KB
/
Copy pathTBCSAppSwitcherCollectionViewCell.x
File metadata and controls
50 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#import "TBCSAppSwitcherCollectionViewCell.h"
#import "TBCSDisplayItem.h"
#import "TBCSPreferencesManager.h"
#import <UIKit/UIImage+Private.h>
@implementation TBCSAppSwitcherCollectionViewCell {
TBCSDisplayItem *_displayItem;
UIImageView *_appIconImageView;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_appIconImageView = [[UIImageView alloc] init];
_appIconImageView.frame = CGRectMake(0, 0, 55.0, 55.0);
_appIconImageView.center = self.contentView.center;
_appIconImageView.layer.shadowColor = [UIColor darkGrayColor].CGColor;
_appIconImageView.layer.shadowOffset = CGSizeMake(0.5, 0.5);
_appIconImageView.layer.shadowOpacity = 0.5;
_appIconImageView.layer.shadowRadius = 0.5;
_appIconImageView.clipsToBounds = NO;
[self.contentView addSubview:_appIconImageView];
}
return self;
}
- (TBCSDisplayItem *)displayItem {
return _displayItem;
}
- (void)setDisplayItem:(TBCSDisplayItem *)displayItem {
if ([displayItem.type isEqualToString:@"Homescreen"]) {
// if it‘s the home screen icon, we have our own icon for that
BOOL darkMode = [TBCSPreferencesManager sharedInstance].darkMode;
_appIconImageView.image = [[UIImage imageNamed:darkMode ? @"home-dark" : @"home-light" inBundle:bundle] _applicationIconImageForFormat:MIIconVariantDefault precomposed:YES scale:[[UIScreen mainScreen] scale]];
} else {
// get the app’s icon
_appIconImageView.image = [UIImage _applicationIconImageForBundleIdentifier:displayItem.displayIdentifier format:MIIconVariantDefault scale:[[UIScreen mainScreen] scale]];
}
}
#pragma mark - Memory management
- (void)dealloc {
[_appIconImageView release];
[super dealloc];
}
@end