mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
RCTSurface: Couple helper functions for Stage
Summary: We need this trivial funcs to unify spinner appearance logic. Reviewed By: rsnara Differential Revision: D6367072 fbshipit-source-id: 70e288bc1fed5911828a5f6deaa829597bf8ebff
This commit is contained in:
committed by
Facebook Github Bot
parent
da17b237e1
commit
e9e0cd7ab8
@@ -82,7 +82,7 @@
|
||||
_stage = RCTSurfaceStageSurfaceDidInitialize;
|
||||
|
||||
if (!bridge.loading) {
|
||||
_stage = (RCTSurfaceStage)(_stage | RCTSurfaceStageBridgeDidLoad);
|
||||
_stage = _stage | RCTSurfaceStageBridgeDidLoad;
|
||||
}
|
||||
|
||||
[self _registerRootViewTag];
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTDefines.h>
|
||||
|
||||
/**
|
||||
* The stage of the Surface
|
||||
*/
|
||||
@@ -22,3 +24,13 @@ typedef NS_OPTIONS(NSInteger, RCTSurfaceStage) {
|
||||
RCTSurfaceStageSurfaceDidInitialMounting = 1 << 6, // UIManager completed the first mounting pass
|
||||
RCTSurfaceStageSurfaceDidInvalidate = 1 << 7, // Surface received `invalidate` message
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns `YES` if the stage is suitable for displaying normal React Native app.
|
||||
*/
|
||||
RCT_EXTERN BOOL RCTSurfaceStageIsRunning(RCTSurfaceStage stage);
|
||||
|
||||
/**
|
||||
* Returns `YES` if the stage is suitable for displaying activity indicator.
|
||||
*/
|
||||
RCT_EXTERN BOOL RCTSurfaceStageIsPreparing(RCTSurfaceStage stage);
|
||||
|
||||
22
React/Base/Surface/RCTSurfaceStage.m
Normal file
22
React/Base/Surface/RCTSurfaceStage.m
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 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 "RCTSurfaceStage.h"
|
||||
|
||||
BOOL RCTSurfaceStageIsRunning(RCTSurfaceStage stage) {
|
||||
return
|
||||
(stage & RCTSurfaceStageSurfaceDidInitialLayout) &&
|
||||
!(stage & RCTSurfaceStageSurfaceDidInvalidate);
|
||||
}
|
||||
|
||||
BOOL RCTSurfaceStageIsPreparing(RCTSurfaceStage stage) {
|
||||
return
|
||||
!(stage & RCTSurfaceStageSurfaceDidInitialLayout) &&
|
||||
!(stage & RCTSurfaceStageSurfaceDidInvalidate);
|
||||
}
|
||||
Reference in New Issue
Block a user