Skip to content

Commit

Permalink
chore: use lowercase for abbreviation to follow js convention
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed May 17, 2022
1 parent 7411e00 commit 246bd94
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"bracketSpacing": false,
"jsxBracketSameLine": true,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Airplay bridge for React Native.
yarn add react-airplay
npx pod-install
```

- Extra step for creating a bridging header:

> Only required if your project doesn't already use Swift
Create an empty Swift file in XCode, it will then ask if you want to create a bridging header

## Usage
Expand All @@ -25,14 +25,14 @@ import {
showRoutePicker,
useAirplayConnectivity,
useExternalPlaybackAvailability,
useAVAudioSessionRoutes,
useAvAudioSessionRoutes,
} from 'react-airplay';
import {Button, Text} from 'react-native'

const App = () => {
const isAirplayConnected = useAirplayConnectivity();
const isExternalPlaybackAvailable = useExternalPlaybackAvailability();
const routes = useAVAudioSessionRoutes();
const routes = useAvAudioSessionRoutes();

return (
<View>
Expand All @@ -50,7 +50,7 @@ const App = () => {
<Button title="Custom Button" onPress={() => showRoutePicker({prioritizesVideoDevices: true})}/>
)}
{routes.length && (
<Text>Currently playing on {airplayRoutes.map((route) => route.portName).join(', ')}</Text>
<Text>Currently playing on {routes.map((route) => route.portName).join(', ')}</Text>
)}
</View>
);
Expand Down
6 changes: 3 additions & 3 deletions example/ios/ReactAirplayExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = 238P3C58WC;
DevelopmentTeam = 7R86BGW2ND;
LastSwiftMigration = 1240;
};
};
Expand Down Expand Up @@ -426,7 +426,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 238P3C58WC;
DEVELOPMENT_TEAM = 7R86BGW2ND;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = ReactAirplayExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand All @@ -452,7 +452,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 238P3C58WC;
DEVELOPMENT_TEAM = 7R86BGW2ND;
INFOPLIST_FILE = ReactAirplayExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AirplayButton,
showRoutePicker,
useAirplayConnectivity,
useAVAudioSessionRoutes,
useAvAudioSessionRoutes,
useExternalPlaybackAvailability,
} from 'react-airplay';
import {Platform, ScrollView} from 'react-native';
Expand All @@ -15,7 +15,7 @@ export default () => {
useCachedValue: false,
});
const isAirplayConnected = useAirplayConnectivity();
const routes = useAVAudioSessionRoutes();
const routes = useAvAudioSessionRoutes();

return (
<ScrollView contentContainerStyle={styles.container}>
Expand Down
2 changes: 1 addition & 1 deletion ios/ReactAirplay/Modules/RAAirplayConnectivityContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@interface RCT_EXTERN_MODULE (RAAirplayConnectivityContext, RCTEventEmitter)

_RCT_EXTERN_REMAP_METHOD(fetchAVAudioSessionRoutes,
_RCT_EXTERN_REMAP_METHOD(fetchAvAudioSessionRoutes,
fetchAVAudioSessionRoutesWithResolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject, NO)
Expand Down
16 changes: 8 additions & 8 deletions src/airplayModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ExternalPlaybackAvailabilityContext = NativeModule & {
};

/* As per https://developer.apple.com/documentation/avfaudio/avaudiosession/port */
export type AVAudioSessionPortType =
export type AvAudioSessionPortType =
| 'BuiltInMic'
| 'HeadsetMic'
| 'LineIn'
Expand All @@ -32,24 +32,24 @@ export type AVAudioSessionPortType =
| 'UsbAudio'
| 'Virtual';

export interface AVAudioSessionChannel {
export interface AvAudioSessionChannel {
channelName: string;
channelNumber: number;
owningPortUID: string;
channelLabel: string;
}

export interface AVAudioSessionRoute {
export interface AvAudioSessionRoute {
portName: string;
portType: AVAudioSessionPortType;
channels: AVAudioSessionChannel[];
portType: AvAudioSessionPortType;
channels: AvAudioSessionChannel[];
uid: string;
hasHardwareVoiceCallProcessing: boolean;
isSpatialAudioEnabled: boolean;
}

export type AirplayConnectivityContext = NativeModule & {
fetchAVAudioSessionRoutes: () => Promise<AVAudioSessionRoute[]>;
fetchAvAudioSessionRoutes: () => Promise<AvAudioSessionRoute[]>;
};

export type RoutePickerContext = NativeModule & {
Expand Down Expand Up @@ -99,8 +99,8 @@ export const onExternalPlaybackAvailabilityChanged = (
callback,
);

export const onAVAudioSessionRoutesChanged = (
callback: (routes: AVAudioSessionRoute[]) => void,
export const onAvAudioSessionRoutesChanged = (
callback: (routes: AvAudioSessionRoute[]) => void,
) =>
AirplayConnectivityEventEmitter.addListener(
AV_AUDIO_SESSION_ROUTES_CHANGED,
Expand Down
14 changes: 7 additions & 7 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {useEffect, useState} from 'react';

import {
AirplayConnectivityContext,
AVAudioSessionRoute,
AvAudioSessionRoute,
ExternalPlaybackAvailabilityContext,
onAVAudioSessionRoutesChanged,
onAvAudioSessionRoutesChanged,
onExternalPlaybackAvailabilityChanged,
} from './airplayModule';

Expand Down Expand Up @@ -41,17 +41,17 @@ export const useAirplayConnectivity = () => {
};

export const useAirplayRoutes = () => {
const routes = useAVAudioSessionRoutes();
const routes = useAvAudioSessionRoutes();
return routes.filter(route => route.portType === 'AirPlay');
};

export const useAVAudioSessionRoutes = () => {
const [routes, setRoutes] = useState<AVAudioSessionRoute[]>([]);
export const useAvAudioSessionRoutes = () => {
const [routes, setRoutes] = useState<AvAudioSessionRoute[]>([]);

useEffect(() => {
const subscription = onAVAudioSessionRoutesChanged(setRoutes);
const subscription = onAvAudioSessionRoutesChanged(setRoutes);

AirplayConnectivityContext?.fetchAVAudioSessionRoutes().then(setRoutes);
AirplayConnectivityContext?.fetchAvAudioSessionRoutes().then(setRoutes);

return subscription.remove.bind(subscription);
}, []);
Expand Down

0 comments on commit 246bd94

Please sign in to comment.