Skip to content

Commit 7712b4f

Browse files
committed
1.1.1
1 parent 8d42ffe commit 7712b4f

File tree

10 files changed

+56
-16
lines changed

10 files changed

+56
-16
lines changed

lib/example/App.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function App(): JSX.Element;

lib/example/App.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { StyleSheet, View, Button, Platform } from "react-native";
3+
import RNSystemSounds from "react-native-system-sounds";
4+
export default function App() {
5+
return (React.createElement(View, { style: styles.container },
6+
React.createElement(Button, { onPress: () => {
7+
console.log("HERE");
8+
RNSystemSounds.beep();
9+
}, title: "Play positive beep" }),
10+
React.createElement(Button, { onPress: () => RNSystemSounds.beep(RNSystemSounds.Beeps.Negative), title: "Play negative beep" }),
11+
React.createElement(Button, { onPress: () => RNSystemSounds.play(Platform.select({
12+
android: RNSystemSounds.AndroidSoundIDs.TONE_CDMA_ABBR_ALERT,
13+
ios: RNSystemSounds.iOSSoundIDs.AudioToneBusy,
14+
})), title: "Play custom system sound" })));
15+
}
16+
const styles = StyleSheet.create({
17+
container: {
18+
flex: 1,
19+
alignItems: "center",
20+
justifyContent: "center",
21+
},
22+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* @format
3+
*/
4+
import 'react-native';

lib/example/__tests__/App.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @format
3+
*/
4+
import 'react-native';
5+
import React from 'react';
6+
import App from '../App';
7+
// Note: import explicitly to use the types shiped with jest.
8+
import { it } from '@jest/globals';
9+
// Note: test renderer must be required after react-native.
10+
import renderer from 'react-test-renderer';
11+
it('renders correctly', () => {
12+
renderer.create(React.createElement(App, null));
13+
});
File renamed without changes.

lib/index.d.ts renamed to lib/src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AndroidSoundIDs, iOSSoundIDs } from "./constants";
2-
declare type TSoundId = typeof AndroidSoundIDs[keyof typeof AndroidSoundIDs] | typeof iOSSoundIDs[keyof typeof iOSSoundIDs];
2+
type TSoundId = typeof AndroidSoundIDs[keyof typeof AndroidSoundIDs] | typeof iOSSoundIDs[keyof typeof iOSSoundIDs];
33
declare class RNSystemSounds {
44
static AndroidSoundIDs: {
55
readonly TONE_CDMA_ABBR_ALERT: 97;

lib/index.js renamed to lib/src/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import { NativeModules, Platform } from "react-native";
22
import { AndroidSoundIDs, iOSSoundIDs } from "./constants";
33
const { RNSystemSounds: RNSystemSoundsNativeModule } = NativeModules;
44
class RNSystemSounds {
5+
static AndroidSoundIDs = AndroidSoundIDs;
6+
static iOSSoundIDs = iOSSoundIDs;
7+
static Beeps = {
8+
Positive: Platform.select({
9+
ios: iOSSoundIDs.Headset_AnswerCall,
10+
android: AndroidSoundIDs.TONE_PROP_BEEP,
11+
}),
12+
Negative: Platform.select({
13+
ios: iOSSoundIDs.Headset_EndCall,
14+
android: AndroidSoundIDs.TONE_PROP_ACK,
15+
}),
16+
};
517
static play(soundID) {
618
if (Platform.OS === "android") {
719
RNSystemSoundsNativeModule.stopSystemSound();
@@ -12,16 +24,4 @@ class RNSystemSounds {
1224
this.play(soundID);
1325
}
1426
}
15-
RNSystemSounds.AndroidSoundIDs = AndroidSoundIDs;
16-
RNSystemSounds.iOSSoundIDs = iOSSoundIDs;
17-
RNSystemSounds.Beeps = {
18-
Positive: Platform.select({
19-
ios: iOSSoundIDs.Headset_AnswerCall,
20-
android: AndroidSoundIDs.TONE_PROP_BEEP,
21-
}),
22-
Negative: Platform.select({
23-
ios: iOSSoundIDs.Headset_EndCall,
24-
android: AndroidSoundIDs.TONE_PROP_ACK,
25-
}),
26-
};
2727
export default RNSystemSounds;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@dashdoc/react-native-system-sounds",
33
"title": "React Native System Sounds",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"description": "A module to play system sounds and beeps for React Native on iOS and Android (no sound files).",
66
"homepage": "https://github.com/Dashdoc/react-native-system-sounds",
77
"main": "lib/index.js",

0 commit comments

Comments
 (0)