Skip to content

Commit

Permalink
RCTSurface: activityIndicatorViewFactory was removed from RCTSurfaceView
Browse files Browse the repository at this point in the history
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 43b2509
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 37 deletions.
3 changes: 0 additions & 3 deletions React/Base/Surface/RCTSurfaceView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 5 additions & 34 deletions React/Base/Surface/RCTSurfaceView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

@implementation RCTSurfaceView {
RCTSurfaceRootView *_Nullable _rootView;
UIView *_Nullable _activityIndicatorView;
RCTSurfaceStage _stage;
}

Expand Down Expand Up @@ -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
Expand All @@ -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.