Skip to content

Commit 0c64923

Browse files
authored
fix: simulator detection in demo apps (#1125)
## Description Due to deprecation of the used variable from Constants (therefore introducing whong behaviour on physical devices), this PR uses `react-native-device-info` for simulator detecting, instead of Expo Constants. ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [x] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [ ] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [x] iOS - [x] Android ### Testing instructions <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
1 parent 05b274e commit 0c64923

6 files changed

Lines changed: 75 additions & 18 deletions

File tree

apps/computer-vision/components/BottomBar.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import ColorPalette from '../colors';
22
import FontAwesome from '@expo/vector-icons/FontAwesome';
3-
import Constants from 'expo-constants';
43
import { View, TouchableOpacity, StyleSheet, Text } from 'react-native';
54
import { useSafeAreaInsets } from 'react-native-safe-area-context';
5+
import DeviceInfo from 'react-native-device-info';
6+
7+
const isDevice = DeviceInfo.isEmulatorSync();
68

79
export const BottomBar = ({
810
handleCameraPress,
@@ -17,20 +19,17 @@ export const BottomBar = ({
1719
}) => {
1820
const { bottom } = useSafeAreaInsets();
1921
const disabled = !hasImage || isGenerating;
20-
2122
return (
2223
<View style={[styles.bottomContainer, { paddingBottom: bottom || 16 }]}>
2324
<View style={styles.bottomIconsContainer}>
2425
<TouchableOpacity onPress={() => handleCameraPress(false)}>
2526
<FontAwesome name="photo" size={24} color={ColorPalette.primary} />
2627
</TouchableOpacity>
27-
<TouchableOpacity
28-
onPress={() => Constants.isDevice && handleCameraPress(true)}
29-
>
28+
<TouchableOpacity onPress={() => isDevice && handleCameraPress(true)}>
3029
<FontAwesome
3130
name="camera"
3231
size={24}
33-
color={Constants.isDevice ? ColorPalette.primary : '#888'}
32+
color={isDevice ? ColorPalette.primary : '#888'}
3433
/>
3534
</TouchableOpacity>
3635
</View>

apps/computer-vision/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
"@shopify/react-native-skia": "2.6.2",
1919
"expo": "^55.0.13",
2020
"expo-build-properties": "~55.0.13",
21-
"expo-constants": "~55.0.13",
21+
"expo-constants": "^55.0.16",
2222
"expo-font": "~55.0.6",
2323
"expo-linking": "~55.0.12",
2424
"expo-router": "~55.0.11",
2525
"expo-status-bar": "~55.0.5",
2626
"metro-config": "^0.83.0",
2727
"react": "19.2.5",
2828
"react-native": "0.83.4",
29+
"react-native-device-info": "^15.0.2",
2930
"react-native-executorch": "workspace:*",
3031
"react-native-executorch-expo-resource-fetcher": "workspace:*",
3132
"react-native-gesture-handler": "~2.31.1",
@@ -46,7 +47,9 @@
4647
"@babel/core": "^7.29.0",
4748
"@types/pngjs": "^6.0.5",
4849
"@types/react": "~19.2.0",
49-
"babel-preset-expo": "~55.0.16"
50+
"@types/react-refresh": "^0",
51+
"babel-preset-expo": "~55.0.16",
52+
"react-refresh": "^0.18.0"
5053
},
5154
"private": true
5255
}

apps/llm/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"expo-brightness": "~55.0.13",
2020
"expo-build-properties": "~55.0.13",
2121
"expo-calendar": "~55.0.14",
22-
"expo-constants": "~55.0.13",
22+
"expo-constants": "^55.0.16",
2323
"expo-document-picker": "~55.0.13",
2424
"expo-font": "~55.0.6",
2525
"expo-linking": "~55.0.12",
@@ -46,7 +46,9 @@
4646
"devDependencies": {
4747
"@babel/core": "^7.29.0",
4848
"@types/react": "~19.2.14",
49-
"babel-preset-expo": "~55.0.16"
49+
"@types/react-refresh": "^0",
50+
"babel-preset-expo": "~55.0.16",
51+
"react-refresh": "^0.18.0"
5052
},
5153
"private": true
5254
}

apps/speech/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
"devDependencies": {
3434
"@babel/core": "^7.29.0",
3535
"@types/react": "~19.2.14",
36-
"babel-preset-expo": "~55.0.16"
36+
"@types/react-refresh": "^0",
37+
"babel-preset-expo": "~55.0.16",
38+
"react-refresh": "^0.18.0"
3739
},
3840
"private": true
3941
}

apps/text-embeddings/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@react-navigation/native": "^7.2.2",
1818
"expo": "^55.0.13",
1919
"expo-build-properties": "~55.0.13",
20-
"expo-constants": "~55.0.13",
20+
"expo-constants": "^55.0.16",
2121
"expo-linking": "~55.0.12",
2222
"expo-router": "~55.0.11",
2323
"expo-status-bar": "~55.0.5",
@@ -36,7 +36,9 @@
3636
"devDependencies": {
3737
"@babel/core": "^7.29.0",
3838
"@types/react": "~19.2.14",
39-
"babel-preset-expo": "~55.0.16"
39+
"@types/react-refresh": "^0",
40+
"babel-preset-expo": "~55.0.16",
41+
"react-refresh": "^0.18.0"
4042
},
4143
"private": true
4244
}

yarn.lock

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,17 @@ __metadata:
27152715
languageName: node
27162716
linkType: hard
27172717

2718+
"@expo/env@npm:~2.1.2":
2719+
version: 2.1.2
2720+
resolution: "@expo/env@npm:2.1.2"
2721+
dependencies:
2722+
chalk: "npm:^4.0.0"
2723+
debug: "npm:^4.3.4"
2724+
getenv: "npm:^2.0.0"
2725+
checksum: 10/e127ae2449de94afc52e41c8a4254b21eb6df047ba24da8b0a3baa245840338dc1eb00c8447fed6059ead13dae8dddef4ce8ce44c44f4154a886007967f473af
2726+
languageName: node
2727+
linkType: hard
2728+
27182729
"@expo/fingerprint@npm:0.15.4":
27192730
version: 0.15.4
27202731
resolution: "@expo/fingerprint@npm:0.15.4"
@@ -5809,7 +5820,7 @@ __metadata:
58095820
languageName: node
58105821
linkType: hard
58115822

5812-
"@types/babel__core@npm:^7.1.14, @types/babel__core@npm:^7.20.5":
5823+
"@types/babel__core@npm:*, @types/babel__core@npm:^7.1.14, @types/babel__core@npm:^7.20.5":
58135824
version: 7.20.5
58145825
resolution: "@types/babel__core@npm:7.20.5"
58155826
dependencies:
@@ -5977,6 +5988,16 @@ __metadata:
59775988
languageName: node
59785989
linkType: hard
59795990

5991+
"@types/react-refresh@npm:^0":
5992+
version: 0.14.7
5993+
resolution: "@types/react-refresh@npm:0.14.7"
5994+
dependencies:
5995+
"@types/babel__core": "npm:*"
5996+
csstype: "npm:^3.2.2"
5997+
checksum: 10/c4eca39a4e6991ad637044294045824784a048cbf84c8972361c686af7c17a32ffb11e3a24be519f7961a6690fce4a92a8007e2a060197dca43b0b66eff56bc6
5998+
languageName: node
5999+
linkType: hard
6000+
59806001
"@types/react-test-renderer@npm:^19.1.0":
59816002
version: 19.1.0
59826003
resolution: "@types/react-test-renderer@npm:19.1.0"
@@ -7883,17 +7904,19 @@ __metadata:
78837904
"@shopify/react-native-skia": "npm:2.6.2"
78847905
"@types/pngjs": "npm:^6.0.5"
78857906
"@types/react": "npm:~19.2.0"
7907+
"@types/react-refresh": "npm:^0"
78867908
babel-preset-expo: "npm:~55.0.16"
78877909
expo: "npm:^55.0.13"
78887910
expo-build-properties: "npm:~55.0.13"
7889-
expo-constants: "npm:~55.0.13"
7911+
expo-constants: "npm:^55.0.16"
78907912
expo-font: "npm:~55.0.6"
78917913
expo-linking: "npm:~55.0.12"
78927914
expo-router: "npm:~55.0.11"
78937915
expo-status-bar: "npm:~55.0.5"
78947916
metro-config: "npm:^0.83.0"
78957917
react: "npm:19.2.5"
78967918
react-native: "npm:0.83.4"
7919+
react-native-device-info: "npm:^15.0.2"
78977920
react-native-executorch: "workspace:*"
78987921
react-native-executorch-expo-resource-fetcher: "workspace:*"
78997922
react-native-gesture-handler: "npm:~2.31.1"
@@ -7909,6 +7932,7 @@ __metadata:
79097932
react-native-vision-camera: "npm:^5.0.6"
79107933
react-native-vision-camera-worklets: "npm:^5.0.6"
79117934
react-native-worklets: "npm:0.8.1"
7935+
react-refresh: "npm:^0.18.0"
79127936
languageName: unknown
79137937
linkType: soft
79147938

@@ -9436,6 +9460,18 @@ __metadata:
94369460
languageName: node
94379461
linkType: hard
94389462

9463+
"expo-constants@npm:^55.0.16":
9464+
version: 55.0.16
9465+
resolution: "expo-constants@npm:55.0.16"
9466+
dependencies:
9467+
"@expo/env": "npm:~2.1.2"
9468+
peerDependencies:
9469+
expo: "*"
9470+
react-native: "*"
9471+
checksum: 10/80caf27dc74972b4a0245e2268be51748eb403622f30b9129c6838fa80740a88f31e4941f2f9c493fdd1cd0c8512b440dfc9cf78a26eb7ca92826c54cd4641b2
9472+
languageName: node
9473+
linkType: hard
9474+
94399475
"expo-constants@npm:~18.0.11, expo-constants@npm:~18.0.12, expo-constants@npm:~18.0.13":
94409476
version: 18.0.13
94419477
resolution: "expo-constants@npm:18.0.13"
@@ -9449,7 +9485,7 @@ __metadata:
94499485
languageName: node
94509486
linkType: hard
94519487

9452-
"expo-constants@npm:~55.0.13, expo-constants@npm:~55.0.15":
9488+
"expo-constants@npm:~55.0.15":
94539489
version: 55.0.15
94549490
resolution: "expo-constants@npm:55.0.15"
94559491
dependencies:
@@ -12680,12 +12716,13 @@ __metadata:
1268012716
"@react-navigation/drawer": "npm:^7.9.4"
1268112717
"@react-navigation/native": "npm:^7.2.2"
1268212718
"@types/react": "npm:~19.2.14"
12719+
"@types/react-refresh": "npm:^0"
1268312720
babel-preset-expo: "npm:~55.0.16"
1268412721
expo: "npm:^55.0.13"
1268512722
expo-brightness: "npm:~55.0.13"
1268612723
expo-build-properties: "npm:~55.0.13"
1268712724
expo-calendar: "npm:~55.0.14"
12688-
expo-constants: "npm:~55.0.13"
12725+
expo-constants: "npm:^55.0.16"
1268912726
expo-document-picker: "npm:~55.0.13"
1269012727
expo-font: "npm:~55.0.6"
1269112728
expo-linking: "npm:~55.0.12"
@@ -12708,6 +12745,7 @@ __metadata:
1270812745
react-native-svg: "npm:15.15.4"
1270912746
react-native-svg-transformer: "npm:^1.5.3"
1271012747
react-native-worklets: "npm:0.8.1"
12748+
react-refresh: "npm:^0.18.0"
1271112749
languageName: unknown
1271212750
linkType: soft
1271312751

@@ -15781,6 +15819,13 @@ __metadata:
1578115819
languageName: node
1578215820
linkType: hard
1578315821

15822+
"react-refresh@npm:^0.18.0":
15823+
version: 0.18.0
15824+
resolution: "react-refresh@npm:0.18.0"
15825+
checksum: 10/504c331c19776bf8320c23bad7f80b3a28de03301ed7523b0dd21d3f02bf2b53bbdd5aa52469b187bc90f358614b2ba303c088a0765c95f4f0a68c43a7d67b1d
15826+
languageName: node
15827+
linkType: hard
15828+
1578415829
"react-refresh@npm:^0.4.0":
1578515830
version: 0.4.3
1578615831
resolution: "react-refresh@npm:0.4.3"
@@ -16636,6 +16681,7 @@ __metadata:
1663616681
"@babel/core": "npm:^7.29.0"
1663716682
"@react-native/metro-config": "npm:^0.83.0"
1663816683
"@types/react": "npm:~19.2.14"
16684+
"@types/react-refresh": "npm:^0"
1663916685
babel-preset-expo: "npm:~55.0.16"
1664016686
buffer: "npm:^6.0.3"
1664116687
expo: "npm:^55.0.13"
@@ -16654,6 +16700,7 @@ __metadata:
1665416700
react-native-svg: "npm:15.15.4"
1665516701
react-native-svg-transformer: "npm:^1.5.3"
1665616702
react-native-worklets: "npm:0.8.1"
16703+
react-refresh: "npm:^0.18.0"
1665716704
languageName: unknown
1665816705
linkType: soft
1665916706

@@ -17096,10 +17143,11 @@ __metadata:
1709617143
"@react-navigation/drawer": "npm:^7.9.4"
1709717144
"@react-navigation/native": "npm:^7.2.2"
1709817145
"@types/react": "npm:~19.2.14"
17146+
"@types/react-refresh": "npm:^0"
1709917147
babel-preset-expo: "npm:~55.0.16"
1710017148
expo: "npm:^55.0.13"
1710117149
expo-build-properties: "npm:~55.0.13"
17102-
expo-constants: "npm:~55.0.13"
17150+
expo-constants: "npm:^55.0.16"
1710317151
expo-linking: "npm:~55.0.12"
1710417152
expo-router: "npm:~55.0.11"
1710517153
expo-status-bar: "npm:~55.0.5"
@@ -17114,6 +17162,7 @@ __metadata:
1711417162
react-native-screens: "npm:~4.24.0"
1711517163
react-native-svg: "npm:15.15.4"
1711617164
react-native-worklets: "npm:0.8.1"
17165+
react-refresh: "npm:^0.18.0"
1711717166
languageName: unknown
1711817167
linkType: soft
1711917168

0 commit comments

Comments
 (0)