Permalink
Browse files

RCTSurface: activityIndicatorViewFactory was removed from RCTSurfaceView

Summary: Apparently we don't need this at this level. This will be implemented as part of RCTSufraceHostingView.

Reviewed By: rsnara

Differential Revision: D6367071

fbshipit-source-id: 71a2361b8a0c6594c63602165ce5e054de62630d
  • Loading branch information...
shergin authored and facebook-github-bot committed Dec 4, 2017
1 parent e9e0cd7 commit 43b25093202472c5af07d4f393d831e4d1484b07
Showing with 5 additions and 37 deletions.
  1. +0 −3 React/Base/Surface/RCTSurfaceView.h
  2. +5 −34 React/Base/Surface/RCTSurfaceView.mm
@@ -13,16 +13,13 @@ NS_ASSUME_NONNULL_BEGIN
@class RCTSurface;
typedef UIView *(^RCTSurfaceActivityIndicatorViewFactory)();
/**
* UIView instance which represents the Surface
*/
@interface RCTSurfaceView : UIView
- (instancetype)initWithSurface:(RCTSurface *)surface NS_DESIGNATED_INITIALIZER;
@property (nonatomic, copy, nullable) RCTSurfaceActivityIndicatorViewFactory activityIndicatorViewFactory;
@property (nonatomic, weak, readonly, nullable) RCTSurface *surface;
@end
@@ -16,7 +16,6 @@
@implementation RCTSurfaceView {
RCTSurfaceRootView *_Nullable _rootView;
UIView *_Nullable _activityIndicatorView;
RCTSurfaceStage _stage;
}
@@ -44,30 +43,14 @@ - (void)setRootView:(RCTSurfaceRootView *)rootView
[_rootView removeFromSuperview];
_rootView = rootView;
[self updateStage];
[self _updateStage];
}
- (RCTSurfaceRootView *)rootView
{
return _rootView;
}
#pragma mark - activityIndicatorView
- (void)setActivityIndicatorView:(UIView *)view
{
[_activityIndicatorView removeFromSuperview];
_activityIndicatorView = view;
_activityIndicatorView.frame = self.bounds;
_activityIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:_activityIndicatorView];
}
- (UIView *)activityIndicatorView
{
return _activityIndicatorView;
}
#pragma mark - stage
- (void)setStage:(RCTSurfaceStage)stage
@@ -78,38 +61,26 @@ - (void)setStage:(RCTSurfaceStage)stage
_stage = stage;
[self updateStage];
[self _updateStage];
}
- (RCTSurfaceStage)stage
{
return _stage;
}
#pragma mark - Visibility
#pragma mark - Private
- (void)updateStage
- (void)_updateStage
{
BOOL displayRootView = _stage & RCTSurfaceStageSurfaceDidInitialLayout;
BOOL displayActivityIndicator = !displayRootView;
if (displayRootView) {
if (RCTSurfaceStageIsRunning(_stage)) {
if (_rootView.superview != self) {
[self addSubview:_rootView];
}
}
else {
[_rootView removeFromSuperview];
}
if (displayActivityIndicator) {
if (!_activityIndicatorView && self.activityIndicatorViewFactory != nil) {
self.activityIndicatorView = self.activityIndicatorViewFactory();
}
}
else {
[_activityIndicatorView removeFromSuperview];
}
}
@end

0 comments on commit 43b2509

Please sign in to comment.