From 5701ae2145c7af4fa86b5a82f5883e62af7a61f0 Mon Sep 17 00:00:00 2001 From: Yu Wang Date: Fri, 14 Jul 2017 18:14:46 -0700 Subject: [PATCH] Support `shadowView.rootView` Reviewed By: shergin Differential Revision: D5418509 fbshipit-source-id: 585b088678096ccf8416ea21a675d8953bfa82c8 --- React/Views/RCTShadowView+Hierarchy.h | 16 ++++++++++++++++ React/Views/RCTShadowView+Hierarchy.m | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 React/Views/RCTShadowView+Hierarchy.h create mode 100644 React/Views/RCTShadowView+Hierarchy.m diff --git a/React/Views/RCTShadowView+Hierarchy.h b/React/Views/RCTShadowView+Hierarchy.h new file mode 100644 index 000000000..be644c953 --- /dev/null +++ b/React/Views/RCTShadowView+Hierarchy.h @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +#import +#import + +@interface RCTShadowView (Hierarchy) + +@property (nonatomic, readonly) RCTRootShadowView *rootView; + +@end diff --git a/React/Views/RCTShadowView+Hierarchy.m b/React/Views/RCTShadowView+Hierarchy.m new file mode 100644 index 000000000..d0b05c8a9 --- /dev/null +++ b/React/Views/RCTShadowView+Hierarchy.m @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +#import "RCTShadowView+Hierarchy.h" + +@implementation RCTShadowView (Hierarchy) + +- (nullable RCTRootShadowView *)rootView +{ + RCTShadowView *view = self; + while (view != nil && ![view isKindOfClass:[RCTRootShadowView class]]) { + view = view.superview; + } + + return (RCTRootShadowView *)view; +} + +@end