@stream-io/video-react-native-sdk 0.0.1-alpha.366 → 0.0.1-alpha.368

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/__tests__/components/CallControls.test.js +11 -7
  3. package/dist/__tests__/components/CallControls.test.js.map +1 -1
  4. package/dist/src/components/call/CallControls/AcceptCallButton.d.ts +22 -0
  5. package/dist/src/components/call/CallControls/AcceptCallButton.js +39 -0
  6. package/dist/src/components/call/CallControls/AcceptCallButton.js.map +1 -0
  7. package/dist/src/components/call/CallControls/CallControls.d.ts +16 -0
  8. package/dist/src/components/call/CallControls/CallControls.js +38 -0
  9. package/dist/src/components/call/CallControls/CallControls.js.map +1 -0
  10. package/dist/src/components/{utility/internal → call/CallControls}/CallControlsButton.d.ts +5 -1
  11. package/dist/src/components/{utility/internal → call/CallControls}/CallControlsButton.js +12 -7
  12. package/dist/src/components/call/CallControls/CallControlsButton.js.map +1 -0
  13. package/dist/src/components/call/CallControls/ChatButton.d.ts +20 -0
  14. package/dist/src/components/call/CallControls/ChatButton.js +58 -0
  15. package/dist/src/components/call/CallControls/ChatButton.js.map +1 -0
  16. package/dist/src/components/{utility/internal → call/CallControls}/HangupCallButton.d.ts +12 -1
  17. package/dist/src/components/{utility/internal → call/CallControls}/HangupCallButton.js +10 -16
  18. package/dist/src/components/call/CallControls/HangupCallButton.js.map +1 -0
  19. package/dist/src/components/call/CallControls/ReactionButton.d.ts +14 -0
  20. package/dist/src/components/call/CallControls/ReactionButton.js +76 -0
  21. package/dist/src/components/call/CallControls/ReactionButton.js.map +1 -0
  22. package/dist/src/components/call/CallControls/RejectCallButton.d.ts +23 -0
  23. package/dist/src/components/call/CallControls/RejectCallButton.js +45 -0
  24. package/dist/src/components/call/CallControls/RejectCallButton.js.map +1 -0
  25. package/dist/src/components/call/CallControls/ToggleAudioPreviewButton.d.ts +14 -0
  26. package/dist/src/components/call/CallControls/ToggleAudioPreviewButton.js +39 -0
  27. package/dist/src/components/call/CallControls/ToggleAudioPreviewButton.js.map +1 -0
  28. package/dist/src/components/call/CallControls/ToggleAudioPublishingButton.d.ts +14 -0
  29. package/dist/src/components/{utility/internal/ToggleAudioButton.js → call/CallControls/ToggleAudioPublishingButton.js} +14 -23
  30. package/dist/src/components/call/CallControls/ToggleAudioPublishingButton.js.map +1 -0
  31. package/dist/src/components/call/CallControls/ToggleCameraFaceButton.d.ts +14 -0
  32. package/dist/src/components/{utility/internal → call/CallControls}/ToggleCameraFaceButton.js +12 -16
  33. package/dist/src/components/call/CallControls/ToggleCameraFaceButton.js.map +1 -0
  34. package/dist/src/components/call/CallControls/ToggleVideoPreviewButton.d.ts +14 -0
  35. package/dist/src/components/call/CallControls/ToggleVideoPreviewButton.js +39 -0
  36. package/dist/src/components/call/CallControls/ToggleVideoPreviewButton.js.map +1 -0
  37. package/dist/src/components/call/CallControls/ToggleVideoPublishingButton.d.ts +14 -0
  38. package/dist/src/components/{utility/internal/ToggleVideoButton.js → call/CallControls/ToggleVideoPublishingButton.js} +14 -23
  39. package/dist/src/components/call/CallControls/ToggleVideoPublishingButton.js.map +1 -0
  40. package/dist/src/components/call/CallControls/index.d.ts +11 -0
  41. package/dist/src/components/call/CallControls/index.js +28 -0
  42. package/dist/src/components/call/CallControls/index.js.map +1 -0
  43. package/dist/src/components/call/CallTopView/CallTopView.d.ts +22 -0
  44. package/dist/src/components/call/CallTopView/CallTopView.js +106 -0
  45. package/dist/src/components/call/CallTopView/CallTopView.js.map +1 -0
  46. package/dist/src/components/call/CallTopView/ParticipantsInfoBadge.d.ts +7 -0
  47. package/dist/src/components/call/CallTopView/ParticipantsInfoBadge.js +52 -0
  48. package/dist/src/components/call/CallTopView/ParticipantsInfoBadge.js.map +1 -0
  49. package/dist/src/components/call/CallTopView/index.d.ts +2 -0
  50. package/dist/src/components/call/CallTopView/index.js +19 -0
  51. package/dist/src/components/call/CallTopView/index.js.map +1 -0
  52. package/dist/src/components/call/IncomingCall.js +10 -75
  53. package/dist/src/components/call/IncomingCall.js.map +1 -1
  54. package/dist/src/components/call/Lobby.js +8 -30
  55. package/dist/src/components/call/Lobby.js.map +1 -1
  56. package/dist/src/components/call/OutgoingCall.d.ts +1 -1
  57. package/dist/src/components/call/OutgoingCall.js +5 -15
  58. package/dist/src/components/call/OutgoingCall.js.map +1 -1
  59. package/dist/src/components/call/ReactionsPicker.js +3 -3
  60. package/dist/src/components/call/ReactionsPicker.js.map +1 -1
  61. package/dist/src/components/call/index.d.ts +1 -0
  62. package/dist/src/components/call/index.js +1 -0
  63. package/dist/src/components/call/index.js.map +1 -1
  64. package/dist/src/components/participants/index.d.ts +0 -2
  65. package/dist/src/components/participants/index.js +0 -2
  66. package/dist/src/components/participants/index.js.map +1 -1
  67. package/dist/src/icons/Back.d.ts +5 -0
  68. package/dist/src/icons/Back.js +13 -0
  69. package/dist/src/icons/Back.js.map +1 -0
  70. package/dist/src/icons/TopViewBackground.d.ts +13 -0
  71. package/dist/src/icons/TopViewBackground.js +19 -0
  72. package/dist/src/icons/TopViewBackground.js.map +1 -0
  73. package/dist/src/icons/index.d.ts +1 -4
  74. package/dist/src/icons/index.js +1 -4
  75. package/dist/src/icons/index.js.map +1 -1
  76. package/dist/src/theme/padding.js +1 -1
  77. package/dist/src/translations/en.json +1 -0
  78. package/dist/src/translations/index.d.ts +1 -0
  79. package/dist/version.d.ts +1 -1
  80. package/dist/version.js +1 -1
  81. package/package.json +1 -1
  82. package/src/components/call/CallControls/AcceptCallButton.tsx +58 -0
  83. package/src/components/call/CallControls/CallControls.tsx +48 -0
  84. package/src/components/{utility/internal → call/CallControls}/CallControlsButton.tsx +18 -10
  85. package/src/components/call/CallControls/ChatButton.tsx +87 -0
  86. package/src/components/{utility/internal → call/CallControls}/HangupCallButton.tsx +17 -18
  87. package/src/components/call/CallControls/ReactionButton.tsx +80 -0
  88. package/src/components/call/CallControls/RejectCallButton.tsx +65 -0
  89. package/src/components/call/CallControls/ToggleAudioPreviewButton.tsx +61 -0
  90. package/src/components/{utility/internal/ToggleAudioButton.tsx → call/CallControls/ToggleAudioPublishingButton.tsx} +24 -24
  91. package/src/components/{utility/internal → call/CallControls}/ToggleCameraFaceButton.tsx +26 -19
  92. package/src/components/call/CallControls/ToggleVideoPreviewButton.tsx +61 -0
  93. package/src/components/{utility/internal/ToggleVideoButton.tsx → call/CallControls/ToggleVideoPublishingButton.tsx} +24 -24
  94. package/src/components/call/CallControls/index.tsx +11 -0
  95. package/src/components/call/CallTopView/CallTopView.tsx +130 -0
  96. package/src/components/call/CallTopView/ParticipantsInfoBadge.tsx +61 -0
  97. package/src/components/call/CallTopView/index.ts +2 -0
  98. package/src/components/call/IncomingCall.tsx +8 -76
  99. package/src/components/call/Lobby.tsx +10 -55
  100. package/src/components/call/OutgoingCall.tsx +5 -38
  101. package/src/components/call/ReactionsPicker.tsx +3 -3
  102. package/src/components/call/index.ts +1 -0
  103. package/src/components/participants/index.ts +0 -2
  104. package/src/icons/Back.tsx +15 -0
  105. package/src/icons/TopViewBackground.tsx +43 -0
  106. package/src/icons/index.tsx +1 -4
  107. package/src/theme/padding.ts +1 -1
  108. package/src/translations/en.json +1 -0
  109. package/dist/__tests__/components/ParticipantBadge.test.d.ts +0 -1
  110. package/dist/__tests__/components/ParticipantBadge.test.js +0 -70
  111. package/dist/__tests__/components/ParticipantBadge.test.js.map +0 -1
  112. package/dist/src/components/call/CallControls.d.ts +0 -35
  113. package/dist/src/components/call/CallControls.js +0 -136
  114. package/dist/src/components/call/CallControls.js.map +0 -1
  115. package/dist/src/components/participants/ParticipantsInfoBadge.d.ts +0 -8
  116. package/dist/src/components/participants/ParticipantsInfoBadge.js +0 -74
  117. package/dist/src/components/participants/ParticipantsInfoBadge.js.map +0 -1
  118. package/dist/src/components/participants/ParticipantsInfoList.d.ts +0 -17
  119. package/dist/src/components/participants/ParticipantsInfoList.js +0 -243
  120. package/dist/src/components/participants/ParticipantsInfoList.js.map +0 -1
  121. package/dist/src/components/participants/internal/ParticipantActions.d.ts +0 -8
  122. package/dist/src/components/participants/internal/ParticipantActions.js +0 -236
  123. package/dist/src/components/participants/internal/ParticipantActions.js.map +0 -1
  124. package/dist/src/components/utility/internal/CallControlsButton.js.map +0 -1
  125. package/dist/src/components/utility/internal/HangupCallButton.js.map +0 -1
  126. package/dist/src/components/utility/internal/ToggleAudioButton.d.ts +0 -1
  127. package/dist/src/components/utility/internal/ToggleAudioButton.js.map +0 -1
  128. package/dist/src/components/utility/internal/ToggleCameraFaceButton.d.ts +0 -1
  129. package/dist/src/components/utility/internal/ToggleCameraFaceButton.js.map +0 -1
  130. package/dist/src/components/utility/internal/ToggleVideoButton.d.ts +0 -1
  131. package/dist/src/components/utility/internal/ToggleVideoButton.js.map +0 -1
  132. package/dist/src/icons/ArrowRight.d.ts +0 -5
  133. package/dist/src/icons/ArrowRight.js +0 -13
  134. package/dist/src/icons/ArrowRight.js.map +0 -1
  135. package/dist/src/icons/Cross.d.ts +0 -6
  136. package/dist/src/icons/Cross.js +0 -13
  137. package/dist/src/icons/Cross.js.map +0 -1
  138. package/dist/src/icons/Pin.d.ts +0 -5
  139. package/dist/src/icons/Pin.js +0 -13
  140. package/dist/src/icons/Pin.js.map +0 -1
  141. package/dist/src/icons/VideoDisabled.d.ts +0 -5
  142. package/dist/src/icons/VideoDisabled.js +0 -14
  143. package/dist/src/icons/VideoDisabled.js.map +0 -1
  144. package/src/components/call/CallControls.tsx +0 -195
  145. package/src/components/participants/ParticipantsInfoBadge.tsx +0 -70
  146. package/src/components/participants/ParticipantsInfoList.tsx +0 -319
  147. package/src/components/participants/internal/ParticipantActions.tsx +0 -289
  148. package/src/icons/ArrowRight.tsx +0 -17
  149. package/src/icons/Cross.tsx +0 -15
  150. package/src/icons/Pin.tsx +0 -17
  151. package/src/icons/VideoDisabled.tsx +0 -23
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { CallControlsButton } from './CallControlsButton';
3
+ import { theme } from '../../../theme';
4
+ import { Video, VideoSlash } from '../../../icons';
5
+ import { useMediaStreamManagement } from '../../../providers';
6
+
7
+ /**
8
+ * Props for the Toggle Video preview button
9
+ */
10
+ export type ToggleVideoPreviewButtonProps = {
11
+ /**
12
+ * Handler to be called when the the video preview button is pressed.
13
+ * @returns void
14
+ */
15
+ onPressHandler?: () => void;
16
+ };
17
+
18
+ /**
19
+ * Button to toggle video mute/unmute status before joining the call.
20
+ */
21
+ export const ToggleVideoPreviewButton = ({
22
+ onPressHandler,
23
+ }: ToggleVideoPreviewButtonProps) => {
24
+ const { initialVideoEnabled, toggleInitialVideoMuteState } =
25
+ useMediaStreamManagement();
26
+
27
+ const VideoIcon = !initialVideoEnabled ? (
28
+ <VideoSlash color={theme.light.static_white} />
29
+ ) : (
30
+ <Video color={theme.light.static_black} />
31
+ );
32
+
33
+ const toggleVideoPreviewHandler = () => {
34
+ if (onPressHandler) {
35
+ onPressHandler();
36
+ return;
37
+ }
38
+ toggleInitialVideoMuteState();
39
+ };
40
+
41
+ return (
42
+ <CallControlsButton
43
+ onPress={toggleVideoPreviewHandler}
44
+ color={
45
+ initialVideoEnabled
46
+ ? theme.light.static_white
47
+ : theme.light.static_black
48
+ }
49
+ style={[
50
+ theme.button.md,
51
+ {
52
+ shadowColor: initialVideoEnabled
53
+ ? theme.light.static_white
54
+ : theme.light.static_black,
55
+ },
56
+ ]}
57
+ >
58
+ {VideoIcon}
59
+ </CallControlsButton>
60
+ );
61
+ };
@@ -8,21 +8,36 @@ import {
8
8
  } from '@stream-io/video-react-bindings';
9
9
  import { CallControlsButton } from './CallControlsButton';
10
10
  import { muteStatusColor } from '../../../utils';
11
- import { Alert, StyleSheet } from 'react-native';
11
+ import { Alert } from 'react-native';
12
12
  import { theme } from '../../../theme';
13
13
  import { Video, VideoSlash } from '../../../icons';
14
14
  import { usePermissionNotification } from '../../../hooks';
15
15
  import { useMediaStreamManagement } from '../../../providers';
16
16
 
17
- export const ToggleVideoButton = () => {
17
+ /**
18
+ * Props for the Toggle Video publishing button
19
+ */
20
+ export type ToggleVideoPublishingButtonProps = {
21
+ /**
22
+ * Handler to be called when the the video publishing button is pressed.
23
+ * @returns void
24
+ */
25
+ onPressHandler?: () => void;
26
+ };
27
+
28
+ /**
29
+ * Button to toggle video mute/unmute status while in the call.
30
+ */
31
+ export const ToggleVideoPublishingButton = ({
32
+ onPressHandler,
33
+ }: ToggleVideoPublishingButtonProps) => {
18
34
  const [isAwaitingApproval, setIsAwaitingApproval] = useState(false);
19
35
  const { isVideoMuted, toggleVideoMuted } = useMediaStreamManagement();
20
36
  const { t } = useI18n();
21
-
37
+ const call = useCall();
22
38
  const userHasSendVideoCapability = useHasPermissions(
23
39
  OwnCapability.SEND_VIDEO,
24
40
  );
25
- const call = useCall();
26
41
 
27
42
  useEffect(() => {
28
43
  if (userHasSendVideoCapability) {
@@ -57,8 +72,12 @@ export const ToggleVideoButton = () => {
57
72
  });
58
73
 
59
74
  const handleToggleVideoButton = async () => {
75
+ if (onPressHandler) {
76
+ onPressHandler();
77
+ return;
78
+ }
60
79
  if (userHasSendVideoCapability) {
61
- await toggleVideoMuted();
80
+ toggleVideoMuted();
62
81
  return;
63
82
  }
64
83
  if (!isAwaitingApproval) {
@@ -73,7 +92,6 @@ export const ToggleVideoButton = () => {
73
92
  <CallControlsButton
74
93
  onPress={handleToggleVideoButton}
75
94
  color={muteStatusColor(isVideoMuted)}
76
- style={!isVideoMuted ? styles.button : null}
77
95
  >
78
96
  {isVideoMuted ? (
79
97
  <VideoSlash color={theme.light.static_white} />
@@ -84,21 +102,3 @@ export const ToggleVideoButton = () => {
84
102
  </Restricted>
85
103
  );
86
104
  };
87
-
88
- const styles = StyleSheet.create({
89
- button: {
90
- // For iOS
91
- shadowOffset: {
92
- width: 0,
93
- height: 6,
94
- },
95
- shadowOpacity: 0.37,
96
- shadowRadius: 7.49,
97
-
98
- // For android
99
- elevation: 6,
100
- },
101
- svgContainerStyle: {
102
- paddingTop: theme.padding.xs,
103
- },
104
- });
@@ -0,0 +1,11 @@
1
+ export * from './AcceptCallButton';
2
+ export * from './RejectCallButton';
3
+ export * from './HangupCallButton';
4
+ export * from './ToggleAudioPreviewButton';
5
+ export * from './ToggleVideoPreviewButton';
6
+ export * from './ToggleAudioPublishingButton';
7
+ export * from './ToggleVideoPublishingButton';
8
+ export * from './ToggleCameraFaceButton';
9
+ export * from './ChatButton';
10
+ export * from './ReactionButton';
11
+ export * from './CallControls';
@@ -0,0 +1,130 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ Text,
6
+ StyleProp,
7
+ ViewStyle,
8
+ Pressable,
9
+ } from 'react-native';
10
+ import { ParticipantsInfoBadge } from './ParticipantsInfoBadge';
11
+ import { theme } from '../../../theme';
12
+ import { Back } from '../../../icons/Back';
13
+ import { Z_INDEX } from '../../../constants';
14
+ import { TopViewBackground } from '../../../icons';
15
+ import { useCallStateHooks, useI18n } from '@stream-io/video-react-bindings';
16
+ import { CallingState } from '@stream-io/video-client';
17
+
18
+ export type CallTopViewProps = {
19
+ /**
20
+ * Handler to be called when the back button is pressed in the CallTopView.
21
+ * @returns void
22
+ */
23
+ onBackPressed?: () => void;
24
+ /**
25
+ * Handler to be called when the Participant icon is pressed in the CallTopView.
26
+ * @returns
27
+ */
28
+ onParticipantInfoPress?: () => void;
29
+ /**
30
+ * Title to be rendered at the center of the Header.
31
+ */
32
+ title?: string;
33
+ /**
34
+ * Style to override the container of the CallTopView.
35
+ */
36
+ style?: StyleProp<ViewStyle>;
37
+ };
38
+
39
+ export const CallTopView = ({
40
+ onBackPressed,
41
+ onParticipantInfoPress,
42
+ title,
43
+ style,
44
+ }: CallTopViewProps) => {
45
+ const { useCallCallingState } = useCallStateHooks();
46
+ const callingState = useCallCallingState();
47
+ const { t } = useI18n();
48
+ const [headerHeight, setHeaderHeight] = useState<number>(0);
49
+ const isCallReconnecting = callingState === CallingState.RECONNECTING;
50
+
51
+ const onLayout: React.ComponentProps<typeof View>['onLayout'] = (event) => {
52
+ const { height } = event.nativeEvent.layout;
53
+ setHeaderHeight(height);
54
+ };
55
+
56
+ return (
57
+ <View style={[styles.container, style]}>
58
+ {/* Component for the background of the CallTopView. Since it has a Linear Gradient, an SVG is used to render it. */}
59
+ <TopViewBackground height={headerHeight} width={'100%'} />
60
+ <View style={styles.topView} onLayout={onLayout}>
61
+ <View style={styles.leftElement}>
62
+ {onBackPressed && (
63
+ <Pressable
64
+ style={({ pressed }) => [
65
+ theme.icon.md,
66
+ styles.backIcon,
67
+ { opacity: pressed ? 0.2 : 1 },
68
+ ]}
69
+ onPress={onBackPressed}
70
+ >
71
+ <Back color={theme.light.static_white} />
72
+ </Pressable>
73
+ )}
74
+ </View>
75
+ <View style={styles.centerElement}>
76
+ {title ? (
77
+ <Text style={styles.title} numberOfLines={1}>
78
+ {title}
79
+ </Text>
80
+ ) : (
81
+ isCallReconnecting && (
82
+ <Text style={styles.title}>{t('Reconnecting...')}</Text>
83
+ )
84
+ )}
85
+ </View>
86
+ <View style={styles.rightElement}>
87
+ <ParticipantsInfoBadge
88
+ onParticipantInfoPress={onParticipantInfoPress}
89
+ />
90
+ </View>
91
+ </View>
92
+ </View>
93
+ );
94
+ };
95
+
96
+ const styles = StyleSheet.create({
97
+ container: {
98
+ zIndex: Z_INDEX.IN_FRONT,
99
+ position: 'absolute',
100
+ left: 0,
101
+ right: 0,
102
+ },
103
+ topView: {
104
+ position: 'absolute',
105
+ flexDirection: 'row',
106
+ paddingVertical: theme.padding.lg,
107
+ alignItems: 'center',
108
+ },
109
+ backIcon: {
110
+ // Added to compensate the participant badge surface area
111
+ marginLeft: theme.margin.sm,
112
+ },
113
+ leftElement: {
114
+ flex: 1,
115
+ alignItems: 'flex-start',
116
+ },
117
+ centerElement: {
118
+ flex: 1,
119
+ alignItems: 'center',
120
+ flexGrow: 3,
121
+ },
122
+ rightElement: {
123
+ flex: 1,
124
+ alignItems: 'flex-end',
125
+ },
126
+ title: {
127
+ ...theme.fonts.subtitleBold,
128
+ color: theme.light.static_white,
129
+ },
130
+ });
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { Pressable, StyleSheet, Text, View } from 'react-native';
3
+ import { Participants } from '../../../icons';
4
+ import { useCallStateHooks } from '@stream-io/video-react-bindings';
5
+ import { theme } from '../../../theme';
6
+ import { Z_INDEX } from '../../../constants';
7
+ import { CallTopViewProps } from '..';
8
+
9
+ export type ParticipantsInfoBadgeProps = Pick<
10
+ CallTopViewProps,
11
+ 'onParticipantInfoPress'
12
+ >;
13
+
14
+ /**
15
+ * Badge that shows the number of participants in the call.
16
+ * When pressed, it opens the ParticipantsInfoList.
17
+ */
18
+ export const ParticipantsInfoBadge = ({
19
+ onParticipantInfoPress,
20
+ }: ParticipantsInfoBadgeProps) => {
21
+ const { useParticipantCount } = useCallStateHooks();
22
+ const participantCount = useParticipantCount();
23
+
24
+ return (
25
+ <Pressable
26
+ onPress={onParticipantInfoPress}
27
+ style={({ pressed }) => [
28
+ { ...styles.container, opacity: pressed ? 0.2 : 1 },
29
+ ]}
30
+ disabled={!onParticipantInfoPress}
31
+ >
32
+ <View style={theme.icon.md}>
33
+ <Participants color={theme.light.static_white} />
34
+ </View>
35
+ <View style={styles.badge}>
36
+ <Text style={styles.badgeText}>{participantCount}</Text>
37
+ </View>
38
+ </Pressable>
39
+ );
40
+ };
41
+
42
+ const styles = StyleSheet.create({
43
+ container: {
44
+ flexDirection: 'row',
45
+ },
46
+ badge: {
47
+ justifyContent: 'center',
48
+ paddingHorizontal: theme.padding.sm,
49
+ backgroundColor: theme.light.text_low_emphasis,
50
+ borderRadius: theme.rounded.xl,
51
+ zIndex: Z_INDEX.IN_FRONT,
52
+ bottom: theme.spacing.xl,
53
+ right: theme.spacing.xl,
54
+ },
55
+ badgeText: {
56
+ includeFontPadding: false,
57
+ color: theme.light.static_white,
58
+ textAlign: 'center',
59
+ ...theme.fonts.subtitle,
60
+ },
61
+ });
@@ -0,0 +1,2 @@
1
+ export * from './CallTopView';
2
+ export * from './ParticipantsInfoBadge';
@@ -1,17 +1,15 @@
1
- import React, { useCallback } from 'react';
1
+ import React from 'react';
2
2
  import { ImageBackground, StyleSheet, Text, View } from 'react-native';
3
- import { CallControlsButton } from '../utility/internal/CallControlsButton';
4
3
  import {
5
- useCall,
6
4
  useCallStateHooks,
7
5
  useConnectedUser,
8
6
  useI18n,
9
7
  } from '@stream-io/video-react-bindings';
10
8
  import { UserInfo } from './internal/UserInfo';
11
- import { Phone, PhoneDown, Video, VideoSlash } from '../../icons';
12
9
  import { theme } from '../../theme';
13
- import { useMediaStreamManagement } from '../../providers/MediaStreamManagement';
14
- import { CallingState } from '@stream-io/video-client';
10
+ import { RejectCallButton } from './CallControls/RejectCallButton';
11
+ import { AcceptCallButton } from './CallControls/AcceptCallButton';
12
+ import { ToggleVideoPreviewButton } from './CallControls/ToggleVideoPreviewButton';
15
13
 
16
14
  /**
17
15
  * The props for the Accept Call button in the IncomingCall component.
@@ -57,42 +55,8 @@ export const IncomingCall = ({
57
55
  acceptCallButton,
58
56
  rejectCallButton,
59
57
  }: IncomingCallType) => {
60
- const { toggleInitialVideoMuteState, initialVideoEnabled } =
61
- useMediaStreamManagement();
62
- const call = useCall();
63
- const { useCallCallingState } = useCallStateHooks();
64
- const callingState = useCallCallingState();
65
58
  const { t } = useI18n();
66
59
 
67
- const acceptCallHandler = useCallback(async () => {
68
- if (acceptCallButton?.onPressHandler) {
69
- acceptCallButton.onPressHandler();
70
- return;
71
- }
72
- try {
73
- await call?.join();
74
- } catch (error) {
75
- console.log('Error joining Call', error);
76
- }
77
- // eslint-disable-next-line react-hooks/exhaustive-deps
78
- }, [call]);
79
-
80
- const rejectCallHandler = useCallback(async () => {
81
- if (rejectCallButton?.onPressHandler) {
82
- rejectCallButton.onPressHandler();
83
- return;
84
- }
85
- try {
86
- if (callingState === CallingState.LEFT) {
87
- return;
88
- }
89
- await call?.leave({ reject: true });
90
- } catch (error) {
91
- console.log('Error rejecting Call', error);
92
- }
93
- // eslint-disable-next-line react-hooks/exhaustive-deps
94
- }, [call]);
95
-
96
60
  return (
97
61
  <Background>
98
62
  <View style={styles.content}>
@@ -101,38 +65,9 @@ export const IncomingCall = ({
101
65
  </View>
102
66
 
103
67
  <View style={styles.buttonGroup}>
104
- <CallControlsButton
105
- onPress={rejectCallHandler}
106
- color={theme.light.error}
107
- style={[styles.button, theme.button.lg]}
108
- svgContainerStyle={[styles.svgContainerStyle, theme.icon.lg]}
109
- >
110
- <PhoneDown color={theme.light.static_white} />
111
- </CallControlsButton>
112
- <CallControlsButton
113
- onPress={toggleInitialVideoMuteState}
114
- color={
115
- initialVideoEnabled
116
- ? theme.light.static_white
117
- : theme.light.overlay_dark
118
- }
119
- style={[styles.button, theme.button.lg]}
120
- svgContainerStyle={[styles.svgContainerStyle, theme.icon.lg]}
121
- >
122
- {!initialVideoEnabled ? (
123
- <VideoSlash color={theme.light.static_white} />
124
- ) : (
125
- <Video color={theme.light.static_black} />
126
- )}
127
- </CallControlsButton>
128
- <CallControlsButton
129
- onPress={acceptCallHandler}
130
- color={theme.light.info}
131
- style={[styles.button, theme.button.lg]}
132
- svgContainerStyle={[styles.svgContainerStyle, theme.icon.lg]}
133
- >
134
- <Phone color={theme.light.static_white} />
135
- </CallControlsButton>
68
+ <RejectCallButton onPressHandler={rejectCallButton?.onPressHandler} />
69
+ <ToggleVideoPreviewButton />
70
+ <AcceptCallButton onPressHandler={acceptCallButton?.onPressHandler} />
136
71
  </View>
137
72
  </Background>
138
73
  );
@@ -186,9 +121,6 @@ const styles = StyleSheet.create({
186
121
  },
187
122
  buttonGroup: {
188
123
  flexDirection: 'row',
189
- justifyContent: 'space-between',
190
- paddingHorizontal: theme.padding.xl,
124
+ justifyContent: 'space-evenly',
191
125
  },
192
- button: {},
193
- svgContainerStyle: {},
194
126
  });
@@ -1,13 +1,12 @@
1
1
  import React from 'react';
2
2
  import { Pressable, StyleSheet, Text, View } from 'react-native';
3
- import { Mic, MicOff, Video, VideoSlash } from '../../icons';
3
+ import { MicOff } from '../../icons';
4
4
  import {
5
5
  useCall,
6
6
  useCallStateHooks,
7
7
  useConnectedUser,
8
8
  useI18n,
9
9
  } from '@stream-io/video-react-bindings';
10
- import { CallControlsButton } from '../utility/internal/CallControlsButton';
11
10
  import { theme } from '../../theme';
12
11
  import { useLocalVideoStream } from '../../hooks';
13
12
  import { VideoRenderer } from '../utility/internal/VideoRenderer';
@@ -15,6 +14,8 @@ import { Avatar } from '../utility/Avatar';
15
14
  import { StreamVideoParticipant } from '@stream-io/video-client';
16
15
  import { LOCAL_VIDEO_VIEW_STYLE } from '../../constants';
17
16
  import { useMediaStreamManagement } from '../../providers/MediaStreamManagement';
17
+ import { ToggleAudioPreviewButton } from './CallControls/ToggleAudioPreviewButton';
18
+ import { ToggleVideoPreviewButton } from './CallControls/ToggleVideoPreviewButton';
18
19
 
19
20
  /**
20
21
  * Use this view prior to joining a call.
@@ -44,13 +45,8 @@ type LobbyProps = {
44
45
  export const Lobby = ({ joinCallButton }: LobbyProps) => {
45
46
  const localVideoStream = useLocalVideoStream();
46
47
  const connectedUser = useConnectedUser();
47
- const {
48
- initialAudioEnabled,
49
- initialVideoEnabled,
50
- toggleInitialAudioMuteState,
51
- toggleInitialVideoMuteState,
52
- isCameraOnFrontFacingMode,
53
- } = useMediaStreamManagement();
48
+ const { initialVideoEnabled, isCameraOnFrontFacingMode } =
49
+ useMediaStreamManagement();
54
50
  const isVideoAvailable = !!localVideoStream && initialVideoEnabled;
55
51
  const call = useCall();
56
52
  const { useCallMetadata } = useCallStateHooks();
@@ -58,27 +54,12 @@ export const Lobby = ({ joinCallButton }: LobbyProps) => {
58
54
  const { t } = useI18n();
59
55
  const participantsCount = callMetadata?.session?.participants.length;
60
56
 
61
- const MicIcon = !initialAudioEnabled ? (
62
- <MicOff color={theme.light.static_white} />
63
- ) : (
64
- <Mic color={theme.light.static_black} />
65
- );
66
- const VideoIcon = !initialVideoEnabled ? (
67
- <VideoSlash color={theme.light.static_white} />
68
- ) : (
69
- <Video color={theme.light.static_black} />
70
- );
71
-
72
57
  const connectedUserAsParticipant = {
73
58
  userId: connectedUser?.id,
74
59
  image: connectedUser?.image,
75
60
  name: connectedUser?.name,
76
61
  } as StreamVideoParticipant;
77
62
 
78
- const muteStatusColor = (muted: boolean) => {
79
- return muted ? theme.light.static_black : theme.light.static_white;
80
- };
81
-
82
63
  return (
83
64
  <View style={styles.container}>
84
65
  <View style={styles.content}>
@@ -103,32 +84,8 @@ export const Lobby = ({ joinCallButton }: LobbyProps) => {
103
84
  <ParticipantStatus />
104
85
  </View>
105
86
  <View style={styles.buttonGroup}>
106
- <CallControlsButton
107
- onPress={toggleInitialAudioMuteState}
108
- color={muteStatusColor(!initialAudioEnabled)}
109
- style={[
110
- styles.button,
111
- theme.button.md,
112
- {
113
- shadowColor: muteStatusColor(!initialAudioEnabled),
114
- },
115
- ]}
116
- >
117
- {MicIcon}
118
- </CallControlsButton>
119
- <CallControlsButton
120
- onPress={toggleInitialVideoMuteState}
121
- color={muteStatusColor(!initialVideoEnabled)}
122
- style={[
123
- styles.button,
124
- theme.button.md,
125
- {
126
- shadowColor: muteStatusColor(!initialVideoEnabled),
127
- },
128
- ]}
129
- >
130
- {VideoIcon}
131
- </CallControlsButton>
87
+ <ToggleAudioPreviewButton />
88
+ <ToggleVideoPreviewButton />
132
89
  </View>
133
90
  </>
134
91
  )}
@@ -182,17 +139,18 @@ const styles = StyleSheet.create({
182
139
  justifyContent: 'center',
183
140
  },
184
141
  content: {
185
- alignItems: 'center',
186
142
  paddingHorizontal: theme.padding.md,
187
143
  },
188
144
  heading: {
189
145
  color: theme.light.static_white,
190
146
  ...theme.fonts.heading4,
147
+ textAlign: 'center',
191
148
  },
192
149
  subHeading: {
193
150
  color: theme.light.text_low_emphasis,
194
151
  ...theme.fonts.subtitle,
195
152
  marginBottom: theme.margin.sm,
153
+ textAlign: 'center',
196
154
  },
197
155
  videoView: {
198
156
  backgroundColor: theme.light.disabled,
@@ -208,12 +166,9 @@ const styles = StyleSheet.create({
208
166
  topView: {},
209
167
  buttonGroup: {
210
168
  flexDirection: 'row',
211
- justifyContent: 'center',
169
+ justifyContent: 'space-evenly',
212
170
  marginBottom: theme.margin.md,
213
171
  },
214
- button: {
215
- marginHorizontal: theme.margin.sm,
216
- },
217
172
  info: {
218
173
  backgroundColor: theme.light.static_overlay,
219
174
  padding: theme.padding.md,
@@ -1,8 +1,6 @@
1
1
  import React from 'react';
2
2
  import { StyleSheet, Text, View } from 'react-native';
3
3
  import { UserInfo } from './internal/UserInfo';
4
- import { CallControlsButton } from '../utility/internal/CallControlsButton';
5
- import { Mic, MicOff, Video, VideoSlash } from '../../icons';
6
4
  import { VideoRenderer } from '../utility/internal/VideoRenderer';
7
5
  import { useLocalVideoStream } from '../../hooks/useLocalVideoStream';
8
6
  import { theme } from '../../theme';
@@ -11,8 +9,10 @@ import { useMediaStreamManagement } from '../../providers/MediaStreamManagement'
11
9
  import {
12
10
  HangUpCallButton,
13
11
  HangUpCallButtonProps,
14
- } from '../utility/internal/HangupCallButton';
12
+ } from './CallControls/HangupCallButton';
15
13
  import { useI18n } from '@stream-io/video-react-bindings';
14
+ import { ToggleAudioPreviewButton } from './CallControls/ToggleAudioPreviewButton';
15
+ import { ToggleVideoPreviewButton } from './CallControls/ToggleVideoPreviewButton';
16
16
 
17
17
  /**
18
18
  * Props for the OutgoingCall Component.
@@ -29,16 +29,7 @@ export type OutgoingCallProps = {
29
29
  * Used after the user has initiated a call.
30
30
  */
31
31
  export const OutgoingCall = ({ hangupCallButton }: OutgoingCallProps) => {
32
- const {
33
- initialAudioEnabled,
34
- initialVideoEnabled,
35
- toggleInitialAudioMuteState,
36
- toggleInitialVideoMuteState,
37
- } = useMediaStreamManagement();
38
32
  const { t } = useI18n();
39
- const muteStatusColor = (status: boolean) => {
40
- return status ? theme.light.overlay_dark : theme.light.static_white;
41
- };
42
33
 
43
34
  return (
44
35
  <>
@@ -49,30 +40,8 @@ export const OutgoingCall = ({ hangupCallButton }: OutgoingCallProps) => {
49
40
  </View>
50
41
  <View style={styles.buttonGroup}>
51
42
  <View style={styles.deviceControlButtons}>
52
- <CallControlsButton
53
- onPress={toggleInitialAudioMuteState}
54
- color={muteStatusColor(!initialAudioEnabled)}
55
- style={[styles.button, theme.button.lg]}
56
- svgContainerStyle={[styles.svgContainerStyle, theme.icon.lg]}
57
- >
58
- {!initialAudioEnabled ? (
59
- <MicOff color={theme.light.static_white} />
60
- ) : (
61
- <Mic color={theme.light.static_black} />
62
- )}
63
- </CallControlsButton>
64
- <CallControlsButton
65
- onPress={toggleInitialVideoMuteState}
66
- color={muteStatusColor(!initialVideoEnabled)}
67
- style={[styles.button, theme.button.lg]}
68
- svgContainerStyle={[styles.svgContainerStyle, theme.icon.lg]}
69
- >
70
- {!initialVideoEnabled ? (
71
- <VideoSlash color={theme.light.static_white} />
72
- ) : (
73
- <Video color={theme.light.static_black} />
74
- )}
75
- </CallControlsButton>
43
+ <ToggleAudioPreviewButton />
44
+ <ToggleVideoPreviewButton />
76
45
  </View>
77
46
  <HangUpCallButton
78
47
  onPressHandler={hangupCallButton?.onPressHandler}
@@ -131,6 +100,4 @@ const styles = StyleSheet.create({
131
100
  cancelCallButton: {
132
101
  alignSelf: 'center',
133
102
  },
134
- button: {},
135
- svgContainerStyle: {},
136
103
  });