mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[tvOS] Expose UIFocusEnvironment Protocol methods to ASDisplayNode
This commit is contained in:
@@ -660,6 +660,16 @@ NS_ASSUME_NONNULL_END
|
||||
- (BOOL)isFirstResponder;
|
||||
- (BOOL)canPerformAction:(nonnull SEL)action withSender:(nonnull id)sender;
|
||||
|
||||
#if TARGET_OS_TV
|
||||
//Focus Engine
|
||||
- (void)setNeedsFocusUpdate;
|
||||
- (BOOL)canBecomeFocused;
|
||||
- (void)updateFocusIfNeeded;
|
||||
- (void)didUpdateFocusInContext:(nonnull UIFocusUpdateContext *)context withAnimationCoordinator:(nonnull UIFocusAnimationCoordinator *)coordinator;
|
||||
- (BOOL)shouldUpdateFocusInContext:(nonnull UIFocusUpdateContext *)context;
|
||||
- (nullable UIView *)preferredFocusedView;
|
||||
#endif
|
||||
|
||||
// Accessibility support
|
||||
@property (atomic, assign) BOOL isAccessibilityElement;
|
||||
@property (nullable, atomic, copy) NSString *accessibilityLabel;
|
||||
|
||||
@@ -2312,6 +2312,38 @@ static void _recursivelySetDisplaySuspended(ASDisplayNode *node, CALayer *layer,
|
||||
return self;
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
#pragma mark - UIFocusEnvironment Protocol (tvOS)
|
||||
|
||||
- (void)setNeedsFocusUpdate
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)updateFocusIfNeeded
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)shouldUpdateFocusInContext:(UIFocusUpdateContext *)context
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (UIView *)preferredFocusedView
|
||||
{
|
||||
if (self.nodeLoaded) {
|
||||
return self.view;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
||||
@implementation ASDisplayNode (Debugging)
|
||||
|
||||
@@ -331,4 +331,36 @@
|
||||
return _node;
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
#pragma mark - tvOS
|
||||
- (BOOL)canBecomeFocused
|
||||
{
|
||||
return [_node canBecomeFocused];
|
||||
}
|
||||
|
||||
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
|
||||
{
|
||||
return [_node didUpdateFocusInContext:context withAnimationCoordinator:coordinator];
|
||||
}
|
||||
|
||||
- (void)setNeedsFocusUpdate
|
||||
{
|
||||
return [_node setNeedsFocusUpdate];
|
||||
}
|
||||
|
||||
- (void)updateFocusIfNeeded
|
||||
{
|
||||
return [_node updateFocusIfNeeded];
|
||||
}
|
||||
|
||||
- (BOOL)shouldUpdateFocusInContext:(UIFocusUpdateContext *)context
|
||||
{
|
||||
return [_node shouldUpdateFocusInContext:context];
|
||||
}
|
||||
|
||||
- (UIView *)preferredFocusedView
|
||||
{
|
||||
return [_node preferredFocusedView];
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
||||
@@ -81,6 +81,46 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
// Focus Engine
|
||||
- (BOOL)canBecomeFocused
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setNeedsFocusUpdate
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
[_view setNeedsFocusUpdate];
|
||||
}
|
||||
|
||||
- (void)updateFocusIfNeeded
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
[_view updateFocusIfNeeded];
|
||||
}
|
||||
|
||||
- (BOOL)shouldUpdateFocusInContext:(UIFocusUpdateContext *)context
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (UIView *)preferredFocusedView
|
||||
{
|
||||
if (self.nodeLoaded) {
|
||||
return _view;
|
||||
}
|
||||
else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
- (BOOL)isFirstResponder
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
Reference in New Issue
Block a user