Fabric: More clang-format

Summary: Apparently, I haven't modify all files in D14018903. Here is the last (I hope) chunk.

Reviewed By: JoshuaGross

Differential Revision: D14058288

fbshipit-source-id: b21950cdd1aa9aa55b0c72fac0f8b44e4a7d131c
This commit is contained in:
Valentin Shergin
2019-02-13 14:11:50 -08:00
committed by Facebook Github Bot
parent 6b21109d3d
commit 9101ebdfbb
22 changed files with 202 additions and 235 deletions

View File

@@ -7,12 +7,13 @@
#import "RCTActivityIndicatorViewComponentView.h"
#import <react/components/activityindicator/ActivityIndicatorViewShadowNode.h>
#import <react/components/activityindicator/ActivityIndicatorViewProps.h>
#import <react/components/activityindicator/ActivityIndicatorViewShadowNode.h>
using namespace facebook::react;
static UIActivityIndicatorViewStyle convertActivityIndicatorViewStyle(const ActivityIndicatorViewSize &size) {
static UIActivityIndicatorViewStyle convertActivityIndicatorViewStyle(const ActivityIndicatorViewSize &size)
{
switch (size) {
case ActivityIndicatorViewSize::Small:
return UIActivityIndicatorViewStyleWhite;

View File

@@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
#import "RCTViewComponentView.h"
#import <React/RCTImageResponseDelegate.h>
#import "RCTViewComponentView.h"
NS_ASSUME_NONNULL_BEGIN

View File

@@ -7,16 +7,16 @@
#import "RCTImageComponentView.h"
#import <React/RCTImageResponseObserverProxy.h>
#import <react/components/image/ImageEventEmitter.h>
#import <react/components/image/ImageLocalData.h>
#import <react/components/image/ImageProps.h>
#import <react/components/image/ImageShadowNode.h>
#import <react/imagemanager/ImageRequest.h>
#import <react/imagemanager/RCTImagePrimitivesConversions.h>
#import <React/RCTImageResponseObserverProxy.h>
#import "RCTConversions.h"
#import "MainQueueExecutor.h"
#import "RCTConversions.h"
@implementation RCTImageComponentView {
UIImageView *_imageView;
@@ -35,7 +35,7 @@
_imageView.clipsToBounds = YES;
_imageView.contentMode = (UIViewContentMode)RCTResizeModeFromImageResizeMode(defaultProps->resizeMode);
_imageResponseObserverProxy = std::make_unique<RCTImageResponseObserverProxy>((__bridge void *)self);
self.contentView = _imageView;
@@ -75,24 +75,24 @@
}
}
- (void)updateLocalData:(SharedLocalData)localData
oldLocalData:(SharedLocalData)oldLocalData
- (void)updateLocalData:(SharedLocalData)localData oldLocalData:(SharedLocalData)oldLocalData
{
SharedImageLocalData previousData = _imageLocalData;
_imageLocalData = std::static_pointer_cast<const ImageLocalData>(localData);
assert(_imageLocalData);
bool havePreviousData = previousData != nullptr;
if (!havePreviousData || _imageLocalData->getImageSource() != previousData->getImageSource()) {
self.coordinator = _imageLocalData->getImageRequest().getObserverCoordinator();
// Loading actually starts a little before this, but this is the first time we know
// the image is loading and can fire an event from this component
std::static_pointer_cast<const ImageEventEmitter>(_eventEmitter)->onLoadStart();
}
}
- (void)setCoordinator:(const ImageResponseObserverCoordinator *)coordinator {
- (void)setCoordinator:(const ImageResponseObserverCoordinator *)coordinator
{
if (_coordinator) {
_coordinator->removeObserver(_imageResponseObserverProxy.get());
}
@@ -110,7 +110,7 @@
_imageLocalData.reset();
}
-(void)dealloc
- (void)dealloc
{
self.coordinator = nullptr;
_imageResponseObserverProxy.reset();
@@ -118,7 +118,7 @@
#pragma mark - RCTImageResponseDelegate
- (void)didReceiveImage:(UIImage *)image fromObserver:(void*)observer
- (void)didReceiveImage:(UIImage *)image fromObserver:(void *)observer
{
std::static_pointer_cast<const ImageEventEmitter>(_eventEmitter)->onLoad();
@@ -138,7 +138,7 @@
}
self->_imageView.image = image;
// Apply trilinear filtering to smooth out mis-sized images.
self->_imageView.layer.minificationFilter = kCAFilterTrilinear;
self->_imageView.layer.magnificationFilter = kCAFilterTrilinear;
@@ -146,13 +146,14 @@
std::static_pointer_cast<const ImageEventEmitter>(self->_eventEmitter)->onLoadEnd();
}
- (void)didReceiveProgress:(float)progress fromObserver:(void*)observer {
- (void)didReceiveProgress:(float)progress fromObserver:(void *)observer
{
std::static_pointer_cast<const ImageEventEmitter>(_eventEmitter)->onProgress(progress);
}
- (void)didReceiveFailureFromObserver:(void*)observer {
- (void)didReceiveFailureFromObserver:(void *)observer
{
std::static_pointer_cast<const ImageEventEmitter>(_eventEmitter)->onError();
}
@end

View File

@@ -7,8 +7,8 @@
#import "RCTRootComponentView.h"
#import <react/components/root/RootShadowNode.h>
#import <react/components/root/RootProps.h>
#import <react/components/root/RootShadowNode.h>
using namespace facebook::react;

View File

@@ -8,10 +8,10 @@
#import "RCTScrollViewComponentView.h"
#import <React/RCTAssert.h>
#import <react/components/scrollview/ScrollViewShadowNode.h>
#import <react/components/scrollview/ScrollViewEventEmitter.h>
#import <react/components/scrollview/ScrollViewLocalData.h>
#import <react/components/scrollview/ScrollViewProps.h>
#import <react/components/scrollview/ScrollViewEventEmitter.h>
#import <react/components/scrollview/ScrollViewShadowNode.h>
#import <react/graphics/Geometry.h>
#import "RCTConversions.h"
@@ -63,9 +63,9 @@ using namespace facebook::react;
[super updateProps:props oldProps:oldProps];
#define REMAP_PROP(reactName, localName, target) \
#define REMAP_PROP(reactName, localName, target) \
if (oldScrollViewProps.reactName != newScrollViewProps.reactName) { \
target.localName = newScrollViewProps.reactName; \
target.localName = newScrollViewProps.reactName; \
}
#define REMAP_VIEW_PROP(reactName, localName) REMAP_PROP(reactName, localName, self)
@@ -80,11 +80,11 @@ using namespace facebook::react;
MAP_SCROLL_VIEW_PROP(bouncesZoom);
MAP_SCROLL_VIEW_PROP(canCancelContentTouches);
MAP_SCROLL_VIEW_PROP(centerContent);
//MAP_SCROLL_VIEW_PROP(automaticallyAdjustContentInsets);
// MAP_SCROLL_VIEW_PROP(automaticallyAdjustContentInsets);
MAP_SCROLL_VIEW_PROP(decelerationRate);
MAP_SCROLL_VIEW_PROP(directionalLockEnabled);
//MAP_SCROLL_VIEW_PROP(indicatorStyle);
//MAP_SCROLL_VIEW_PROP(keyboardDismissMode);
// MAP_SCROLL_VIEW_PROP(indicatorStyle);
// MAP_SCROLL_VIEW_PROP(keyboardDismissMode);
MAP_SCROLL_VIEW_PROP(maximumZoomScale);
MAP_SCROLL_VIEW_PROP(minimumZoomScale);
MAP_SCROLL_VIEW_PROP(scrollEnabled);
@@ -95,30 +95,27 @@ using namespace facebook::react;
MAP_SCROLL_VIEW_PROP(showsVerticalScrollIndicator);
MAP_VIEW_PROP(scrollEventThrottle);
MAP_SCROLL_VIEW_PROP(zoomScale);
//MAP_SCROLL_VIEW_PROP(contentInset);
//MAP_SCROLL_VIEW_PROP(scrollIndicatorInsets);
//MAP_SCROLL_VIEW_PROP(snapToInterval);
//MAP_SCROLL_VIEW_PROP(snapToAlignment);
// MAP_SCROLL_VIEW_PROP(contentInset);
// MAP_SCROLL_VIEW_PROP(scrollIndicatorInsets);
// MAP_SCROLL_VIEW_PROP(snapToInterval);
// MAP_SCROLL_VIEW_PROP(snapToAlignment);
}
- (void)updateLocalData:(SharedLocalData)localData
oldLocalData:(SharedLocalData)oldLocalData
- (void)updateLocalData:(SharedLocalData)localData oldLocalData:(SharedLocalData)oldLocalData
{
assert(std::dynamic_pointer_cast<const ScrollViewLocalData>(localData));
_scrollViewLocalData = std::static_pointer_cast<const ScrollViewLocalData>(localData);
CGSize contentSize = RCTCGSizeFromSize(_scrollViewLocalData->getContentSize());
_contentView.frame = CGRect {CGPointZero, contentSize};
_contentView.frame = CGRect{CGPointZero, contentSize};
_scrollView.contentSize = contentSize;
}
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[_contentView insertSubview:childComponentView atIndex:index];
}
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
RCTAssert(childComponentView.superview == _contentView, @"Attempt to unmount improperly mounted component view.");
[childComponentView removeFromSuperview];
@@ -152,14 +149,17 @@ using namespace facebook::react;
std::static_pointer_cast<const ScrollViewEventEmitter>(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]);
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint *)targetContentOffset
{
std::static_pointer_cast<const ScrollViewEventEmitter>(_eventEmitter)->onScrollEndDrag([self _scrollViewMetrics]);
}
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
std::static_pointer_cast<const ScrollViewEventEmitter>(_eventEmitter)->onMomentumScrollBegin([self _scrollViewMetrics]);
std::static_pointer_cast<const ScrollViewEventEmitter>(_eventEmitter)
->onMomentumScrollBegin([self _scrollViewMetrics]);
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

View File

@@ -7,11 +7,11 @@
#import "RCTSliderComponentView.h"
#import <React/RCTImageResponseObserverProxy.h>
#import <react/components/slider/SliderEventEmitter.h>
#import <react/components/slider/SliderLocalData.h>
#import <react/components/slider/SliderProps.h>
#import <react/components/slider/SliderShadowNode.h>
#import <react/components/slider/SliderLocalData.h>
#import <React/RCTImageResponseObserverProxy.h>
#import "MainQueueExecutor.h"
@@ -21,12 +21,12 @@ using namespace facebook::react;
UISlider *_sliderView;
float _previousValue;
SharedSliderLocalData _sliderLocalData;
UIImage *_trackImage;
UIImage *_minimumTrackImage;
UIImage *_maximumTrackImage;
UIImage *_thumbImage;
const ImageResponseObserverCoordinator *_trackImageCoordinator;
const ImageResponseObserverCoordinator *_minimumTrackImageCoordinator;
const ImageResponseObserverCoordinator *_maximumTrackImageCoordinator;
@@ -38,7 +38,6 @@ using namespace facebook::react;
std::unique_ptr<RCTImageResponseObserverProxy> _thumbImageResponseObserverProxy;
}
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
@@ -47,14 +46,10 @@ using namespace facebook::react;
_sliderView = [[UISlider alloc] initWithFrame:self.bounds];
[_sliderView addTarget:self
action:@selector(onChange:)
forControlEvents:UIControlEventValueChanged];
[_sliderView addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged];
[_sliderView addTarget:self
action:@selector(sliderTouchEnd:)
forControlEvents:(UIControlEventTouchUpInside |
UIControlEventTouchUpOutside |
UIControlEventTouchCancel)];
forControlEvents:(UIControlEventTouchUpInside | UIControlEventTouchUpOutside | UIControlEventTouchCancel)];
_sliderView.value = defaultProps->value;
@@ -74,7 +69,7 @@ using namespace facebook::react;
- (void)prepareForRecycle
{
[super prepareForRecycle];
self.trackImageCoordinator = nullptr;
self.minimumTrackImageCoordinator = nullptr;
self.maximumTrackImageCoordinator = nullptr;
@@ -94,7 +89,7 @@ using namespace facebook::react;
_thumbImage = nil;
}
-(void)dealloc
- (void)dealloc
{
self.trackImageCoordinator = nullptr;
self.minimumTrackImageCoordinator = nullptr;
@@ -158,21 +153,22 @@ using namespace facebook::react;
}
}
- (void)updateLocalData:(SharedLocalData)localData
oldLocalData:(SharedLocalData)oldLocalData
- (void)updateLocalData:(SharedLocalData)localData oldLocalData:(SharedLocalData)oldLocalData
{
SharedSliderLocalData previousData = _sliderLocalData;
_sliderLocalData = std::static_pointer_cast<const SliderLocalData>(localData);
assert(_sliderLocalData);
bool havePreviousData = previousData != nullptr;
if (!havePreviousData || _sliderLocalData->getTrackImageSource() != previousData->getTrackImageSource()) {
self.trackImageCoordinator = _sliderLocalData->getTrackImageRequest().getObserverCoordinator();
}
if (!havePreviousData || _sliderLocalData->getMinimumTrackImageSource() != previousData->getMinimumTrackImageSource()) {
if (!havePreviousData ||
_sliderLocalData->getMinimumTrackImageSource() != previousData->getMinimumTrackImageSource()) {
self.minimumTrackImageCoordinator = _sliderLocalData->getMinimumTrackImageRequest().getObserverCoordinator();
}
if (!havePreviousData || _sliderLocalData->getMaximumTrackImageSource() != previousData->getMaximumTrackImageSource()) {
if (!havePreviousData ||
_sliderLocalData->getMaximumTrackImageSource() != previousData->getMaximumTrackImageSource()) {
self.maximumTrackImageCoordinator = _sliderLocalData->getMaximumTrackImageRequest().getObserverCoordinator();
}
if (!havePreviousData || _sliderLocalData->getThumbImageSource() != previousData->getThumbImageSource()) {
@@ -180,7 +176,8 @@ using namespace facebook::react;
}
}
- (void)setTrackImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator {
- (void)setTrackImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator
{
if (_trackImageCoordinator) {
_trackImageCoordinator->removeObserver(_trackImageResponseObserverProxy.get());
}
@@ -190,7 +187,8 @@ using namespace facebook::react;
}
}
- (void)setMinimumTrackImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator {
- (void)setMinimumTrackImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator
{
if (_minimumTrackImageCoordinator) {
_minimumTrackImageCoordinator->removeObserver(_minimumTrackImageResponseObserverProxy.get());
}
@@ -200,7 +198,8 @@ using namespace facebook::react;
}
}
- (void)setMaximumTrackImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator {
- (void)setMaximumTrackImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator
{
if (_maximumTrackImageCoordinator) {
_maximumTrackImageCoordinator->removeObserver(_maximumTrackImageResponseObserverProxy.get());
}
@@ -210,7 +209,8 @@ using namespace facebook::react;
}
}
- (void)setThumbImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator {
- (void)setThumbImageCoordinator:(const ImageResponseObserverCoordinator *)coordinator
{
if (_thumbImageCoordinator) {
_thumbImageCoordinator->removeObserver(_thumbImageResponseObserverProxy.get());
}
@@ -220,56 +220,58 @@ using namespace facebook::react;
}
}
- (void)setTrackImage:(UIImage *)trackImage {
- (void)setTrackImage:(UIImage *)trackImage
{
if ([trackImage isEqual:_trackImage]) {
return;
}
_trackImage = trackImage;
_minimumTrackImage = nil;
_maximumTrackImage = nil;
CGFloat width = trackImage.size.width / 2;
UIImage *minimumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){
0, width, 0, width
} resizingMode:UIImageResizingModeStretch];
UIImage *maximumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){
0, width, 0, width
} resizingMode:UIImageResizingModeStretch];
UIImage *minimumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){0, width, 0, width}
resizingMode:UIImageResizingModeStretch];
UIImage *maximumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){0, width, 0, width}
resizingMode:UIImageResizingModeStretch];
[_sliderView setMinimumTrackImage:minimumTrackImage forState:UIControlStateNormal];
[_sliderView setMaximumTrackImage:maximumTrackImage forState:UIControlStateNormal];
}
-(void)setMinimumTrackImage:(UIImage *)minimumTrackImage {
- (void)setMinimumTrackImage:(UIImage *)minimumTrackImage
{
if ([minimumTrackImage isEqual:_minimumTrackImage] && _trackImage == nil) {
return;
}
_trackImage = nil;
_minimumTrackImage = minimumTrackImage;
_minimumTrackImage = [_minimumTrackImage resizableImageWithCapInsets:(UIEdgeInsets) {
0, _minimumTrackImage.size.width, 0, 0
} resizingMode:UIImageResizingModeStretch];
_minimumTrackImage =
[_minimumTrackImage resizableImageWithCapInsets:(UIEdgeInsets){0, _minimumTrackImage.size.width, 0, 0}
resizingMode:UIImageResizingModeStretch];
[_sliderView setMinimumTrackImage:_minimumTrackImage forState:UIControlStateNormal];
}
-(void)setMaximumTrackImage:(UIImage *)maximumTrackImage {
- (void)setMaximumTrackImage:(UIImage *)maximumTrackImage
{
if ([maximumTrackImage isEqual:_maximumTrackImage] && _trackImage == nil) {
return;
}
_trackImage = nil;
_maximumTrackImage = maximumTrackImage;
_maximumTrackImage = [_maximumTrackImage resizableImageWithCapInsets:(UIEdgeInsets) {
0, 0, 0, _maximumTrackImage.size.width
} resizingMode:UIImageResizingModeStretch];
_maximumTrackImage =
[_maximumTrackImage resizableImageWithCapInsets:(UIEdgeInsets){0, 0, 0, _maximumTrackImage.size.width}
resizingMode:UIImageResizingModeStretch];
[_sliderView setMaximumTrackImage:_maximumTrackImage forState:UIControlStateNormal];
}
-(void)setThumbImage:(UIImage *)thumbImage {
- (void)setThumbImage:(UIImage *)thumbImage
{
if ([thumbImage isEqual:_thumbImage]) {
return;
}
_thumbImage = thumbImage;
[_sliderView setThumbImage:thumbImage forState:UIControlStateNormal];
}
@@ -289,14 +291,12 @@ using namespace facebook::react;
float value = sender.value;
const auto &props = *std::static_pointer_cast<const SliderProps>(_props);
if (props.step > 0 && value <= (props.maximumValue - props.minimumValue)) {
value = MAX(props.minimumValue,
MIN(props.maximumValue,
props.minimumValue + round((value - props.minimumValue) / props.step) * props.step
)
);
value = MAX(
props.minimumValue,
MIN(props.maximumValue, props.minimumValue + round((value - props.minimumValue) / props.step) * props.step));
[_sliderView setValue:value animated:YES];
}
@@ -306,7 +306,7 @@ using namespace facebook::react;
if (!continuous) {
std::dynamic_pointer_cast<const SliderEventEmitter>(_eventEmitter)->onSlidingComplete(value);
}
_previousValue = value;
}
@@ -325,11 +325,12 @@ using namespace facebook::react;
}
}
- (void)didReceiveProgress:(float)progress fromObserver:(void *)observer {
- (void)didReceiveProgress:(float)progress fromObserver:(void *)observer
{
}
- (void)didReceiveFailureFromObserver:(void *)observer {
- (void)didReceiveFailureFromObserver:(void *)observer
{
}
@end

View File

@@ -26,9 +26,7 @@ using namespace facebook::react;
_switchView = [[UISwitch alloc] initWithFrame:self.bounds];
[_switchView addTarget:self
action:@selector(onChange:)
forControlEvents:UIControlEventValueChanged];
[_switchView addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged];
_switchView.on = defaultProps->value;
@@ -86,7 +84,8 @@ using namespace facebook::react;
}
_wasOn = sender.on;
std::dynamic_pointer_cast<const SwitchEventEmitter>(_eventEmitter)->onChange(SwitchOnChangeStruct{.value=static_cast<bool>(sender.on)});
std::dynamic_pointer_cast<const SwitchEventEmitter>(_eventEmitter)
->onChange(SwitchOnChangeStruct{.value = static_cast<bool>(sender.on)});
}
@end

View File

@@ -12,8 +12,8 @@
#import <react/components/text/ParagraphShadowNode.h>
#import <react/core/LocalData.h>
#import <react/graphics/Geometry.h>
#import <react/textlayoutmanager/TextLayoutManager.h>
#import <react/textlayoutmanager/RCTTextLayoutManager.h>
#import <react/textlayoutmanager/TextLayoutManager.h>
#import "RCTConversions.h"
using namespace facebook::react;
@@ -55,8 +55,7 @@ using namespace facebook::react;
_paragraphAttributes = paragraphProps->paragraphAttributes;
}
- (void)updateLocalData:(SharedLocalData)localData
oldLocalData:(SharedLocalData)oldLocalData
- (void)updateLocalData:(SharedLocalData)localData oldLocalData:(SharedLocalData)oldLocalData
{
_paragraphLocalData = std::static_pointer_cast<const ParagraphLocalData>(localData);
assert(_paragraphLocalData);
@@ -75,10 +74,9 @@ using namespace facebook::react;
return;
}
SharedTextLayoutManager textLayoutManager =
_paragraphLocalData->getTextLayoutManager();
SharedTextLayoutManager textLayoutManager = _paragraphLocalData->getTextLayoutManager();
RCTTextLayoutManager *nativeTextLayoutManager =
(__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager();
(__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager();
CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame());
@@ -91,8 +89,7 @@ using namespace facebook::react;
- (NSString *)accessibilityLabel
{
NSString *superAccessibilityLabel =
RCTNSStringFromStringNilIfEmpty(_props->accessibilityLabel);
NSString *superAccessibilityLabel = RCTNSStringFromStringNilIfEmpty(_props->accessibilityLabel);
if (superAccessibilityLabel) {
return superAccessibilityLabel;
}
@@ -111,14 +108,15 @@ using namespace facebook::react;
}
SharedTextLayoutManager textLayoutManager = _paragraphLocalData->getTextLayoutManager();
RCTTextLayoutManager *nativeTextLayoutManager = (__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager();
RCTTextLayoutManager *nativeTextLayoutManager =
(__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager();
CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame());
SharedEventEmitter eventEmitter =
[nativeTextLayoutManager getEventEmitterWithAttributeString:_paragraphLocalData->getAttributedString()
paragraphAttributes:_paragraphAttributes
frame:frame
atPoint:point];
[nativeTextLayoutManager getEventEmitterWithAttributeString:_paragraphLocalData->getAttributedString()
paragraphAttributes:_paragraphAttributes
frame:frame
atPoint:point];
if (!eventEmitter) {
return _eventEmitter;

View File

@@ -8,13 +8,13 @@
#import <UIKit/UIKit.h>
#import <React/RCTComponentViewProtocol.h>
#import <React/RCTTouchableComponentViewProtocol.h>
#import <React/UIView+ComponentViewProtocol.h>
#import <react/core/LayoutMetrics.h>
#import <react/core/Props.h>
#import <react/components/view/ViewEventEmitter.h>
#import <react/components/view/ViewProps.h>
#import <react/core/LayoutMetrics.h>
#import <react/core/Props.h>
#import <react/events/EventEmitter.h>
#import <React/RCTTouchableComponentViewProtocol.h>
NS_ASSUME_NONNULL_BEGIN
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
* UIView class for <View> component.
*/
@interface RCTViewComponentView : UIView <RCTComponentViewProtocol, RCTTouchableComponentViewProtocol> {
@protected
@protected
facebook::react::LayoutMetrics _layoutMetrics;
facebook::react::SharedViewProps _props;
facebook::react::SharedViewEventEmitter _eventEmitter;

View File

@@ -7,19 +7,18 @@
#import "RCTViewComponentView.h"
#import <react/components/view/ViewShadowNode.h>
#import <react/components/view/ViewProps.h>
#import <react/components/view/ViewEventEmitter.h>
#import <objc/runtime.h>
#import <React/RCTAssert.h>
#import <React/RCTBorderDrawing.h>
#import <objc/runtime.h>
#import <react/components/view/ViewEventEmitter.h>
#import <react/components/view/ViewProps.h>
#import <react/components/view/ViewShadowNode.h>
#import "RCTConversions.h"
using namespace facebook::react;
@implementation RCTViewComponentView
{
@implementation RCTViewComponentView {
UIColor *_backgroundColor;
CALayer *_borderLayer;
}
@@ -84,25 +83,23 @@ using namespace facebook::react;
+ (ComponentHandle)componentHandle
{
RCTAssert(
self == [RCTViewComponentView class],
@"`+[RCTComponentViewProtocol componentHandle]` must be implemented for all subclasses (and `%@` particularly).", NSStringFromClass([self class]));
self == [RCTViewComponentView class],
@"`+[RCTComponentViewProtocol componentHandle]` must be implemented for all subclasses (and `%@` particularly).",
NSStringFromClass([self class]));
return ViewShadowNode::Handle();
}
- (void)updateProps:(SharedProps)props
oldProps:(SharedProps)oldProps
- (void)updateProps:(SharedProps)props oldProps:(SharedProps)oldProps
{
#ifndef NS_BLOCK_ASSERTIONS
auto propsRawPtr = _props.get();
RCTAssert(
propsRawPtr &&
(
[self class] == [RCTViewComponentView class] ||
typeid(*propsRawPtr).hash_code() != typeid(const ViewProps).hash_code()
),
@"`RCTViewComponentView` subclasses (and `%@` particularly) must setup `_props`"
" instance variable with a default value in the constructor.", NSStringFromClass([self class])
);
propsRawPtr &&
([self class] == [RCTViewComponentView class] ||
typeid(*propsRawPtr).hash_code() != typeid(const ViewProps).hash_code()),
@"`RCTViewComponentView` subclasses (and `%@` particularly) must setup `_props`"
" instance variable with a default value in the constructor.",
NSStringFromClass([self class]));
#endif
const auto &oldViewProps = *std::static_pointer_cast<const ViewProps>(oldProps ?: _props);
@@ -194,11 +191,8 @@ using namespace facebook::react;
}
// `border`
if (
oldViewProps.borderStyles != newViewProps.borderStyles ||
oldViewProps.borderRadii != newViewProps.borderRadii ||
oldViewProps.borderColors != newViewProps.borderColors
) {
if (oldViewProps.borderStyles != newViewProps.borderStyles || oldViewProps.borderRadii != newViewProps.borderRadii ||
oldViewProps.borderColors != newViewProps.borderColors) {
needsInvalidateLayer = YES;
}
@@ -224,7 +218,8 @@ using namespace facebook::react;
// `accessibilityTraits`
if (oldViewProps.accessibilityTraits != newViewProps.accessibilityTraits) {
self.accessibilityElement.accessibilityTraits = RCTUIAccessibilityTraitsFromAccessibilityTraits(newViewProps.accessibilityTraits);
self.accessibilityElement.accessibilityTraits =
RCTUIAccessibilityTraitsFromAccessibilityTraits(newViewProps.accessibilityTraits);
}
// `accessibilityViewIsModal`
@@ -257,8 +252,7 @@ using namespace facebook::react;
_eventEmitter = std::static_pointer_cast<const ViewEventEmitter>(eventEmitter);
}
- (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics
oldLayoutMetrics:(LayoutMetrics)oldLayoutMetrics
- (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics oldLayoutMetrics:(LayoutMetrics)oldLayoutMetrics
{
_layoutMetrics = layoutMetrics;
@@ -291,11 +285,11 @@ using namespace facebook::react;
}
NSArray<__kindof UIView *> *sortedSubviews =
[self.subviews sortedArrayUsingComparator:^NSComparisonResult(UIView *a, UIView *b) {
// Ensure sorting is stable by treating equal `zIndex` as ascending so
// that original order is preserved.
return a.layer.zPosition > b.layer.zPosition ? NSOrderedDescending : NSOrderedAscending;
}];
[self.subviews sortedArrayUsingComparator:^NSComparisonResult(UIView *a, UIView *b) {
// Ensure sorting is stable by treating equal `zIndex` as ascending so
// that original order is preserved.
return a.layer.zPosition > b.layer.zPosition ? NSOrderedDescending : NSOrderedAscending;
}];
for (UIView *subview in [sortedSubviews reverseObjectEnumerator]) {
UIView *hitView = [subview hitTest:[subview convertPoint:point fromView:self] withEvent:event];
@@ -322,34 +316,32 @@ using namespace facebook::react;
}
}
static RCTCornerRadii RCTCornerRadiiFromBorderRadii(BorderRadii borderRadii) {
return RCTCornerRadii {
.topLeft = (CGFloat)borderRadii.topLeft,
.topRight = (CGFloat)borderRadii.topRight,
.bottomLeft = (CGFloat)borderRadii.bottomLeft,
.bottomRight = (CGFloat)borderRadii.bottomRight
};
static RCTCornerRadii RCTCornerRadiiFromBorderRadii(BorderRadii borderRadii)
{
return RCTCornerRadii{.topLeft = (CGFloat)borderRadii.topLeft,
.topRight = (CGFloat)borderRadii.topRight,
.bottomLeft = (CGFloat)borderRadii.bottomLeft,
.bottomRight = (CGFloat)borderRadii.bottomRight};
}
static RCTBorderColors RCTBorderColorsFromBorderColors(BorderColors borderColors) {
return RCTBorderColors {
.left = RCTCGColorRefFromSharedColor(borderColors.left),
.top = RCTCGColorRefFromSharedColor(borderColors.top),
.bottom = RCTCGColorRefFromSharedColor(borderColors.bottom),
.right = RCTCGColorRefFromSharedColor(borderColors.right)
};
static RCTBorderColors RCTBorderColorsFromBorderColors(BorderColors borderColors)
{
return RCTBorderColors{.left = RCTCGColorRefFromSharedColor(borderColors.left),
.top = RCTCGColorRefFromSharedColor(borderColors.top),
.bottom = RCTCGColorRefFromSharedColor(borderColors.bottom),
.right = RCTCGColorRefFromSharedColor(borderColors.right)};
}
static UIEdgeInsets UIEdgeInsetsFromBorderInsets(EdgeInsets edgeInsets) {
return UIEdgeInsets {
.left = (CGFloat)edgeInsets.left,
.top = (CGFloat)edgeInsets.top,
.bottom = (CGFloat)edgeInsets.bottom,
.right = (CGFloat)edgeInsets.right
};
static UIEdgeInsets UIEdgeInsetsFromBorderInsets(EdgeInsets edgeInsets)
{
return UIEdgeInsets{.left = (CGFloat)edgeInsets.left,
.top = (CGFloat)edgeInsets.top,
.bottom = (CGFloat)edgeInsets.bottom,
.right = (CGFloat)edgeInsets.right};
}
static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) {
static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
{
switch (borderStyle) {
case BorderStyle::Solid:
return RCTBorderStyleSolid;
@@ -363,7 +355,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) {
- (void)invalidateLayer
{
const auto borderMetrics =
_props->resolveBorderMetrics(_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft);
_props->resolveBorderMetrics(_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft);
CALayer *layer = self.layer;
@@ -373,7 +365,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) {
if (CGColorGetAlpha(_backgroundColor.CGColor) > 0.999) {
// If view has a solid background color, calculate shadow path from border.
const RCTCornerInsets cornerInsets =
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero);
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero);
CGPathRef shadowPath = RCTPathCreateWithRoundedRect(self.bounds, cornerInsets, nil);
layer.shadowPath = shadowPath;
CGPathRelease(shadowPath);
@@ -387,19 +379,15 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) {
// Stage 2. Border Rendering
const bool useCoreAnimationBorderRendering =
borderMetrics.borderColors.isUniform() &&
borderMetrics.borderWidths.isUniform() &&
borderMetrics.borderStyles.isUniform() &&
borderMetrics.borderRadii.isUniform() &&
borderMetrics.borderStyles.left == BorderStyle::Solid &&
(
// iOS draws borders in front of the content whereas CSS draws them behind
// the content. For this reason, only use iOS border drawing when clipping
// or when the border is hidden.
borderMetrics.borderWidths.left == 0 ||
colorComponentsFromColor(borderMetrics.borderColors.left).alpha == 0 ||
self.clipsToBounds
);
borderMetrics.borderColors.isUniform() && borderMetrics.borderWidths.isUniform() &&
borderMetrics.borderStyles.isUniform() && borderMetrics.borderRadii.isUniform() &&
borderMetrics.borderStyles.left == BorderStyle::Solid &&
(
// iOS draws borders in front of the content whereas CSS draws them behind
// the content. For this reason, only use iOS border drawing when clipping
// or when the border is hidden.
borderMetrics.borderWidths.left == 0 ||
colorComponentsFromColor(borderMetrics.borderColors.left).alpha == 0 || self.clipsToBounds);
if (useCoreAnimationBorderRendering) {
if (_borderLayer) {
@@ -430,24 +418,22 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) {
_contentView.layer.masksToBounds = NO;
UIImage *image = RCTGetBorderImage(
RCTBorderStyleFromBorderStyle(borderMetrics.borderStyles.left),
layer.bounds.size,
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
UIEdgeInsetsFromBorderInsets(borderMetrics.borderWidths),
RCTBorderColorsFromBorderColors(borderMetrics.borderColors),
_backgroundColor.CGColor,
self.clipsToBounds
);
RCTBorderStyleFromBorderStyle(borderMetrics.borderStyles.left),
layer.bounds.size,
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
UIEdgeInsetsFromBorderInsets(borderMetrics.borderWidths),
RCTBorderColorsFromBorderColors(borderMetrics.borderColors),
_backgroundColor.CGColor,
self.clipsToBounds);
if (image == nil) {
_borderLayer.contents = nil;
} else {
CGSize imageSize = image.size;
UIEdgeInsets imageCapInsets = image.capInsets;
CGRect contentsCenter = CGRect {
CGPoint {imageCapInsets.left / imageSize.width, imageCapInsets.top / imageSize.height},
CGSize {(CGFloat)1.0 / imageSize.width, (CGFloat)1.0 / imageSize.height}
};
CGRect contentsCenter =
CGRect{CGPoint{imageCapInsets.left / imageSize.width, imageCapInsets.top / imageSize.height},
CGSize{(CGFloat)1.0 / imageSize.width, (CGFloat)1.0 / imageSize.height}};
_borderLayer.contents = (id)image.CGImage;
_borderLayer.contentsScale = image.scale;
@@ -456,7 +442,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) {
if (isResizable) {
_borderLayer.contentsCenter = contentsCenter;
} else {
_borderLayer.contentsCenter = CGRect { CGPoint {0.0, 0.0}, CGSize {1.0, 1.0}};
_borderLayer.contentsCenter = CGRect{CGPoint{0.0, 0.0}, CGSize{1.0, 1.0}};
}
}
@@ -470,10 +456,9 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) {
} else {
// In this case we have to generate masking layer manually.
CGPathRef path = RCTPathCreateWithRoundedRect(
self.bounds,
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero),
nil
);
self.bounds,
RCTGetCornerInsets(RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii), UIEdgeInsetsZero),
nil);
maskLayer = [CAShapeLayer layer];
maskLayer.path = path;
@@ -533,9 +518,10 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view)
NSMutableArray<UIAccessibilityCustomAction *> *customActions = [NSMutableArray array];
for (const auto &accessibilityAction : accessibilityActions) {
[customActions addObject:[[UIAccessibilityCustomAction alloc] initWithName:RCTNSStringFromString(accessibilityAction)
target:self
selector:@selector(didActivateAccessibilityCustomAction:)]];
[customActions
addObject:[[UIAccessibilityCustomAction alloc] initWithName:RCTNSStringFromString(accessibilityAction)
target:self
selector:@selector(didActivateAccessibilityCustomAction:)]];
}
return [customActions copy];

View File

@@ -7,9 +7,9 @@
#import <UIKit/UIKit.h>
#import <react/core/ReactPrimitives.h>
#import <React/RCTMountItemProtocol.h>
#import <React/RCTPrimitives.h>
#import <react/core/ReactPrimitives.h>
NS_ASSUME_NONNULL_BEGIN
@@ -20,8 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface RCTCreateMountItem : NSObject <RCTMountItemProtocol>
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
tag:(ReactTag)tag;
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle tag:(ReactTag)tag;
@end

View File

@@ -16,8 +16,7 @@ using namespace facebook::react;
ReactTag _tag;
}
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
tag:(ReactTag)tag
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle tag:(ReactTag)tag
{
if (self = [super init]) {
_componentHandle = componentHandle;

View File

@@ -7,9 +7,9 @@
#import <UIKit/UIKit.h>
#import <react/core/ReactPrimitives.h>
#import <React/RCTMountItemProtocol.h>
#import <React/RCTPrimitives.h>
#import <react/core/ReactPrimitives.h>
NS_ASSUME_NONNULL_BEGIN
@@ -18,8 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface RCTDeleteMountItem : NSObject <RCTMountItemProtocol>
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
tag:(ReactTag)tag;
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle tag:(ReactTag)tag;
@end

View File

@@ -16,8 +16,7 @@ using namespace facebook::react;
ReactTag _tag;
}
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
tag:(ReactTag)tag
- (instancetype)initWithComponentHandle:(facebook::react::ComponentHandle)componentHandle tag:(ReactTag)tag
{
if (self = [super init]) {
_componentHandle = componentHandle;

View File

@@ -19,9 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface RCTInsertMountItem : NSObject <RCTMountItemProtocol>
- (instancetype)initWithChildTag:(ReactTag)childTag
parentTag:(ReactTag)parentTag
index:(NSInteger)index;
- (instancetype)initWithChildTag:(ReactTag)childTag parentTag:(ReactTag)parentTag index:(NSInteger)index;
@end

View File

@@ -15,9 +15,7 @@
NSInteger _index;
}
- (instancetype)initWithChildTag:(ReactTag)childTag
parentTag:(ReactTag)parentTag
index:(NSInteger)index
- (instancetype)initWithChildTag:(ReactTag)childTag parentTag:(ReactTag)parentTag index:(NSInteger)index
{
if (self = [super init]) {
_childTag = childTag;
@@ -37,8 +35,7 @@
return;
}
[parentComponentView mountChildComponentView:childComponentView
index:_index];
[parentComponentView mountChildComponentView:childComponentView index:_index];
}
@end

View File

@@ -17,9 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface RCTRemoveMountItem : NSObject <RCTMountItemProtocol>
- (instancetype)initWithChildTag:(ReactTag)childTag
parentTag:(ReactTag)parentTag
index:(NSInteger)index;
- (instancetype)initWithChildTag:(ReactTag)childTag parentTag:(ReactTag)parentTag index:(NSInteger)index;
@end

View File

@@ -15,9 +15,7 @@
NSInteger _index;
}
- (instancetype)initWithChildTag:(ReactTag)childTag
parentTag:(ReactTag)parentTag
index:(NSInteger)index
- (instancetype)initWithChildTag:(ReactTag)childTag parentTag:(ReactTag)parentTag index:(NSInteger)index
{
if (self = [super init]) {
_childTag = childTag;
@@ -37,8 +35,7 @@
return;
}
[parentComponentView unmountChildComponentView:childComponentView
index:_index];
[parentComponentView unmountChildComponentView:childComponentView index:_index];
}
@end

View File

@@ -18,8 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface RCTUpdateEventEmitterMountItem : NSObject <RCTMountItemProtocol>
- (instancetype)initWithTag:(ReactTag)tag
eventEmitter:(facebook::react::SharedEventEmitter)eventEmitter;
- (instancetype)initWithTag:(ReactTag)tag eventEmitter:(facebook::react::SharedEventEmitter)eventEmitter;
@end

View File

@@ -16,8 +16,7 @@ using namespace facebook::react;
SharedEventEmitter _eventEmitter;
}
- (instancetype)initWithTag:(ReactTag)tag
eventEmitter:(SharedEventEmitter)eventEmitter
- (instancetype)initWithTag:(ReactTag)tag eventEmitter:(SharedEventEmitter)eventEmitter
{
if (self = [super init]) {
_tag = tag;

View File

@@ -34,8 +34,7 @@ using namespace facebook::react;
{
UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:_tag];
[componentView updateLayoutMetrics:_newLayoutMetrics
oldLayoutMetrics:_oldLayoutMetrics];
[componentView updateLayoutMetrics:_newLayoutMetrics oldLayoutMetrics:_oldLayoutMetrics];
}
@end

View File

@@ -17,9 +17,7 @@ using namespace facebook::react;
SharedProps _newProps;
}
- (instancetype)initWithTag:(ReactTag)tag
oldProps:(SharedProps)oldProps
newProps:(SharedProps)newProps
- (instancetype)initWithTag:(ReactTag)tag oldProps:(SharedProps)oldProps newProps:(SharedProps)newProps
{
if (self = [super init]) {
_tag = tag;