@stream-io/video-react-native-sdk 0.1.9 → 0.1.11

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 (230) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +5 -4
  3. package/dist/commonjs/components/Call/CallContent/CallContent.js +1 -1
  4. package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
  5. package/dist/commonjs/components/Livestream/HostLivestream/HostLivestream.js +71 -0
  6. package/dist/commonjs/components/Livestream/HostLivestream/HostLivestream.js.map +1 -0
  7. package/dist/commonjs/components/Livestream/HostLivestream/index.js +17 -0
  8. package/dist/commonjs/components/Livestream/HostLivestream/index.js.map +1 -0
  9. package/dist/commonjs/components/Livestream/LivestreamControls/HostLivestreamControls.js +69 -0
  10. package/dist/commonjs/components/Livestream/LivestreamControls/HostLivestreamControls.js.map +1 -0
  11. package/dist/commonjs/components/Livestream/LivestreamControls/HostStartStreamButton.js +113 -0
  12. package/dist/commonjs/components/Livestream/LivestreamControls/HostStartStreamButton.js.map +1 -0
  13. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js +70 -0
  14. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js.map +1 -0
  15. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamMediaControls.js +38 -0
  16. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamMediaControls.js.map +1 -0
  17. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js +70 -0
  18. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js.map +1 -0
  19. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js +83 -0
  20. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js.map +1 -0
  21. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLivestreamControls.js +64 -0
  22. package/dist/commonjs/components/Livestream/LivestreamControls/ViewerLivestreamControls.js.map +1 -0
  23. package/dist/commonjs/components/Livestream/LivestreamControls/index.js +61 -0
  24. package/dist/commonjs/components/Livestream/LivestreamControls/index.js.map +1 -0
  25. package/dist/commonjs/components/Livestream/LivestreamLayout/LivestreamLayout.js +65 -0
  26. package/dist/commonjs/components/Livestream/LivestreamLayout/LivestreamLayout.js.map +1 -0
  27. package/dist/commonjs/components/Livestream/LivestreamLayout/index.js +17 -0
  28. package/dist/commonjs/components/Livestream/LivestreamLayout/index.js.map +1 -0
  29. package/dist/commonjs/components/Livestream/LivestreamTopView/DurationBadge.js +144 -0
  30. package/dist/commonjs/components/Livestream/LivestreamTopView/DurationBadge.js.map +1 -0
  31. package/dist/commonjs/components/Livestream/LivestreamTopView/FollowerCount.js +71 -0
  32. package/dist/commonjs/components/Livestream/LivestreamTopView/FollowerCount.js.map +1 -0
  33. package/dist/commonjs/components/Livestream/LivestreamTopView/HostLivestreamTopView.js +87 -0
  34. package/dist/commonjs/components/Livestream/LivestreamTopView/HostLivestreamTopView.js.map +1 -0
  35. package/dist/commonjs/components/Livestream/LivestreamTopView/LiveIndicator.js +55 -0
  36. package/dist/commonjs/components/Livestream/LivestreamTopView/LiveIndicator.js.map +1 -0
  37. package/dist/commonjs/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js +80 -0
  38. package/dist/commonjs/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js.map +1 -0
  39. package/dist/commonjs/components/Livestream/LivestreamTopView/index.js +50 -0
  40. package/dist/commonjs/components/Livestream/LivestreamTopView/index.js.map +1 -0
  41. package/dist/commonjs/components/Livestream/ViewerLivestream/ViewerLivestream.js +88 -0
  42. package/dist/commonjs/components/Livestream/ViewerLivestream/ViewerLivestream.js.map +1 -0
  43. package/dist/commonjs/components/Livestream/ViewerLivestream/index.js +17 -0
  44. package/dist/commonjs/components/Livestream/ViewerLivestream/index.js.map +1 -0
  45. package/dist/commonjs/components/Livestream/index.js +61 -0
  46. package/dist/commonjs/components/Livestream/index.js.map +1 -0
  47. package/dist/commonjs/components/index.js +11 -0
  48. package/dist/commonjs/components/index.js.map +1 -1
  49. package/dist/commonjs/hooks/usePaginatedLayoutSortPreset.js +26 -0
  50. package/dist/commonjs/hooks/usePaginatedLayoutSortPreset.js.map +1 -0
  51. package/dist/commonjs/icons/EndStreamIcon.js +20 -0
  52. package/dist/commonjs/icons/EndStreamIcon.js.map +1 -0
  53. package/dist/commonjs/icons/Eye.js +20 -0
  54. package/dist/commonjs/icons/Eye.js.map +1 -0
  55. package/dist/commonjs/icons/LeaveStreamIcon.js +20 -0
  56. package/dist/commonjs/icons/LeaveStreamIcon.js.map +1 -0
  57. package/dist/commonjs/icons/ShieldBadge.js +20 -0
  58. package/dist/commonjs/icons/ShieldBadge.js.map +1 -0
  59. package/dist/commonjs/icons/StartStreamIcon.js +20 -0
  60. package/dist/commonjs/icons/StartStreamIcon.js.map +1 -0
  61. package/dist/commonjs/icons/index.js +55 -0
  62. package/dist/commonjs/icons/index.js.map +1 -1
  63. package/dist/commonjs/theme/theme.js +70 -0
  64. package/dist/commonjs/theme/theme.js.map +1 -1
  65. package/dist/commonjs/translations/en.json +6 -1
  66. package/dist/commonjs/version.js +1 -1
  67. package/dist/commonjs/version.js.map +1 -1
  68. package/dist/module/components/Call/CallContent/CallContent.js +1 -1
  69. package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
  70. package/dist/module/components/Livestream/HostLivestream/HostLivestream.js +64 -0
  71. package/dist/module/components/Livestream/HostLivestream/HostLivestream.js.map +1 -0
  72. package/dist/module/components/Livestream/HostLivestream/index.js +2 -0
  73. package/dist/module/components/Livestream/HostLivestream/index.js.map +1 -0
  74. package/dist/module/components/Livestream/LivestreamControls/HostLivestreamControls.js +62 -0
  75. package/dist/module/components/Livestream/LivestreamControls/HostLivestreamControls.js.map +1 -0
  76. package/dist/module/components/Livestream/LivestreamControls/HostStartStreamButton.js +105 -0
  77. package/dist/module/components/Livestream/LivestreamControls/HostStartStreamButton.js.map +1 -0
  78. package/dist/module/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js +63 -0
  79. package/dist/module/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js.map +1 -0
  80. package/dist/module/components/Livestream/LivestreamControls/LivestreamMediaControls.js +31 -0
  81. package/dist/module/components/Livestream/LivestreamControls/LivestreamMediaControls.js.map +1 -0
  82. package/dist/module/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js +63 -0
  83. package/dist/module/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js.map +1 -0
  84. package/dist/module/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js +75 -0
  85. package/dist/module/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.js.map +1 -0
  86. package/dist/module/components/Livestream/LivestreamControls/ViewerLivestreamControls.js +57 -0
  87. package/dist/module/components/Livestream/LivestreamControls/ViewerLivestreamControls.js.map +1 -0
  88. package/dist/module/components/Livestream/LivestreamControls/index.js +6 -0
  89. package/dist/module/components/Livestream/LivestreamControls/index.js.map +1 -0
  90. package/dist/module/components/Livestream/LivestreamLayout/LivestreamLayout.js +58 -0
  91. package/dist/module/components/Livestream/LivestreamLayout/LivestreamLayout.js.map +1 -0
  92. package/dist/module/components/Livestream/LivestreamLayout/index.js +2 -0
  93. package/dist/module/components/Livestream/LivestreamLayout/index.js.map +1 -0
  94. package/dist/module/components/Livestream/LivestreamTopView/DurationBadge.js +136 -0
  95. package/dist/module/components/Livestream/LivestreamTopView/DurationBadge.js.map +1 -0
  96. package/dist/module/components/Livestream/LivestreamTopView/FollowerCount.js +64 -0
  97. package/dist/module/components/Livestream/LivestreamTopView/FollowerCount.js.map +1 -0
  98. package/dist/module/components/Livestream/LivestreamTopView/HostLivestreamTopView.js +80 -0
  99. package/dist/module/components/Livestream/LivestreamTopView/HostLivestreamTopView.js.map +1 -0
  100. package/dist/module/components/Livestream/LivestreamTopView/LiveIndicator.js +48 -0
  101. package/dist/module/components/Livestream/LivestreamTopView/LiveIndicator.js.map +1 -0
  102. package/dist/module/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js +73 -0
  103. package/dist/module/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.js.map +1 -0
  104. package/dist/module/components/Livestream/LivestreamTopView/index.js +5 -0
  105. package/dist/module/components/Livestream/LivestreamTopView/index.js.map +1 -0
  106. package/dist/module/components/Livestream/ViewerLivestream/ViewerLivestream.js +81 -0
  107. package/dist/module/components/Livestream/ViewerLivestream/ViewerLivestream.js.map +1 -0
  108. package/dist/module/components/Livestream/ViewerLivestream/index.js +2 -0
  109. package/dist/module/components/Livestream/ViewerLivestream/index.js.map +1 -0
  110. package/dist/module/components/Livestream/index.js +6 -0
  111. package/dist/module/components/Livestream/index.js.map +1 -0
  112. package/dist/module/components/index.js +1 -0
  113. package/dist/module/components/index.js.map +1 -1
  114. package/dist/module/hooks/usePaginatedLayoutSortPreset.js +19 -0
  115. package/dist/module/hooks/usePaginatedLayoutSortPreset.js.map +1 -0
  116. package/dist/module/icons/EndStreamIcon.js +12 -0
  117. package/dist/module/icons/EndStreamIcon.js.map +1 -0
  118. package/dist/module/icons/Eye.js +12 -0
  119. package/dist/module/icons/Eye.js.map +1 -0
  120. package/dist/module/icons/LeaveStreamIcon.js +12 -0
  121. package/dist/module/icons/LeaveStreamIcon.js.map +1 -0
  122. package/dist/module/icons/ShieldBadge.js +12 -0
  123. package/dist/module/icons/ShieldBadge.js.map +1 -0
  124. package/dist/module/icons/StartStreamIcon.js +12 -0
  125. package/dist/module/icons/StartStreamIcon.js.map +1 -0
  126. package/dist/module/icons/index.js +5 -0
  127. package/dist/module/icons/index.js.map +1 -1
  128. package/dist/module/theme/theme.js +70 -0
  129. package/dist/module/theme/theme.js.map +1 -1
  130. package/dist/module/translations/en.json +6 -1
  131. package/dist/module/version.js +1 -1
  132. package/dist/module/version.js.map +1 -1
  133. package/dist/typescript/components/Livestream/HostLivestream/HostLivestream.d.ts +30 -0
  134. package/dist/typescript/components/Livestream/HostLivestream/HostLivestream.d.ts.map +1 -0
  135. package/dist/typescript/components/Livestream/HostLivestream/index.d.ts +2 -0
  136. package/dist/typescript/components/Livestream/HostLivestream/index.d.ts.map +1 -0
  137. package/dist/typescript/components/Livestream/LivestreamControls/HostLivestreamControls.d.ts +25 -0
  138. package/dist/typescript/components/Livestream/LivestreamControls/HostLivestreamControls.d.ts.map +1 -0
  139. package/dist/typescript/components/Livestream/LivestreamControls/HostStartStreamButton.d.ts +25 -0
  140. package/dist/typescript/components/Livestream/LivestreamControls/HostStartStreamButton.d.ts.map +1 -0
  141. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamAudioControlButton.d.ts +6 -0
  142. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamAudioControlButton.d.ts.map +1 -0
  143. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamMediaControls.d.ts +10 -0
  144. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamMediaControls.d.ts.map +1 -0
  145. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamVideoControlButton.d.ts +6 -0
  146. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamVideoControlButton.d.ts.map +1 -0
  147. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.d.ts +16 -0
  148. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.d.ts.map +1 -0
  149. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLivestreamControls.d.ts +16 -0
  150. package/dist/typescript/components/Livestream/LivestreamControls/ViewerLivestreamControls.d.ts.map +1 -0
  151. package/dist/typescript/components/Livestream/LivestreamControls/index.d.ts +6 -0
  152. package/dist/typescript/components/Livestream/LivestreamControls/index.d.ts.map +1 -0
  153. package/dist/typescript/components/Livestream/LivestreamLayout/LivestreamLayout.d.ts +17 -0
  154. package/dist/typescript/components/Livestream/LivestreamLayout/LivestreamLayout.d.ts.map +1 -0
  155. package/dist/typescript/components/Livestream/LivestreamLayout/index.d.ts +2 -0
  156. package/dist/typescript/components/Livestream/LivestreamLayout/index.d.ts.map +1 -0
  157. package/dist/typescript/components/Livestream/LivestreamTopView/DurationBadge.d.ts +12 -0
  158. package/dist/typescript/components/Livestream/LivestreamTopView/DurationBadge.d.ts.map +1 -0
  159. package/dist/typescript/components/Livestream/LivestreamTopView/FollowerCount.d.ts +10 -0
  160. package/dist/typescript/components/Livestream/LivestreamTopView/FollowerCount.d.ts.map +1 -0
  161. package/dist/typescript/components/Livestream/LivestreamTopView/HostLivestreamTopView.d.ts +26 -0
  162. package/dist/typescript/components/Livestream/LivestreamTopView/HostLivestreamTopView.d.ts.map +1 -0
  163. package/dist/typescript/components/Livestream/LivestreamTopView/LiveIndicator.d.ts +10 -0
  164. package/dist/typescript/components/Livestream/LivestreamTopView/LiveIndicator.d.ts.map +1 -0
  165. package/dist/typescript/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.d.ts +26 -0
  166. package/dist/typescript/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.d.ts.map +1 -0
  167. package/dist/typescript/components/Livestream/LivestreamTopView/index.d.ts +5 -0
  168. package/dist/typescript/components/Livestream/LivestreamTopView/index.d.ts.map +1 -0
  169. package/dist/typescript/components/Livestream/ViewerLivestream/ViewerLivestream.d.ts +32 -0
  170. package/dist/typescript/components/Livestream/ViewerLivestream/ViewerLivestream.d.ts.map +1 -0
  171. package/dist/typescript/components/Livestream/ViewerLivestream/index.d.ts +2 -0
  172. package/dist/typescript/components/Livestream/ViewerLivestream/index.d.ts.map +1 -0
  173. package/dist/typescript/components/Livestream/index.d.ts +6 -0
  174. package/dist/typescript/components/Livestream/index.d.ts.map +1 -0
  175. package/dist/typescript/components/index.d.ts +1 -0
  176. package/dist/typescript/components/index.d.ts.map +1 -1
  177. package/dist/typescript/hooks/usePaginatedLayoutSortPreset.d.ts +3 -0
  178. package/dist/typescript/hooks/usePaginatedLayoutSortPreset.d.ts.map +1 -0
  179. package/dist/typescript/icons/EndStreamIcon.d.ts +3 -0
  180. package/dist/typescript/icons/EndStreamIcon.d.ts.map +1 -0
  181. package/dist/typescript/icons/Eye.d.ts +3 -0
  182. package/dist/typescript/icons/Eye.d.ts.map +1 -0
  183. package/dist/typescript/icons/LeaveStreamIcon.d.ts +3 -0
  184. package/dist/typescript/icons/LeaveStreamIcon.d.ts.map +1 -0
  185. package/dist/typescript/icons/ShieldBadge.d.ts +3 -0
  186. package/dist/typescript/icons/ShieldBadge.d.ts.map +1 -0
  187. package/dist/typescript/icons/StartStreamIcon.d.ts +3 -0
  188. package/dist/typescript/icons/StartStreamIcon.d.ts.map +1 -0
  189. package/dist/typescript/icons/index.d.ts +5 -0
  190. package/dist/typescript/icons/index.d.ts.map +1 -1
  191. package/dist/typescript/theme/theme.d.ts +70 -0
  192. package/dist/typescript/theme/theme.d.ts.map +1 -1
  193. package/dist/typescript/translations/index.d.ts +6 -1
  194. package/dist/typescript/translations/index.d.ts.map +1 -1
  195. package/dist/typescript/version.d.ts +1 -1
  196. package/dist/typescript/version.d.ts.map +1 -1
  197. package/package.json +3 -3
  198. package/src/components/Call/CallContent/CallContent.tsx +1 -1
  199. package/src/components/Livestream/HostLivestream/HostLivestream.tsx +99 -0
  200. package/src/components/Livestream/HostLivestream/index.ts +1 -0
  201. package/src/components/Livestream/LivestreamControls/HostLivestreamControls.tsx +87 -0
  202. package/src/components/Livestream/LivestreamControls/HostStartStreamButton.tsx +163 -0
  203. package/src/components/Livestream/LivestreamControls/LivestreamAudioControlButton.tsx +78 -0
  204. package/src/components/Livestream/LivestreamControls/LivestreamMediaControls.tsx +32 -0
  205. package/src/components/Livestream/LivestreamControls/LivestreamVideoControlButton.tsx +78 -0
  206. package/src/components/Livestream/LivestreamControls/ViewerLeaveStreamButton.tsx +102 -0
  207. package/src/components/Livestream/LivestreamControls/ViewerLivestreamControls.tsx +75 -0
  208. package/src/components/Livestream/LivestreamControls/index.ts +5 -0
  209. package/src/components/Livestream/LivestreamLayout/LivestreamLayout.tsx +77 -0
  210. package/src/components/Livestream/LivestreamLayout/index.ts +1 -0
  211. package/src/components/Livestream/LivestreamTopView/DurationBadge.tsx +170 -0
  212. package/src/components/Livestream/LivestreamTopView/FollowerCount.tsx +74 -0
  213. package/src/components/Livestream/LivestreamTopView/HostLivestreamTopView.tsx +105 -0
  214. package/src/components/Livestream/LivestreamTopView/LiveIndicator.tsx +53 -0
  215. package/src/components/Livestream/LivestreamTopView/ViewerLivestreamTopView.tsx +102 -0
  216. package/src/components/Livestream/LivestreamTopView/index.ts +4 -0
  217. package/src/components/Livestream/ViewerLivestream/ViewerLivestream.tsx +126 -0
  218. package/src/components/Livestream/ViewerLivestream/index.ts +1 -0
  219. package/src/components/Livestream/index.ts +5 -0
  220. package/src/components/index.ts +1 -0
  221. package/src/hooks/usePaginatedLayoutSortPreset.ts +27 -0
  222. package/src/icons/EndStreamIcon.tsx +13 -0
  223. package/src/icons/Eye.tsx +13 -0
  224. package/src/icons/LeaveStreamIcon.tsx +13 -0
  225. package/src/icons/ShieldBadge.tsx +13 -0
  226. package/src/icons/StartStreamIcon.tsx +13 -0
  227. package/src/icons/index.tsx +5 -0
  228. package/src/theme/theme.ts +140 -0
  229. package/src/translations/en.json +6 -1
  230. package/src/version.ts +1 -1
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+
4
+ import {
5
+ ViewerLeaveStreamButton as DefaultViewerLeaveStreamButton,
6
+ ViewerLeaveStreamButtonProps,
7
+ } from './ViewerLeaveStreamButton';
8
+ import { useTheme } from '../../../contexts';
9
+ import { Z_INDEX } from '../../../constants';
10
+
11
+ /**
12
+ * Props for the ViewerLivestreamControls component.
13
+ */
14
+ export type ViewerLivestreamControlsProps = ViewerLeaveStreamButtonProps & {
15
+ /**
16
+ * Component to customize the leave stream button on the viewer's end live stream.
17
+ */
18
+ ViewerLeaveStreamButton?: React.ComponentType<ViewerLeaveStreamButtonProps> | null;
19
+ };
20
+
21
+ /**
22
+ * The ViewerLivestreamControls component displays the call controls for the live stream at viewer's end.
23
+ */
24
+ export const ViewerLivestreamControls = ({
25
+ ViewerLeaveStreamButton = DefaultViewerLeaveStreamButton,
26
+ onLeaveStreamHandler,
27
+ }: ViewerLivestreamControlsProps) => {
28
+ const {
29
+ theme: { colors, viewerLivestreamControls },
30
+ } = useTheme();
31
+
32
+ return (
33
+ <View
34
+ style={[
35
+ styles.container,
36
+ {
37
+ backgroundColor: colors.static_overlay,
38
+ },
39
+ viewerLivestreamControls.container,
40
+ ]}
41
+ >
42
+ <View style={[styles.leftElement, viewerLivestreamControls.leftElement]}>
43
+ {ViewerLeaveStreamButton && (
44
+ <ViewerLeaveStreamButton
45
+ onLeaveStreamHandler={onLeaveStreamHandler}
46
+ />
47
+ )}
48
+ </View>
49
+ <View
50
+ style={[styles.rightElement, viewerLivestreamControls.rightElement]}
51
+ />
52
+ </View>
53
+ );
54
+ };
55
+
56
+ const styles = StyleSheet.create({
57
+ container: {
58
+ position: 'absolute',
59
+ bottom: 0,
60
+ flexDirection: 'row',
61
+ alignItems: 'center',
62
+ paddingVertical: 16,
63
+ paddingHorizontal: 8,
64
+ zIndex: Z_INDEX.IN_FRONT,
65
+ },
66
+ content: {},
67
+ leftElement: {
68
+ flex: 1,
69
+ alignItems: 'flex-start',
70
+ },
71
+ rightElement: {
72
+ flex: 1,
73
+ alignItems: 'flex-end',
74
+ },
75
+ });
@@ -0,0 +1,5 @@
1
+ export * from './HostLivestreamControls';
2
+ export * from './LivestreamMediaControls';
3
+ export * from './HostStartStreamButton';
4
+ export * from './LivestreamAudioControlButton';
5
+ export * from './LivestreamVideoControlButton';
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { SfuModels, StreamVideoParticipant } from '@stream-io/video-client';
3
+ import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
4
+ import { StyleSheet, View, ViewStyle } from 'react-native';
5
+ import { usePaginatedLayoutSortPreset } from '../../../hooks/usePaginatedLayoutSortPreset';
6
+ import { useTheme } from '../../../contexts';
7
+ import {
8
+ VideoRenderer as DefaultVideoRenderer,
9
+ VideoRendererProps,
10
+ } from '../../Participant';
11
+
12
+ /**
13
+ * Props for the LivestreamLayout component.
14
+ */
15
+ export type LivestreamLayoutProps = {
16
+ /*
17
+ * Check if device is in landscape mode.
18
+ * This will apply the landscape mode styles to the component.
19
+ */
20
+ landscape?: boolean;
21
+ /**
22
+ * Component to customize the video component of the participant.
23
+ */
24
+ VideoRenderer?: React.ComponentType<VideoRendererProps> | null;
25
+ };
26
+
27
+ const hasScreenShare = (p?: StreamVideoParticipant) =>
28
+ p?.publishedTracks.includes(SfuModels.TrackType.SCREEN_SHARE);
29
+
30
+ /**
31
+ * The LivestreamLayout component presents the live stream video layout.
32
+ */
33
+ export const LivestreamLayout = ({
34
+ landscape,
35
+ VideoRenderer = DefaultVideoRenderer,
36
+ }: LivestreamLayoutProps) => {
37
+ const { useParticipants, useHasOngoingScreenShare } = useCallStateHooks();
38
+ const call = useCall();
39
+ const {
40
+ theme: { colors, livestreamLayout },
41
+ } = useTheme();
42
+ const [currentSpeaker, ...otherParticipants] = useParticipants();
43
+ const hasOngoingScreenShare = useHasOngoingScreenShare();
44
+ const presenter = hasOngoingScreenShare
45
+ ? hasScreenShare(currentSpeaker) && currentSpeaker
46
+ : otherParticipants.find(hasScreenShare);
47
+
48
+ usePaginatedLayoutSortPreset(call);
49
+
50
+ const landScapeStyles: ViewStyle = {
51
+ flexDirection: landscape ? 'row' : 'column',
52
+ };
53
+
54
+ return (
55
+ <View
56
+ style={[
57
+ styles.container,
58
+ landScapeStyles,
59
+ { backgroundColor: colors.dark_gray },
60
+ livestreamLayout.container,
61
+ ]}
62
+ >
63
+ {VideoRenderer && hasOngoingScreenShare && presenter && (
64
+ <VideoRenderer trackType="screenShareTrack" participant={presenter} />
65
+ )}
66
+ {VideoRenderer && !hasOngoingScreenShare && currentSpeaker && (
67
+ <VideoRenderer participant={currentSpeaker} trackType="videoTrack" />
68
+ )}
69
+ </View>
70
+ );
71
+ };
72
+
73
+ const styles = StyleSheet.create({
74
+ container: {
75
+ flex: 1,
76
+ },
77
+ });
@@ -0,0 +1 @@
1
+ export * from './LivestreamLayout';
@@ -0,0 +1,170 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { StyleSheet, Text, View } from 'react-native';
3
+ import { useTheme } from '../../../contexts';
4
+ import { ShieldBadge } from '../../../icons';
5
+ import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
6
+ import { CallSessionResponse, StreamCallEvent } from '@stream-io/video-client';
7
+
8
+ /**
9
+ * Props for the HostDurationBadge component.
10
+ */
11
+ export type DurationBadgeProps = {
12
+ mode?: 'host' | 'viewer';
13
+ };
14
+
15
+ /**
16
+ * The HostDurationBadge component displays the duration while the live stream is active.
17
+ */
18
+ export const DurationBadge = ({ mode }: DurationBadgeProps) => {
19
+ const { useCallSession } = useCallStateHooks();
20
+ const session = useCallSession();
21
+
22
+ const [duration, setDuration] = useState(() => {
23
+ if (!session || !session.live_started_at) {
24
+ return 0;
25
+ }
26
+ const liveStartTime = new Date(session.live_started_at);
27
+ const now = new Date();
28
+ return Math.floor((now.getTime() - liveStartTime.getTime()) / 1000);
29
+ });
30
+
31
+ const call = useCall();
32
+ const {
33
+ theme: {
34
+ colors,
35
+ variants: { iconSizes },
36
+ durationBadge,
37
+ },
38
+ } = useTheme();
39
+
40
+ // for host
41
+ useEffect(() => {
42
+ if (mode !== 'host') {
43
+ return;
44
+ }
45
+ let intervalId: NodeJS.Timer;
46
+
47
+ const handleLiveStarted = () => {
48
+ intervalId = setInterval(() => {
49
+ setDuration((d) => d + 1);
50
+ }, 1000);
51
+ };
52
+
53
+ const handleLiveEnded = (event: StreamCallEvent) => {
54
+ const callDetails = (
55
+ event as StreamCallEvent & {
56
+ call: { session: CallSessionResponse };
57
+ }
58
+ ).call.session;
59
+ if (callDetails?.live_ended_at !== null) {
60
+ clearInterval(intervalId);
61
+ }
62
+ };
63
+
64
+ const callLiveStartedUnsubscribe = call?.on(
65
+ 'call.live_started',
66
+ handleLiveStarted,
67
+ );
68
+ const callUpdatedUnsubscribe = call?.on('call.updated', handleLiveEnded);
69
+
70
+ return () => {
71
+ if (mode !== 'host') {
72
+ return;
73
+ }
74
+ if (callLiveStartedUnsubscribe && callUpdatedUnsubscribe) {
75
+ callLiveStartedUnsubscribe();
76
+ callUpdatedUnsubscribe();
77
+ }
78
+ if (intervalId) {
79
+ clearInterval(intervalId);
80
+ }
81
+ };
82
+ }, [call, mode]);
83
+
84
+ // for viewer
85
+ useEffect(() => {
86
+ if (mode !== 'viewer') {
87
+ return;
88
+ }
89
+ let intervalId: NodeJS.Timer;
90
+ const handleLiveStarted = () => {
91
+ intervalId = setInterval(() => {
92
+ setDuration((d) => d + 1);
93
+ }, 1000);
94
+ };
95
+
96
+ handleLiveStarted();
97
+
98
+ return () => {
99
+ if (mode !== 'viewer') {
100
+ return;
101
+ }
102
+ if (intervalId) {
103
+ clearInterval(intervalId);
104
+ }
105
+ };
106
+ }, [mode]);
107
+
108
+ const formatDuration = (durationInMs: number) => {
109
+ const days = Math.floor(durationInMs / 86400);
110
+ const hours = Math.floor(durationInMs / 3600);
111
+ const minutes = Math.floor((durationInMs % 3600) / 60);
112
+ const seconds = durationInMs % 60;
113
+
114
+ return `${days ? days + ' ' : ''}${hours ? hours + ':' : ''}${
115
+ minutes < 10 ? '0' : ''
116
+ }${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
117
+ };
118
+
119
+ return (
120
+ <View
121
+ style={[
122
+ styles.container,
123
+ { backgroundColor: colors.dark_gray },
124
+ durationBadge.container,
125
+ ]}
126
+ >
127
+ <View
128
+ style={[
129
+ styles.icon,
130
+ {
131
+ height: iconSizes.xs,
132
+ width: iconSizes.xs,
133
+ },
134
+ durationBadge.icon,
135
+ ]}
136
+ >
137
+ <ShieldBadge />
138
+ </View>
139
+ <Text
140
+ style={[
141
+ styles.label,
142
+ { color: colors.static_white },
143
+ durationBadge.label,
144
+ ]}
145
+ >
146
+ {formatDuration(duration)}
147
+ </Text>
148
+ </View>
149
+ );
150
+ };
151
+
152
+ const styles = StyleSheet.create({
153
+ container: {
154
+ paddingHorizontal: 8,
155
+ paddingVertical: 4,
156
+ borderRadius: 4,
157
+ flexDirection: 'row',
158
+ alignItems: 'center',
159
+ justifyContent: 'center',
160
+ },
161
+ icon: {},
162
+ label: {
163
+ textAlign: 'center',
164
+ fontSize: 13,
165
+ fontWeight: '400',
166
+ flexShrink: 1,
167
+ includeFontPadding: false,
168
+ paddingLeft: 4,
169
+ },
170
+ });
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import { StyleSheet, Text, View } from 'react-native';
3
+ import { useTheme } from '../../../contexts';
4
+ import { useCallStateHooks } from '@stream-io/video-react-bindings';
5
+ import { Eye } from '../../../icons';
6
+
7
+ /**
8
+ * Props for the FollowerCount component.
9
+ */
10
+ export type FollowerCountProps = {};
11
+
12
+ /**
13
+ * The FollowerCount component that displays the number of participants while in the call.
14
+ */
15
+ export const FollowerCount = ({}: FollowerCountProps) => {
16
+ const {
17
+ theme: {
18
+ colors,
19
+ variants: { iconSizes },
20
+ followerCount,
21
+ },
22
+ } = useTheme();
23
+ const { useParticipantCount } = useCallStateHooks();
24
+ const totalParticipants = useParticipantCount();
25
+ return (
26
+ <View
27
+ style={[
28
+ styles.container,
29
+ { backgroundColor: colors.dark_gray },
30
+ followerCount.container,
31
+ ]}
32
+ >
33
+ <View
34
+ style={[
35
+ styles.icon,
36
+ { height: iconSizes.xs, width: iconSizes.xs },
37
+ followerCount.icon,
38
+ ]}
39
+ >
40
+ <Eye />
41
+ </View>
42
+ <Text
43
+ style={[
44
+ styles.label,
45
+ { color: colors.static_white },
46
+ followerCount.label,
47
+ ]}
48
+ >
49
+ {totalParticipants}
50
+ </Text>
51
+ </View>
52
+ );
53
+ };
54
+
55
+ const styles = StyleSheet.create({
56
+ container: {
57
+ paddingHorizontal: 8,
58
+ paddingVertical: 4,
59
+ borderTopRightRadius: 4,
60
+ borderBottomRightRadius: 4,
61
+ flexDirection: 'row',
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ },
65
+ icon: {},
66
+ label: {
67
+ fontSize: 13,
68
+ fontWeight: '400',
69
+ flexShrink: 1,
70
+ textAlign: 'center',
71
+ includeFontPadding: false,
72
+ marginLeft: 4,
73
+ },
74
+ });
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import {
4
+ DurationBadge as DefaultDurationBadge,
5
+ DurationBadgeProps,
6
+ } from './DurationBadge';
7
+ import {
8
+ LiveIndicator as DefaultLiveIndicator,
9
+ LiveIndicatorProps,
10
+ } from './LiveIndicator';
11
+ import {
12
+ FollowerCount as DefaultFollowerCount,
13
+ FollowerCountProps,
14
+ } from './FollowerCount';
15
+ import { useTheme } from '../../../contexts';
16
+ import { useCallStateHooks } from '@stream-io/video-react-bindings';
17
+ import { Z_INDEX } from '../../../constants';
18
+
19
+ /**
20
+ * Props for the HostLivestreamTopView component.
21
+ */
22
+ export type HostLivestreamTopViewProps = {
23
+ /**
24
+ * Component to customize the Duration badge component on the host's live stream's top view.
25
+ */
26
+ DurationBadge?: React.ComponentType<DurationBadgeProps> | null;
27
+ /**
28
+ * Component to customize the Live indicator on the host's live stream's top view.
29
+ */
30
+ LiveIndicator?: React.ComponentType<LiveIndicatorProps> | null;
31
+ /**
32
+ * Component to customize the Follower count indicator on the host's live stream's top view.
33
+ */
34
+ FollowerCount?: React.ComponentType<FollowerCountProps> | null;
35
+ };
36
+
37
+ /**
38
+ * The HostLivestreamTopView component displays the top view component of the host's live stream.
39
+ */
40
+ export const HostLivestreamTopView = ({
41
+ DurationBadge = DefaultDurationBadge,
42
+ LiveIndicator = DefaultLiveIndicator,
43
+ FollowerCount = DefaultFollowerCount,
44
+ }: HostLivestreamTopViewProps) => {
45
+ const { useIsCallLive, useIsCallBroadcastingInProgress } =
46
+ useCallStateHooks();
47
+ const isCallLive = useIsCallLive();
48
+ const isBroadcasting = useIsCallBroadcastingInProgress();
49
+
50
+ const liveOrBroadcasting = isCallLive || isBroadcasting;
51
+ const {
52
+ theme: { colors, hostLivestreamTopView },
53
+ } = useTheme();
54
+ return (
55
+ <View
56
+ style={[
57
+ styles.container,
58
+ { backgroundColor: colors.static_overlay },
59
+ hostLivestreamTopView.container,
60
+ ]}
61
+ >
62
+ <View style={[styles.leftElement, hostLivestreamTopView.leftElement]}>
63
+ {DurationBadge && <DurationBadge mode="host" />}
64
+ </View>
65
+ <View
66
+ style={[styles.centerElement, hostLivestreamTopView.centerElement]}
67
+ />
68
+ <View style={[styles.rightElement, hostLivestreamTopView.rightElement]}>
69
+ <View style={[styles.liveInfo, hostLivestreamTopView.liveInfo]}>
70
+ {liveOrBroadcasting && LiveIndicator && <LiveIndicator />}
71
+ {FollowerCount && <FollowerCount />}
72
+ </View>
73
+ </View>
74
+ </View>
75
+ );
76
+ };
77
+
78
+ const styles = StyleSheet.create({
79
+ container: {
80
+ position: 'absolute',
81
+ top: 0,
82
+ flexDirection: 'row',
83
+ alignItems: 'center',
84
+ paddingVertical: 16,
85
+ paddingHorizontal: 8,
86
+ borderBottomEndRadius: 8,
87
+ borderBottomStartRadius: 8,
88
+ zIndex: Z_INDEX.IN_FRONT,
89
+ },
90
+ liveInfo: {
91
+ flexDirection: 'row',
92
+ },
93
+ leftElement: {
94
+ flex: 1,
95
+ alignItems: 'flex-start',
96
+ },
97
+ centerElement: {
98
+ flex: 1,
99
+ alignItems: 'center',
100
+ },
101
+ rightElement: {
102
+ flex: 1,
103
+ alignItems: 'flex-end',
104
+ },
105
+ });
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { StyleSheet, Text, View } from 'react-native';
3
+ import { useTheme } from '../../../contexts';
4
+ import { useI18n } from '@stream-io/video-react-bindings';
5
+
6
+ /**
7
+ * Props for the LiveIndicator component.
8
+ */
9
+ export type LiveIndicatorProps = {};
10
+
11
+ /**
12
+ * The LiveIndicator component displays whether the live stream is live or not.
13
+ */
14
+ export const LiveIndicator = ({}: LiveIndicatorProps) => {
15
+ const {
16
+ theme: { colors, typefaces, liveIndicator },
17
+ } = useTheme();
18
+ const { t } = useI18n();
19
+ return (
20
+ <View
21
+ style={[
22
+ styles.container,
23
+ { backgroundColor: colors.primary },
24
+ liveIndicator.container,
25
+ ]}
26
+ >
27
+ <Text
28
+ style={[
29
+ styles.label,
30
+ { color: colors.static_white },
31
+ typefaces.subtitleBold,
32
+ liveIndicator.label,
33
+ ]}
34
+ >
35
+ {t('Live')}
36
+ </Text>
37
+ </View>
38
+ );
39
+ };
40
+
41
+ const styles = StyleSheet.create({
42
+ container: {
43
+ paddingHorizontal: 8,
44
+ paddingVertical: 4,
45
+ borderTopLeftRadius: 4,
46
+ borderBottomLeftRadius: 4,
47
+ justifyContent: 'center',
48
+ },
49
+ label: {
50
+ textAlign: 'center',
51
+ includeFontPadding: false,
52
+ },
53
+ });
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import {
4
+ DurationBadge as DefaultDurationBadge,
5
+ DurationBadgeProps,
6
+ } from './DurationBadge';
7
+ import {
8
+ LiveIndicator as DefaultLiveIndicator,
9
+ LiveIndicatorProps,
10
+ } from './LiveIndicator';
11
+ import {
12
+ FollowerCount as DefaultFollowerCount,
13
+ FollowerCountProps,
14
+ } from './FollowerCount';
15
+ import { useTheme } from '../../../contexts';
16
+ import { Z_INDEX } from '../../../constants';
17
+
18
+ /**
19
+ * Props for the ViewerLivestreamTopView component.
20
+ */
21
+ export type ViewerLivestreamTopViewProps = {
22
+ /**
23
+ * Component to customize the Duration badge component on the viewer's live stream's top view.
24
+ */
25
+ DurationBadge?: React.ComponentType<DurationBadgeProps> | null;
26
+ /**
27
+ * Component to customize the Live indicator on the viewer's live stream's top view.
28
+ */
29
+ LiveIndicator?: React.ComponentType<LiveIndicatorProps> | null;
30
+ /**
31
+ * Component to customize the Follower count indicator on the viewer's live stream's top view.
32
+ */
33
+ FollowerCount?: React.ComponentType<FollowerCountProps> | null;
34
+ };
35
+
36
+ /**
37
+ * The ViewerLivestreamTopView component displays the top view component of the viewer's live stream.
38
+ */
39
+ export const ViewerLivestreamTopView = ({
40
+ DurationBadge = DefaultDurationBadge,
41
+ LiveIndicator = DefaultLiveIndicator,
42
+ FollowerCount = DefaultFollowerCount,
43
+ }: ViewerLivestreamTopViewProps) => {
44
+ const {
45
+ theme: { colors, viewerLivestreamTopView },
46
+ } = useTheme();
47
+
48
+ return (
49
+ <View
50
+ style={[
51
+ styles.container,
52
+ { backgroundColor: colors.static_overlay },
53
+ viewerLivestreamTopView.container,
54
+ ]}
55
+ >
56
+ <View style={[styles.leftElement, viewerLivestreamTopView.leftElement]}>
57
+ <View style={[styles.liveInfo, viewerLivestreamTopView.liveInfo]}>
58
+ {LiveIndicator && <LiveIndicator />}
59
+ {FollowerCount && <FollowerCount />}
60
+ </View>
61
+ </View>
62
+ <View
63
+ style={[styles.centerElement, viewerLivestreamTopView.centerElement]}
64
+ >
65
+ {DurationBadge && <DurationBadge mode="viewer" />}
66
+ </View>
67
+ <View
68
+ style={[styles.rightElement, viewerLivestreamTopView.rightElement]}
69
+ />
70
+ </View>
71
+ );
72
+ };
73
+
74
+ const styles = StyleSheet.create({
75
+ container: {
76
+ position: 'absolute',
77
+ top: 0,
78
+ flexDirection: 'row',
79
+ alignItems: 'center',
80
+ paddingVertical: 16,
81
+ paddingHorizontal: 8,
82
+ borderBottomEndRadius: 8,
83
+ borderBottomStartRadius: 8,
84
+ zIndex: Z_INDEX.IN_FRONT,
85
+ },
86
+ liveInfo: {
87
+ flexDirection: 'row',
88
+ },
89
+ leftElement: {
90
+ flex: 1,
91
+ alignItems: 'flex-start',
92
+ },
93
+ centerElement: {
94
+ flex: 1,
95
+ alignItems: 'center',
96
+ flexGrow: 3,
97
+ },
98
+ rightElement: {
99
+ flex: 1,
100
+ alignItems: 'flex-end',
101
+ },
102
+ });
@@ -0,0 +1,4 @@
1
+ export * from './DurationBadge';
2
+ export * from './FollowerCount';
3
+ export * from './LiveIndicator';
4
+ export * from './HostLivestreamTopView';