|
| 1 | +const RNS_CONTROLLED_BOTTOM_TABS_DEFAULT = false; |
| 2 | + |
| 3 | +// TODO: Migrate freeze here |
| 4 | + |
| 5 | +/** |
| 6 | + * Exposes information useful for downstream navigation library implementers, |
| 7 | + * so they can keep reasonable backward compatibility, if desired. |
| 8 | + * |
| 9 | + * We don't mean for this object to only grow in number of fields, however at the same time |
| 10 | + * we won't be very hasty to reduce it. Expect gradual changes. |
| 11 | + */ |
| 12 | +export const compatibilityFlags = { |
| 13 | + /** |
| 14 | + * Because of a bug introduced in https://github.com/software-mansion/react-native-screens/pull/1646 |
| 15 | + * react-native-screens v3.21 changed how header's backTitle handles whitespace strings in https://github.com/software-mansion/react-native-screens/pull/1726 |
| 16 | + * To allow for backwards compatibility in @react-navigation/native-stack we need a way to check if this version or newer is used. |
| 17 | + * See https://github.com/react-navigation/react-navigation/pull/11423 for more context. |
| 18 | + */ |
| 19 | + isNewBackTitleImplementation: true, |
| 20 | + |
| 21 | + /** |
| 22 | + * With version 4.0.0 the header implementation has been changed. To allow for backward compat |
| 23 | + * with native-stack@v6 we want to expose a way to check whether the new implementation |
| 24 | + * is in use or not. |
| 25 | + * |
| 26 | + * See: |
| 27 | + * * https://github.com/software-mansion/react-native-screens/pull/2325 |
| 28 | + * * https://github.com/react-navigation/react-navigation/pull/12125 |
| 29 | + */ |
| 30 | + usesHeaderFlexboxImplementation: true, |
| 31 | +} as const; |
| 32 | + |
| 33 | +const _featureFlags = { |
| 34 | + experiment: { |
| 35 | + controlledBottomTabs: RNS_CONTROLLED_BOTTOM_TABS_DEFAULT, |
| 36 | + }, |
| 37 | + stable: {}, |
| 38 | +}; |
| 39 | + |
| 40 | +/** |
| 41 | + * Exposes configurable global behaviour of the library. |
| 42 | + * |
| 43 | + * Most of these can be overridden on particular component level, these are global switches. |
| 44 | + */ |
| 45 | +export const featureFlags = { |
| 46 | + /** |
| 47 | + * Flags to enable experimental features. These might be removed w/o notice or moved to stable. |
| 48 | + */ |
| 49 | + experiment: { |
| 50 | + get controlledBottomTabs() { |
| 51 | + return _featureFlags.experiment.controlledBottomTabs; |
| 52 | + }, |
| 53 | + set controlledBottomTabs(value: boolean) { |
| 54 | + if ( |
| 55 | + value !== _featureFlags.experiment.controlledBottomTabs && |
| 56 | + _featureFlags.experiment.controlledBottomTabs !== |
| 57 | + RNS_CONTROLLED_BOTTOM_TABS_DEFAULT |
| 58 | + ) { |
| 59 | + console.error( |
| 60 | + `[RNScreens] controlledBottomTabs feature flag modified for a second time; this might lead to unexpected effects`, |
| 61 | + ); |
| 62 | + } |
| 63 | + _featureFlags.experiment.controlledBottomTabs = value; |
| 64 | + }, |
| 65 | + }, |
| 66 | + /** |
| 67 | + * Section for stable flags, which can be used to configure library behaviour. |
| 68 | + */ |
| 69 | + stable: {}, |
| 70 | +}; |
| 71 | + |
| 72 | +export default featureFlags; |
0 commit comments