Merge pull request #341 from ascagnel/tv-fixes

tvOS app UI/UX fixes
This commit is contained in:
Cameron Gutman
2018-11-19 20:16:50 -08:00
committed by GitHub
30 changed files with 294 additions and 15 deletions

View File

@@ -1001,9 +1001,8 @@ static NSMutableSet* hostList;
cell.layer.shadowOpacity = 0.5f;
cell.layer.shadowPath = shadowPath.CGPath;
cell.layer.borderWidth = 1;
#if !TARGET_OS_TV
cell.layer.borderWidth = 1;
cell.layer.borderColor = [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3f] CGColor];
cell.exclusiveTouch = YES;
#endif
@@ -1055,12 +1054,20 @@ static NSMutableSet* hostList;
self.navigationController.navigationBar.topItem.rightBarButtonItem.enabled = YES;
}
#if TARGET_OS_TV
- (BOOL)canBecomeFocused {
return YES;
}
#endif
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
#if !TARGET_OS_TV
if (context.nextFocusedView != nil) {
[context.nextFocusedView setAlpha:0.8];
}
[context.previouslyFocusedView setAlpha:1.0];
#endif
}
@end

View File

@@ -12,7 +12,13 @@
#import <UIKit/UIKit.h>
#if TARGET_OS_TV
@import GameController;
@interface StreamFrameViewController : GCEventViewController <ConnectionCallbacks, EdgeDetectionDelegate>
#else
@interface StreamFrameViewController : UIViewController <ConnectionCallbacks, EdgeDetectionDelegate>
#endif
@property (strong, nonatomic) IBOutlet UILabel *stageLabel;
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *spinner;
@property (nonatomic) StreamConfiguration* streamConfig;

View File

@@ -20,6 +20,8 @@
ControllerSupport *_controllerSupport;
StreamManager *_streamMan;
NSTimer *_inactivityTimer;
UITapGestureRecognizer *_menuGestureRecognizer;
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
}
- (void)viewDidAppear:(BOOL)animated
@@ -31,6 +33,15 @@
#endif
}
#ifdef TARGET_OS_TV
- (void)controllerPauseButtonPressed:(id)sender { }
- (void)controllerPauseButtonDoublePressed:(id)sender {
Log(LOG_I, @"Menu double-pressed -- backing out of stream");
[self returnToMainFrame];
}
#endif
- (void)viewDidLoad
{
[super viewDidLoad];
@@ -46,6 +57,21 @@
_controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig];
_inactivityTimer = nil;
#if TARGET_OS_TV
if (!_menuGestureRecognizer || !_menuDoubleTapGestureRecognizer) {
_menuGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)];
_menuGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
_menuDoubleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonDoublePressed:)];
_menuDoubleTapGestureRecognizer.numberOfTapsRequired = 2;
[_menuGestureRecognizer requireGestureRecognizerToFail:_menuDoubleTapGestureRecognizer];
_menuDoubleTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
}
[self.view addGestureRecognizer:_menuGestureRecognizer];
[self.view addGestureRecognizer:_menuDoubleTapGestureRecognizer];
#endif
_streamMan = [[StreamManager alloc] initWithConfig:self.streamConfig
renderView:self.view
connectionCallbacks:self];