livevoice-sdk-react-native 1.0.3 → 2.0.1

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 (231) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +119 -7
  3. package/android/build.gradle +52 -84
  4. package/android/gradle.properties +10 -6
  5. package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +93 -126
  6. package/android/src/main/java/io/livevoice/react/LiveVoiceSdkReactNativePackage.kt +12 -13
  7. package/android/src/main/java/io/livevoice/react/__SDK.kt +16 -2
  8. package/ios/LiveVoiceSdkReactNative.h +5 -5
  9. package/ios/LiveVoiceSdkReactNative.mm +308 -0
  10. package/ios/__SDK.h +16 -2
  11. package/lib/module/components/AudioOutputSwitchView.js +13 -13
  12. package/lib/module/components/AudioOutputSwitchView.js.map +1 -1
  13. package/lib/module/components/BrandingView.js +13 -11
  14. package/lib/module/components/BrandingView.js.map +1 -1
  15. package/lib/module/components/ChannelView.js +27 -48
  16. package/lib/module/components/ChannelView.js.map +1 -1
  17. package/lib/module/components/ErrorView.js +12 -10
  18. package/lib/module/components/ErrorView.js.map +1 -1
  19. package/lib/module/components/LiveVoiceView.js +153 -61
  20. package/lib/module/components/LiveVoiceView.js.map +1 -1
  21. package/lib/module/components/PlayButtonView.js +255 -94
  22. package/lib/module/components/PlayButtonView.js.map +1 -1
  23. package/lib/module/components/ReconnectingView.js +16 -13
  24. package/lib/module/components/ReconnectingView.js.map +1 -1
  25. package/lib/module/components/WarningView.js +12 -10
  26. package/lib/module/components/WarningView.js.map +1 -1
  27. package/lib/module/components/index.js +12 -10
  28. package/lib/module/components/index.js.map +1 -1
  29. package/lib/module/icons/captions@1x.png +0 -0
  30. package/lib/module/icons/captions@2x.png +0 -0
  31. package/lib/module/icons/pause@1x.png +0 -0
  32. package/lib/module/icons/pause@2x.png +0 -0
  33. package/lib/module/icons/play@1x.png +0 -0
  34. package/lib/module/icons/play@2x.png +0 -0
  35. package/lib/module/index.js +14 -222
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/sdk/LiveVoiceSdk.js +371 -0
  38. package/lib/module/sdk/LiveVoiceSdk.js.map +1 -0
  39. package/lib/module/sdk/LiveVoiceState.js +66 -0
  40. package/lib/module/sdk/LiveVoiceState.js.map +1 -0
  41. package/lib/module/specs/NativeLiveVoiceSdk.js +16 -10
  42. package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
  43. package/lib/module/util/Colors.js +14 -11
  44. package/lib/module/util/Colors.js.map +1 -1
  45. package/lib/module/util/ForegroundServiceConfig.js +21 -11
  46. package/lib/module/util/ForegroundServiceConfig.js.map +1 -1
  47. package/lib/module/util/PlayingState.js +12 -10
  48. package/lib/module/util/PlayingState.js.map +1 -1
  49. package/lib/module/util/Translations.js +12 -10
  50. package/lib/module/util/Translations.js.map +1 -1
  51. package/lib/module/util/logger.js +76 -0
  52. package/lib/module/util/logger.js.map +1 -0
  53. package/lib/typescript/package.json +1 -0
  54. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +1 -0
  55. package/lib/typescript/src/components/BrandingView.d.ts.map +1 -0
  56. package/lib/typescript/{commonjs/src → src}/components/ChannelView.d.ts +4 -2
  57. package/lib/typescript/src/components/ChannelView.d.ts.map +1 -0
  58. package/lib/typescript/src/components/ErrorView.d.ts.map +1 -0
  59. package/lib/typescript/src/components/LiveVoiceView.d.ts +28 -0
  60. package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -0
  61. package/lib/typescript/src/components/PlayButtonView.d.ts +341 -0
  62. package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -0
  63. package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -0
  64. package/lib/typescript/src/components/WarningView.d.ts.map +1 -0
  65. package/lib/typescript/src/components/index.d.ts.map +1 -0
  66. package/lib/typescript/src/index.d.ts +7 -0
  67. package/lib/typescript/src/index.d.ts.map +1 -0
  68. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +210 -0
  69. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -0
  70. package/lib/typescript/src/sdk/LiveVoiceState.d.ts +12 -0
  71. package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -0
  72. package/lib/typescript/{module/src → src}/specs/NativeLiveVoiceSdk.d.ts +6 -3
  73. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -0
  74. package/lib/typescript/{commonjs/src → src}/util/Colors.d.ts +2 -1
  75. package/lib/typescript/src/util/Colors.d.ts.map +1 -0
  76. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +19 -0
  77. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +1 -0
  78. package/lib/typescript/src/util/PlayingState.d.ts.map +1 -0
  79. package/lib/typescript/src/util/Translations.d.ts.map +1 -0
  80. package/lib/typescript/src/util/UIState.d.ts +86 -0
  81. package/lib/typescript/src/util/UIState.d.ts.map +1 -0
  82. package/lib/typescript/src/util/logger.d.ts +23 -0
  83. package/lib/typescript/src/util/logger.d.ts.map +1 -0
  84. package/livevoice-sdk-react-native.podspec +20 -41
  85. package/package.json +41 -122
  86. package/src/components/AudioOutputSwitchView.tsx +13 -13
  87. package/src/components/BrandingView.tsx +13 -11
  88. package/src/components/ChannelView.tsx +32 -36
  89. package/src/components/ErrorView.tsx +12 -10
  90. package/src/components/LiveVoiceView.tsx +231 -89
  91. package/src/components/PlayButtonView.tsx +293 -98
  92. package/src/components/ReconnectingView.tsx +20 -13
  93. package/src/components/WarningView.tsx +12 -10
  94. package/src/components/index.tsx +12 -10
  95. package/src/icons/captions@1x.png +0 -0
  96. package/src/icons/captions@2x.png +0 -0
  97. package/src/icons/pause@1x.png +0 -0
  98. package/src/icons/pause@2x.png +0 -0
  99. package/src/icons/play@1x.png +0 -0
  100. package/src/icons/play@2x.png +0 -0
  101. package/src/index.tsx +19 -236
  102. package/src/sdk/LiveVoiceSdk.ts +408 -0
  103. package/src/sdk/LiveVoiceState.ts +89 -0
  104. package/src/specs/NativeLiveVoiceSdk.ts +24 -16
  105. package/src/util/Colors.ts +15 -11
  106. package/src/util/ForegroundServiceConfig.tsx +21 -11
  107. package/src/util/PlayingState.ts +12 -10
  108. package/src/util/Translations.ts +12 -10
  109. package/src/util/UIState.ts +54 -13
  110. package/src/util/logger.ts +92 -0
  111. package/android/generated/java/io/livevoice/react/NativeLiveVoiceSdkSpec.java +0 -186
  112. package/android/generated/jni/CMakeLists.txt +0 -36
  113. package/android/generated/jni/RNLiveVoiceSpec-generated.cpp +0 -235
  114. package/android/generated/jni/RNLiveVoiceSpec.h +0 -31
  115. package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI-generated.cpp +0 -245
  116. package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +0 -398
  117. package/android/src/main/AndroidManifest.xml +0 -3
  118. package/android/src/main/java/io/livevoice/react/Mappings.kt +0 -54
  119. package/android/src/main/java/io/livevoice/react/NativeModels.kt +0 -77
  120. package/ios/LivevoiceSdkReactNative.mm +0 -250
  121. package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec-generated.mm +0 -292
  122. package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec.h +0 -101
  123. package/ios/generated/RNLiveVoiceSpecJSI-generated.cpp +0 -245
  124. package/ios/generated/RNLiveVoiceSpecJSI.h +0 -398
  125. package/lib/commonjs/components/AudioOutputSwitchView.js +0 -144
  126. package/lib/commonjs/components/AudioOutputSwitchView.js.map +0 -1
  127. package/lib/commonjs/components/BrandingView.js +0 -78
  128. package/lib/commonjs/components/BrandingView.js.map +0 -1
  129. package/lib/commonjs/components/ChannelView.js +0 -117
  130. package/lib/commonjs/components/ChannelView.js.map +0 -1
  131. package/lib/commonjs/components/ErrorView.js +0 -88
  132. package/lib/commonjs/components/ErrorView.js.map +0 -1
  133. package/lib/commonjs/components/LiveVoiceView.js +0 -107
  134. package/lib/commonjs/components/LiveVoiceView.js.map +0 -1
  135. package/lib/commonjs/components/PlayButtonView.js +0 -161
  136. package/lib/commonjs/components/PlayButtonView.js.map +0 -1
  137. package/lib/commonjs/components/ReconnectingView.js +0 -109
  138. package/lib/commonjs/components/ReconnectingView.js.map +0 -1
  139. package/lib/commonjs/components/WarningView.js +0 -58
  140. package/lib/commonjs/components/WarningView.js.map +0 -1
  141. package/lib/commonjs/components/index.js +0 -94
  142. package/lib/commonjs/components/index.js.map +0 -1
  143. package/lib/commonjs/icons/branding.png +0 -0
  144. package/lib/commonjs/icons/cpu.png +0 -0
  145. package/lib/commonjs/icons/headphones.png +0 -0
  146. package/lib/commonjs/icons/mic.png +0 -0
  147. package/lib/commonjs/icons/pause.png +0 -0
  148. package/lib/commonjs/icons/play.png +0 -0
  149. package/lib/commonjs/icons/speaker.png +0 -0
  150. package/lib/commonjs/index.js +0 -327
  151. package/lib/commonjs/index.js.map +0 -1
  152. package/lib/commonjs/specs/NativeLiveVoiceSdk.js +0 -19
  153. package/lib/commonjs/specs/NativeLiveVoiceSdk.js.map +0 -1
  154. package/lib/commonjs/util/Colors.js +0 -30
  155. package/lib/commonjs/util/Colors.js.map +0 -1
  156. package/lib/commonjs/util/ForegroundServiceConfig.js +0 -33
  157. package/lib/commonjs/util/ForegroundServiceConfig.js.map +0 -1
  158. package/lib/commonjs/util/PlayingState.js +0 -24
  159. package/lib/commonjs/util/PlayingState.js.map +0 -1
  160. package/lib/commonjs/util/Translations.js +0 -47
  161. package/lib/commonjs/util/Translations.js.map +0 -1
  162. package/lib/commonjs/util/UIState.js +0 -6
  163. package/lib/commonjs/util/UIState.js.map +0 -1
  164. package/lib/module/icons/pause.png +0 -0
  165. package/lib/module/icons/play.png +0 -0
  166. package/lib/typescript/commonjs/package.json +0 -1
  167. package/lib/typescript/commonjs/src/components/AudioOutputSwitchView.d.ts.map +0 -1
  168. package/lib/typescript/commonjs/src/components/BrandingView.d.ts.map +0 -1
  169. package/lib/typescript/commonjs/src/components/ChannelView.d.ts.map +0 -1
  170. package/lib/typescript/commonjs/src/components/ErrorView.d.ts.map +0 -1
  171. package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts +0 -6
  172. package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts.map +0 -1
  173. package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts +0 -146
  174. package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts.map +0 -1
  175. package/lib/typescript/commonjs/src/components/ReconnectingView.d.ts.map +0 -1
  176. package/lib/typescript/commonjs/src/components/WarningView.d.ts.map +0 -1
  177. package/lib/typescript/commonjs/src/components/index.d.ts.map +0 -1
  178. package/lib/typescript/commonjs/src/index.d.ts +0 -149
  179. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  180. package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts +0 -48
  181. package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts.map +0 -1
  182. package/lib/typescript/commonjs/src/util/Colors.d.ts.map +0 -1
  183. package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts +0 -12
  184. package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts.map +0 -1
  185. package/lib/typescript/commonjs/src/util/PlayingState.d.ts.map +0 -1
  186. package/lib/typescript/commonjs/src/util/Translations.d.ts.map +0 -1
  187. package/lib/typescript/commonjs/src/util/UIState.d.ts +0 -45
  188. package/lib/typescript/commonjs/src/util/UIState.d.ts.map +0 -1
  189. package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts +0 -6
  190. package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts.map +0 -1
  191. package/lib/typescript/module/src/components/BrandingView.d.ts +0 -6
  192. package/lib/typescript/module/src/components/BrandingView.d.ts.map +0 -1
  193. package/lib/typescript/module/src/components/ChannelView.d.ts +0 -13
  194. package/lib/typescript/module/src/components/ChannelView.d.ts.map +0 -1
  195. package/lib/typescript/module/src/components/ErrorView.d.ts +0 -9
  196. package/lib/typescript/module/src/components/ErrorView.d.ts.map +0 -1
  197. package/lib/typescript/module/src/components/LiveVoiceView.d.ts +0 -6
  198. package/lib/typescript/module/src/components/LiveVoiceView.d.ts.map +0 -1
  199. package/lib/typescript/module/src/components/PlayButtonView.d.ts +0 -146
  200. package/lib/typescript/module/src/components/PlayButtonView.d.ts.map +0 -1
  201. package/lib/typescript/module/src/components/ReconnectingView.d.ts +0 -9
  202. package/lib/typescript/module/src/components/ReconnectingView.d.ts.map +0 -1
  203. package/lib/typescript/module/src/components/WarningView.d.ts +0 -8
  204. package/lib/typescript/module/src/components/WarningView.d.ts.map +0 -1
  205. package/lib/typescript/module/src/components/index.d.ts +0 -9
  206. package/lib/typescript/module/src/components/index.d.ts.map +0 -1
  207. package/lib/typescript/module/src/index.d.ts +0 -149
  208. package/lib/typescript/module/src/index.d.ts.map +0 -1
  209. package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts.map +0 -1
  210. package/lib/typescript/module/src/util/Colors.d.ts +0 -13
  211. package/lib/typescript/module/src/util/Colors.d.ts.map +0 -1
  212. package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts +0 -12
  213. package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts.map +0 -1
  214. package/lib/typescript/module/src/util/PlayingState.d.ts +0 -7
  215. package/lib/typescript/module/src/util/PlayingState.d.ts.map +0 -1
  216. package/lib/typescript/module/src/util/Translations.d.ts +0 -22
  217. package/lib/typescript/module/src/util/Translations.d.ts.map +0 -1
  218. package/lib/typescript/module/src/util/UIState.d.ts +0 -45
  219. package/lib/typescript/module/src/util/UIState.d.ts.map +0 -1
  220. package/react-native.config.js +0 -12
  221. package/src/icons/pause.png +0 -0
  222. package/src/icons/play.png +0 -0
  223. /package/lib/{typescript/module → module}/package.json +0 -0
  224. /package/lib/typescript/{commonjs/src → src}/components/AudioOutputSwitchView.d.ts +0 -0
  225. /package/lib/typescript/{commonjs/src → src}/components/BrandingView.d.ts +0 -0
  226. /package/lib/typescript/{commonjs/src → src}/components/ErrorView.d.ts +0 -0
  227. /package/lib/typescript/{commonjs/src → src}/components/ReconnectingView.d.ts +0 -0
  228. /package/lib/typescript/{commonjs/src → src}/components/WarningView.d.ts +0 -0
  229. /package/lib/typescript/{commonjs/src → src}/components/index.d.ts +0 -0
  230. /package/lib/typescript/{commonjs/src → src}/util/PlayingState.d.ts +0 -0
  231. /package/lib/typescript/{commonjs/src → src}/util/Translations.d.ts +0 -0
@@ -1,129 +1,271 @@
1
- /*
2
- * This source file is part of the LiveVoice SDK project
3
- *
4
- * Copyright (c) LiveVoice GmbH
5
- * Licensed under the MIT license
6
- *
7
- * See LICENSE for license information
8
- *
9
- * SPDX-License-Identifier: MIT
10
- */
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the LiveVoice SDK project
4
+ //
5
+ // Copyright (c) LiveVoice GmbH
6
+ // Licensed under the MIT license
7
+ //
8
+ // See LICENSE for license information
9
+ //
10
+ // SPDX-License-Identifier: MIT
11
+ //
12
+ //===----------------------------------------------------------------------===//
11
13
 
12
14
  import {
13
- type UiState,
14
- type AvailableSubtitleConfigs,
15
- getCurrentUiState,
16
- onUiStateChanged,
17
15
  startChannel,
18
16
  stopChannel,
19
17
  reconnect,
20
- onAvailableSubtitleConfigsChanged,
21
- onSubtitlesChanged,
18
+ startSubtitles,
19
+ } from '../sdk/LiveVoiceSdk';
20
+ import {
21
+ type Claims,
22
+ getCurrentUiState,
23
+ onUiStateChanged,
22
24
  getCurrentClaims,
23
- BrandingView,
24
- ErrorView,
25
- ReconnectingView
26
- } from 'livevoice-sdk-react-native';
25
+ } from '../sdk/LiveVoiceState';
26
+ import { BrandingView } from './BrandingView';
27
+ import { ErrorView } from './ErrorView';
28
+ import { ReconnectingView } from './ReconnectingView';
29
+
30
+ import { PlayingState } from "../util/PlayingState";
27
31
 
28
- import { useEffect, useState } from 'react';
29
- import { View, ActivityIndicator } from 'react-native';
32
+ import { Fragment, useEffect, useState } from "react";
33
+ import { View, ActivityIndicator, Text, useColorScheme } from "react-native";
30
34
 
31
- import { COLORS } from '../util/Colors';
32
- import { type Channel } from '../util/UIState';
33
- import { ChannelView } from './ChannelView';
35
+ import { COLORS } from "../util/Colors";
36
+ import { Translations } from "../util/Translations";
37
+ import { type Channel, type UiState } from "../util/UIState";
38
+ import { ChannelView } from "./ChannelView";
39
+
40
+ /** Per-cell helpers passed to {@link LiveVoiceViewProps.renderChannel}, mirroring the native SDKs. */
41
+ export interface ChannelCellHelpers {
42
+ /** Whether this is the last channel in the (filtered) list — e.g. to omit a trailing divider. */
43
+ isLastInList: boolean;
44
+ /** Toggle audio for this channel: starts it if stopped, stops it if playing. */
45
+ onAudioPress: () => void;
46
+ }
47
+
48
+ /** Renders a custom channel cell. See {@link LiveVoiceViewProps.renderChannel}. */
49
+ export type RenderChannel = (
50
+ channel: Channel,
51
+ helpers: ChannelCellHelpers,
52
+ ) => React.ReactNode;
34
53
 
35
54
  export interface LiveVoiceViewProps {
36
55
  isDarkMode?: boolean;
56
+ /**
57
+ * Return true for channels that should be displayed by the drop-in view.
58
+ */
59
+ filter?: (channel: Channel) => boolean;
60
+ /**
61
+ * Render a custom channel cell instead of the default one.
62
+ *
63
+ * Requires an API key that permits custom UI. If a `renderChannel` is provided but the joined
64
+ * event's key doesn't allow custom UI, the view shows the invalid-api-key error instead — the
65
+ * same gating the native SDKs apply. When omitted, the default cell is used.
66
+ */
67
+ renderChannel?: RenderChannel;
37
68
  }
38
69
 
39
- export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({ isDarkMode }) => {
40
- const [uiState, setUiState] = useState<UiState>((() => getCurrentUiState()))
70
+ function useLiveVoiceViewState(): {
71
+ claims: Claims | null;
72
+ uiState: UiState;
73
+ } {
74
+ const [uiState, setUiState] = useState<UiState>(() => getCurrentUiState());
75
+ const [claims, setClaims] = useState<Claims | null>(() =>
76
+ getCurrentUiState().type === 'ready' ? getCurrentClaims() : null,
77
+ );
41
78
 
42
79
  useEffect(() => {
43
- let subscription: { remove: () => void; } | undefined =
44
- onUiStateChanged((data: UiState) => {
45
- setUiState(data);
46
- });
47
- return () => {
48
- subscription?.remove();
49
- subscription = undefined;
80
+ // Claims belong to the current `ready` session. Read them fresh on every
81
+ // `ready` transition and clear them otherwise, so a stale value (e.g.
82
+ // `customUiAllowed` from a previously joined API key) can never outlive the
83
+ // session that produced it and keep the gate open after switching keys.
84
+ const apply = (nextUiState: UiState) => {
85
+ setUiState(nextUiState);
86
+ setClaims(nextUiState.type === 'ready' ? getCurrentClaims() : null);
50
87
  };
51
- }, []);
52
88
 
53
- useEffect(() => {
54
- let subscription: { remove: () => void; } | undefined =
55
- onAvailableSubtitleConfigsChanged((data: AvailableSubtitleConfigs) => {
56
- console.log('available subtitles changed!' + JSON.stringify(data))
57
- });
58
- return () => {
59
- subscription?.remove();
60
- subscription = undefined;
61
- };
62
- }, []);
89
+ const subscription = onUiStateChanged(apply);
90
+
91
+ apply(getCurrentUiState());
63
92
 
64
- useEffect(() => {
65
- let subscription: { remove: () => void; } | undefined =
66
- onSubtitlesChanged((data: [String]) => {
67
- console.log('subtitles changed!' + JSON.stringify(data))
68
- });
69
93
  return () => {
70
- subscription?.remove();
71
- subscription = undefined;
94
+ subscription.remove();
72
95
  };
73
96
  }, []);
74
97
 
75
- const claims = getCurrentClaims()
98
+ return { uiState, claims };
99
+ }
100
+
101
+ export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({
102
+ isDarkMode,
103
+ filter,
104
+ renderChannel,
105
+ }) => {
106
+ const systemDarkMode = useColorScheme() === "dark";
107
+ const dark = isDarkMode ?? systemDarkMode;
108
+ const { uiState, claims } = useLiveVoiceViewState();
76
109
 
77
110
  switch (uiState.type) {
78
- case 'ready':
79
- return (<View>
80
- {uiState.channels.map((channel: Channel, index: number) => (
81
- <ChannelView
82
- key={index}
83
- playingState={channel.playingState}
84
- isDarkMode={isDarkMode}
85
- muted={channel.isAudioMuted}
86
- isOnline={channel.isOnline}
87
- aiSpeaker={channel.isAiSpeaker}
88
- channelName={channel.name}
89
- onPress={() => channel.playingState === 'PLAYING' ? stopChannel() : startChannel(channel.id)}
111
+ case "ready": {
112
+ const backgroundColor = dark ? COLORS.cardBgDark : COLORS.cardBg;
113
+ const dividerColor = dark ? COLORS.dividerDark : COLORS.divider;
114
+ const visibleChannels =
115
+ filter == null ? uiState.channels : uiState.channels.filter(filter);
116
+ const customUiAllowed = claims?.customUiAllowed ?? false;
117
+
118
+ // A custom cell was provided but the joined event's key doesn't permit custom UI.
119
+ // Mirror the native SDKs and surface the invalid-api-key error instead of rendering it.
120
+ if (renderChannel != null && !customUiAllowed) {
121
+ return (
122
+ <ErrorView
123
+ state={{
124
+ type: "error",
125
+ message: Translations.sdkErrorInvalidApiKey(),
126
+ canBeRetried: false,
127
+ }}
128
+ isDarkMode={dark}
129
+ onPress={() => {}}
90
130
  />
91
- ))}
131
+ );
132
+ }
133
+
134
+ const showBranding = claims === null || !claims.hideBranding;
135
+ const emptyText =
136
+ uiState.channels.length === 0 || filter == null
137
+ ? Translations.noChannels()
138
+ : Translations.sdkNoMatchingChannels();
92
139
 
93
- {
94
- (claims === null || !claims.hideBranding) && (
95
- <BrandingView isDarkMode={isDarkMode} />)
96
- }
97
- </View>)
140
+ const emptyView = (
141
+ <View style={{ paddingVertical: 30, paddingHorizontal: 16 }}>
142
+ <Text
143
+ style={{
144
+ fontSize: 14,
145
+ fontWeight: "500",
146
+ textAlign: "center",
147
+ color: dark ? COLORS.white : COLORS.black,
148
+ }}
149
+ >
150
+ {emptyText}
151
+ </Text>
152
+ </View>
153
+ );
98
154
 
99
- case 'loading':
100
- const backgroundColor = isDarkMode ? COLORS.cardBgDark : COLORS.cardBg
155
+ // Custom cells get full control (no card chrome / dividers), like the native SDKs.
156
+ if (renderChannel != null) {
157
+ return (
158
+ <View style={{ width: "100%" }}>
159
+ {visibleChannels.length === 0
160
+ ? emptyView
161
+ : visibleChannels.map((channel: Channel, index: number) => (
162
+ <Fragment key={channel.id}>
163
+ {renderChannel(channel, {
164
+ isLastInList: index === visibleChannels.length - 1,
165
+ onAudioPress: () =>
166
+ channel.playingState === PlayingState.PLAYING
167
+ ? stopChannel()
168
+ : startChannel(channel.id),
169
+ })}
170
+ </Fragment>
171
+ ))}
172
+ {showBranding && <BrandingView isDarkMode={dark} />}
173
+ </View>
174
+ );
175
+ }
101
176
 
177
+ // Default cells.
102
178
  return (
103
- <View style={{
104
- width: '100%',
105
- padding: 10,
106
- borderRadius: 8,
107
- justifyContent: 'center',
108
- alignItems: 'center',
109
- backgroundColor: backgroundColor
110
- }}>
179
+ <View style={{ width: "100%" }}>
180
+ <View
181
+ style={{
182
+ backgroundColor: backgroundColor,
183
+ borderRadius: 8,
184
+ overflow: "hidden",
185
+ }}
186
+ >
187
+ {visibleChannels.length === 0 ? (
188
+ emptyView
189
+ ) : (
190
+ visibleChannels.map((channel: Channel, index: number) => (
191
+ <View key={channel.id}>
192
+ <ChannelView
193
+ playingState={channel.playingState}
194
+ isDarkMode={dark}
195
+ muted={channel.isAudioMuted}
196
+ isOnline={channel.isOnline}
197
+ hasAudio={channel.hasAudio}
198
+ hasSubtitles={channel.hasSubtitles}
199
+ channelName={channel.name}
200
+ onAudioPress={() =>
201
+ channel.playingState === PlayingState.PLAYING
202
+ ? stopChannel()
203
+ : startChannel(channel.id)
204
+ }
205
+ onSubtitlesPress={() => startSubtitles(channel.id)}
206
+ />
207
+ {index < visibleChannels.length - 1 && (
208
+ <View
209
+ style={{
210
+ height: 1,
211
+ backgroundColor: dividerColor,
212
+ marginHorizontal: 10,
213
+ }}
214
+ />
215
+ )}
216
+ </View>
217
+ ))
218
+ )}
219
+ {showBranding && <BrandingView isDarkMode={dark} />}
220
+ </View>
221
+ </View>
222
+ );
223
+ }
224
+
225
+ case "loading":
226
+ const loadingBackgroundColor = dark
227
+ ? COLORS.cardBgDark
228
+ : COLORS.cardBg;
229
+
230
+ return (
231
+ <View
232
+ style={{
233
+ width: "100%",
234
+ padding: 10,
235
+ borderRadius: 8,
236
+ justifyContent: "center",
237
+ alignItems: "center",
238
+ backgroundColor: loadingBackgroundColor,
239
+ }}
240
+ >
111
241
  <ActivityIndicator size={40} color={COLORS.primary} />
112
242
  </View>
113
243
  );
114
244
 
115
- case 'error':
245
+ case "error":
116
246
  return (
117
- <ErrorView state={uiState} onPress={() => { reconnect() }} />
118
- )
247
+ <ErrorView
248
+ state={uiState}
249
+ isDarkMode={dark}
250
+ onPress={() => {
251
+ reconnect();
252
+ }}
253
+ />
254
+ );
119
255
 
120
- case 'reconnecting':
256
+ case "reconnecting":
121
257
  return (
122
- <ReconnectingView state={uiState} onPress={() => { reconnect() }} />
123
- )
258
+ <ReconnectingView
259
+ state={uiState}
260
+ isDarkMode={dark}
261
+ onPress={() => {
262
+ reconnect();
263
+ }}
264
+ />
265
+ );
124
266
  default:
125
- return <View />
267
+ return <View />;
126
268
  }
127
269
  };
128
270
 
129
- export default LiveVoiceView;
271
+ export default LiveVoiceView;