Skip to content

Commit e7e0acd

Browse files
authored
Add fabric support to the example app (#3204)
## Description <!-- Description and motivation for this PR. Include 'Fixes #<number>' if this is fixing some issue. --> Adds `fabric` support to the example app. To use `fabric`, set the optional `FABRIC_ENABLED` environment variable to `1` during `yarn` installation. ## Test plan - test `fabric` - `cd example` - `FABRIC_ENABLED=1 yarn` - `yarn start` - run `Android` via `Android Studio` - `cd ios` - bundle exec pod install` - run `iOS` via `XCode` - see how when apps load, the metro displays `bridgeless mode enabled` message - test `paper` - `cd example` - `yarn` - `yarn start` - run `Android` via `Android Studio` - `cd ios` - `bundle exec pod install` - run `iOS` via `XCode`
1 parent e827e9b commit e7e0acd

File tree

8 files changed

+1202
-326
lines changed

8 files changed

+1202
-326
lines changed

example/app.config.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
export default ({ config }) => ({
2+
...config,
3+
name: 'example',
4+
slug: 'example',
5+
version: '0.0.1',
6+
orientation: 'portrait',
7+
icon: './assets/icon.png',
8+
sdkVersion: '51.0.0',
9+
splash: {
10+
image: './assets/splash.png',
11+
resizeMode: 'cover',
12+
backgroundColor: '#F8F9FF',
13+
},
14+
ios: {
15+
bundleIdentifier: 'com.example',
16+
buildNumber: '1',
17+
supportsTablet: true,
18+
},
19+
android: {
20+
versionCode: 1,
21+
package: 'com.example',
22+
adaptiveIcon: {
23+
foregroundImage: './assets/adaptive-icon.png',
24+
backgroundColor: '#F8F9FF',
25+
},
26+
},
27+
web: {
28+
favicon: './assets/favicon.png',
29+
},
30+
plugins: [
31+
[
32+
'expo-camera',
33+
{
34+
cameraPermission: 'Allow RNGH example to access your camera',
35+
},
36+
],
37+
[
38+
'expo-font',
39+
{
40+
fonts: [
41+
'./node_modules/@swmansion/icons/fonts/broken/swm-icons-broken.ttf',
42+
'./node_modules/@swmansion/icons/fonts/outline/swm-icons-outline.ttf',
43+
'./node_modules/@swmansion/icons/fonts/curved/swm-icons-curved.ttf',
44+
],
45+
},
46+
],
47+
[
48+
'expo-build-properties',
49+
{
50+
ios: {
51+
newArchEnabled: Boolean(Number(process.env.FABRIC_ENABLED)),
52+
},
53+
android: {
54+
newArchEnabled: Boolean(Number(process.env.FABRIC_ENABLED)),
55+
},
56+
},
57+
],
58+
],
59+
});

example/app.json

Lines changed: 0 additions & 49 deletions
This file was deleted.

example/package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,32 @@
1414
"postinstall": "patch-package && expo prebuild"
1515
},
1616
"dependencies": {
17-
"@expo/metro-config": "~0.18.1",
18-
"@expo/metro-runtime": "^3.2.1",
17+
"@expo/metro-config": "~0.18.11",
18+
"@expo/metro-runtime": "~3.2.3",
1919
"@react-native-async-storage/async-storage": "^1.23.1",
2020
"@react-native-community/slider": "^4.5.2",
2121
"@react-native-community/viewpager": "^5.0.11",
22-
"@react-native-masked-view/masked-view": "^0.2.8",
22+
"@react-native-masked-view/masked-view": "0.3.1",
2323
"@react-navigation/elements": "^1.3.7",
2424
"@react-navigation/native": "^6.1.17",
2525
"@react-navigation/stack": "^6.3.29",
2626
"@swmansion/icons": "^0.0.1",
27-
"expo": "^51.0.0",
28-
"expo-camera": "~15.0.9",
27+
"expo": "~51.0.38",
28+
"expo-build-properties": "^0.12.5",
29+
"expo-camera": "~15.0.16",
2930
"expo-font": "~12.0.10",
3031
"hoist-non-react-statics": "^3.3.2",
3132
"invariant": "^2.2.4",
3233
"patch-package": "^6.5.1",
3334
"postinstall-postinstall": "^2.1.0",
3435
"react": "18.2.0",
3536
"react-dom": "18.2.0",
36-
"react-native": "0.74.1",
37+
"react-native": "0.75.4",
3738
"react-native-gesture-handler": "link:..",
3839
"react-native-reanimated": "3.15.5",
39-
"react-native-safe-area-context": "4.10.1",
40-
"react-native-screens": "3.31.1",
41-
"react-native-svg": "^15.8.0",
40+
"react-native-safe-area-context": "4.10.5",
41+
"react-native-screens": "3.35.0",
42+
"react-native-svg": "15.8.0",
4243
"react-native-web": "~0.19.10"
4344
},
4445
"devDependencies": {
@@ -48,7 +49,7 @@
4849
"@tsconfig/react-native": "^3.0.5",
4950
"@types/jest": "^29.5.12",
5051
"@types/metro-config": "^0.76.3",
51-
"@types/react": "^18.3.1",
52+
"@types/react": "~18.2.79",
5253
"@types/react-native": "^0.73.0",
5354
"@types/react-test-renderer": "^18.3.0",
5455
"@typescript-eslint/parser": "^7.8.0",
@@ -59,7 +60,7 @@
5960
"jest": "^29.7.0",
6061
"prettier": "3.3.3",
6162
"react-test-renderer": "18.3.1",
62-
"typescript": "^5.1.3"
63+
"typescript": "~5.3.3"
6364
},
6465
"resolutions": {
6566
"@typescript-eslint/eslint-plugin": "^5.17.0",

example/src/release_tests/gesturizedPressable/functionalStylesExample.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import React from 'react';
2-
import {
3-
PressableStateCallbackType,
4-
StyleProp,
5-
StyleSheet,
6-
View,
7-
ViewStyle,
8-
} from 'react-native';
2+
import { PressableStateCallbackType, StyleSheet, View } from 'react-native';
93
import TestingBase from './testingBase';
104

115
export function FunctionalStyleExample() {
12-
const functionalStyle = (
13-
state: PressableStateCallbackType
14-
): StyleProp<ViewStyle> => {
6+
const functionalStyle = (state: PressableStateCallbackType) => {
157
if (state.pressed) {
168
return {
179
width: 100,

example/src/release_tests/nestedPressables/index.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import React from 'react';
22
import {
33
Pressable as LegacyPressable,
44
PressableStateCallbackType,
5-
StyleProp,
65
StyleSheet,
76
Text,
87
View,
9-
ViewStyle,
108
} from 'react-native';
119
import {
1210
ScrollView,
@@ -28,29 +26,23 @@ export default function Example() {
2826

2927
const BOX_SIZE_COEFFICIENT = 100;
3028

31-
const getBoxStyle = (size: number): StyleProp<ViewStyle> => ({
29+
const getBoxStyle = (size: number) => ({
3230
width: size,
3331
height: size,
3432
borderWidth: 1,
3533
});
3634

37-
const innerStyle = ({
38-
pressed,
39-
}: PressableStateCallbackType): StyleProp<ViewStyle> => [
35+
const innerStyle = ({ pressed }: PressableStateCallbackType) => [
4036
getBoxStyle(BOX_SIZE_COEFFICIENT),
4137
pressed ? { backgroundColor: '#c00' } : { backgroundColor: '#c77' },
4238
styles.centering,
4339
];
44-
const middleStyle = ({
45-
pressed,
46-
}: PressableStateCallbackType): StyleProp<ViewStyle> => [
40+
const middleStyle = ({ pressed }: PressableStateCallbackType) => [
4741
getBoxStyle(BOX_SIZE_COEFFICIENT * 2),
4842
pressed ? { backgroundColor: '#0c0' } : { backgroundColor: '#7a7' },
4943
styles.centering,
5044
];
51-
const outerStyle = ({
52-
pressed,
53-
}: PressableStateCallbackType): StyleProp<ViewStyle> => [
45+
const outerStyle = ({ pressed }: PressableStateCallbackType) => [
5446
getBoxStyle(BOX_SIZE_COEFFICIENT * 3),
5547
pressed ? { backgroundColor: '#00c' } : { backgroundColor: '#88a' },
5648
styles.centering,

example/src/release_tests/rectButton/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';
2+
import { StyleSheet, Text, View } from 'react-native';
33
import { RectButton } from 'react-native-gesture-handler';
44

55
export default function RectButtonBorders() {
@@ -62,10 +62,14 @@ export default function RectButtonBorders() {
6262
);
6363
}
6464

65-
type ButtonProps = { style: StyleProp<ViewStyle>; text: string };
65+
type ButtonProps = {
66+
// RN cross-version conflicts prevent us from using `ViewStyle` with RNGH <= 2.21.0 and RN >= 0.75.0
67+
style: Record<string, string | number>;
68+
text: string;
69+
};
6670

6771
function Button({ style, text }: ButtonProps) {
68-
const rectButtonStyles: StyleProp<ViewStyle> = [styles.button, style];
72+
const rectButtonStyles = [styles.button, style];
6973

7074
const onPress = () => alert(`Pressed ${text}!`);
7175

example/src/release_tests/touchables/index.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const renderSampleBox = (color?: string) => (
3333
/>
3434
);
3535

36-
const toReactNativeTouchable = (touchable: React.ComponentType<unknown>) => {
36+
const toReactNativeTouchable = (
37+
touchable: React.ComponentType<unknown>
38+
): React.ElementType => {
3739
if (touchable === TouchableOpacity) {
3840
return RNTouchableOpacity;
3941
}
@@ -53,9 +55,11 @@ type Touchables = {
5355
type: React.ComponentType<any>;
5456
props?: Record<string, unknown>;
5557
color?: string;
56-
renderChild: (() => null) | ((color?: string) => React.ReactNode);
58+
renderChild: (color?: string) => React.ReactNode;
5759
text: string;
58-
background?: (A: typeof TouchableNativeFeedback) => BackgroundPropType;
60+
background?: (
61+
A: typeof TouchableNativeFeedback | typeof RNTouchableNativeFeedback
62+
) => BackgroundPropType;
5963
};
6064

6165
const TOUCHABLES: Touchables[] = [
@@ -297,7 +301,10 @@ const TOUCHABLES: Touchables[] = [
297301
];
298302

299303
const screens: Record<string, Touchables> = TOUCHABLES.reduce(
300-
(map: Record<string, Touchables>, obj) => ((map[obj.text] = obj), map),
304+
(map: Record<string, Touchables>, obj: Touchables) => {
305+
map[obj.text] = obj;
306+
return map;
307+
},
301308
{}
302309
);
303310

@@ -353,12 +360,10 @@ export class TouchableExample extends Component<
353360
color,
354361
} = screens[this.props.route.params.item];
355362
const RNTouchable = toReactNativeTouchable(GHTouchable);
356-
const Component: React.ComponentType<any> = this.state.useScrollView
357-
? ScrollView
358-
: View;
363+
const Wrapper = this.state.useScrollView ? ScrollView : View;
359364

360365
return (
361-
<Component style={{ width: '100%', height: '100%', padding: 10 }}>
366+
<Wrapper style={{ width: '100%', height: '100%', padding: 10 }}>
362367
<TouchableOpacity onPress={this.toggleScrollView}>
363368
<Text>
364369
Use {this.state.useScrollView ? 'View' : 'ScrollView'} as a wrapper
@@ -382,7 +387,7 @@ export class TouchableExample extends Component<
382387
{renderChild(color)}
383388
</GHTouchable>
384389
</View>
385-
</Component>
390+
</Wrapper>
386391
);
387392
}
388393
}

0 commit comments

Comments
 (0)