livevoice-sdk-react-native 1.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 +20 -0
- package/README.md +13 -0
- package/android/build.gradle +135 -0
- package/android/generated/java/io/livevoice/react/NativeLiveVoiceSdkSpec.java +182 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNLiveVoiceSpec-generated.cpp +229 -0
- package/android/generated/jni/RNLiveVoiceSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI-generated.cpp +238 -0
- package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +389 -0
- package/android/gradle.properties +7 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +293 -0
- package/android/src/main/java/io/livevoice/react/LiveVoiceSdkReactNativePackage.kt +45 -0
- package/android/src/main/java/io/livevoice/react/Mappings.kt +54 -0
- package/android/src/main/java/io/livevoice/react/NativeModels.kt +77 -0
- package/ios/LiveVoiceSdkReactNative.h +21 -0
- package/ios/LivevoiceSdkReactNative.mm +234 -0
- package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec-generated.mm +285 -0
- package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec.h +100 -0
- package/ios/generated/RNLiveVoiceSpecJSI-generated.cpp +238 -0
- package/ios/generated/RNLiveVoiceSpecJSI.h +389 -0
- package/lib/commonjs/components/AudioOutputSwitchView.js +140 -0
- package/lib/commonjs/components/AudioOutputSwitchView.js.map +1 -0
- package/lib/commonjs/components/BrandingView.js +78 -0
- package/lib/commonjs/components/BrandingView.js.map +1 -0
- package/lib/commonjs/components/ChannelView.js +117 -0
- package/lib/commonjs/components/ChannelView.js.map +1 -0
- package/lib/commonjs/components/ErrorView.js +88 -0
- package/lib/commonjs/components/ErrorView.js.map +1 -0
- package/lib/commonjs/components/LiveVoiceView.js +95 -0
- package/lib/commonjs/components/LiveVoiceView.js.map +1 -0
- package/lib/commonjs/components/PlayButtonView.js +161 -0
- package/lib/commonjs/components/PlayButtonView.js.map +1 -0
- package/lib/commonjs/components/ReconnectingView.js +109 -0
- package/lib/commonjs/components/ReconnectingView.js.map +1 -0
- package/lib/commonjs/components/WarningView.js +58 -0
- package/lib/commonjs/components/WarningView.js.map +1 -0
- package/lib/commonjs/components/index.js +94 -0
- package/lib/commonjs/components/index.js.map +1 -0
- 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 +310 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/specs/NativeLiveVoiceSdk.js +19 -0
- package/lib/commonjs/specs/NativeLiveVoiceSdk.js.map +1 -0
- package/lib/commonjs/util/Colors.js +30 -0
- package/lib/commonjs/util/Colors.js.map +1 -0
- package/lib/commonjs/util/ForegroundServiceConfig.js +33 -0
- package/lib/commonjs/util/ForegroundServiceConfig.js.map +1 -0
- package/lib/commonjs/util/PlayingState.js +24 -0
- package/lib/commonjs/util/PlayingState.js.map +1 -0
- package/lib/commonjs/util/Translations.js +47 -0
- package/lib/commonjs/util/Translations.js.map +1 -0
- package/lib/commonjs/util/UIState.js +6 -0
- package/lib/commonjs/util/UIState.js.map +1 -0
- package/lib/module/components/AudioOutputSwitchView.js +134 -0
- package/lib/module/components/AudioOutputSwitchView.js.map +1 -0
- package/lib/module/components/BrandingView.js +72 -0
- package/lib/module/components/BrandingView.js.map +1 -0
- package/lib/module/components/ChannelView.js +110 -0
- package/lib/module/components/ChannelView.js.map +1 -0
- package/lib/module/components/ErrorView.js +82 -0
- package/lib/module/components/ErrorView.js.map +1 -0
- package/lib/module/components/LiveVoiceView.js +90 -0
- package/lib/module/components/LiveVoiceView.js.map +1 -0
- package/lib/module/components/PlayButtonView.js +156 -0
- package/lib/module/components/PlayButtonView.js.map +1 -0
- package/lib/module/components/ReconnectingView.js +103 -0
- package/lib/module/components/ReconnectingView.js.map +1 -0
- package/lib/module/components/WarningView.js +52 -0
- package/lib/module/components/WarningView.js.map +1 -0
- package/lib/module/components/index.js +22 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/icons/branding.png +0 -0
- package/lib/module/icons/cpu.png +0 -0
- package/lib/module/icons/headphones.png +0 -0
- package/lib/module/icons/mic.png +0 -0
- package/lib/module/icons/pause.png +0 -0
- package/lib/module/icons/play.png +0 -0
- package/lib/module/icons/speaker.png +0 -0
- package/lib/module/index.js +215 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js +16 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -0
- package/lib/module/util/Colors.js +26 -0
- package/lib/module/util/Colors.js.map +1 -0
- package/lib/module/util/ForegroundServiceConfig.js +28 -0
- package/lib/module/util/ForegroundServiceConfig.js.map +1 -0
- package/lib/module/util/PlayingState.js +21 -0
- package/lib/module/util/PlayingState.js.map +1 -0
- package/lib/module/util/Translations.js +41 -0
- package/lib/module/util/Translations.js.map +1 -0
- package/lib/module/util/UIState.js +4 -0
- package/lib/module/util/UIState.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/components/AudioOutputSwitchView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/AudioOutputSwitchView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/BrandingView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/BrandingView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ChannelView.d.ts +13 -0
- package/lib/typescript/commonjs/src/components/ChannelView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ErrorView.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/ErrorView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts +146 -0
- package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ReconnectingView.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/ReconnectingView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/WarningView.d.ts +8 -0
- package/lib/typescript/commonjs/src/components/WarningView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/index.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +129 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts +47 -0
- package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/Colors.d.ts +13 -0
- package/lib/typescript/commonjs/src/util/Colors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts +12 -0
- package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/PlayingState.d.ts +7 -0
- package/lib/typescript/commonjs/src/util/PlayingState.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/Translations.d.ts +22 -0
- package/lib/typescript/commonjs/src/util/Translations.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/UIState.d.ts +45 -0
- package/lib/typescript/commonjs/src/util/UIState.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts +6 -0
- package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/BrandingView.d.ts +6 -0
- package/lib/typescript/module/src/components/BrandingView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ChannelView.d.ts +13 -0
- package/lib/typescript/module/src/components/ChannelView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ErrorView.d.ts +9 -0
- package/lib/typescript/module/src/components/ErrorView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/LiveVoiceView.d.ts +6 -0
- package/lib/typescript/module/src/components/LiveVoiceView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/PlayButtonView.d.ts +146 -0
- package/lib/typescript/module/src/components/PlayButtonView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ReconnectingView.d.ts +9 -0
- package/lib/typescript/module/src/components/ReconnectingView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/WarningView.d.ts +8 -0
- package/lib/typescript/module/src/components/WarningView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/index.d.ts +9 -0
- package/lib/typescript/module/src/components/index.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +129 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts +47 -0
- package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/util/Colors.d.ts +13 -0
- package/lib/typescript/module/src/util/Colors.d.ts.map +1 -0
- package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts +12 -0
- package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/util/PlayingState.d.ts +7 -0
- package/lib/typescript/module/src/util/PlayingState.d.ts.map +1 -0
- package/lib/typescript/module/src/util/Translations.d.ts +22 -0
- package/lib/typescript/module/src/util/Translations.d.ts.map +1 -0
- package/lib/typescript/module/src/util/UIState.d.ts +45 -0
- package/lib/typescript/module/src/util/UIState.d.ts.map +1 -0
- package/livevoice-sdk-react-native.podspec +58 -0
- package/package.json +207 -0
- package/react-native.config.js +12 -0
- package/src/components/AudioOutputSwitchView.tsx +145 -0
- package/src/components/BrandingView.tsx +66 -0
- package/src/components/ChannelView.tsx +99 -0
- package/src/components/ErrorView.tsx +89 -0
- package/src/components/LiveVoiceView.tsx +120 -0
- package/src/components/PlayButtonView.tsx +181 -0
- package/src/components/ReconnectingView.tsx +133 -0
- package/src/components/WarningView.tsx +60 -0
- package/src/components/index.tsx +19 -0
- package/src/icons/branding.png +0 -0
- package/src/icons/cpu.png +0 -0
- package/src/icons/headphones.png +0 -0
- package/src/icons/mic.png +0 -0
- package/src/icons/pause.png +0 -0
- package/src/icons/play.png +0 -0
- package/src/icons/speaker.png +0 -0
- package/src/index.tsx +221 -0
- package/src/specs/NativeLiveVoiceSdk.ts +75 -0
- package/src/util/Colors.ts +27 -0
- package/src/util/ForegroundServiceConfig.tsx +32 -0
- package/src/util/PlayingState.ts +18 -0
- package/src/util/Translations.ts +39 -0
- package/src/util/UIState.ts +65 -0
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type UiState,
|
|
14
|
+
type AvailableSubtitleConfigs,
|
|
15
|
+
getCurrentUiState,
|
|
16
|
+
onUiStateChanged,
|
|
17
|
+
startChannel,
|
|
18
|
+
stopChannel,
|
|
19
|
+
reconnect,
|
|
20
|
+
onAvailableSubtitleConfigsChanged,
|
|
21
|
+
onSubtitlesChanged,
|
|
22
|
+
getCurrentClaims,
|
|
23
|
+
BrandingView,
|
|
24
|
+
ErrorView,
|
|
25
|
+
ReconnectingView
|
|
26
|
+
} from 'livevoice-sdk-react-native';
|
|
27
|
+
|
|
28
|
+
import { useEffect, useState } from 'react';
|
|
29
|
+
import { View, ActivityIndicator } from 'react-native';
|
|
30
|
+
|
|
31
|
+
import { COLORS } from '../util/Colors';
|
|
32
|
+
import { type Channel } from '../util/UIState';
|
|
33
|
+
import { ChannelView } from './ChannelView';
|
|
34
|
+
|
|
35
|
+
export interface LiveVoiceViewProps {
|
|
36
|
+
isDarkMode?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({ isDarkMode }) => {
|
|
40
|
+
const [uiState, setUiState] = useState<UiState>((() => getCurrentUiState()))
|
|
41
|
+
|
|
42
|
+
useEffect(
|
|
43
|
+
() => { onUiStateChanged((data: UiState) => { setUiState(data); }); },
|
|
44
|
+
[]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
useEffect(
|
|
48
|
+
() => {
|
|
49
|
+
onAvailableSubtitleConfigsChanged((data: AvailableSubtitleConfigs) => {
|
|
50
|
+
console.log('available subtitles changed!' + JSON.stringify(data))
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
[]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
useEffect(
|
|
58
|
+
() => {
|
|
59
|
+
onSubtitlesChanged((data: [String]) => {
|
|
60
|
+
console.log('subtitles changed!' + JSON.stringify(data))
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
[]
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const claims = getCurrentClaims()
|
|
67
|
+
|
|
68
|
+
switch (uiState.type) {
|
|
69
|
+
case 'ready':
|
|
70
|
+
return (<View>
|
|
71
|
+
{uiState.channels.map((channel: Channel, index: number) => (
|
|
72
|
+
<ChannelView
|
|
73
|
+
key={index}
|
|
74
|
+
playingState={channel.playingState}
|
|
75
|
+
isDarkMode={isDarkMode}
|
|
76
|
+
muted={channel.isAudioMuted}
|
|
77
|
+
isOnline={channel.isOnline}
|
|
78
|
+
aiSpeaker={channel.isAiSpeaker}
|
|
79
|
+
channelName={channel.name}
|
|
80
|
+
onPress={() => channel.playingState === 'PLAYING' ? stopChannel() : startChannel(channel.id)}
|
|
81
|
+
/>
|
|
82
|
+
))}
|
|
83
|
+
|
|
84
|
+
{
|
|
85
|
+
(claims === null || !claims.hideBranding) && (
|
|
86
|
+
<BrandingView isDarkMode={isDarkMode} />)
|
|
87
|
+
}
|
|
88
|
+
</View>)
|
|
89
|
+
|
|
90
|
+
case 'loading':
|
|
91
|
+
const backgroundColor = isDarkMode ? COLORS.cardBgDark : COLORS.cardBg
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<View style={{
|
|
95
|
+
width: '100%',
|
|
96
|
+
padding: 10,
|
|
97
|
+
borderRadius: 8,
|
|
98
|
+
justifyContent: 'center',
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
backgroundColor: backgroundColor
|
|
101
|
+
}}>
|
|
102
|
+
<ActivityIndicator size={40} color={COLORS.primary} />
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
case 'error':
|
|
107
|
+
return (
|
|
108
|
+
<ErrorView state={uiState} onPress={() => { reconnect() }} />
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
case 'reconnecting':
|
|
112
|
+
return (
|
|
113
|
+
<ReconnectingView state={uiState} onPress={() => { reconnect() }} />
|
|
114
|
+
)
|
|
115
|
+
default:
|
|
116
|
+
return <View />
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default LiveVoiceView;
|
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { COLORS } from '../util/Colors';
|
|
13
|
+
import { ActivityIndicator, Image, TouchableOpacity, useColorScheme } from 'react-native'
|
|
14
|
+
import { PlayingState } from '../util/PlayingState';
|
|
15
|
+
|
|
16
|
+
export interface PlayButtonProps {
|
|
17
|
+
playingState: PlayingState;
|
|
18
|
+
isChannelOnline: boolean;
|
|
19
|
+
isDarkMode?: boolean;
|
|
20
|
+
onPress: () => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const PlayButtonView: React.FC<PlayButtonProps> = ({
|
|
24
|
+
playingState,
|
|
25
|
+
isChannelOnline,
|
|
26
|
+
isDarkMode = useColorScheme() === 'dark',
|
|
27
|
+
onPress,
|
|
28
|
+
|
|
29
|
+
}) => {
|
|
30
|
+
const isPlaying = playingState === PlayingState.PLAYING;
|
|
31
|
+
const isTransitioning = playingState === PlayingState.TRANSITIONING;
|
|
32
|
+
|
|
33
|
+
const iconColor = !isChannelOnline
|
|
34
|
+
? (isDarkMode ? '#585858' : '#dee2e6')
|
|
35
|
+
: isPlaying
|
|
36
|
+
? COLORS.primary
|
|
37
|
+
: COLORS.white;
|
|
38
|
+
|
|
39
|
+
const opacity = isChannelOnline ? 1 : 0.8;
|
|
40
|
+
|
|
41
|
+
const getButtonIcon = () => {
|
|
42
|
+
if (isTransitioning) {
|
|
43
|
+
return <ActivityIndicator size={20} color={iconColor} style={{ opacity }} />;
|
|
44
|
+
}
|
|
45
|
+
return isPlaying ? (
|
|
46
|
+
<Image
|
|
47
|
+
source={require('../icons/pause.png')}
|
|
48
|
+
style={[{tintColor: iconColor, width: 20, height: 20}]}
|
|
49
|
+
/>) : (
|
|
50
|
+
<Image
|
|
51
|
+
source={require('../icons/play.png')}
|
|
52
|
+
style={[{tintColor: iconColor, width: 20, height: 20}]}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const getStyleType = () => {
|
|
58
|
+
if (!isChannelOnline) return 'offline';
|
|
59
|
+
if (isPlaying) return 'playing';
|
|
60
|
+
return 'paused';
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<TouchableOpacity
|
|
65
|
+
style={[getButtonStyle(getStyleType(), isDarkMode), { opacity }]}
|
|
66
|
+
onPress={onPress}
|
|
67
|
+
activeOpacity={0.8}
|
|
68
|
+
>
|
|
69
|
+
{getButtonIcon()}
|
|
70
|
+
</TouchableOpacity>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type ButtonStyleType = 'paused' | 'playing' | 'offline';
|
|
75
|
+
|
|
76
|
+
export const getButtonStyle = (
|
|
77
|
+
type: ButtonStyleType,
|
|
78
|
+
isDarkMode: boolean
|
|
79
|
+
) => {
|
|
80
|
+
return ButtonStyles[type][isDarkMode ? 'dark' : 'light'];
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const baseButtonStyle = {
|
|
84
|
+
paddingVertical: 8,
|
|
85
|
+
paddingHorizontal: 18,
|
|
86
|
+
borderRadius: 10,
|
|
87
|
+
borderWidth: 2,
|
|
88
|
+
outlineStyle: 'solid' as const,
|
|
89
|
+
outlineWidth: 3,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const ButtonColorLight = {
|
|
93
|
+
orange: '#f56230',
|
|
94
|
+
orange_light: '#f67b51',
|
|
95
|
+
orange_dark: '#b93305',
|
|
96
|
+
|
|
97
|
+
errorBackground: '#f1f1f1',
|
|
98
|
+
|
|
99
|
+
playButtonBorderThinOffline: '#d1d1d6',
|
|
100
|
+
playButtonBorderThickOffline: '#f2f2f7',
|
|
101
|
+
playButtonIconOffline: '#dee2e6',
|
|
102
|
+
|
|
103
|
+
playButtonBorderThickOnline: '#f5623021',
|
|
104
|
+
playButtonIconOnline: '#ffffff',
|
|
105
|
+
playButtonFillOnline: '#f56230',
|
|
106
|
+
|
|
107
|
+
playButtonGlowPlaying: '#f56230b3',
|
|
108
|
+
playButtonBorderThickPlaying: '#f56230',
|
|
109
|
+
playButtonIconPlaying: '#f56230',
|
|
110
|
+
playButtonFillPlaying: '#ffffff',
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const ButtonColorDark = {
|
|
114
|
+
orange: '#f56230',
|
|
115
|
+
orange_light: '#f67b51',
|
|
116
|
+
orange_dark: '#b93305',
|
|
117
|
+
|
|
118
|
+
errorBackground: '#111111',
|
|
119
|
+
|
|
120
|
+
playButtonBorderThinOffline: '#212121',
|
|
121
|
+
playButtonBorderThickOffline: '#585858',
|
|
122
|
+
playButtonIconOffline: '#585858',
|
|
123
|
+
|
|
124
|
+
playButtonBorderThickOnline: '#77392421',
|
|
125
|
+
playButtonIconOnline: '#ffffff',
|
|
126
|
+
playButtonFillOnline: '#f56230',
|
|
127
|
+
|
|
128
|
+
playButtonGlowPlaying: '#f56230',
|
|
129
|
+
playButtonBorderThickPlaying: '#ff7433',
|
|
130
|
+
playButtonIconPlaying: '#f56230',
|
|
131
|
+
playButtonFillPlaying: '#ffffff',
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const ButtonStyles = {
|
|
135
|
+
paused: {
|
|
136
|
+
light: {
|
|
137
|
+
...baseButtonStyle,
|
|
138
|
+
backgroundColor: ButtonColorLight.playButtonFillOnline,
|
|
139
|
+
borderColor: 'transparent',
|
|
140
|
+
outlineColor: ButtonColorLight.playButtonBorderThickOnline,
|
|
141
|
+
},
|
|
142
|
+
dark: {
|
|
143
|
+
...baseButtonStyle,
|
|
144
|
+
backgroundColor: ButtonColorDark.playButtonFillOnline,
|
|
145
|
+
borderColor: 'transparent',
|
|
146
|
+
outlineColor: ButtonColorDark.playButtonBorderThickOnline,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
playing: {
|
|
151
|
+
light: {
|
|
152
|
+
...baseButtonStyle,
|
|
153
|
+
backgroundColor: ButtonColorLight.playButtonFillPlaying,
|
|
154
|
+
borderColor: ButtonColorLight.playButtonFillPlaying,
|
|
155
|
+
outlineColor: ButtonColorLight.playButtonBorderThickPlaying,
|
|
156
|
+
},
|
|
157
|
+
dark: {
|
|
158
|
+
...baseButtonStyle,
|
|
159
|
+
backgroundColor: ButtonColorDark.playButtonFillPlaying,
|
|
160
|
+
borderColor: ButtonColorDark.playButtonFillPlaying,
|
|
161
|
+
outlineColor: ButtonColorDark.playButtonBorderThickPlaying,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
offline: {
|
|
166
|
+
light: {
|
|
167
|
+
...baseButtonStyle,
|
|
168
|
+
backgroundColor: 'transparent',
|
|
169
|
+
borderColor: ButtonColorLight.playButtonBorderThinOffline,
|
|
170
|
+
outlineColor: ButtonColorLight.playButtonBorderThickOffline,
|
|
171
|
+
},
|
|
172
|
+
dark: {
|
|
173
|
+
...baseButtonStyle,
|
|
174
|
+
backgroundColor: 'transparent',
|
|
175
|
+
borderColor: ButtonColorDark.playButtonBorderThinOffline,
|
|
176
|
+
outlineColor: ButtonColorDark.playButtonBorderThickOffline,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export default PlayButtonView;
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React, { useEffect } from 'react';
|
|
13
|
+
import { View, Text, useColorScheme, StyleSheet, TouchableOpacity, ActivityIndicator } from 'react-native';
|
|
14
|
+
import { COLORS } from '../util/Colors';
|
|
15
|
+
|
|
16
|
+
import { type Reconnecting } from '../util/UIState';
|
|
17
|
+
import { Translations } from '../util/Translations';
|
|
18
|
+
|
|
19
|
+
export interface ReconnectingProps {
|
|
20
|
+
isDarkMode?: boolean
|
|
21
|
+
state: Reconnecting
|
|
22
|
+
onPress: () => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const ReconnectingView: React.FC<ReconnectingProps> = (props) => {
|
|
26
|
+
const isDarkMode = props.isDarkMode ?? useColorScheme() === 'dark';
|
|
27
|
+
const reconnectingState = props.state;
|
|
28
|
+
const isAttemptOngoing = reconnectingState.state.type === 'inProgress';
|
|
29
|
+
|
|
30
|
+
const [secUntilRetry, setSecUntilRetry] = React.useState(0);
|
|
31
|
+
|
|
32
|
+
//updated the countdown every second!
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const newValue = calculateSecondsUntilRetry(reconnectingState)
|
|
35
|
+
console.log('Updated seconds' + newValue)
|
|
36
|
+
setSecUntilRetry(newValue);
|
|
37
|
+
|
|
38
|
+
const interval = setInterval(() => {
|
|
39
|
+
const newValue = calculateSecondsUntilRetry(reconnectingState)
|
|
40
|
+
console.log('Updated seconds' + newValue)
|
|
41
|
+
setSecUntilRetry(newValue);
|
|
42
|
+
}, 1000);
|
|
43
|
+
|
|
44
|
+
return () => clearInterval(interval); // Clean up when unmounted
|
|
45
|
+
}, [reconnectingState]);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<View
|
|
49
|
+
style={[
|
|
50
|
+
styles.container,
|
|
51
|
+
isDarkMode ? { backgroundColor: COLORS.cardBgDark } : { backgroundColor: COLORS.cardBg }
|
|
52
|
+
]}>
|
|
53
|
+
|
|
54
|
+
<Text
|
|
55
|
+
style={[styles.text, isDarkMode ? styles.darkText : styles.lightText]}>
|
|
56
|
+
{reconnectingState.state.type === 'awaitingRetry'
|
|
57
|
+
? Translations.errorScreenRetryingIn(secUntilRetry)
|
|
58
|
+
: Translations.errorScreenRetrying()}
|
|
59
|
+
</Text>
|
|
60
|
+
|
|
61
|
+
{/* Retry-Button */}
|
|
62
|
+
<TouchableOpacity
|
|
63
|
+
onPress={props.onPress}
|
|
64
|
+
activeOpacity={0.9}
|
|
65
|
+
style={[
|
|
66
|
+
styles.button,
|
|
67
|
+
{
|
|
68
|
+
minWidth: 100, // fixed width, so it doesn't change size when showing the ActivityIndicator
|
|
69
|
+
backgroundColor: isDarkMode ? '#fff' : '#191919',
|
|
70
|
+
},
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
{isAttemptOngoing
|
|
74
|
+
? (
|
|
75
|
+
<ActivityIndicator
|
|
76
|
+
size='small'
|
|
77
|
+
color={isDarkMode ? '#191919' : '#fff'}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
: (
|
|
81
|
+
<Text
|
|
82
|
+
style={[
|
|
83
|
+
styles.buttonText,
|
|
84
|
+
isDarkMode ? styles.lightText : styles.darkText,
|
|
85
|
+
]}>
|
|
86
|
+
{Translations.errorRetryNowButton()}
|
|
87
|
+
</Text>
|
|
88
|
+
)}
|
|
89
|
+
</TouchableOpacity>
|
|
90
|
+
</View>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
function calculateSecondsUntilRetry(reconnectingState: Reconnecting): number {
|
|
95
|
+
return reconnectingState.state.type == 'awaitingRetry' ? Math.max(0, reconnectingState.state.atTimestamp - Date.now() / 1000) : 0
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const styles = StyleSheet.create({
|
|
99
|
+
container: {
|
|
100
|
+
paddingVertical: 30,
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
justifyContent: 'center',
|
|
103
|
+
borderRadius: 8,
|
|
104
|
+
width: '100%',
|
|
105
|
+
marginBottom: 10,
|
|
106
|
+
},
|
|
107
|
+
text: {
|
|
108
|
+
fontSize: 14,
|
|
109
|
+
fontWeight: '500',
|
|
110
|
+
textAlign: 'center',
|
|
111
|
+
},
|
|
112
|
+
dangerText: {
|
|
113
|
+
color: '#F1521B',
|
|
114
|
+
},
|
|
115
|
+
darkText: {
|
|
116
|
+
color: '#fff',
|
|
117
|
+
},
|
|
118
|
+
lightText: {
|
|
119
|
+
color: '#191919',
|
|
120
|
+
},
|
|
121
|
+
button: {
|
|
122
|
+
paddingHorizontal: 10,
|
|
123
|
+
paddingVertical: 8,
|
|
124
|
+
borderRadius: 8,
|
|
125
|
+
marginTop: 10,
|
|
126
|
+
},
|
|
127
|
+
buttonText: {
|
|
128
|
+
color: '#fff',
|
|
129
|
+
fontSize: 14,
|
|
130
|
+
fontWeight: '500',
|
|
131
|
+
textAlign: 'center',
|
|
132
|
+
},
|
|
133
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { View, Text, useColorScheme, StyleSheet } from 'react-native';
|
|
14
|
+
import { COLORS } from '../util/Colors';
|
|
15
|
+
|
|
16
|
+
export interface WarningProps {
|
|
17
|
+
isDarkMode?: boolean;
|
|
18
|
+
text?: string;
|
|
19
|
+
onPress: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const WarningView: React.FC<WarningProps> = (props) => {
|
|
23
|
+
const isDarkMode = props.isDarkMode ?? useColorScheme() === 'dark';
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View
|
|
27
|
+
style={[
|
|
28
|
+
styles.container,
|
|
29
|
+
isDarkMode ? { backgroundColor: COLORS.cardBgDark } : { backgroundColor: COLORS.cardBg }
|
|
30
|
+
]}
|
|
31
|
+
>
|
|
32
|
+
<Text
|
|
33
|
+
style={[styles.text, isDarkMode ? styles.darkText : styles.lightText]}
|
|
34
|
+
>
|
|
35
|
+
{props.text || 'No channels found'}
|
|
36
|
+
</Text>
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
container: {
|
|
43
|
+
paddingVertical: 30,
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
borderRadius: 8,
|
|
47
|
+
width: '100%',
|
|
48
|
+
marginBottom: 10,
|
|
49
|
+
},
|
|
50
|
+
text: {
|
|
51
|
+
fontSize: 14,
|
|
52
|
+
fontWeight: '500',
|
|
53
|
+
},
|
|
54
|
+
darkText: {
|
|
55
|
+
color: '#fff',
|
|
56
|
+
},
|
|
57
|
+
lightText: {
|
|
58
|
+
color: '#191919',
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
*/
|
|
11
|
+
|
|
12
|
+
export * from './AudioOutputSwitchView';
|
|
13
|
+
export * from './BrandingView';
|
|
14
|
+
export * from './ChannelView';
|
|
15
|
+
export * from './ErrorView';
|
|
16
|
+
export * from './LiveVoiceView';
|
|
17
|
+
export * from './PlayButtonView';
|
|
18
|
+
export * from './ReconnectingView';
|
|
19
|
+
export * from './WarningView';
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|