From 287b5d697f1d810b72d6b2771cda730170a96028 Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Mon, 1 Apr 2024 12:37:48 -0700 Subject: [PATCH] LayoutAnimation types to Kotlin (#43728) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43728 # Changelog: [Internal] - As in the title, converts corresponding type declarations in `react/uimanager/layoutanimation/*Type.kt` to Kotlin. Differential Revision: D55574530 fbshipit-source-id: 8527b5c9b491435c60ed9c05092ffeccd7552f9c --- .../ReactAndroid/api/ReactAndroid.api | 16 ++++++++ .../layoutanimation/AnimatedPropertyType.java | 37 ----------------- .../layoutanimation/AnimatedPropertyType.kt | 32 +++++++++++++++ .../layoutanimation/InterpolatorType.java | 40 ------------------- .../layoutanimation/InterpolatorType.kt | 33 +++++++++++++++ .../layoutanimation/LayoutAnimationType.java | 33 --------------- .../layoutanimation/LayoutAnimationType.kt | 28 +++++++++++++ 7 files changed, 109 insertions(+), 110 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 061a7803e6f..1401adc4398 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -5622,6 +5622,22 @@ public class com/facebook/react/uimanager/events/TouchesHelper { public fun ()V } +public final class com/facebook/react/uimanager/layoutanimation/InterpolatorType : java/lang/Enum { + public static final field Companion Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType$Companion; + public static final field EASE_IN Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; + public static final field EASE_IN_EASE_OUT Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; + public static final field EASE_OUT Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; + public static final field LINEAR Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; + public static final field SPRING Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; + public static final fun fromString (Ljava/lang/String;)Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; + public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; + public static fun values ()[Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; +} + +public final class com/facebook/react/uimanager/layoutanimation/InterpolatorType$Companion { + public final fun fromString (Ljava/lang/String;)Lcom/facebook/react/uimanager/layoutanimation/InterpolatorType; +} + public class com/facebook/react/uimanager/layoutanimation/LayoutAnimationController { public fun ()V public fun applyLayoutUpdate (Landroid/view/View;IIII)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.java deleted file mode 100644 index 15005421e13..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.uimanager.layoutanimation; - -import com.facebook.infer.annotation.Nullsafe; - -/** - * Enum representing the different view properties that can be used when animating layout for view - * creation. - */ -/* package */ @Nullsafe(Nullsafe.Mode.LOCAL) -enum AnimatedPropertyType { - OPACITY, - SCALE_X, - SCALE_Y, - SCALE_XY; - - public static AnimatedPropertyType fromString(String name) { - switch (name) { - case "opacity": - return OPACITY; - case "scaleX": - return SCALE_X; - case "scaleY": - return SCALE_Y; - case "scaleXY": - return SCALE_XY; - default: - throw new IllegalArgumentException("Unsupported animated property: " + name); - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.kt new file mode 100644 index 00000000000..0eb8571e9a7 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/AnimatedPropertyType.kt @@ -0,0 +1,32 @@ +/* + * 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.uimanager.layoutanimation + +/** + * Enum representing the different view properties that can be used when animating layout for view + * creation. + */ +internal enum class AnimatedPropertyType { + OPACITY, + SCALE_X, + SCALE_Y, + SCALE_XY; + + companion object { + @JvmStatic + public fun fromString(name: String): AnimatedPropertyType { + return when (name) { + "opacity" -> OPACITY + "scaleX" -> SCALE_X + "scaleY" -> SCALE_Y + "scaleXY" -> SCALE_XY + else -> throw IllegalArgumentException("Unsupported animated property: $name") + } + } + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.java deleted file mode 100644 index c05d2378cfc..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.uimanager.layoutanimation; - -import com.facebook.infer.annotation.Nullsafe; -import java.util.Locale; - -/** - * Enum representing the different interpolators that can be used in layout animation configuration. - */ -/* package */ @Nullsafe(Nullsafe.Mode.LOCAL) -enum InterpolatorType { - LINEAR, - EASE_IN, - EASE_OUT, - EASE_IN_EASE_OUT, - SPRING; - - public static InterpolatorType fromString(String name) { - switch (name.toLowerCase(Locale.US)) { - case "linear": - return LINEAR; - case "easein": - return EASE_IN; - case "easeout": - return EASE_OUT; - case "easeineaseout": - return EASE_IN_EASE_OUT; - case "spring": - return SPRING; - default: - throw new IllegalArgumentException("Unsupported interpolation type : " + name); - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.kt new file mode 100644 index 00000000000..14264edd123 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/InterpolatorType.kt @@ -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.uimanager.layoutanimation + +/** + * Enum representing the different interpolators that can be used in layout animation configuration. + */ +public enum class InterpolatorType { + LINEAR, + EASE_IN, + EASE_OUT, + EASE_IN_EASE_OUT, + SPRING; + + public companion object { + @JvmStatic + public fun fromString(name: String): InterpolatorType { + return when (name.lowercase()) { + "linear" -> LINEAR + "easein" -> EASE_IN + "easeout" -> EASE_OUT + "easeineaseout" -> EASE_IN_EASE_OUT + "spring" -> SPRING + else -> throw IllegalArgumentException("Unsupported interpolation type : $name") + } + } + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.java deleted file mode 100644 index 86599997953..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.uimanager.layoutanimation; - -import com.facebook.infer.annotation.Nullsafe; - -/** - * Enum representing the different animation type that can be specified in layout animation config. - */ -/* package */ @Nullsafe(Nullsafe.Mode.LOCAL) -enum LayoutAnimationType { - CREATE, - UPDATE, - DELETE; - - public static String toString(LayoutAnimationType type) { - switch (type) { - case CREATE: - return "create"; - case UPDATE: - return "update"; - case DELETE: - return "delete"; - default: - throw new IllegalArgumentException("Unsupported LayoutAnimationType: " + type); - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.kt new file mode 100644 index 00000000000..4ba71b89490 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationType.kt @@ -0,0 +1,28 @@ +/* + * 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.uimanager.layoutanimation + +/** + * Enum representing the different animation type that can be specified in layout animation config. + */ +internal enum class LayoutAnimationType { + CREATE, + UPDATE, + DELETE; + + companion object { + @JvmStatic + fun toString(type: LayoutAnimationType): String { + return when (type) { + CREATE -> "create" + UPDATE -> "update" + DELETE -> "delete" + } + } + } +}