Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react-native): add lobby footer component #1091

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ Prop to customize the Join call button in the Lobby component.
| Type | Default Value |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`JoinCallButton`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Call/Lobby/JoinCallButton.tsx) |

### `LobbyFooter`

Prop to customize the Lobby Footer in the Lobby component.

| Type | Default Value |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`LobbyFooter`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Call/Lobby/LobbyFooter.tsx) |
52 changes: 16 additions & 36 deletions packages/react-native-sdk/src/components/Call/Lobby/Lobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {
import { useTheme } from '../../../contexts/ThemeContext';
import { useCallMediaStreamCleanup } from '../../../hooks/internal/useCallMediaStreamCleanup';
import type { MediaStream } from '@stream-io/react-native-webrtc';
import {
LobbyFooter as DefaultLobbyFooter,
LobbyFooterProps,
} from './LobbyFooter';

/**
* Props for the Lobby Component.
Expand All @@ -36,6 +40,10 @@ export type LobbyProps = {
* Component to customize the Join Call Button in the Lobby component.
*/
JoinCallButton?: ComponentType<JoinCallButtonProps> | null;
/**
* Component to customize the Lobby Footer in the Lobby component.
*/
LobbyFooter?: ComponentType<LobbyFooterProps> | null;
};

/**
Expand All @@ -45,20 +53,19 @@ export const Lobby = ({
onJoinCallHandler,
LobbyControls = DefaultLobbyControls,
JoinCallButton = DefaultJoinCallButton,
LobbyFooter = DefaultLobbyFooter,
}: LobbyProps) => {
const {
theme: { colors, lobby, typefaces },
} = useTheme();
const connectedUser = useConnectedUser();
const { useCameraState, useCallSession } = useCallStateHooks();
const { useCameraState } = useCallStateHooks();
const { status: cameraStatus } = useCameraState();
const call = useCall();
const session = useCallSession();
const { t } = useI18n();
const localVideoStream = call?.camera.state.mediaStream as unknown as
| MediaStream
| undefined;
const participantsCount = session?.participants.length;

useCallMediaStreamCleanup();

Expand Down Expand Up @@ -122,35 +129,12 @@ export const Lobby = ({
{LobbyControls && <LobbyControls />}
</>
)}
<View
style={[
styles.infoContainer,
{ backgroundColor: colors.static_overlay },
lobby.infoContainer,
]}
>
<Text
style={[
{ color: colors.static_white },
typefaces.subtitleBold,
lobby.infoText,
]}
>
{t('You are about to join a call with id {{ callId }}.', {
callId: call?.id,
}) +
' ' +
(participantsCount
? t(
'{{ numberOfParticipants }} participant(s) are in the call.',
{ numberOfParticipants: participantsCount },
)
: t('You are first to Join the call.'))}
</Text>
{JoinCallButton && (
<JoinCallButton onJoinCallHandler={onJoinCallHandler} />
)}
</View>
{LobbyFooter && (
<LobbyFooter
JoinCallButton={JoinCallButton}
onJoinCallHandler={onJoinCallHandler}
/>
)}
</View>
);
};
Expand Down Expand Up @@ -229,10 +213,6 @@ const styles = StyleSheet.create({
padding: 8,
},
topView: {},
infoContainer: {
padding: 12,
borderRadius: 10,
},
participantStatusContainer: {
alignSelf: 'flex-start',
flexDirection: 'row',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from 'react';
import { LobbyProps } from './Lobby';
import { View, StyleSheet, Text } from 'react-native';
import {
useCall,
useCallStateHooks,
useI18n,
} from '@stream-io/video-react-bindings';
import { useTheme } from '../../../contexts/ThemeContext';

/**
* Props for the Lobby Footer in the Lobby component.
*/
export type LobbyFooterProps = Pick<
LobbyProps,
'onJoinCallHandler' | 'JoinCallButton'
>;

/**
* The default Lobby Footer to be used in the Lobby component.
*/
export const LobbyFooter = ({
onJoinCallHandler,
JoinCallButton,
}: LobbyFooterProps) => {
const {
theme: { colors, lobby, typefaces },
} = useTheme();
const { useCallSession } = useCallStateHooks();

const { t } = useI18n();

const call = useCall();
const session = useCallSession();

const participantsCount = session?.participants.length;

return (
<View
style={[
styles.infoContainer,
{ backgroundColor: colors.static_overlay },
lobby.infoContainer,
]}
>
<Text
style={[
{ color: colors.static_white },
typefaces.subtitleBold,
lobby.infoText,
]}
>
{t('You are about to join a call with id {{ callId }}.', {
callId: call?.id,
}) +
' ' +
(participantsCount
? t('{{ numberOfParticipants }} participant(s) are in the call.', {
numberOfParticipants: participantsCount,
})
: t('You are first to join the call.'))}
</Text>
{JoinCallButton && (
<JoinCallButton onJoinCallHandler={onJoinCallHandler} />
)}
</View>
);
};

const styles = StyleSheet.create({
infoContainer: {
padding: 12,
borderRadius: 10,
},
});
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './Lobby';
export * from './JoinCallButton';
export * from './LobbyFooter';
2 changes: 1 addition & 1 deletion packages/react-native-sdk/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Join": "Join",
"You": "You",
"Reconnecting...": "Reconnecting...",
"You are first to Join the call.": "You are first to Join the call.",
"You are first to join the call.": "You are first to join the call.",
"Participants ({{ numberOfParticipants }})": "Participants ({{ numberOfParticipants }})",
"{{ userName }} is sharing their screen": "{{ userName }} is sharing their screen",
"{{ numberOfParticipants }} participant(s) are in the call.": "{{ numberOfParticipants }} participant(s) are in the call.",
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/react-native/dogfood/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Cancel": "Cancel",
"Before Joining": "Before Joining",
"Setup your audio and video": "Setup your audio and video",
"You are first to Join the call.": "You are first to Join the call.",
"You are first to join the call.": "You are first to join the call.",
"Join as Guest or Anonymously": "Join as Guest or Anonymously",
"Join with your Stream Account": "Join with your Stream Account",
"Stream DogFood App": "Stream DogFood App",
Expand Down
Loading