mirror of
https://github.com/status-im/react-native.git
synced 2025-01-17 21:11:45 +00:00
dd3a6eda70
Summary: This diff contains several tight to each other changes (which can/should not be split into several diffs): * The props parsing/conversion process was de-virtualized: we don't use virtual `apply` method to parse props anymore. Instead, we use old-fashioned constructors. * All fields of Props classes which represent props values were marked as `const` which make impossible to modify them after the objects were created (even if we have non-const value-of/pointer-to the whole Props object). Those fields are also `public` now. * All custom handwritten getters were removed (because we don't need them anymore). So, now we don't need all those custom getters which makes code much more compact, performant and codegen-friendly. Reviewed By: fkgozali Differential Revision: D7901245 fbshipit-source-id: 9f4b1fd2da64bf963b63215ed3bd74b9d3c58dd5
72 lines
2.1 KiB
Plaintext
72 lines
2.1 KiB
Plaintext
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTParagraphComponentView.h"
|
|
|
|
#import <fabric/core/LocalData.h>
|
|
#import <fabric/graphics/Geometry.h>
|
|
#import <fabric/text/ParagraphLocalData.h>
|
|
#import <fabric/text/ParagraphProps.h>
|
|
#import <fabric/textlayoutmanager/TextLayoutManager.h>
|
|
#import <fabric/textlayoutmanager/RCTTextLayoutManager.h>
|
|
#import "RCTConversions.h"
|
|
|
|
using namespace facebook::react;
|
|
|
|
@implementation RCTParagraphComponentView {
|
|
SharedParagraphLocalData _paragraphLocalData;
|
|
ParagraphAttributes _paragraphAttributes;
|
|
}
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
if (self = [super initWithFrame:frame]) {
|
|
self.isAccessibilityElement = YES;
|
|
self.accessibilityTraits |= UIAccessibilityTraitStaticText;
|
|
self.opaque = NO;
|
|
self.contentMode = UIViewContentModeRedraw;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)updateProps:(SharedProps)props oldProps:(SharedProps)oldProps
|
|
{
|
|
[super updateProps:props oldProps:oldProps];
|
|
auto paragraphProps = std::static_pointer_cast<const ParagraphProps>(props);
|
|
assert(paragraphProps);
|
|
_paragraphAttributes = paragraphProps->paragraphAttributes;
|
|
}
|
|
|
|
- (void)updateLocalData:(SharedLocalData)localData
|
|
oldLocalData:(SharedLocalData)oldLocalData
|
|
{
|
|
_paragraphLocalData = std::static_pointer_cast<const ParagraphLocalData>(localData);
|
|
assert(_paragraphLocalData);
|
|
[self setNeedsDisplay];
|
|
}
|
|
|
|
- (void)drawRect:(CGRect)rect
|
|
{
|
|
if (!_paragraphLocalData) {
|
|
return;
|
|
}
|
|
|
|
SharedTextLayoutManager textLayoutManager =
|
|
_paragraphLocalData->getTextLayoutManager();
|
|
RCTTextLayoutManager *nativeTextLayoutManager =
|
|
(__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager();
|
|
|
|
CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame());
|
|
|
|
[nativeTextLayoutManager drawAttributedString:_paragraphLocalData->getAttributedString()
|
|
paragraphAttributes:_paragraphAttributes
|
|
frame:frame];
|
|
}
|
|
|
|
@end
|