Add support for hiding apps

This commit is contained in:
Cameron Gutman
2020-11-02 20:32:57 -06:00
parent a483c6ea41
commit f55daf941c
6 changed files with 128 additions and 19 deletions
+15 -1
View File
@@ -9,7 +9,7 @@
#import "UIAppView.h"
#import "AppAssetManager.h"
static const float REFRESH_CYCLE = 2.0f;
static const float REFRESH_CYCLE = 1.0f;
@implementation UIAppView {
TemporaryApp* _app;
@@ -40,10 +40,15 @@ static UIImage* noImage;
self.frame = CGRectMake(0, 0, 150, 200);
#endif
[self setAlpha:app.hidden ? 0.4 : 1.0];
_appImage = [[UIImageView alloc] initWithFrame:self.frame];
[_appImage setImage:noImage];
[self addSubview:_appImage];
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(appLongClicked:)];
[self addGestureRecognizer:longPressRecognizer];
if (@available(iOS 9.0, tvOS 9.0, *)) {
[self addTarget:self action:@selector(appClicked) forControlEvents:UIControlEventPrimaryActionTriggered];
}
@@ -78,6 +83,12 @@ static UIImage* noImage;
[_callback appClicked:_app];
}
- (void) appLongClicked:(UILongPressGestureRecognizer*)gesture {
if (gesture.state == UIGestureRecognizerStateBegan) {
[_callback appLongClicked:_app];
}
}
- (void) updateAppImage {
if (_appOverlay != nil) {
[_appOverlay removeFromSuperview];
@@ -185,6 +196,9 @@ static UIImage* noImage;
[self updateAppImage];
}
// Update opacity if neccessary
[self setAlpha:_app.hidden ? 0.4 : 1.0];
// Stop updating when we detach from our parent view
if (self.superview != nil) {
[self performSelector:@selector(updateLoop) withObject:self afterDelay:REFRESH_CYCLE];