-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add codegen support for DimensionValue for components (#35953)
Summary: Pull Request resolved: #35953 DimensionValue is a reserved prop type that can be a number or string (such as '50%'). On Java, it will get converted to a YogaValue (converter added to this diff); on C++ it will get converted to a YGValue (converter already exists as it's used in Fabric). Changelog: [Internal][Added] - Add codegen support for DimensionValue for components Reviewed By: cipolleschi Differential Revision: D42650799 fbshipit-source-id: 1d2bc30bbd93837dedbbb4c74f814963c8140957
- Loading branch information
1 parent
97e707d
commit d3cc48d
Showing
54 changed files
with
1,466 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
ReactAndroid/src/main/java/com/facebook/react/bridge/DimensionPropConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.bridge; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.facebook.yoga.YogaUnit; | ||
import com.facebook.yoga.YogaValue; | ||
|
||
public class DimensionPropConverter { | ||
|
||
@Nullable | ||
public static YogaValue getDimension(@Nullable Object value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
|
||
if (value instanceof Double) { | ||
return new YogaValue(((Double) value).floatValue(), YogaUnit.POINT); | ||
} | ||
|
||
if (value instanceof String) { | ||
return YogaValue.parse((String) value); | ||
} | ||
|
||
throw new JSApplicationCausedNativeException( | ||
"DimensionValue: the value must be a number or string."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.