@@ -177,6 +177,8 @@ - (void)loadView
177177- (void )viewWillAppear : (BOOL )animated
178178{
179179 [super viewWillAppear: animated];
180+
181+ #if !TARGET_OS_TV
180182
181183 NSNotificationCenter * const notificationCenter = [NSNotificationCenter defaultCenter ];
182184
@@ -189,6 +191,8 @@ - (void)viewWillAppear:(BOOL)animated
189191 selector: @selector (handleKeyboardWillHideNotification: )
190192 name: UIKeyboardWillHideNotification
191193 object: nil ];
194+
195+ #endif
192196
193197 if (self.viewModel == nil ) {
194198 self.viewModel = self.viewModelLoader .initialViewModel ;
@@ -214,11 +218,15 @@ - (void)viewDidAppear:(BOOL)animated
214218- (void )viewWillDisappear : (BOOL )animated
215219{
216220 [super viewWillDisappear: animated];
217-
221+
222+ #if !TARGET_OS_TV
223+
218224 NSNotificationCenter * const notificationCenter = [NSNotificationCenter defaultCenter ];
219225 [notificationCenter removeObserver: self name: UIKeyboardWillShowNotification object: nil ];
220226 [notificationCenter removeObserver: self name: UIKeyboardWillHideNotification object: nil ];
221-
227+
228+ #endif
229+
222230 self.viewHasBeenLaidOut = NO ;
223231}
224232
@@ -774,6 +782,15 @@ - (BOOL)collectionViewShouldBeginScrolling:(HUBCollectionView *)collectionView
774782 return [delegate viewControllerShouldStartScrolling: self ];
775783}
776784
785+ #if TARGET_OS_TV
786+ - (BOOL )collectionView : (UICollectionView *)collectionView canFocusItemAtIndexPath : (NSIndexPath *)indexPath
787+ {
788+ HUBComponentCollectionViewCell *cell = (HUBComponentCollectionViewCell *)[collectionView cellForItemAtIndexPath: indexPath];
789+ HUBComponentWrapper * const wrapper = [self componentWrapperFromCell: cell];
790+ return wrapper.visibleChildren .count == 0 ;
791+ }
792+ #endif
793+
777794#pragma mark - UIScrollViewDelegate
778795
779796- (void )scrollViewDidScroll : (UIScrollView *)scrollView
@@ -858,6 +875,7 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni
858875}
859876
860877#pragma mark - Notification handling
878+ #if !TARGET_OS_TV
861879
862880- (void )handleKeyboardWillShowNotification : (NSNotification *)notification
863881{
@@ -871,6 +889,7 @@ - (void)handleKeyboardWillHideNotification:(NSNotification *)notification
871889 self.visibleKeyboardHeight = 0 ;
872890 [self updateOverlayComponentCenterPointsWithKeyboardNotification: notification];
873891}
892+ #endif
874893
875894#pragma mark - Private utilities
876895
@@ -984,9 +1003,13 @@ - (CGFloat)calculateTopContentInset
9841003 if (self.headerComponentWrapper != nil ) {
9851004 return 0 ;
9861005 }
987-
1006+ # if !TARGET_OS_TV
9881007 CGFloat const statusBarWidth = CGRectGetWidth ([UIApplication sharedApplication ].statusBarFrame );
9891008 CGFloat const statusBarHeight = CGRectGetHeight ([UIApplication sharedApplication ].statusBarFrame );
1009+ #else
1010+ CGFloat const statusBarWidth = 0.0 ;
1011+ CGFloat const statusBarHeight = 0.0 ;
1012+ #endif
9901013 CGFloat const navigationBarWidth = CGRectGetWidth (self.navigationController .navigationBar .frame );
9911014 CGFloat const navigationBarHeight = CGRectGetHeight (self.navigationController .navigationBar .frame );
9921015 CGFloat const topBarHeight = MIN (statusBarWidth, statusBarHeight) + MIN (navigationBarWidth, navigationBarHeight);
@@ -1066,6 +1089,7 @@ - (CGPoint)overlayComponentCenterPoint
10661089 proposedCenterPoint: proposedCenterPoint];
10671090}
10681091
1092+ #if !TARGET_OS_TV
10691093- (void )updateOverlayComponentCenterPointsWithKeyboardNotification : (NSNotification *)notification
10701094{
10711095 NSTimeInterval const animationDuration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue ];
@@ -1081,6 +1105,7 @@ - (void)updateOverlayComponentCenterPointsWithKeyboardNotification:(NSNotificati
10811105
10821106 [UIView commitAnimations ];
10831107}
1108+ #endif
10841109
10851110- (HUBComponentWrapper *)configureHeaderOrOverlayComponentWrapperWithModel : (id <HUBComponentModel>)componentModel
10861111 previousComponentWrapper : (nullable HUBComponentWrapper *)previousComponentWrapper
@@ -1536,6 +1561,20 @@ - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
15361561 [self .collectionView setContentOffset: contentOffset animated: animated];
15371562}
15381563
1564+ #pragma mark - Focus engine
1565+ #if TARGET_OS_TV
1566+
1567+ - (void )didUpdateFocusInContext : (UIFocusUpdateContext *)context withAnimationCoordinator : (UIFocusAnimationCoordinator *)coordinator {
1568+ HUBComponentCollectionViewCell *previousItem = (HUBComponentCollectionViewCell *)context.previouslyFocusedView ;
1569+ HUBComponentWrapper * const previousWrapper = [self componentWrapperFromCell: previousItem];
1570+ [previousWrapper updateViewForFocusState: HUBComponentFocusStateNone];
1571+ HUBComponentCollectionViewCell *nextItem = (HUBComponentCollectionViewCell *)context.nextFocusedView ;
1572+ HUBComponentWrapper * const nextWrapper = [self componentWrapperFromCell: nextItem];
1573+ [nextWrapper updateViewForFocusState: HUBComponentFocusStateInFocus];
1574+ }
1575+
1576+ #endif
1577+
15391578@end
15401579
15411580NS_ASSUME_NONNULL_END
0 commit comments