mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-27 06:12:24 +08:00
Fabric: Proper way to represent (and parse) borders in ViewProps
Summary: @public Previously, ViewProps class coundn't represent whole spectre of possible values of border metrics (e.g. the border color was unified). Now it's complete and direction-specific. Reviewed By: sahrens Differential Revision: D9628361 fbshipit-source-id: 6d3b3d4d7e3008e2168cbca732ff99fe5ea595e8
This commit is contained in:
committed by
Facebook Github Bot
parent
6e7ffff4a5
commit
ca1e9032a4
@@ -8,6 +8,7 @@
|
||||
#include "ViewProps.h"
|
||||
|
||||
#include <fabric/components/view/conversions.h>
|
||||
#include <fabric/components/view/propsConversions.h>
|
||||
#include <fabric/core/propsConversions.h>
|
||||
#include <fabric/debug/debugStringConvertibleUtils.h>
|
||||
#include <fabric/graphics/conversions.h>
|
||||
@@ -24,10 +25,10 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps):
|
||||
opacity(convertRawProp(rawProps, "opacity", sourceProps.opacity, (Float)1.0)),
|
||||
foregroundColor(convertRawProp(rawProps, "foregroundColor", sourceProps.foregroundColor)),
|
||||
backgroundColor(convertRawProp(rawProps, "backgroundColor", sourceProps.backgroundColor)),
|
||||
borderWidth(convertRawProp(rawProps, "borderWidth", sourceProps.borderWidth)),
|
||||
borderRadius(convertRawProp(rawProps, "borderRadius", sourceProps.borderRadius)),
|
||||
borderColor(convertRawProp(rawProps, "borderColor", sourceProps.borderColor)),
|
||||
borderStyle(convertRawProp(rawProps, "borderStyle", sourceProps.borderStyle)),
|
||||
borderWidths(convertRawProp(rawProps, "border", "Width", sourceProps.borderWidths)),
|
||||
borderRadii(convertRawProp(rawProps, "border", "Radius", sourceProps.borderRadii)),
|
||||
borderColors(convertRawProp(rawProps, "border", "Color", sourceProps.borderColors)),
|
||||
borderStyles(convertRawProp(rawProps, "border", "Style", sourceProps.borderStyles)),
|
||||
shadowColor(convertRawProp(rawProps, "shadowColor", sourceProps.shadowColor)),
|
||||
shadowOffset(convertRawProp(rawProps, "shadowOffset", sourceProps.shadowOffset)),
|
||||
shadowOpacity(convertRawProp(rawProps, "shadowOpacity", sourceProps.shadowOpacity)),
|
||||
@@ -40,6 +41,17 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps):
|
||||
hitSlop(convertRawProp(rawProps, "hitSlop", sourceProps.hitSlop)),
|
||||
onLayout(convertRawProp(rawProps, "onLayout", sourceProps.onLayout)) {};
|
||||
|
||||
#pragma mark - Convenience Methods
|
||||
|
||||
BorderMetrics ViewProps::resolveBorderMetrics(bool isRTL) const {
|
||||
return {
|
||||
.borderColors = borderColors.resolve(isRTL, {}),
|
||||
.borderWidths = borderWidths.resolve(isRTL, 0),
|
||||
.borderRadii = borderRadii.resolve(isRTL, 0),
|
||||
.borderStyles = borderStyles.resolve(isRTL, BorderStyle::Solid)
|
||||
};
|
||||
}
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
SharedDebugStringConvertibleList ViewProps::getDebugProps() const {
|
||||
|
||||
Reference in New Issue
Block a user