Skip to content

Commit 7e9908c

Browse files
committed
chore(expo-example-app): extending example
1 parent dfcb901 commit 7e9908c

File tree

3 files changed

+75
-38
lines changed

3 files changed

+75
-38
lines changed

apps/expo-example-app/ios/ExpoExampleApp.xcodeproj/project.pbxproj

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
11FB4A9DA4874A4A93522A1B /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = E99B908A430E460B94C03C8C /* noop-file.swift */; };
1011
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
1112
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1213
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1314
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */; };
14-
69A349121A4644FF9356E68E /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32B9975796F647FABCCD77EB /* noop-file.swift */; };
15+
5DBD9273912684209EE80793 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 714914345BEBEC0FEBDB9301 /* PrivacyInfo.xcprivacy */; };
1516
96905EF65AED1B983A6B3ABC /* libPods-ExpoExampleApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58EEBF8E8E6FB1BC6CAF49B5 /* libPods-ExpoExampleApp.a */; };
16-
B073068FD776C8F69C674A8A /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 6451BEBE8E39D32B566384D5 /* PrivacyInfo.xcprivacy */; };
1717
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
1818
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
1919
/* End PBXBuildFile section */
@@ -25,16 +25,16 @@
2525
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ExpoExampleApp/Images.xcassets; sourceTree = "<group>"; };
2626
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ExpoExampleApp/Info.plist; sourceTree = "<group>"; };
2727
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ExpoExampleApp/main.m; sourceTree = "<group>"; };
28-
32B9975796F647FABCCD77EB /* noop-file.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = "noop-file.swift"; path = "ExpoExampleApp/noop-file.swift"; sourceTree = "<group>"; };
28+
4E90B32FFA5F4EEBA5681656 /* ExpoExampleApp-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; name = "ExpoExampleApp-Bridging-Header.h"; path = "ExpoExampleApp/ExpoExampleApp-Bridging-Header.h"; sourceTree = "<group>"; };
2929
58EEBF8E8E6FB1BC6CAF49B5 /* libPods-ExpoExampleApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExpoExampleApp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
30-
6451BEBE8E39D32B566384D5 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = ExpoExampleApp/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3130
6C2E3173556A471DD304B334 /* Pods-ExpoExampleApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExpoExampleApp.debug.xcconfig"; path = "Target Support Files/Pods-ExpoExampleApp/Pods-ExpoExampleApp.debug.xcconfig"; sourceTree = "<group>"; };
31+
714914345BEBEC0FEBDB9301 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = ExpoExampleApp/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3232
7A4D352CD337FB3A3BF06240 /* Pods-ExpoExampleApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExpoExampleApp.release.xcconfig"; path = "Target Support Files/Pods-ExpoExampleApp/Pods-ExpoExampleApp.release.xcconfig"; sourceTree = "<group>"; };
3333
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = SplashScreen.storyboard; path = ExpoExampleApp/SplashScreen.storyboard; sourceTree = "<group>"; };
3434
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "<group>"; };
35+
E99B908A430E460B94C03C8C /* noop-file.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = "noop-file.swift"; path = "ExpoExampleApp/noop-file.swift"; sourceTree = "<group>"; };
3536
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
3637
FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-ExpoExampleApp/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
37-
FB4927614A594C7AB58C55D4 /* ExpoExampleApp-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; name = "ExpoExampleApp-Bridging-Header.h"; path = "ExpoExampleApp/ExpoExampleApp-Bridging-Header.h"; sourceTree = "<group>"; };
3838
/* End PBXFileReference section */
3939

4040
/* Begin PBXFrameworksBuildPhase section */
@@ -59,9 +59,9 @@
5959
13B07FB61A68108700A75B9A /* Info.plist */,
6060
13B07FB71A68108700A75B9A /* main.m */,
6161
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */,
62-
32B9975796F647FABCCD77EB /* noop-file.swift */,
63-
FB4927614A594C7AB58C55D4 /* ExpoExampleApp-Bridging-Header.h */,
64-
6451BEBE8E39D32B566384D5 /* PrivacyInfo.xcprivacy */,
62+
E99B908A430E460B94C03C8C /* noop-file.swift */,
63+
4E90B32FFA5F4EEBA5681656 /* ExpoExampleApp-Bridging-Header.h */,
64+
714914345BEBEC0FEBDB9301 /* PrivacyInfo.xcprivacy */,
6565
);
6666
name = ExpoExampleApp;
6767
sourceTree = "<group>";
@@ -147,13 +147,13 @@
147147
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ExpoExampleApp" */;
148148
buildPhases = (
149149
08A4A3CD28434E44B6B9DE2E /* [CP] Check Pods Manifest.lock */,
150-
F9078CDE06B46BCEBE89AF73 /* [Expo] Configure project */,
150+
7FD98D3DCF134E61A926AC9B /* [Expo] Configure project */,
151151
13B07F871A680F5B00A75B9A /* Sources */,
152152
13B07F8C1A680F5B00A75B9A /* Frameworks */,
153153
13B07F8E1A680F5B00A75B9A /* Resources */,
154154
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
155155
800E24972A6A228C8D4807E9 /* [CP] Copy Pods Resources */,
156-
CEBFE3CFB4F55F8F0BA1529A /* [CP] Embed Pods Frameworks */,
156+
CAA177080225C24FAD977EF1 /* [CP] Embed Pods Frameworks */,
157157
);
158158
buildRules = (
159159
);
@@ -203,7 +203,7 @@
203203
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */,
204204
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
205205
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */,
206-
B073068FD776C8F69C674A8A /* PrivacyInfo.xcprivacy in Resources */,
206+
5DBD9273912684209EE80793 /* PrivacyInfo.xcprivacy in Resources */,
207207
);
208208
runOnlyForDeploymentPostprocessing = 0;
209209
};
@@ -247,6 +247,25 @@
247247
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
248248
showEnvVarsInLog = 0;
249249
};
250+
7FD98D3DCF134E61A926AC9B /* [Expo] Configure project */ = {
251+
isa = PBXShellScriptBuildPhase;
252+
alwaysOutOfDate = 1;
253+
buildActionMask = 2147483647;
254+
files = (
255+
);
256+
inputFileListPaths = (
257+
);
258+
inputPaths = (
259+
);
260+
name = "[Expo] Configure project";
261+
outputFileListPaths = (
262+
);
263+
outputPaths = (
264+
);
265+
runOnlyForDeploymentPostprocessing = 0;
266+
shellPath = /bin/sh;
267+
shellScript = "# This script configures Expo modules and generates the modules provider file.\nbash -l -c \"./Pods/Target\\ Support\\ Files/Pods-ExpoExampleApp/expo-configure-project.sh\"\n";
268+
};
250269
800E24972A6A228C8D4807E9 /* [CP] Copy Pods Resources */ = {
251270
isa = PBXShellScriptBuildPhase;
252271
buildActionMask = 2147483647;
@@ -279,7 +298,7 @@
279298
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ExpoExampleApp/Pods-ExpoExampleApp-resources.sh\"\n";
280299
showEnvVarsInLog = 0;
281300
};
282-
CEBFE3CFB4F55F8F0BA1529A /* [CP] Embed Pods Frameworks */ = {
301+
CAA177080225C24FAD977EF1 /* [CP] Embed Pods Frameworks */ = {
283302
isa = PBXShellScriptBuildPhase;
284303
buildActionMask = 2147483647;
285304
files = (
@@ -297,25 +316,6 @@
297316
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ExpoExampleApp/Pods-ExpoExampleApp-frameworks.sh\"\n";
298317
showEnvVarsInLog = 0;
299318
};
300-
F9078CDE06B46BCEBE89AF73 /* [Expo] Configure project */ = {
301-
isa = PBXShellScriptBuildPhase;
302-
alwaysOutOfDate = 1;
303-
buildActionMask = 2147483647;
304-
files = (
305-
);
306-
inputFileListPaths = (
307-
);
308-
inputPaths = (
309-
);
310-
name = "[Expo] Configure project";
311-
outputFileListPaths = (
312-
);
313-
outputPaths = (
314-
);
315-
runOnlyForDeploymentPostprocessing = 0;
316-
shellPath = /bin/sh;
317-
shellScript = "# This script configures Expo modules and generates the modules provider file.\nbash -l -c \"./Pods/Target\\ Support\\ Files/Pods-ExpoExampleApp/expo-configure-project.sh\"\n";
318-
};
319319
/* End PBXShellScriptBuildPhase section */
320320

321321
/* Begin PBXSourcesBuildPhase section */
@@ -326,7 +326,7 @@
326326
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */,
327327
13B07FC11A68108700A75B9A /* main.m in Sources */,
328328
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */,
329-
69A349121A4644FF9356E68E /* noop-file.swift in Sources */,
329+
11FB4A9DA4874A4A93522A1B /* noop-file.swift in Sources */,
330330
);
331331
runOnlyForDeploymentPostprocessing = 0;
332332
};

apps/expo-example-app/ios/ExpoExampleApp/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
<key>NSAllowsLocalNetworking</key>
4545
<true/>
4646
</dict>
47+
<key>NSBluetoothAlwaysUsageDescription</key>
48+
<string>Your reason to use bluetooth</string>
4749
<key>UILaunchStoryboardName</key>
4850
<string>SplashScreen</string>
4951
<key>UIRequiredDeviceCapabilities</key>

apps/expo-example-app/src/app/App.tsx

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { useState } from 'react'
2-
import { Pressable, SafeAreaView, StatusBar, Text } from 'react-native'
3-
import { useBluetoothState } from 'react-native-bluetooth-state-manager'
2+
import { Alert, Pressable, SafeAreaView, StatusBar, Text } from 'react-native'
3+
import {
4+
BluetoothStateManager,
5+
useBluetoothState,
6+
} from 'react-native-bluetooth-state-manager'
47

58
export const App = () => {
69
const [items, setItems] = useState<number[]>([...Array(5)].map((_, i) => i))
7-
console.log({ items })
10+
const [enabled, setEnabled] = useState(false)
811

912
return (
1013
<>
@@ -14,9 +17,41 @@ export const App = () => {
1417
flex: 1,
1518
justifyContent: 'center',
1619
alignItems: 'center',
20+
rowGap: 12,
1721
}}
1822
>
1923
<Text>Example Expo App</Text>
24+
25+
<Pressable
26+
onPress={() => {
27+
setEnabled((prev) => !prev)
28+
}}
29+
>
30+
<Text>Enabled: {enabled ? 'Yes' : 'No'}</Text>
31+
</Pressable>
32+
33+
<Pressable
34+
onPress={() => {
35+
Alert.alert('State', BluetoothStateManager.getStateSync())
36+
}}
37+
>
38+
<Text>Get State Sync</Text>
39+
</Pressable>
40+
41+
<Pressable
42+
onPress={() => {
43+
BluetoothStateManager.getState()
44+
.then((state) => {
45+
Alert.alert('State', state)
46+
})
47+
.catch((error) => {
48+
Alert.alert('State error', error)
49+
})
50+
}}
51+
>
52+
<Text>Get State</Text>
53+
</Pressable>
54+
2055
{items.map((_, index) => {
2156
return (
2257
<Pressable
@@ -32,7 +67,7 @@ export const App = () => {
3267
}}
3368
>
3469
<Text>{index}.</Text>
35-
<Listener />
70+
<Listener enabled={enabled} />
3671
</Pressable>
3772
)
3873
})}
@@ -50,8 +85,8 @@ export const App = () => {
5085
)
5186
}
5287

53-
const Listener = () => {
54-
const bleState = useBluetoothState()
88+
const Listener = ({ enabled }: { enabled: boolean }) => {
89+
const bleState = useBluetoothState(enabled)
5590
console.log({ bleState })
5691
return <Text>{bleState}</Text>
5792
}

0 commit comments

Comments
 (0)