mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 10:14:49 +00:00
f91f7d91a1
Summary: This is reimagining of interoperability layer between Yoga and ShadowViews (at least in Yoga -> RN part). Goals: * Make it clear and easy. * Make clear separation between "what layout what", now parent always layout children, noone layout itself. * Make possible to interleave Yoga layout with custom imperative layout (may be used in SafeAreaView, Text, Modal, InputAccessoryView and so on). Reviewed By: mmmulani Differential Revision: D6863654 fbshipit-source-id: 5a6a933874f121d46f744aab99a31ae42ddd4a1b
35 lines
1.1 KiB
Objective-C
35 lines
1.1 KiB
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import "RCTScrollContentShadowView.h"
|
|
|
|
#import <yoga/Yoga.h>
|
|
|
|
#import "RCTUtils.h"
|
|
|
|
@implementation RCTScrollContentShadowView
|
|
|
|
- (void)layoutWithMetrics:(RCTLayoutMetrics)layoutMetrics
|
|
layoutContext:(RCTLayoutContext)layoutContext
|
|
{
|
|
if (layoutMetrics.layoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
|
|
// Motivation:
|
|
// Yoga place `contentView` on the right side of `scrollView` when RTL layout is enfoced.
|
|
// That breaks everything; it is completely pointless to (re)position `contentView`
|
|
// because it is `contentView`'s job. So, we work around it here.
|
|
|
|
layoutContext.absolutePosition.x += layoutMetrics.frame.size.width;
|
|
layoutMetrics.frame.origin.x = 0;
|
|
}
|
|
|
|
[super layoutWithMetrics:layoutMetrics layoutContext:layoutContext];
|
|
}
|
|
|
|
@end
|