/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/React/Base/Surface/RCTSurfaceView.mm
84 строки
2 KB
Ramanpreet Nara
Add macros to remove old runtime
12 июн 2025, 22:43
12 июн 2025, 22:43
fb1a4d7
Код
Авторство
О чём код?
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import "RCTSurfaceView.h" #import "RCTSurfaceView+Internal.h" #import "RCTDefines.h" #import "RCTSurface.h" #import "RCTSurfaceProtocol.h" #import "RCTSurfaceRootView.h" @implementation RCTSurfaceView { RCTSurfaceRootView *_Nullable _rootView; RCTSurfaceStage _stage; } RCT_NOT_IMPLEMENTED(-(instancetype)init) RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) RCT_NOT_IMPLEMENTED(-(nullable instancetype)initWithCoder : (NSCoder *)coder) - (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface { if (self = [super initWithFrame:CGRectZero]) { _stage = surface.stage; _surface = surface; } return self; } #pragma mark - Internal Interface - (void)setRootView:(RCTSurfaceRootView *_Nullable)rootView { if (_rootView == rootView) { return; } [_rootView removeFromSuperview]; _rootView = rootView; [self _updateStage]; } - (RCTSurfaceRootView *)rootView { return _rootView; } #pragma mark - stage - (void)setStage:(RCTSurfaceStage)stage { if (stage == _stage) { return; } _stage = stage; [self _updateStage]; } - (RCTSurfaceStage)stage { return _stage; } #pragma mark - Private - (void)_updateStage { if (RCTSurfaceStageIsRunning(_stage)) { if (_rootView && _rootView.superview != self) { [self addSubview:_rootView]; } } else { [_rootView removeFromSuperview]; } } @end