2018-01-24 10:17:57 +03:00
|
|
|
/**
|
2018-09-12 01:27:47 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-01-24 10:17:57 +03:00
|
|
|
*
|
2018-02-17 05:24:55 +03:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-01-24 10:17:57 +03:00
|
|
|
*/
|
|
|
|
|
CocoaPods frameworks compatibility: Step 2 (#25619)
Summary:
This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in https://github.com/facebook/react-native/pull/25393#issuecomment-508457700. If accepted, it will fix https://github.com/facebook/react-native/issues/25349.
It builds on the changes I made in https://github.com/facebook/react-native/pull/25496 by ensuring each podspec has a unique value for `header_dir` so that framework imports do not conflict. Every podspec which should be included in the `<React/*>` namespace now includes it's headers from `React-Core.podspec`.
The following pods can still be imported with `<React/*>` and so should not have breaking changes: `React-ART`,`React-DevSupport`, `React-CoreModules`, `React-RCTActionSheet`, `React-RCTAnimation`, `React-RCTBlob`, `React-RCTImage`, `React-RCTLinking`, `React-RCTNetwork`, `React-RCTPushNotification`, `React-RCTSettings`, `React-RCTText`, `React-RCTSettings`, `React-RCTVibration`, `React-RCTWebSocket` .
There are still a few breaking changes which I hope will be acceptable:
- `React-Core.podspec` has been moved to the root of the project. Any `Podfile` that references it will need to update the path.
- ~~`React-turbomodule-core`'s headers now live under `<turbomodule/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-turbomodulesamples`'s headers now live under `<turbomodulesamples/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-TypeSaferty`'s headers now live under `<TypeSafety/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511040967.
- ~~`React-jscallinvoker`'s headers now live under `<jscallinvoker/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- Each podspec now uses `s.static_framework = true`. This means that a minimum of CocoaPods 1.5 ([released in April 2018](http://blog.cocoapods.org/CocoaPods-1.5.0/)) is now required. This is needed so that the ` __has_include` conditions can still work when frameworks are enabled.
Still to do:
- ~~Including `React-turbomodule-core` with `use_frameworks!` enabled causes the C++ import failures we saw in https://github.com/facebook/react-native/issues/25349. I'm sure it will be possible to fix this but I need to dig deeper (perhaps a custom modulemap would be needed).~~ Addressed by https://github.com/facebook/react-native/pull/25619/commits/33573511f02f3502a28bad48e085e9a4b8608302.
- I haven't got Fabric working yet. I wonder if it would be acceptable to move Fabric out of the `<React/*>` namespace since it is new? �
## Changelog
[iOS] [Fixed] - Fixed compatibility with CocoaPods frameworks.
Pull Request resolved: https://github.com/facebook/react-native/pull/25619
Test Plan:
### FB
```
buck build catalyst
```
### Sample Project
Everything should work exactly as before, where `use_frameworks!` is not in `Podfile`s. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which has `use_frameworks!` in its `Podfile` to demonstrate this is fixed.
You can see that it works with these steps:
1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git`
2. `git checkout fix-frameworks-subspecs`
3. `cd ios && pod install`
4. `cd .. && react-native run-ios`
The sample app will build and run successfully. To see that it still works without frameworks, remove `use_frameworks!` from the `Podfile` and do steps 3 and 4 again.
### RNTesterPods
`RNTesterPodsPods` can now work with or without `use_frameworks!`.
1. Go to the `RNTester` directory and run `pod install`.
2. Run the tests in `RNTesterPods.xcworkspace` to see that everything still works fine.
3. Uncomment the `use_frameworks!` line at the top of `RNTester/Podfile` and run `pod install` again.
4. Run the tests again and see that it still works with frameworks enabled.
Reviewed By: PeteTheHeat
Differential Revision: D16465247
Pulled By: PeteTheHeat
fbshipit-source-id: cad837e9cced06d30cc5b372af1c65c7780b9e7a
2019-07-25 08:26:42 +03:00
|
|
|
#import <React/RCTBaseTextInputShadowView.h>
|
2018-01-24 10:17:57 +03:00
|
|
|
|
|
|
|
#import <React/RCTBridge.h>
|
|
|
|
#import <React/RCTShadowView+Layout.h>
|
|
|
|
#import <React/RCTUIManager.h>
|
|
|
|
#import <yoga/Yoga.h>
|
|
|
|
|
|
|
|
#import "NSTextStorage+FontScaling.h"
|
CocoaPods frameworks compatibility: Step 2 (#25619)
Summary:
This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in https://github.com/facebook/react-native/pull/25393#issuecomment-508457700. If accepted, it will fix https://github.com/facebook/react-native/issues/25349.
It builds on the changes I made in https://github.com/facebook/react-native/pull/25496 by ensuring each podspec has a unique value for `header_dir` so that framework imports do not conflict. Every podspec which should be included in the `<React/*>` namespace now includes it's headers from `React-Core.podspec`.
The following pods can still be imported with `<React/*>` and so should not have breaking changes: `React-ART`,`React-DevSupport`, `React-CoreModules`, `React-RCTActionSheet`, `React-RCTAnimation`, `React-RCTBlob`, `React-RCTImage`, `React-RCTLinking`, `React-RCTNetwork`, `React-RCTPushNotification`, `React-RCTSettings`, `React-RCTText`, `React-RCTSettings`, `React-RCTVibration`, `React-RCTWebSocket` .
There are still a few breaking changes which I hope will be acceptable:
- `React-Core.podspec` has been moved to the root of the project. Any `Podfile` that references it will need to update the path.
- ~~`React-turbomodule-core`'s headers now live under `<turbomodule/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-turbomodulesamples`'s headers now live under `<turbomodulesamples/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-TypeSaferty`'s headers now live under `<TypeSafety/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511040967.
- ~~`React-jscallinvoker`'s headers now live under `<jscallinvoker/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- Each podspec now uses `s.static_framework = true`. This means that a minimum of CocoaPods 1.5 ([released in April 2018](http://blog.cocoapods.org/CocoaPods-1.5.0/)) is now required. This is needed so that the ` __has_include` conditions can still work when frameworks are enabled.
Still to do:
- ~~Including `React-turbomodule-core` with `use_frameworks!` enabled causes the C++ import failures we saw in https://github.com/facebook/react-native/issues/25349. I'm sure it will be possible to fix this but I need to dig deeper (perhaps a custom modulemap would be needed).~~ Addressed by https://github.com/facebook/react-native/pull/25619/commits/33573511f02f3502a28bad48e085e9a4b8608302.
- I haven't got Fabric working yet. I wonder if it would be acceptable to move Fabric out of the `<React/*>` namespace since it is new? �
## Changelog
[iOS] [Fixed] - Fixed compatibility with CocoaPods frameworks.
Pull Request resolved: https://github.com/facebook/react-native/pull/25619
Test Plan:
### FB
```
buck build catalyst
```
### Sample Project
Everything should work exactly as before, where `use_frameworks!` is not in `Podfile`s. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which has `use_frameworks!` in its `Podfile` to demonstrate this is fixed.
You can see that it works with these steps:
1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git`
2. `git checkout fix-frameworks-subspecs`
3. `cd ios && pod install`
4. `cd .. && react-native run-ios`
The sample app will build and run successfully. To see that it still works without frameworks, remove `use_frameworks!` from the `Podfile` and do steps 3 and 4 again.
### RNTesterPods
`RNTesterPodsPods` can now work with or without `use_frameworks!`.
1. Go to the `RNTester` directory and run `pod install`.
2. Run the tests in `RNTesterPods.xcworkspace` to see that everything still works fine.
3. Uncomment the `use_frameworks!` line at the top of `RNTester/Podfile` and run `pod install` again.
4. Run the tests again and see that it still works with frameworks enabled.
Reviewed By: PeteTheHeat
Differential Revision: D16465247
Pulled By: PeteTheHeat
fbshipit-source-id: cad837e9cced06d30cc5b372af1c65c7780b9e7a
2019-07-25 08:26:42 +03:00
|
|
|
#import <React/RCTBaseTextInputView.h>
|
2018-01-24 10:17:57 +03:00
|
|
|
|
|
|
|
@implementation RCTBaseTextInputShadowView
|
|
|
|
{
|
|
|
|
__weak RCTBridge *_bridge;
|
|
|
|
NSAttributedString *_Nullable _previousAttributedText;
|
|
|
|
BOOL _needsUpdateView;
|
|
|
|
NSAttributedString *_Nullable _localAttributedText;
|
|
|
|
CGSize _previousContentSize;
|
|
|
|
|
2018-09-11 03:45:04 +03:00
|
|
|
NSString *_text;
|
2018-01-24 10:17:57 +03:00
|
|
|
NSTextStorage *_textStorage;
|
|
|
|
NSTextContainer *_textContainer;
|
|
|
|
NSLayoutManager *_layoutManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
|
|
{
|
|
|
|
if (self = [super init]) {
|
|
|
|
_bridge = bridge;
|
|
|
|
_needsUpdateView = YES;
|
|
|
|
|
|
|
|
YGNodeSetMeasureFunc(self.yogaNode, RCTBaseTextInputShadowViewMeasure);
|
2018-02-16 04:40:14 +03:00
|
|
|
YGNodeSetBaselineFunc(self.yogaNode, RCTTextInputShadowViewBaseline);
|
2018-01-24 10:17:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isYogaLeafNode
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2019-09-17 19:15:56 +03:00
|
|
|
- (void)didSetProps:(NSArray<NSString *> *)changedProps
|
|
|
|
{
|
|
|
|
[super didSetProps:changedProps];
|
|
|
|
|
|
|
|
// `backgroundColor` and `opacity` are being applied directly to a UIView,
|
|
|
|
// therefore we need to exclude them from base `textAttributes`.
|
|
|
|
self.textAttributes.backgroundColor = nil;
|
|
|
|
self.textAttributes.opacity = NAN;
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:04:16 +03:00
|
|
|
- (void)layoutSubviewsWithContext:(RCTLayoutContext)layoutContext
|
|
|
|
{
|
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
2018-01-24 10:17:57 +03:00
|
|
|
- (void)setLocalData:(NSObject *)localData
|
|
|
|
{
|
|
|
|
NSAttributedString *attributedText = (NSAttributedString *)localData;
|
|
|
|
|
|
|
|
if ([attributedText isEqualToAttributedString:_localAttributedText]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_localAttributedText = attributedText;
|
|
|
|
[self dirtyLayout];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dirtyLayout
|
|
|
|
{
|
|
|
|
[super dirtyLayout];
|
|
|
|
_needsUpdateView = YES;
|
|
|
|
YGNodeMarkDirty(self.yogaNode);
|
|
|
|
[self invalidateContentSize];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)invalidateContentSize
|
|
|
|
{
|
|
|
|
if (!_onContentSizeChange) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:04:16 +03:00
|
|
|
CGSize maximumSize = self.layoutMetrics.frame.size;
|
2018-01-24 10:17:57 +03:00
|
|
|
|
|
|
|
if (_maximumNumberOfLines == 1) {
|
|
|
|
maximumSize.width = CGFLOAT_MAX;
|
|
|
|
} else {
|
|
|
|
maximumSize.height = CGFLOAT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGSize contentSize = [self sizeThatFitsMinimumSize:(CGSize)CGSizeZero maximumSize:maximumSize];
|
|
|
|
|
|
|
|
if (CGSizeEqualToSize(_previousContentSize, contentSize)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_previousContentSize = contentSize;
|
|
|
|
|
|
|
|
_onContentSizeChange(@{
|
|
|
|
@"contentSize": @{
|
|
|
|
@"height": @(contentSize.height),
|
|
|
|
@"width": @(contentSize.width),
|
|
|
|
},
|
|
|
|
@"target": self.reactTag,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-09-11 03:45:04 +03:00
|
|
|
- (NSString *)text
|
|
|
|
{
|
|
|
|
return _text;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setText:(NSString *)text
|
|
|
|
{
|
|
|
|
_text = text;
|
|
|
|
// Clear `_previousAttributedText` to notify the view about the change
|
|
|
|
// when `text` native prop is set.
|
|
|
|
_previousAttributedText = nil;
|
|
|
|
[self dirtyLayout];
|
|
|
|
}
|
|
|
|
|
2018-01-24 10:17:57 +03:00
|
|
|
#pragma mark - RCTUIManagerObserver
|
|
|
|
|
|
|
|
- (void)uiManagerWillPerformMounting
|
|
|
|
{
|
|
|
|
if (YGNodeIsDirty(self.yogaNode)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_needsUpdateView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_needsUpdateView = NO;
|
|
|
|
|
|
|
|
UIEdgeInsets borderInsets = self.borderAsInsets;
|
|
|
|
UIEdgeInsets paddingInsets = self.paddingAsInsets;
|
|
|
|
|
|
|
|
RCTTextAttributes *textAttributes = [self.textAttributes copy];
|
|
|
|
|
|
|
|
NSMutableAttributedString *attributedText =
|
|
|
|
[[NSMutableAttributedString alloc] initWithAttributedString:[self attributedTextWithBaseTextAttributes:nil]];
|
|
|
|
|
2019-07-23 13:19:41 +03:00
|
|
|
// Removing all references to Shadow Views and tags to avoid unnecessary retaining
|
2018-01-24 10:17:57 +03:00
|
|
|
// and problems with comparing the strings.
|
|
|
|
[attributedText removeAttribute:RCTBaseTextShadowViewEmbeddedShadowViewAttributeName
|
|
|
|
range:NSMakeRange(0, attributedText.length)];
|
|
|
|
|
|
|
|
[attributedText removeAttribute:RCTTextAttributesTagAttributeName
|
|
|
|
range:NSMakeRange(0, attributedText.length)];
|
|
|
|
|
|
|
|
if (self.text.length) {
|
|
|
|
NSAttributedString *propertyAttributedText =
|
|
|
|
[[NSAttributedString alloc] initWithString:self.text
|
|
|
|
attributes:self.textAttributes.effectiveTextAttributes];
|
|
|
|
[attributedText insertAttributedString:propertyAttributedText atIndex:0];
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL isAttributedTextChanged = NO;
|
|
|
|
if (![_previousAttributedText isEqualToAttributedString:attributedText]) {
|
|
|
|
// We have to follow `set prop` pattern:
|
|
|
|
// If the value has not changed, we must not notify the view about the change,
|
|
|
|
// otherwise we may break local (temporary) state of the text input.
|
|
|
|
isAttributedTextChanged = YES;
|
|
|
|
_previousAttributedText = [attributedText copy];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSNumber *tag = self.reactTag;
|
|
|
|
|
|
|
|
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
|
|
RCTBaseTextInputView *baseTextInputView = (RCTBaseTextInputView *)viewRegistry[tag];
|
|
|
|
if (!baseTextInputView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
baseTextInputView.textAttributes = textAttributes;
|
|
|
|
baseTextInputView.reactBorderInsets = borderInsets;
|
|
|
|
baseTextInputView.reactPaddingInsets = paddingInsets;
|
|
|
|
|
|
|
|
if (isAttributedTextChanged) {
|
2019-06-06 19:13:52 +03:00
|
|
|
// Don't set `attributedText` if length equal to zero, otherwise it would shrink when attributes contain like `lineHeight`.
|
|
|
|
if (attributedText.length != 0) {
|
|
|
|
baseTextInputView.attributedText = attributedText;
|
|
|
|
} else {
|
|
|
|
baseTextInputView.attributedText = nil;
|
|
|
|
}
|
2018-01-24 10:17:57 +03:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2018-02-16 04:40:14 +03:00
|
|
|
- (NSAttributedString *)measurableAttributedText
|
2018-01-24 10:17:57 +03:00
|
|
|
{
|
|
|
|
// Only for the very first render when we don't have `_localAttributedText`,
|
|
|
|
// we use value directly from the property and/or nested content.
|
|
|
|
NSAttributedString *attributedText =
|
|
|
|
_localAttributedText ?: [self attributedTextWithBaseTextAttributes:nil];
|
|
|
|
|
|
|
|
if (attributedText.length == 0) {
|
|
|
|
// It's impossible to measure empty attributed string because all attributes are
|
2019-07-23 13:19:41 +03:00
|
|
|
// associated with some characters, so no characters means no data.
|
2018-01-24 10:17:57 +03:00
|
|
|
|
|
|
|
// Placeholder also can represent the intrinsic size when it is visible.
|
|
|
|
NSString *text = self.placeholder;
|
|
|
|
if (!text.length) {
|
2018-03-19 12:10:36 +03:00
|
|
|
// Note: `zero-width space` is insufficient in some cases.
|
|
|
|
text = @"I";
|
2018-01-24 10:17:57 +03:00
|
|
|
}
|
|
|
|
attributedText = [[NSAttributedString alloc] initWithString:text attributes:self.textAttributes.effectiveTextAttributes];
|
|
|
|
}
|
|
|
|
|
2018-02-16 04:40:14 +03:00
|
|
|
return attributedText;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize
|
|
|
|
{
|
|
|
|
NSAttributedString *attributedText = [self measurableAttributedText];
|
|
|
|
|
2018-01-24 10:17:57 +03:00
|
|
|
if (!_textStorage) {
|
|
|
|
_textContainer = [NSTextContainer new];
|
|
|
|
_textContainer.lineFragmentPadding = 0.0; // Note, the default value is 5.
|
|
|
|
_layoutManager = [NSLayoutManager new];
|
|
|
|
[_layoutManager addTextContainer:_textContainer];
|
|
|
|
_textStorage = [NSTextStorage new];
|
|
|
|
[_textStorage addLayoutManager:_layoutManager];
|
|
|
|
}
|
|
|
|
|
|
|
|
_textContainer.size = maximumSize;
|
|
|
|
_textContainer.maximumNumberOfLines = _maximumNumberOfLines;
|
|
|
|
[_textStorage replaceCharactersInRange:(NSRange){0, _textStorage.length}
|
|
|
|
withAttributedString:attributedText];
|
|
|
|
[_layoutManager ensureLayoutForTextContainer:_textContainer];
|
|
|
|
CGSize size = [_layoutManager usedRectForTextContainer:_textContainer].size;
|
|
|
|
|
|
|
|
return (CGSize){
|
|
|
|
MAX(minimumSize.width, MIN(RCTCeilPixelValue(size.width), maximumSize.width)),
|
|
|
|
MAX(minimumSize.height, MIN(RCTCeilPixelValue(size.height), maximumSize.height))
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-16 04:40:14 +03:00
|
|
|
- (CGFloat)lastBaselineForSize:(CGSize)size
|
|
|
|
{
|
|
|
|
NSAttributedString *attributedText = [self measurableAttributedText];
|
|
|
|
|
|
|
|
__block CGFloat maximumDescender = 0.0;
|
|
|
|
|
|
|
|
[attributedText enumerateAttribute:NSFontAttributeName
|
|
|
|
inRange:NSMakeRange(0, attributedText.length)
|
|
|
|
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
|
|
|
|
usingBlock:
|
|
|
|
^(UIFont *font, NSRange range, __unused BOOL *stop) {
|
|
|
|
if (maximumDescender > font.descender) {
|
|
|
|
maximumDescender = font.descender;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
return size.height + maximumDescender;
|
|
|
|
}
|
|
|
|
|
2018-01-24 10:17:57 +03:00
|
|
|
static YGSize RCTBaseTextInputShadowViewMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode)
|
|
|
|
{
|
|
|
|
RCTShadowView *shadowView = (__bridge RCTShadowView *)YGNodeGetContext(node);
|
|
|
|
|
|
|
|
CGSize minimumSize = CGSizeMake(0, 0);
|
|
|
|
CGSize maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);
|
|
|
|
|
|
|
|
CGSize size = {
|
|
|
|
RCTCoreGraphicsFloatFromYogaFloat(width),
|
|
|
|
RCTCoreGraphicsFloatFromYogaFloat(height)
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (widthMode) {
|
|
|
|
case YGMeasureModeUndefined:
|
|
|
|
break;
|
|
|
|
case YGMeasureModeExactly:
|
|
|
|
minimumSize.width = size.width;
|
|
|
|
maximumSize.width = size.width;
|
|
|
|
break;
|
|
|
|
case YGMeasureModeAtMost:
|
|
|
|
maximumSize.width = size.width;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (heightMode) {
|
|
|
|
case YGMeasureModeUndefined:
|
|
|
|
break;
|
|
|
|
case YGMeasureModeExactly:
|
|
|
|
minimumSize.height = size.height;
|
|
|
|
maximumSize.height = size.height;
|
|
|
|
break;
|
|
|
|
case YGMeasureModeAtMost:
|
|
|
|
maximumSize.height = size.height;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGSize measuredSize = [shadowView sizeThatFitsMinimumSize:minimumSize maximumSize:maximumSize];
|
|
|
|
|
|
|
|
return (YGSize){
|
|
|
|
RCTYogaFloatFromCoreGraphicsFloat(measuredSize.width),
|
|
|
|
RCTYogaFloatFromCoreGraphicsFloat(measuredSize.height)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-16 04:40:14 +03:00
|
|
|
static float RCTTextInputShadowViewBaseline(YGNodeRef node, const float width, const float height)
|
|
|
|
{
|
|
|
|
RCTBaseTextInputShadowView *shadowTextView = (__bridge RCTBaseTextInputShadowView *)YGNodeGetContext(node);
|
|
|
|
|
|
|
|
CGSize size = (CGSize){
|
|
|
|
RCTCoreGraphicsFloatFromYogaFloat(width),
|
|
|
|
RCTCoreGraphicsFloatFromYogaFloat(height)
|
|
|
|
};
|
|
|
|
|
|
|
|
CGFloat lastBaseline = [shadowTextView lastBaselineForSize:size];
|
|
|
|
|
|
|
|
return RCTYogaFloatFromCoreGraphicsFloat(lastBaseline);
|
|
|
|
}
|
|
|
|
|
2018-01-24 10:17:57 +03:00
|
|
|
@end
|