Skip to content

Commit d7a1d08

Browse files
zeyapmeta-codesync[bot]
authored andcommitted
Create featureflag viewTransitionEnabled (#55537)
Summary: Pull Request resolved: #55537 Changelog: [General] [Added] - Create featureflag viewTransitionEnabled This diff adds a new React Native feature flag `viewTransitionEnabled` to gate the View Transition API feature. The View Transition API enables animated transitions between views, providing a smooth visual experience when navigating between screens or updating UI elements. This flag allows the feature to be gradually rolled out and tested before full enablement. The flag is added across all platform layers: - JavaScript (ReactNativeFeatureFlags.js, NativeReactNativeFeatureFlags.js) - Android Kotlin (ReactNativeFeatureFlags.kt, provider, accessor, defaults) - C++/JNI (ReactNativeFeatureFlags.cpp/h, JReactNativeFeatureFlagsCxxInterop) - Feature flag config (ReactNativeFeatureFlags.config.js) Default value is `false` to ensure the feature is opt-in during experimentation. Reviewed By: NickGerleman Differential Revision: D92713074 fbshipit-source-id: cd9e567df3135f99c8a931fffab655f16883cf94
1 parent b97ca6e commit d7a1d08

20 files changed

Lines changed: 138 additions & 21 deletions

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<049cc0a1aa5ab53ad2ab11c359f49827>>
7+
* @generated SignedSource<<4549fc9a4f431306b7dc70ef3903b8fd>>
88
*/
99

1010
/**
@@ -504,6 +504,12 @@ public object ReactNativeFeatureFlags {
504504
@JvmStatic
505505
public fun viewCullingOutsetRatio(): Double = accessor.viewCullingOutsetRatio()
506506

507+
/**
508+
* Enable the View Transition API for animating transitions between views.
509+
*/
510+
@JvmStatic
511+
public fun viewTransitionEnabled(): Boolean = accessor.viewTransitionEnabled()
512+
507513
/**
508514
* Initial prerender ratio for VirtualView.
509515
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<6d1fc28e24576c1a63dceaa8c974cc1f>>
7+
* @generated SignedSource<<0db6bbb173a96ab07c80a3fbe43671b3>>
88
*/
99

1010
/**
@@ -99,6 +99,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
9999
private var useTurboModuleInteropCache: Boolean? = null
100100
private var useTurboModulesCache: Boolean? = null
101101
private var viewCullingOutsetRatioCache: Double? = null
102+
private var viewTransitionEnabledCache: Boolean? = null
102103
private var virtualViewPrerenderRatioCache: Double? = null
103104

104105
override fun commonTestFlag(): Boolean {
@@ -812,6 +813,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
812813
return cached
813814
}
814815

816+
override fun viewTransitionEnabled(): Boolean {
817+
var cached = viewTransitionEnabledCache
818+
if (cached == null) {
819+
cached = ReactNativeFeatureFlagsCxxInterop.viewTransitionEnabled()
820+
viewTransitionEnabledCache = cached
821+
}
822+
return cached
823+
}
824+
815825
override fun virtualViewPrerenderRatio(): Double {
816826
var cached = virtualViewPrerenderRatioCache
817827
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<26410c9e406969734991456f635be4af>>
7+
* @generated SignedSource<<ec247759261e831159a6f7781bf44998>>
88
*/
99

1010
/**
@@ -186,6 +186,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
186186

187187
@DoNotStrip @JvmStatic public external fun viewCullingOutsetRatio(): Double
188188

189+
@DoNotStrip @JvmStatic public external fun viewTransitionEnabled(): Boolean
190+
189191
@DoNotStrip @JvmStatic public external fun virtualViewPrerenderRatio(): Double
190192

191193
@DoNotStrip @JvmStatic public external fun override(provider: Any)

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<b088aaa5805b084d234c20bed0dec3ab>>
7+
* @generated SignedSource<<102ac98a8c3f2c1a2150c223a099cf72>>
88
*/
99

1010
/**
@@ -181,5 +181,7 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
181181

182182
override fun viewCullingOutsetRatio(): Double = 0.0
183183

184+
override fun viewTransitionEnabled(): Boolean = false
185+
184186
override fun virtualViewPrerenderRatio(): Double = 5.0
185187
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<ee633c2c40fc07aa6cbb5601dfb36cf6>>
7+
* @generated SignedSource<<b7b29f2e01fd0bd43e6509587c862d31>>
88
*/
99

1010
/**
@@ -103,6 +103,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
103103
private var useTurboModuleInteropCache: Boolean? = null
104104
private var useTurboModulesCache: Boolean? = null
105105
private var viewCullingOutsetRatioCache: Double? = null
106+
private var viewTransitionEnabledCache: Boolean? = null
106107
private var virtualViewPrerenderRatioCache: Double? = null
107108

108109
override fun commonTestFlag(): Boolean {
@@ -895,6 +896,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
895896
return cached
896897
}
897898

899+
override fun viewTransitionEnabled(): Boolean {
900+
var cached = viewTransitionEnabledCache
901+
if (cached == null) {
902+
cached = currentProvider.viewTransitionEnabled()
903+
accessedFeatureFlags.add("viewTransitionEnabled")
904+
viewTransitionEnabledCache = cached
905+
}
906+
return cached
907+
}
908+
898909
override fun virtualViewPrerenderRatio(): Double {
899910
var cached = virtualViewPrerenderRatioCache
900911
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<fa7f50fd466b7cb65b208c0b0aaec704>>
7+
* @generated SignedSource<<50f2ea7e87e80a247b6c6ce8e2afd0ec>>
88
*/
99

1010
/**
@@ -181,5 +181,7 @@ public interface ReactNativeFeatureFlagsProvider {
181181

182182
@DoNotStrip public fun viewCullingOutsetRatio(): Double
183183

184+
@DoNotStrip public fun viewTransitionEnabled(): Boolean
185+
184186
@DoNotStrip public fun virtualViewPrerenderRatio(): Double
185187
}

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<698b775afb6ad9295c181ea3d12118d3>>
7+
* @generated SignedSource<<0460a8b25bfb176e47fb12dc091b1961>>
88
*/
99

1010
/**
@@ -513,6 +513,12 @@ class ReactNativeFeatureFlagsJavaProvider
513513
return method(javaProvider_);
514514
}
515515

516+
bool viewTransitionEnabled() override {
517+
static const auto method =
518+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("viewTransitionEnabled");
519+
return method(javaProvider_);
520+
}
521+
516522
double virtualViewPrerenderRatio() override {
517523
static const auto method =
518524
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("virtualViewPrerenderRatio");
@@ -918,6 +924,11 @@ double JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio(
918924
return ReactNativeFeatureFlags::viewCullingOutsetRatio();
919925
}
920926

927+
bool JReactNativeFeatureFlagsCxxInterop::viewTransitionEnabled(
928+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
929+
return ReactNativeFeatureFlags::viewTransitionEnabled();
930+
}
931+
921932
double JReactNativeFeatureFlagsCxxInterop::virtualViewPrerenderRatio(
922933
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
923934
return ReactNativeFeatureFlags::virtualViewPrerenderRatio();
@@ -1191,6 +1202,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
11911202
makeNativeMethod(
11921203
"viewCullingOutsetRatio",
11931204
JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio),
1205+
makeNativeMethod(
1206+
"viewTransitionEnabled",
1207+
JReactNativeFeatureFlagsCxxInterop::viewTransitionEnabled),
11941208
makeNativeMethod(
11951209
"virtualViewPrerenderRatio",
11961210
JReactNativeFeatureFlagsCxxInterop::virtualViewPrerenderRatio),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<7be3a44c6ffc2c9d390f66902ef80d30>>
7+
* @generated SignedSource<<88f40502abd13f8f57015429dd087519>>
88
*/
99

1010
/**
@@ -267,6 +267,9 @@ class JReactNativeFeatureFlagsCxxInterop
267267
static double viewCullingOutsetRatio(
268268
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
269269

270+
static bool viewTransitionEnabled(
271+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
272+
270273
static double virtualViewPrerenderRatio(
271274
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
272275

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<88b22330e8486a820eb42b59fb7279e4>>
7+
* @generated SignedSource<<d96b2f1e4083046cfc061317d117e762>>
88
*/
99

1010
/**
@@ -342,6 +342,10 @@ double ReactNativeFeatureFlags::viewCullingOutsetRatio() {
342342
return getAccessor().viewCullingOutsetRatio();
343343
}
344344

345+
bool ReactNativeFeatureFlags::viewTransitionEnabled() {
346+
return getAccessor().viewTransitionEnabled();
347+
}
348+
345349
double ReactNativeFeatureFlags::virtualViewPrerenderRatio() {
346350
return getAccessor().virtualViewPrerenderRatio();
347351
}

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<af0f34b904e1e555e18f186fb44ca089>>
7+
* @generated SignedSource<<51a4817654c04c979a33f44e42312dd5>>
88
*/
99

1010
/**
@@ -434,6 +434,11 @@ class ReactNativeFeatureFlags {
434434
*/
435435
RN_EXPORT static double viewCullingOutsetRatio();
436436

437+
/**
438+
* Enable the View Transition API for animating transitions between views.
439+
*/
440+
RN_EXPORT static bool viewTransitionEnabled();
441+
437442
/**
438443
* Initial prerender ratio for VirtualView.
439444
*/

0 commit comments

Comments
 (0)