yeet
This commit is contained in:
55
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
generated
vendored
Normal file
55
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTRootView.h>
|
||||
|
||||
#import "RCTSurfaceHostingView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* This is a RCTRootView-compatible implementation of RCTSurfaceHostingView.
|
||||
* Use this class to replace all usages of RCTRootView in the app for easier migration
|
||||
* to RCTSurfaceHostingView.
|
||||
*
|
||||
* WARNING: In the future, RCTRootView will be deprecated in favor of RCTSurfaceHostingView.
|
||||
*/
|
||||
@interface RCTSurfaceHostingProxyRootView : RCTSurfaceHostingView
|
||||
|
||||
#pragma mark RCTRootView compatibility - keep these sync'ed with RCTRootView.h
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *moduleName;
|
||||
@property (nonatomic, strong, readonly) RCTBridge *bridge;
|
||||
@property (nonatomic, copy, readwrite) NSDictionary *appProperties;
|
||||
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility;
|
||||
@property (nonatomic, weak) id<RCTRootViewDelegate> delegate;
|
||||
@property (nonatomic, weak) UIViewController *reactViewController;
|
||||
@property (nonatomic, strong, readonly) UIView *contentView;
|
||||
@property (nonatomic, strong) UIView *loadingView;
|
||||
@property (nonatomic, assign) BOOL passThroughTouches;
|
||||
@property (nonatomic, assign) NSTimeInterval loadingViewFadeDelay;
|
||||
@property (nonatomic, assign) NSTimeInterval loadingViewFadeDuration;
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
launchOptions:(NSDictionary *)launchOptions;
|
||||
|
||||
- (instancetype)initWithSurface:(RCTSurface *)surface
|
||||
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode NS_UNAVAILABLE;
|
||||
|
||||
- (void)cancelTouches;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
182
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm
generated
vendored
Normal file
182
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm
generated
vendored
Normal file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTSurfaceHostingProxyRootView.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTPerformanceLogger.h"
|
||||
#import "RCTProfile.h"
|
||||
#import "RCTRootContentView.h"
|
||||
#import "RCTRootViewDelegate.h"
|
||||
#import "RCTSurface.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
static RCTSurfaceSizeMeasureMode convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibility sizeFlexibility)
|
||||
{
|
||||
switch (sizeFlexibility) {
|
||||
case RCTRootViewSizeFlexibilityWidthAndHeight:
|
||||
return RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightUndefined;
|
||||
case RCTRootViewSizeFlexibilityWidth:
|
||||
return RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightExact;
|
||||
case RCTRootViewSizeFlexibilityHeight:
|
||||
return RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightUndefined;
|
||||
case RCTRootViewSizeFlexibilityNone:
|
||||
return RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact;
|
||||
}
|
||||
}
|
||||
|
||||
static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSizeMeasureMode sizeMeasureMode)
|
||||
{
|
||||
switch (sizeMeasureMode) {
|
||||
case RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightUndefined:
|
||||
return RCTRootViewSizeFlexibilityWidthAndHeight;
|
||||
case RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightExact:
|
||||
return RCTRootViewSizeFlexibilityWidth;
|
||||
case RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightUndefined:
|
||||
return RCTRootViewSizeFlexibilityHeight;
|
||||
case RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact:
|
||||
default:
|
||||
return RCTRootViewSizeFlexibilityNone;
|
||||
}
|
||||
}
|
||||
|
||||
@implementation RCTSurfaceHostingProxyRootView
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
RCTAssert(bridge, @"A bridge instance is required to create an RCTSurfaceHostingProxyRootView");
|
||||
RCTAssert(moduleName, @"A moduleName is required to create an RCTSurfaceHostingProxyRootView");
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTSurfaceHostingProxyRootView init]", nil);
|
||||
|
||||
_bridge = bridge;
|
||||
|
||||
if (!bridge.isLoading) {
|
||||
[bridge.performanceLogger markStartForTag:RCTPLTTI];
|
||||
}
|
||||
|
||||
// `RCTRootViewSizeFlexibilityNone` is the RCTRootView's default.
|
||||
RCTSurfaceSizeMeasureMode sizeMeasureMode = convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibilityNone);
|
||||
|
||||
RCTSurface *surface = [[self class] createSurfaceWithBridge:bridge
|
||||
moduleName:moduleName
|
||||
initialProperties:initialProperties];
|
||||
[surface start];
|
||||
if (self = [super initWithSurface:surface sizeMeasureMode:sizeMeasureMode]) {
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
|
||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
launchOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:bundleURL moduleProvider:nil launchOptions:launchOptions];
|
||||
|
||||
return [self initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
|
||||
|
||||
#pragma mark proxy methods to RCTSurfaceHostingView
|
||||
|
||||
- (NSString *)moduleName
|
||||
{
|
||||
return super.surface.moduleName;
|
||||
}
|
||||
|
||||
- (UIView *)contentView
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSNumber *)reactTag
|
||||
{
|
||||
return super.surface.rootViewTag;
|
||||
}
|
||||
|
||||
- (RCTRootViewSizeFlexibility)sizeFlexibility
|
||||
{
|
||||
return convertToRootViewSizeFlexibility(super.sizeMeasureMode);
|
||||
}
|
||||
|
||||
- (void)setSizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility
|
||||
{
|
||||
super.sizeMeasureMode = convertToSurfaceSizeMeasureMode(sizeFlexibility);
|
||||
}
|
||||
|
||||
- (NSDictionary *)appProperties
|
||||
{
|
||||
return super.surface.properties;
|
||||
}
|
||||
|
||||
- (void)setAppProperties:(NSDictionary *)appProperties
|
||||
{
|
||||
[super.surface setProperties:appProperties];
|
||||
}
|
||||
|
||||
- (UIView *)loadingView
|
||||
{
|
||||
return super.activityIndicatorViewFactory ? super.activityIndicatorViewFactory() : nil;
|
||||
}
|
||||
|
||||
- (void)setLoadingView:(UIView *)loadingView
|
||||
{
|
||||
super.activityIndicatorViewFactory = ^UIView *(void)
|
||||
{
|
||||
return loadingView;
|
||||
};
|
||||
}
|
||||
|
||||
#pragma mark RCTSurfaceDelegate proxying
|
||||
|
||||
- (void)surface:(RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage
|
||||
{
|
||||
[super surface:surface didChangeStage:stage];
|
||||
if (RCTSurfaceStageIsRunning(stage)) {
|
||||
[_bridge.performanceLogger markStopForTag:RCTPLTTI];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTContentDidAppearNotification object:self];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)surface:(RCTSurface *)surface didChangeIntrinsicSize:(CGSize)intrinsicSize
|
||||
{
|
||||
[super surface:surface didChangeIntrinsicSize:intrinsicSize];
|
||||
|
||||
[_delegate rootViewDidChangeIntrinsicSize:(RCTRootView *)self];
|
||||
}
|
||||
|
||||
#pragma mark legacy
|
||||
|
||||
- (UIViewController *)reactViewController
|
||||
{
|
||||
return _reactViewController ?: [super reactViewController];
|
||||
}
|
||||
|
||||
#pragma mark unsupported
|
||||
|
||||
- (void)cancelTouches
|
||||
{
|
||||
// Not supported.
|
||||
}
|
||||
|
||||
@end
|
77
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h
generated
vendored
Normal file
77
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTSurfaceDelegate.h>
|
||||
#import <React/RCTSurfaceSizeMeasureMode.h>
|
||||
#import <React/RCTSurfaceStage.h>
|
||||
|
||||
@class RCTBridge;
|
||||
@class RCTSurface;
|
||||
|
||||
typedef UIView *_Nullable (^RCTSurfaceHostingViewActivityIndicatorViewFactory)(void);
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* UIView subclass which providers interoperability between UIKit and
|
||||
* Surface regarding layout and life-cycle.
|
||||
* This class can be used as easy-to-use general purpose integration point
|
||||
* of ReactNative-powered experiences in UIKit based apps.
|
||||
*/
|
||||
@interface RCTSurfaceHostingView : UIView <RCTSurfaceDelegate>
|
||||
|
||||
/**
|
||||
* Create an instance of RCTSurface to be hosted.
|
||||
*/
|
||||
+ (RCTSurface *)createSurfaceWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties;
|
||||
|
||||
/**
|
||||
* Designated initializer.
|
||||
* Instanciates a view with given Surface object.
|
||||
* Note: The view retains the surface object.
|
||||
*/
|
||||
- (instancetype)initWithSurface:(RCTSurface *)surface
|
||||
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* Convenience initializer.
|
||||
* Instanciates a Surface object with given `bridge`, `moduleName`, and
|
||||
* `initialProperties`, and then use it to instanciate a view.
|
||||
*/
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode;
|
||||
|
||||
/**
|
||||
* Surface object which is currently using to power the view.
|
||||
* Read-only.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) RCTSurface *surface;
|
||||
|
||||
/**
|
||||
* Size measure mode which are defining relationship between UIKit and ReactNative
|
||||
* layout approaches.
|
||||
* Defaults to `RCTSurfaceSizeMeasureModeWidthAtMost | RCTSurfaceSizeMeasureModeHeightAtMost`.
|
||||
*/
|
||||
@property (nonatomic, assign) RCTSurfaceSizeMeasureMode sizeMeasureMode;
|
||||
|
||||
/**
|
||||
* Activity indicator factory.
|
||||
* A hosting view may use this block to instantiate and display custom activity
|
||||
* (loading) indicator (aka "spinner") when it needed.
|
||||
* Defaults to `nil` (no activity indicator).
|
||||
*/
|
||||
@property (nonatomic, copy, nullable) RCTSurfaceHostingViewActivityIndicatorViewFactory activityIndicatorViewFactory;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
247
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm
generated
vendored
Normal file
247
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm
generated
vendored
Normal file
@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTSurfaceHostingView.h"
|
||||
|
||||
#import "RCTConstants.h"
|
||||
#import "RCTDefines.h"
|
||||
#import "RCTSurface.h"
|
||||
#import "RCTSurfaceDelegate.h"
|
||||
#import "RCTSurfaceView.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@interface RCTSurfaceHostingView ()
|
||||
|
||||
@property (nonatomic, assign) BOOL isActivityIndicatorViewVisible;
|
||||
@property (nonatomic, assign) BOOL isSurfaceViewVisible;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTSurfaceHostingView {
|
||||
UIView *_Nullable _activityIndicatorView;
|
||||
UIView *_Nullable _surfaceView;
|
||||
RCTSurfaceStage _stage;
|
||||
}
|
||||
|
||||
+ (RCTSurface *)createSurfaceWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
{
|
||||
return [[RCTSurface alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
||||
RCT_NOT_IMPLEMENTED(-(nullable instancetype)initWithCoder : (NSCoder *)coder)
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties
|
||||
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
|
||||
{
|
||||
RCTSurface *surface = [[self class] createSurfaceWithBridge:bridge
|
||||
moduleName:moduleName
|
||||
initialProperties:initialProperties];
|
||||
[surface start];
|
||||
return [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode];
|
||||
}
|
||||
|
||||
- (instancetype)initWithSurface:(RCTSurface *)surface sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
|
||||
{
|
||||
if (self = [super initWithFrame:CGRectZero]) {
|
||||
_surface = surface;
|
||||
_sizeMeasureMode = sizeMeasureMode;
|
||||
|
||||
_surface.delegate = self;
|
||||
_stage = surface.stage;
|
||||
[self _updateViews];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_surface stop];
|
||||
}
|
||||
|
||||
- (void)setFrame:(CGRect)frame
|
||||
{
|
||||
[super setFrame:frame];
|
||||
|
||||
CGSize minimumSize;
|
||||
CGSize maximumSize;
|
||||
|
||||
RCTSurfaceMinimumSizeAndMaximumSizeFromSizeAndSizeMeasureMode(
|
||||
self.bounds.size, _sizeMeasureMode, &minimumSize, &maximumSize);
|
||||
|
||||
[_surface setMinimumSize:minimumSize maximumSize:maximumSize];
|
||||
}
|
||||
|
||||
- (CGSize)intrinsicContentSize
|
||||
{
|
||||
if (RCTSurfaceStageIsPreparing(_stage)) {
|
||||
if (_activityIndicatorView) {
|
||||
return _activityIndicatorView.intrinsicContentSize;
|
||||
}
|
||||
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
return _surface.intrinsicSize;
|
||||
}
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size
|
||||
{
|
||||
if (RCTSurfaceStageIsPreparing(_stage)) {
|
||||
if (_activityIndicatorView) {
|
||||
return [_activityIndicatorView sizeThatFits:size];
|
||||
}
|
||||
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
CGSize minimumSize;
|
||||
CGSize maximumSize;
|
||||
|
||||
RCTSurfaceMinimumSizeAndMaximumSizeFromSizeAndSizeMeasureMode(size, _sizeMeasureMode, &minimumSize, &maximumSize);
|
||||
|
||||
return [_surface sizeThatFitsMinimumSize:minimumSize maximumSize:maximumSize];
|
||||
}
|
||||
|
||||
- (void)setStage:(RCTSurfaceStage)stage
|
||||
{
|
||||
if (stage == _stage) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL shouldInvalidateLayout = RCTSurfaceStageIsRunning(stage) != RCTSurfaceStageIsRunning(_stage) ||
|
||||
RCTSurfaceStageIsPreparing(stage) != RCTSurfaceStageIsPreparing(_stage);
|
||||
|
||||
_stage = stage;
|
||||
|
||||
if (shouldInvalidateLayout) {
|
||||
[self _invalidateLayout];
|
||||
[self _updateViews];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
|
||||
{
|
||||
if (sizeMeasureMode == _sizeMeasureMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
_sizeMeasureMode = sizeMeasureMode;
|
||||
[self _invalidateLayout];
|
||||
}
|
||||
|
||||
#pragma mark - isActivityIndicatorViewVisible
|
||||
|
||||
- (void)setIsActivityIndicatorViewVisible:(BOOL)visible
|
||||
{
|
||||
if (_isActivityIndicatorViewVisible == visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
_isActivityIndicatorViewVisible = visible;
|
||||
|
||||
if (visible) {
|
||||
if (_activityIndicatorViewFactory) {
|
||||
_activityIndicatorView = _activityIndicatorViewFactory();
|
||||
_activityIndicatorView.frame = self.bounds;
|
||||
_activityIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
[self addSubview:_activityIndicatorView];
|
||||
}
|
||||
} else {
|
||||
[_activityIndicatorView removeFromSuperview];
|
||||
_activityIndicatorView = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - isSurfaceViewVisible
|
||||
|
||||
- (void)setIsSurfaceViewVisible:(BOOL)visible
|
||||
{
|
||||
if (_isSurfaceViewVisible == visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
_isSurfaceViewVisible = visible;
|
||||
|
||||
if (visible) {
|
||||
_surfaceView = _surface.view;
|
||||
_surfaceView.frame = self.bounds;
|
||||
_surfaceView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
[self addSubview:_surfaceView];
|
||||
} else {
|
||||
[_surfaceView removeFromSuperview];
|
||||
_surfaceView = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - activityIndicatorViewFactory
|
||||
|
||||
- (void)setActivityIndicatorViewFactory:(RCTSurfaceHostingViewActivityIndicatorViewFactory)activityIndicatorViewFactory
|
||||
{
|
||||
_activityIndicatorViewFactory = activityIndicatorViewFactory;
|
||||
if (_isActivityIndicatorViewVisible) {
|
||||
self.isActivityIndicatorViewVisible = NO;
|
||||
self.isActivityIndicatorViewVisible = YES;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITraitCollection updates
|
||||
|
||||
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
|
||||
{
|
||||
[super traitCollectionDidChange:previousTraitCollection];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:RCTUserInterfaceStyleDidChangeNotification
|
||||
object:self
|
||||
userInfo:@{
|
||||
RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey : self.traitCollection,
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Private stuff
|
||||
|
||||
- (void)_invalidateLayout
|
||||
{
|
||||
[self invalidateIntrinsicContentSize];
|
||||
[self.superview setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)_updateViews
|
||||
{
|
||||
self.isSurfaceViewVisible = RCTSurfaceStageIsRunning(_stage);
|
||||
self.isActivityIndicatorViewVisible = RCTSurfaceStageIsPreparing(_stage);
|
||||
}
|
||||
|
||||
- (void)didMoveToWindow
|
||||
{
|
||||
[super didMoveToWindow];
|
||||
[self _updateViews];
|
||||
}
|
||||
|
||||
#pragma mark - RCTSurfaceDelegate
|
||||
|
||||
- (void)surface:(__unused RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage
|
||||
{
|
||||
RCTExecuteOnMainQueue(^{
|
||||
[self setStage:stage];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)surface:(__unused RCTSurface *)surface didChangeIntrinsicSize:(__unused CGSize)intrinsicSize
|
||||
{
|
||||
RCTExecuteOnMainQueue(^{
|
||||
[self _invalidateLayout];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
32
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.h
generated
vendored
Normal file
32
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.h
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTDefines.h>
|
||||
|
||||
/**
|
||||
* Bitmask defines how size constrains from `-[UIView sizeThatFits:]`
|
||||
* are translated to `-[RCTSurface sizeThatFitsMinimumSize:maximumSize:]`.
|
||||
*/
|
||||
typedef NS_OPTIONS(NSInteger, RCTSurfaceSizeMeasureMode) {
|
||||
RCTSurfaceSizeMeasureModeWidthUndefined = 0 << 0,
|
||||
RCTSurfaceSizeMeasureModeWidthExact = 1 << 0,
|
||||
RCTSurfaceSizeMeasureModeWidthAtMost = 2 << 0,
|
||||
RCTSurfaceSizeMeasureModeHeightUndefined = 0 << 2,
|
||||
RCTSurfaceSizeMeasureModeHeightExact = 1 << 2,
|
||||
RCTSurfaceSizeMeasureModeHeightAtMost = 2 << 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns size constraints based on `size` and `sizeMeasureMode`.
|
||||
*/
|
||||
RCT_EXTERN void RCTSurfaceMinimumSizeAndMaximumSizeFromSizeAndSizeMeasureMode(
|
||||
CGSize size,
|
||||
RCTSurfaceSizeMeasureMode sizeMeasureMode,
|
||||
CGSize *minimumSize,
|
||||
CGSize *maximumSize);
|
34
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.mm
generated
vendored
Normal file
34
node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.mm
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "RCTSurfaceSizeMeasureMode.h"
|
||||
|
||||
void RCTSurfaceMinimumSizeAndMaximumSizeFromSizeAndSizeMeasureMode(
|
||||
CGSize size,
|
||||
RCTSurfaceSizeMeasureMode sizeMeasureMode,
|
||||
CGSize *minimumSize,
|
||||
CGSize *maximumSize)
|
||||
{
|
||||
*minimumSize = CGSizeZero;
|
||||
*maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);
|
||||
|
||||
if (sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthExact) {
|
||||
minimumSize->width = size.width;
|
||||
maximumSize->width = size.width;
|
||||
} else if (sizeMeasureMode & RCTSurfaceSizeMeasureModeWidthAtMost) {
|
||||
maximumSize->width = size.width;
|
||||
}
|
||||
|
||||
if (sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightExact) {
|
||||
minimumSize->height = size.height;
|
||||
maximumSize->height = size.height;
|
||||
} else if (sizeMeasureMode & RCTSurfaceSizeMeasureModeHeightAtMost) {
|
||||
maximumSize->height = size.height;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user