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.
- package/LICENSE +1 -1
- package/README.md +119 -7
- package/android/build.gradle +52 -84
- package/android/gradle.properties +10 -6
- package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +93 -126
- package/android/src/main/java/io/livevoice/react/LiveVoiceSdkReactNativePackage.kt +12 -13
- package/android/src/main/java/io/livevoice/react/__SDK.kt +16 -2
- package/ios/LiveVoiceSdkReactNative.h +5 -5
- package/ios/LiveVoiceSdkReactNative.mm +308 -0
- package/ios/__SDK.h +16 -2
- package/lib/module/components/AudioOutputSwitchView.js +13 -13
- package/lib/module/components/AudioOutputSwitchView.js.map +1 -1
- package/lib/module/components/BrandingView.js +13 -11
- package/lib/module/components/BrandingView.js.map +1 -1
- package/lib/module/components/ChannelView.js +27 -48
- package/lib/module/components/ChannelView.js.map +1 -1
- package/lib/module/components/ErrorView.js +12 -10
- package/lib/module/components/ErrorView.js.map +1 -1
- package/lib/module/components/LiveVoiceView.js +153 -61
- package/lib/module/components/LiveVoiceView.js.map +1 -1
- package/lib/module/components/PlayButtonView.js +255 -94
- package/lib/module/components/PlayButtonView.js.map +1 -1
- package/lib/module/components/ReconnectingView.js +16 -13
- package/lib/module/components/ReconnectingView.js.map +1 -1
- package/lib/module/components/WarningView.js +12 -10
- package/lib/module/components/WarningView.js.map +1 -1
- package/lib/module/components/index.js +12 -10
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/icons/captions@1x.png +0 -0
- package/lib/module/icons/captions@2x.png +0 -0
- package/lib/module/icons/pause@1x.png +0 -0
- package/lib/module/icons/pause@2x.png +0 -0
- package/lib/module/icons/play@1x.png +0 -0
- package/lib/module/icons/play@2x.png +0 -0
- package/lib/module/index.js +14 -222
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/LiveVoiceSdk.js +371 -0
- package/lib/module/sdk/LiveVoiceSdk.js.map +1 -0
- package/lib/module/sdk/LiveVoiceState.js +66 -0
- package/lib/module/sdk/LiveVoiceState.js.map +1 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js +16 -10
- package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
- package/lib/module/util/Colors.js +14 -11
- package/lib/module/util/Colors.js.map +1 -1
- package/lib/module/util/ForegroundServiceConfig.js +21 -11
- package/lib/module/util/ForegroundServiceConfig.js.map +1 -1
- package/lib/module/util/PlayingState.js +12 -10
- package/lib/module/util/PlayingState.js.map +1 -1
- package/lib/module/util/Translations.js +12 -10
- package/lib/module/util/Translations.js.map +1 -1
- package/lib/module/util/logger.js +76 -0
- package/lib/module/util/logger.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +1 -0
- package/lib/typescript/src/components/BrandingView.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src}/components/ChannelView.d.ts +4 -2
- package/lib/typescript/src/components/ChannelView.d.ts.map +1 -0
- package/lib/typescript/src/components/ErrorView.d.ts.map +1 -0
- package/lib/typescript/src/components/LiveVoiceView.d.ts +28 -0
- package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -0
- package/lib/typescript/src/components/PlayButtonView.d.ts +341 -0
- package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -0
- package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -0
- package/lib/typescript/src/components/WarningView.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +210 -0
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts +12 -0
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -0
- package/lib/typescript/{module/src → src}/specs/NativeLiveVoiceSdk.d.ts +6 -3
- package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src}/util/Colors.d.ts +2 -1
- package/lib/typescript/src/util/Colors.d.ts.map +1 -0
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +19 -0
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +1 -0
- package/lib/typescript/src/util/PlayingState.d.ts.map +1 -0
- package/lib/typescript/src/util/Translations.d.ts.map +1 -0
- package/lib/typescript/src/util/UIState.d.ts +86 -0
- package/lib/typescript/src/util/UIState.d.ts.map +1 -0
- package/lib/typescript/src/util/logger.d.ts +23 -0
- package/lib/typescript/src/util/logger.d.ts.map +1 -0
- package/livevoice-sdk-react-native.podspec +20 -41
- package/package.json +41 -122
- package/src/components/AudioOutputSwitchView.tsx +13 -13
- package/src/components/BrandingView.tsx +13 -11
- package/src/components/ChannelView.tsx +32 -36
- package/src/components/ErrorView.tsx +12 -10
- package/src/components/LiveVoiceView.tsx +231 -89
- package/src/components/PlayButtonView.tsx +293 -98
- package/src/components/ReconnectingView.tsx +20 -13
- package/src/components/WarningView.tsx +12 -10
- package/src/components/index.tsx +12 -10
- package/src/icons/captions@1x.png +0 -0
- package/src/icons/captions@2x.png +0 -0
- package/src/icons/pause@1x.png +0 -0
- package/src/icons/pause@2x.png +0 -0
- package/src/icons/play@1x.png +0 -0
- package/src/icons/play@2x.png +0 -0
- package/src/index.tsx +19 -236
- package/src/sdk/LiveVoiceSdk.ts +408 -0
- package/src/sdk/LiveVoiceState.ts +89 -0
- package/src/specs/NativeLiveVoiceSdk.ts +24 -16
- package/src/util/Colors.ts +15 -11
- package/src/util/ForegroundServiceConfig.tsx +21 -11
- package/src/util/PlayingState.ts +12 -10
- package/src/util/Translations.ts +12 -10
- package/src/util/UIState.ts +54 -13
- package/src/util/logger.ts +92 -0
- package/android/generated/java/io/livevoice/react/NativeLiveVoiceSdkSpec.java +0 -186
- package/android/generated/jni/CMakeLists.txt +0 -36
- package/android/generated/jni/RNLiveVoiceSpec-generated.cpp +0 -235
- package/android/generated/jni/RNLiveVoiceSpec.h +0 -31
- package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI-generated.cpp +0 -245
- package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +0 -398
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/java/io/livevoice/react/Mappings.kt +0 -54
- package/android/src/main/java/io/livevoice/react/NativeModels.kt +0 -77
- package/ios/LivevoiceSdkReactNative.mm +0 -250
- package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec-generated.mm +0 -292
- package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec.h +0 -101
- package/ios/generated/RNLiveVoiceSpecJSI-generated.cpp +0 -245
- package/ios/generated/RNLiveVoiceSpecJSI.h +0 -398
- package/lib/commonjs/components/AudioOutputSwitchView.js +0 -144
- package/lib/commonjs/components/AudioOutputSwitchView.js.map +0 -1
- package/lib/commonjs/components/BrandingView.js +0 -78
- package/lib/commonjs/components/BrandingView.js.map +0 -1
- package/lib/commonjs/components/ChannelView.js +0 -117
- package/lib/commonjs/components/ChannelView.js.map +0 -1
- package/lib/commonjs/components/ErrorView.js +0 -88
- package/lib/commonjs/components/ErrorView.js.map +0 -1
- package/lib/commonjs/components/LiveVoiceView.js +0 -107
- package/lib/commonjs/components/LiveVoiceView.js.map +0 -1
- package/lib/commonjs/components/PlayButtonView.js +0 -161
- package/lib/commonjs/components/PlayButtonView.js.map +0 -1
- package/lib/commonjs/components/ReconnectingView.js +0 -109
- package/lib/commonjs/components/ReconnectingView.js.map +0 -1
- package/lib/commonjs/components/WarningView.js +0 -58
- package/lib/commonjs/components/WarningView.js.map +0 -1
- package/lib/commonjs/components/index.js +0 -94
- package/lib/commonjs/components/index.js.map +0 -1
- package/lib/commonjs/icons/branding.png +0 -0
- package/lib/commonjs/icons/cpu.png +0 -0
- package/lib/commonjs/icons/headphones.png +0 -0
- package/lib/commonjs/icons/mic.png +0 -0
- package/lib/commonjs/icons/pause.png +0 -0
- package/lib/commonjs/icons/play.png +0 -0
- package/lib/commonjs/icons/speaker.png +0 -0
- package/lib/commonjs/index.js +0 -327
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/specs/NativeLiveVoiceSdk.js +0 -19
- package/lib/commonjs/specs/NativeLiveVoiceSdk.js.map +0 -1
- package/lib/commonjs/util/Colors.js +0 -30
- package/lib/commonjs/util/Colors.js.map +0 -1
- package/lib/commonjs/util/ForegroundServiceConfig.js +0 -33
- package/lib/commonjs/util/ForegroundServiceConfig.js.map +0 -1
- package/lib/commonjs/util/PlayingState.js +0 -24
- package/lib/commonjs/util/PlayingState.js.map +0 -1
- package/lib/commonjs/util/Translations.js +0 -47
- package/lib/commonjs/util/Translations.js.map +0 -1
- package/lib/commonjs/util/UIState.js +0 -6
- package/lib/commonjs/util/UIState.js.map +0 -1
- package/lib/module/icons/pause.png +0 -0
- package/lib/module/icons/play.png +0 -0
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/components/AudioOutputSwitchView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/BrandingView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/ChannelView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/ErrorView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts +0 -6
- package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts +0 -146
- package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/ReconnectingView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/WarningView.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -149
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts +0 -48
- package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/util/Colors.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts +0 -12
- package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/util/PlayingState.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/util/Translations.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/util/UIState.d.ts +0 -45
- package/lib/typescript/commonjs/src/util/UIState.d.ts.map +0 -1
- package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts +0 -6
- package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/BrandingView.d.ts +0 -6
- package/lib/typescript/module/src/components/BrandingView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/ChannelView.d.ts +0 -13
- package/lib/typescript/module/src/components/ChannelView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/ErrorView.d.ts +0 -9
- package/lib/typescript/module/src/components/ErrorView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/LiveVoiceView.d.ts +0 -6
- package/lib/typescript/module/src/components/LiveVoiceView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/PlayButtonView.d.ts +0 -146
- package/lib/typescript/module/src/components/PlayButtonView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/ReconnectingView.d.ts +0 -9
- package/lib/typescript/module/src/components/ReconnectingView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/WarningView.d.ts +0 -8
- package/lib/typescript/module/src/components/WarningView.d.ts.map +0 -1
- package/lib/typescript/module/src/components/index.d.ts +0 -9
- package/lib/typescript/module/src/components/index.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -149
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts.map +0 -1
- package/lib/typescript/module/src/util/Colors.d.ts +0 -13
- package/lib/typescript/module/src/util/Colors.d.ts.map +0 -1
- package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts +0 -12
- package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts.map +0 -1
- package/lib/typescript/module/src/util/PlayingState.d.ts +0 -7
- package/lib/typescript/module/src/util/PlayingState.d.ts.map +0 -1
- package/lib/typescript/module/src/util/Translations.d.ts +0 -22
- package/lib/typescript/module/src/util/Translations.d.ts.map +0 -1
- package/lib/typescript/module/src/util/UIState.d.ts +0 -45
- package/lib/typescript/module/src/util/UIState.d.ts.map +0 -1
- package/react-native.config.js +0 -12
- package/src/icons/pause.png +0 -0
- package/src/icons/play.png +0 -0
- /package/lib/{typescript/module → module}/package.json +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/AudioOutputSwitchView.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/BrandingView.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/ErrorView.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/ReconnectingView.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/WarningView.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/components/index.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/util/PlayingState.d.ts +0 -0
- /package/lib/typescript/{commonjs/src → src}/util/Translations.d.ts +0 -0
|
@@ -1,129 +1,271 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
21
|
-
|
|
18
|
+
startSubtitles,
|
|
19
|
+
} from '../sdk/LiveVoiceSdk';
|
|
20
|
+
import {
|
|
21
|
+
type Claims,
|
|
22
|
+
getCurrentUiState,
|
|
23
|
+
onUiStateChanged,
|
|
22
24
|
getCurrentClaims,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from '
|
|
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
|
|
29
|
-
import { View, ActivityIndicator } from
|
|
32
|
+
import { Fragment, useEffect, useState } from "react";
|
|
33
|
+
import { View, ActivityIndicator, Text, useColorScheme } from "react-native";
|
|
30
34
|
|
|
31
|
-
import { COLORS } from
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
71
|
-
subscription = undefined;
|
|
94
|
+
subscription.remove();
|
|
72
95
|
};
|
|
73
96
|
}, []);
|
|
74
97
|
|
|
75
|
-
|
|
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
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
100
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
245
|
+
case "error":
|
|
116
246
|
return (
|
|
117
|
-
<ErrorView
|
|
118
|
-
|
|
247
|
+
<ErrorView
|
|
248
|
+
state={uiState}
|
|
249
|
+
isDarkMode={dark}
|
|
250
|
+
onPress={() => {
|
|
251
|
+
reconnect();
|
|
252
|
+
}}
|
|
253
|
+
/>
|
|
254
|
+
);
|
|
119
255
|
|
|
120
|
-
case
|
|
256
|
+
case "reconnecting":
|
|
121
257
|
return (
|
|
122
|
-
<ReconnectingView
|
|
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;
|