livevoice-sdk-react-native 2.0.0 → 3.0.0

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 (221) hide show
  1. package/README.md +158 -7
  2. package/android/build.gradle +18 -6
  3. package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +121 -221
  4. package/android/src/main/java/io/livevoice/react/__SDK.kt +17 -3
  5. package/ios/LiveVoiceRNBridge.swift +362 -0
  6. package/ios/LiveVoiceSdkReactNative.mm +247 -145
  7. package/ios/__SDK.h +16 -2
  8. package/ios/livevoice_spm_backport.rb +202 -0
  9. package/lib/module/components/BrandingView.js +71 -50
  10. package/lib/module/components/BrandingView.js.map +1 -1
  11. package/lib/module/components/ChannelView.js +368 -54
  12. package/lib/module/components/ChannelView.js.map +1 -1
  13. package/lib/module/components/ErrorView.js +17 -16
  14. package/lib/module/components/ErrorView.js.map +1 -1
  15. package/lib/module/components/LiveVoiceSpinner.js +81 -0
  16. package/lib/module/components/LiveVoiceSpinner.js.map +1 -0
  17. package/lib/module/components/LiveVoiceView.js +351 -104
  18. package/lib/module/components/LiveVoiceView.js.map +1 -1
  19. package/lib/module/components/PasswordPrompt.js +165 -0
  20. package/lib/module/components/PasswordPrompt.js.map +1 -0
  21. package/lib/module/components/PlayButtonView.js +192 -254
  22. package/lib/module/components/PlayButtonView.js.map +1 -1
  23. package/lib/module/components/ReconnectingView.js +43 -62
  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/icons/branding-ios.png +0 -0
  28. package/lib/module/icons/camera-off-android.png +0 -0
  29. package/lib/module/icons/camera-off-android@2x.png +0 -0
  30. package/lib/module/icons/camera-off-android@3x.png +0 -0
  31. package/lib/module/icons/cpu-android.png +0 -0
  32. package/lib/module/icons/cpu-android@2x.png +0 -0
  33. package/lib/module/icons/cpu-android@3x.png +0 -0
  34. package/lib/module/icons/cpu-ios.png +0 -0
  35. package/lib/module/icons/cpu-ios@2x.png +0 -0
  36. package/lib/module/icons/cpu-ios@3x.png +0 -0
  37. package/lib/module/icons/lock-android.png +0 -0
  38. package/lib/module/icons/lock-android@2x.png +0 -0
  39. package/lib/module/icons/lock-android@3x.png +0 -0
  40. package/lib/module/icons/lock-ios.png +0 -0
  41. package/lib/module/icons/lock-ios@2x.png +0 -0
  42. package/lib/module/icons/lock-ios@3x.png +0 -0
  43. package/lib/module/icons/mic-off-android.png +0 -0
  44. package/lib/module/icons/mic-off-android@2x.png +0 -0
  45. package/lib/module/icons/mic-off-android@3x.png +0 -0
  46. package/lib/module/icons/mic-slash-ios.png +0 -0
  47. package/lib/module/icons/mic-slash-ios@2x.png +0 -0
  48. package/lib/module/icons/mic-slash-ios@3x.png +0 -0
  49. package/lib/module/icons/video-slash-ios.png +0 -0
  50. package/lib/module/icons/video-slash-ios@2x.png +0 -0
  51. package/lib/module/icons/video-slash-ios@3x.png +0 -0
  52. package/lib/module/index.js +24 -225
  53. package/lib/module/index.js.map +1 -1
  54. package/lib/module/sdk/Bridge.js +236 -0
  55. package/lib/module/sdk/Bridge.js.map +1 -0
  56. package/lib/module/sdk/Event.js +160 -0
  57. package/lib/module/sdk/Event.js.map +1 -0
  58. package/lib/module/sdk/Lifecycle.js +331 -0
  59. package/lib/module/sdk/Lifecycle.js.map +1 -0
  60. package/lib/module/sdk/LiveVoiceSdk.js +365 -0
  61. package/lib/module/sdk/LiveVoiceSdk.js.map +1 -0
  62. package/lib/module/sdk/LiveVoiceState.js +234 -0
  63. package/lib/module/sdk/LiveVoiceState.js.map +1 -0
  64. package/lib/module/sdk/LogEntries.js +99 -0
  65. package/lib/module/sdk/LogEntries.js.map +1 -0
  66. package/lib/module/sdk/Models.js +2 -0
  67. package/lib/module/{util/UIState.js.map → sdk/Models.js.map} +1 -1
  68. package/lib/module/sdk/NativeSdkVersions.js +24 -0
  69. package/lib/module/sdk/NativeSdkVersions.js.map +1 -0
  70. package/lib/module/sdk/Observables.js +391 -0
  71. package/lib/module/sdk/Observables.js.map +1 -0
  72. package/lib/module/sdk/Passwords.js +298 -0
  73. package/lib/module/sdk/Passwords.js.map +1 -0
  74. package/lib/module/sdk/Playback.js +35 -0
  75. package/lib/module/sdk/Playback.js.map +1 -0
  76. package/lib/module/specs/NativeLiveVoiceSdk.js +12 -10
  77. package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
  78. package/lib/module/util/Colors.js +14 -11
  79. package/lib/module/util/Colors.js.map +1 -1
  80. package/lib/module/util/Translations.js +46 -21
  81. package/lib/module/util/Translations.js.map +1 -1
  82. package/lib/module/util/freeze.js +26 -0
  83. package/lib/module/util/freeze.js.map +1 -0
  84. package/lib/module/util/logger.js +114 -0
  85. package/lib/module/util/logger.js.map +1 -0
  86. package/lib/typescript/src/components/BrandingView.d.ts +4 -0
  87. package/lib/typescript/src/components/BrandingView.d.ts.map +1 -1
  88. package/lib/typescript/src/components/ChannelView.d.ts +29 -3
  89. package/lib/typescript/src/components/ChannelView.d.ts.map +1 -1
  90. package/lib/typescript/src/components/ErrorView.d.ts +5 -3
  91. package/lib/typescript/src/components/ErrorView.d.ts.map +1 -1
  92. package/lib/typescript/src/components/LiveVoiceSpinner.d.ts +16 -0
  93. package/lib/typescript/src/components/LiveVoiceSpinner.d.ts.map +1 -0
  94. package/lib/typescript/src/components/LiveVoiceView.d.ts +85 -3
  95. package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -1
  96. package/lib/typescript/src/components/PasswordPrompt.d.ts +13 -0
  97. package/lib/typescript/src/components/PasswordPrompt.d.ts.map +1 -0
  98. package/lib/typescript/src/components/PlayButtonView.d.ts +12 -329
  99. package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -1
  100. package/lib/typescript/src/components/ReconnectingView.d.ts +6 -3
  101. package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -1
  102. package/lib/typescript/src/components/WarningView.d.ts.map +1 -1
  103. package/lib/typescript/src/index.d.ts +15 -144
  104. package/lib/typescript/src/index.d.ts.map +1 -1
  105. package/lib/typescript/src/sdk/Bridge.d.ts +36 -0
  106. package/lib/typescript/src/sdk/Bridge.d.ts.map +1 -0
  107. package/lib/typescript/src/sdk/Event.d.ts +97 -0
  108. package/lib/typescript/src/sdk/Event.d.ts.map +1 -0
  109. package/lib/typescript/src/sdk/Lifecycle.d.ts +191 -0
  110. package/lib/typescript/src/sdk/Lifecycle.d.ts.map +1 -0
  111. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +215 -0
  112. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -0
  113. package/lib/typescript/src/sdk/LiveVoiceState.d.ts +80 -0
  114. package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -0
  115. package/lib/typescript/src/sdk/LogEntries.d.ts +28 -0
  116. package/lib/typescript/src/sdk/LogEntries.d.ts.map +1 -0
  117. package/lib/typescript/src/sdk/Models.d.ts +114 -0
  118. package/lib/typescript/src/sdk/Models.d.ts.map +1 -0
  119. package/lib/typescript/src/sdk/NativeSdkVersions.d.ts +6 -0
  120. package/lib/typescript/src/sdk/NativeSdkVersions.d.ts.map +1 -0
  121. package/lib/typescript/src/sdk/Observables.d.ts +123 -0
  122. package/lib/typescript/src/sdk/Observables.d.ts.map +1 -0
  123. package/lib/typescript/src/sdk/Passwords.d.ts +72 -0
  124. package/lib/typescript/src/sdk/Passwords.d.ts.map +1 -0
  125. package/lib/typescript/src/sdk/Playback.d.ts +9 -0
  126. package/lib/typescript/src/sdk/Playback.d.ts.map +1 -0
  127. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts +35 -29
  128. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -1
  129. package/lib/typescript/src/util/Colors.d.ts.map +1 -1
  130. package/lib/typescript/src/util/Translations.d.ts +30 -8
  131. package/lib/typescript/src/util/Translations.d.ts.map +1 -1
  132. package/lib/typescript/src/util/freeze.d.ts +6 -0
  133. package/lib/typescript/src/util/freeze.d.ts.map +1 -0
  134. package/lib/typescript/src/util/logger.d.ts +33 -0
  135. package/lib/typescript/src/util/logger.d.ts.map +1 -0
  136. package/livevoice-sdk-react-native.podspec +41 -16
  137. package/package.json +26 -14
  138. package/src/components/BrandingView.tsx +55 -66
  139. package/src/components/ChannelView.tsx +342 -48
  140. package/src/components/ErrorView.tsx +21 -22
  141. package/src/components/LiveVoiceSpinner.tsx +87 -0
  142. package/src/components/LiveVoiceView.tsx +360 -151
  143. package/src/components/PasswordPrompt.tsx +144 -0
  144. package/src/components/PlayButtonView.tsx +177 -279
  145. package/src/components/ReconnectingView.tsx +40 -86
  146. package/src/components/WarningView.tsx +12 -10
  147. package/src/icons/branding-ios.png +0 -0
  148. package/src/icons/camera-off-android.png +0 -0
  149. package/src/icons/camera-off-android@2x.png +0 -0
  150. package/src/icons/camera-off-android@3x.png +0 -0
  151. package/src/icons/cpu-android.png +0 -0
  152. package/src/icons/cpu-android@2x.png +0 -0
  153. package/src/icons/cpu-android@3x.png +0 -0
  154. package/src/icons/cpu-ios.png +0 -0
  155. package/src/icons/cpu-ios@2x.png +0 -0
  156. package/src/icons/cpu-ios@3x.png +0 -0
  157. package/src/icons/lock-android.png +0 -0
  158. package/src/icons/lock-android@2x.png +0 -0
  159. package/src/icons/lock-android@3x.png +0 -0
  160. package/src/icons/lock-ios.png +0 -0
  161. package/src/icons/lock-ios@2x.png +0 -0
  162. package/src/icons/lock-ios@3x.png +0 -0
  163. package/src/icons/mic-off-android.png +0 -0
  164. package/src/icons/mic-off-android@2x.png +0 -0
  165. package/src/icons/mic-off-android@3x.png +0 -0
  166. package/src/icons/mic-slash-ios.png +0 -0
  167. package/src/icons/mic-slash-ios@2x.png +0 -0
  168. package/src/icons/mic-slash-ios@3x.png +0 -0
  169. package/src/icons/video-slash-ios.png +0 -0
  170. package/src/icons/video-slash-ios@2x.png +0 -0
  171. package/src/icons/video-slash-ios@3x.png +0 -0
  172. package/src/index.tsx +105 -252
  173. package/src/sdk/Bridge.ts +259 -0
  174. package/src/sdk/Event.ts +187 -0
  175. package/src/sdk/Lifecycle.ts +366 -0
  176. package/src/sdk/LiveVoiceSdk.ts +384 -0
  177. package/src/sdk/LiveVoiceState.ts +259 -0
  178. package/src/sdk/LogEntries.ts +88 -0
  179. package/src/sdk/Models.ts +129 -0
  180. package/src/sdk/NativeSdkVersions.ts +21 -0
  181. package/src/sdk/Observables.ts +414 -0
  182. package/src/sdk/Passwords.ts +286 -0
  183. package/src/sdk/Playback.ts +30 -0
  184. package/src/specs/NativeLiveVoiceSdk.ts +56 -46
  185. package/src/util/Colors.ts +14 -11
  186. package/src/util/Translations.ts +46 -22
  187. package/src/util/freeze.ts +23 -0
  188. package/src/util/logger.ts +119 -0
  189. package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeLiveVoiceSdkSpec.java +0 -186
  190. package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -28
  191. package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec-generated.cpp +0 -235
  192. package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec.h +0 -31
  193. package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +0 -341
  194. package/android/src/main/java/io/livevoice/react/Mappings.kt +0 -85
  195. package/android/src/main/java/io/livevoice/react/NativeModels.kt +0 -79
  196. package/lib/module/components/AudioOutputSwitchView.js +0 -138
  197. package/lib/module/components/AudioOutputSwitchView.js.map +0 -1
  198. package/lib/module/components/index.js +0 -22
  199. package/lib/module/components/index.js.map +0 -1
  200. package/lib/module/icons/mic.png +0 -0
  201. package/lib/module/util/ForegroundServiceConfig.js +0 -28
  202. package/lib/module/util/ForegroundServiceConfig.js.map +0 -1
  203. package/lib/module/util/PlayingState.js +0 -21
  204. package/lib/module/util/PlayingState.js.map +0 -1
  205. package/lib/module/util/UIState.js +0 -4
  206. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts +0 -6
  207. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +0 -1
  208. package/lib/typescript/src/components/index.d.ts +0 -9
  209. package/lib/typescript/src/components/index.d.ts.map +0 -1
  210. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +0 -12
  211. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +0 -1
  212. package/lib/typescript/src/util/PlayingState.d.ts +0 -7
  213. package/lib/typescript/src/util/PlayingState.d.ts.map +0 -1
  214. package/lib/typescript/src/util/UIState.d.ts +0 -66
  215. package/lib/typescript/src/util/UIState.d.ts.map +0 -1
  216. package/src/components/AudioOutputSwitchView.tsx +0 -146
  217. package/src/components/index.tsx +0 -19
  218. package/src/icons/mic.png +0 -0
  219. package/src/util/ForegroundServiceConfig.tsx +0 -32
  220. package/src/util/PlayingState.ts +0 -18
  221. package/src/util/UIState.ts +0 -89
@@ -0,0 +1,144 @@
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
+ //===----------------------------------------------------------------------===//
13
+
14
+ import { useEffect, useState } from 'react';
15
+ import { Modal, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
16
+
17
+ import { type PromptRequest } from '../sdk/Passwords';
18
+ import { COLORS } from '../util/Colors';
19
+ import { PasswordPromptTexts } from '../util/Translations';
20
+
21
+ export interface PasswordPromptProps {
22
+ request: PromptRequest;
23
+ isDarkMode: boolean;
24
+ /** The password, or `null` for Cancel. */
25
+ onAnswer: (password: string | null) => void;
26
+ }
27
+
28
+ /**
29
+ * The built-in password prompt, for channels and events alike. Its texts come from the native SDK;
30
+ * the title is the channel's or event's name, or "Password required" for a join.
31
+ */
32
+ export const PasswordPrompt: React.FC<PasswordPromptProps> = ({ request, isDarkMode, onAnswer }) => {
33
+ const [password, setPassword] = useState('');
34
+ // A new request starts empty.
35
+ useEffect(() => setPassword(''), [request.requestId]);
36
+
37
+ const isChannel = request.subject.kind === 'channel';
38
+ const text = isDarkMode ? COLORS.white : COLORS.black;
39
+ const confirm = () => { if (password.length > 0) onAnswer(password); };
40
+
41
+ return (
42
+ <Modal transparent animationType="fade" visible onRequestClose={() => onAnswer(null)}>
43
+ <View style={styles.backdrop}>
44
+ <View style={[styles.card, { backgroundColor: isDarkMode ? COLORS.cardBgDark : COLORS.cardBg }]}>
45
+ <Text accessibilityRole="header" style={[styles.title, { color: text }]}>
46
+ {request.name ?? PasswordPromptTexts.title()}
47
+ </Text>
48
+ <Text style={[styles.message, { color: text }]}>
49
+ {isChannel ? PasswordPromptTexts.channelMessage() : PasswordPromptTexts.eventMessage()}
50
+ </Text>
51
+ {request.isRetry && (
52
+ <Text accessibilityLiveRegion="polite" style={[styles.message, styles.wrong]}>
53
+ {PasswordPromptTexts.wrongPassword()}
54
+ </Text>
55
+ )}
56
+ <TextInput
57
+ value={password}
58
+ onChangeText={setPassword}
59
+ onSubmitEditing={confirm}
60
+ placeholder={PasswordPromptTexts.field()}
61
+ accessibilityLabel={PasswordPromptTexts.field()}
62
+ placeholderTextColor={isDarkMode ? '#8e8e93' : '#a0a0a5'}
63
+ secureTextEntry
64
+ autoFocus
65
+ autoCapitalize="none"
66
+ autoCorrect={false}
67
+ returnKeyType="go"
68
+ style={[styles.field, { color: text, borderColor: isDarkMode ? COLORS.dividerDark : COLORS.divider }]}
69
+ />
70
+ <View style={styles.buttons}>
71
+ <TouchableOpacity accessibilityRole="button" onPress={() => onAnswer(null)} style={styles.button}>
72
+ <Text style={[styles.buttonText, { color: text }]}>{PasswordPromptTexts.cancelButton()}</Text>
73
+ </TouchableOpacity>
74
+ <TouchableOpacity
75
+ accessibilityRole="button"
76
+ accessibilityState={{ disabled: password.length === 0 }}
77
+ disabled={password.length === 0}
78
+ onPress={confirm}
79
+ style={styles.button}
80
+ >
81
+ <Text style={[styles.buttonText, styles.confirm, { opacity: password.length === 0 ? 0.4 : 1 }]}>
82
+ {isChannel ? PasswordPromptTexts.channelConfirmButton() : PasswordPromptTexts.eventConfirmButton()}
83
+ </Text>
84
+ </TouchableOpacity>
85
+ </View>
86
+ </View>
87
+ </View>
88
+ </Modal>
89
+ );
90
+ };
91
+
92
+ const styles = StyleSheet.create({
93
+ backdrop: {
94
+ flex: 1,
95
+ justifyContent: 'center',
96
+ alignItems: 'center',
97
+ padding: 24,
98
+ backgroundColor: 'rgba(0, 0, 0, 0.4)',
99
+ },
100
+ card: {
101
+ width: '100%',
102
+ maxWidth: 360,
103
+ borderRadius: 14,
104
+ padding: 20,
105
+ },
106
+ title: {
107
+ fontSize: 17,
108
+ fontWeight: '600',
109
+ textAlign: 'center',
110
+ },
111
+ message: {
112
+ fontSize: 14,
113
+ textAlign: 'center',
114
+ marginTop: 8,
115
+ },
116
+ wrong: {
117
+ color: '#F1521B',
118
+ },
119
+ field: {
120
+ borderWidth: 1,
121
+ borderRadius: 8,
122
+ paddingHorizontal: 12,
123
+ paddingVertical: 10,
124
+ marginTop: 16,
125
+ fontSize: 16,
126
+ },
127
+ buttons: {
128
+ flexDirection: 'row',
129
+ justifyContent: 'flex-end',
130
+ marginTop: 16,
131
+ },
132
+ button: {
133
+ paddingHorizontal: 12,
134
+ paddingVertical: 8,
135
+ marginLeft: 8,
136
+ },
137
+ buttonText: {
138
+ fontSize: 16,
139
+ fontWeight: '500',
140
+ },
141
+ confirm: {
142
+ color: COLORS.primary,
143
+ },
144
+ });
@@ -1,26 +1,28 @@
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
- import { COLORS } from "../util/Colors";
13
14
  import {
14
- ActivityIndicator,
15
15
  Image,
16
+ Platform,
16
17
  TouchableOpacity,
17
18
  useColorScheme,
18
19
  View,
19
20
  } from "react-native";
20
- import { PlayingState } from "../util/PlayingState";
21
+ import { type LiveVoicePlayingState } from "../sdk/Models";
22
+ import { LiveVoiceSpinner } from "./LiveVoiceSpinner";
21
23
 
22
24
  export interface PlayButtonProps {
23
- playingState: PlayingState;
25
+ playingState: LiveVoicePlayingState;
24
26
  isChannelOnline: boolean;
25
27
  hasAudio?: boolean;
26
28
  hasSubtitles?: boolean;
@@ -28,8 +30,18 @@ export interface PlayButtonProps {
28
30
  onAudioPress?: () => void;
29
31
  onSubtitlesPress?: () => void;
30
32
  onPress?: () => void;
33
+ /** The event's brand colour for this appearance; LiveVoice orange when `null`. */
34
+ brandColor?: string | null;
35
+ /** Whether this channel's subtitles are the open ones: the subtitle half is marked. */
36
+ subtitlesOpen?: boolean;
31
37
  }
32
38
 
39
+ /**
40
+ * The default cell's play button, drawn as the native SDK of the platform draws it: iOS
41
+ * `ChannelPlayButton` in its `.sdk` style, Android `PlayButton` in the SDK cell's Listener style.
42
+ * Change them together. Geometry is the same on both; the colours are each platform's own
43
+ * (`buttonColors`).
44
+ */
33
45
  const PlayButtonView: React.FC<PlayButtonProps> = ({
34
46
  playingState,
35
47
  isChannelOnline,
@@ -39,72 +51,52 @@ const PlayButtonView: React.FC<PlayButtonProps> = ({
39
51
  onAudioPress,
40
52
  onSubtitlesPress,
41
53
  onPress,
54
+ brandColor = null,
55
+ subtitlesOpen = false,
42
56
  }) => {
43
- const isPlaying = playingState === PlayingState.PLAYING;
44
- const isTransitioning = playingState === PlayingState.TRANSITIONING;
45
-
46
- const getAudioIconColor = () => {
47
- if (!isChannelOnline) {
48
- return isDarkMode ? "#5a5a60" : "#d1d1d6";
49
- }
50
- return COLORS.white;
51
- };
52
-
53
- const getSubtitlesIconColor = () => {
54
- if (!isChannelOnline) {
55
- return isDarkMode ? "#ffffff" : "#000000";
56
- }
57
- return COLORS.white;
58
- };
59
-
60
- const audioIconColor = getAudioIconColor();
61
- const subtitlesIconColor = getSubtitlesIconColor();
62
-
63
- const getAudioIcon = () => {
64
- if (isTransitioning) {
65
- return <ActivityIndicator size={20} color={audioIconColor} style={{}} />;
66
- }
67
- return isPlaying ? (
68
- <Image
69
- source={require("../icons/pause.png")}
70
- style={[{ tintColor: audioIconColor, width: 30, height: 26 }]}
71
- />
72
- ) : (
73
- <Image
74
- source={require("../icons/play.png")}
75
- style={[{ tintColor: audioIconColor, width: 30, height: 26 }]}
76
- />
77
- );
78
- };
79
-
80
- const getSubtitlesIcon = () => {
81
- return (
57
+ const isPlaying = playingState === "playing";
58
+ const isTransitioning = playingState === "transitioning";
59
+ const colors = buttonColors(isDarkMode);
60
+
61
+ // Play, pause and the spinner share one colour by state, as both native glyphs do.
62
+ const glyphColor = isChannelOnline ? colors.onlineGlyph : colors.offlineGlyph;
63
+ const captionsColor = isChannelOnline ? colors.onlineGlyph : colors.offlineCaptions;
64
+ // The event's brand colour replaces the orange of an online button.
65
+ const fill = isChannelOnline ? brandColor ?? colors.onlineFill : colors.offlineFill;
66
+
67
+ const audioIcon = isTransitioning
68
+ ? <LiveVoiceSpinner size={22} color={glyphColor} />
69
+ : (
82
70
  <Image
83
- source={require("../icons/captions.png")}
84
- style={[{ tintColor: subtitlesIconColor, width: 30, height: 26 }]}
71
+ source={isPlaying ? require("../icons/pause.png") : require("../icons/play.png")}
72
+ style={[{ tintColor: glyphColor, width: 30, height: 26 }]}
85
73
  />
86
74
  );
87
- };
75
+ const subtitlesIcon = (
76
+ <Image
77
+ source={require("../icons/captions.png")}
78
+ style={[{ tintColor: captionsColor, width: 30, height: 26 }]}
79
+ />
80
+ );
88
81
 
89
- const getStyleType = () => {
90
- if (!isChannelOnline) return "offline";
91
- if (isPlaying) return "playing";
92
- return "paused";
93
- };
82
+ // Open subtitles mark the subtitle half with a capsule, as both native SDKs do.
83
+ const marker = (inset: number) => subtitlesOpen && (
84
+ <SubtitlesMarker inset={inset} color={isChannelOnline ? colors.onlineMarker : colors.offlineMarker} />
85
+ );
86
+ // The offline outline, over the button without taking any of its room.
87
+ const border = !isChannelOnline && <ButtonBorder color={colors.outline} />;
94
88
 
95
- // If no audio and no subtitles, render disabled button with dashed border
89
+ // Neither audio nor subtitles: a dashed outline and nothing to press.
96
90
  if (!hasAudio && !hasSubtitles) {
97
- const noContentStyle = {
98
- ...baseButtonStyleNoContent,
99
- backgroundColor: isDarkMode ? "#1c1c1e00" : "#ffffff",
100
- borderColor: isDarkMode
101
- ? COLORS_SCHEME.borderGrayDark
102
- : COLORS_SCHEME.borderGrayLight,
103
- borderStyle: "dashed" as const,
104
- };
105
91
  return (
106
92
  <TouchableOpacity
107
- style={noContentStyle}
93
+ style={{
94
+ ...buttonFrame,
95
+ borderWidth: colors.noInputBorderWidth,
96
+ borderColor: colors.outline,
97
+ borderStyle: "dashed",
98
+ backgroundColor: isChannelOnline && colors.noInputFillsWhenOnline ? fill : colors.noInputFill,
99
+ }}
108
100
  disabled={true}
109
101
  activeOpacity={0.8}
110
102
  >
@@ -113,262 +105,168 @@ const PlayButtonView: React.FC<PlayButtonProps> = ({
113
105
  );
114
106
  }
115
107
 
116
- // If only audio, render simple button
117
- if (hasAudio && !hasSubtitles) {
108
+ if (!hasSubtitles) {
118
109
  return (
119
110
  <TouchableOpacity
120
- style={getButtonStyle(getStyleType(), isDarkMode, false)}
111
+ style={[buttonFrame, { backgroundColor: fill }]}
121
112
  onPress={onAudioPress || onPress}
122
113
  activeOpacity={0.8}
123
114
  >
124
- {getAudioIcon()}
115
+ {audioIcon}
116
+ {border}
125
117
  </TouchableOpacity>
126
118
  );
127
119
  }
128
120
 
129
- // If only subtitles, render subtitles button
130
- if (!hasAudio && hasSubtitles) {
121
+ if (!hasAudio) {
131
122
  return (
132
123
  <TouchableOpacity
133
- style={getButtonStyle(getStyleType(), isDarkMode, false)}
124
+ style={[buttonFrame, { backgroundColor: fill }]}
134
125
  onPress={onSubtitlesPress || onPress}
135
126
  activeOpacity={0.8}
136
127
  >
137
- {getSubtitlesIcon()}
128
+ {marker(3)}
129
+ {subtitlesIcon}
130
+ {border}
138
131
  </TouchableOpacity>
139
132
  );
140
133
  }
141
134
 
142
- // If both audio and subtitles, render split button
135
+ // The divider keeps its slot but is clear while the channel plays or its subtitles are open.
136
+ const dividerColor = isPlaying || subtitlesOpen
137
+ ? "transparent"
138
+ : isChannelOnline ? colors.onlineDivider : colors.offlineDivider;
143
139
  return (
144
- <View style={getSplitButtonContainerStyle(getStyleType(), isDarkMode)}>
145
- <TouchableOpacity
146
- style={getSplitButtonAudioStyle(getStyleType(), isDarkMode)}
147
- onPress={onAudioPress || onPress}
148
- activeOpacity={0.8}
149
- >
150
- {getAudioIcon()}
140
+ <View style={[splitFrame, { backgroundColor: fill }]}>
141
+ <TouchableOpacity style={halfFrame} onPress={onAudioPress || onPress} activeOpacity={0.8}>
142
+ {audioIcon}
151
143
  </TouchableOpacity>
152
- <View style={getDividerStyle(getStyleType(), isDarkMode)} />
153
- <TouchableOpacity
154
- style={getSplitButtonSubtitlesStyle(getStyleType(), isDarkMode)}
155
- onPress={onSubtitlesPress || onPress}
156
- activeOpacity={0.8}
157
- >
158
- {getSubtitlesIcon()}
144
+ <View style={[dividerFrame, { backgroundColor: dividerColor }]} />
145
+ <TouchableOpacity style={halfFrame} onPress={onSubtitlesPress || onPress} activeOpacity={0.8}>
146
+ {marker(4)}
147
+ {subtitlesIcon}
159
148
  </TouchableOpacity>
149
+ {border}
160
150
  </View>
161
151
  );
162
152
  };
163
153
 
164
- type ButtonStyleType = "paused" | "playing" | "offline";
165
-
166
- export const getButtonStyle = (
167
- type: ButtonStyleType,
168
- isDarkMode: boolean,
169
- isSplit: boolean = false,
170
- ) => {
171
- if (isSplit) {
172
- return SplitButtonStyles[type][isDarkMode ? "dark" : "light"].container;
173
- }
174
- return ButtonStyles[type][isDarkMode ? "dark" : "light"];
175
- };
176
-
177
- export const getSplitButtonContainerStyle = (
178
- type: ButtonStyleType,
179
- isDarkMode: boolean,
180
- ) => {
181
- return SplitButtonStyles[type][isDarkMode ? "dark" : "light"].container;
182
- };
183
-
184
- export const getSplitButtonAudioStyle = (
185
- type: ButtonStyleType,
186
- isDarkMode: boolean,
187
- ) => {
188
- return SplitButtonStyles[type][isDarkMode ? "dark" : "light"].audio;
189
- };
190
-
191
- export const getSplitButtonSubtitlesStyle = (
192
- type: ButtonStyleType,
193
- isDarkMode: boolean,
194
- ) => {
195
- return SplitButtonStyles[type][isDarkMode ? "dark" : "light"].subtitles;
196
- };
197
-
198
- export const getDividerStyle = (type: ButtonStyleType, isDarkMode: boolean) => {
199
- // When button is online (orange background), divider is light orange
200
- if (type === "paused" || type === "playing") {
154
+ /**
155
+ * Every colour of the button, light or dark, as the native SDK of this platform has it.
156
+ *
157
+ * Both: LiveVoice orange online (iOS `.lvOrange`, Android `orange`); white glyphs online; the
158
+ * outline and the offline divider `#A0A0A0` / `#E0E0E0` at 50 % (iOS `.lightGrey.opacity(0.5)`,
159
+ * Android `playButtonOutline`); the online divider white at 30 %; the marker white at 25 % online,
160
+ * `#EAEAEF` / `#4E4E4E` offline (iOS `.outlineButtonBorder`, Android
161
+ * `selectedCaptionsBackgroundOffline`).
162
+ *
163
+ * - iOS (`ChannelPlayButton`, `.sdk`): offline fill `.clear`; offline play glyph, pause and spinner
164
+ * `.lightGrey.opacity(0.5)`; offline captions `.primary`.
165
+ * - Android (`PlayButton`, Listener, in `LvAppTheme`): offline fill `background` (`white`,
166
+ * `veryDarkGray`); offline play glyph, pause and spinner `buttonIconInactive` (`veryLightGray`,
167
+ * `darkGray`); offline captions `onBackground` (`lightBlack`, `white`).
168
+ * - The button without input follows iOS on both: filled as an online button when its channel is
169
+ * online, clear otherwise, with a 1 pt dashed outline (Android is changing to match).
170
+ */
171
+ function buttonColors(isDarkMode: boolean) {
172
+ const outline = isDarkMode ? "rgba(224, 224, 224, 0.5)" : "rgba(160, 160, 160, 0.5)";
173
+ const shared = {
174
+ onlineFill: "#F56230",
175
+ onlineGlyph: "#FFFFFF",
176
+ outline,
177
+ onlineDivider: "rgba(255, 255, 255, 0.3)",
178
+ offlineDivider: outline,
179
+ onlineMarker: "rgba(255, 255, 255, 0.25)",
180
+ offlineMarker: isDarkMode ? "#4E4E4E" : "#EAEAEF",
181
+ // Without audio or subtitles, both as iOS: filled as an online button when the channel is
182
+ // online, clear otherwise, and always the 1 pt dashed outline.
183
+ noInputFill: "transparent",
184
+ noInputFillsWhenOnline: true,
185
+ noInputBorderWidth: 1,
186
+ };
187
+ if (Platform.OS === "ios") {
201
188
  return {
202
- width: 1,
203
- height: 24,
204
- backgroundColor: COLORS_SCHEME.dividerOnOrange,
189
+ ...shared,
190
+ offlineFill: "transparent",
191
+ offlineGlyph: outline,
192
+ offlineCaptions: isDarkMode ? "#FFFFFF" : "#000000",
205
193
  };
206
194
  }
207
-
208
- // When button is offline, divider is gray (same as border)
195
+ const background = isDarkMode ? "#212529" : "#FFFFFF";
209
196
  return {
210
- width: 1,
211
- height: 24,
212
- backgroundColor: isDarkMode
213
- ? COLORS_SCHEME.borderGrayDark
214
- : COLORS_SCHEME.borderGrayLight,
197
+ ...shared,
198
+ offlineFill: background,
199
+ offlineGlyph: isDarkMode ? "#343A40" : "#E7E7E7",
200
+ offlineCaptions: isDarkMode ? "#FFFFFF" : "#191919",
215
201
  };
216
- };
217
-
218
- const baseButtonStyle = {
219
- width: 96,
220
- height: 44,
221
- borderRadius: 22,
222
- borderWidth: 1,
223
- alignItems: "center" as const,
224
- justifyContent: "center" as const,
225
- };
202
+ }
226
203
 
227
- const baseButtonStyleNoContent = {
204
+ /**
205
+ * The open-subtitles marker, drawn as the native SDKs draw it: a capsule inset `inset` from the
206
+ * subtitle half's own bounds, 4 beside the play half and 3 on a subtitles-only button.
207
+ */
208
+ const SubtitlesMarker: React.FC<{ inset: number; color: string }> = ({ inset, color }) => (
209
+ <View
210
+ style={{
211
+ position: "absolute",
212
+ top: inset,
213
+ bottom: inset,
214
+ left: inset,
215
+ right: inset,
216
+ borderRadius: (buttonFrame.height - 2 * inset) / 2,
217
+ backgroundColor: color,
218
+ }}
219
+ />
220
+ );
221
+
222
+ /**
223
+ * The offline button's 1 pt outline, drawn over the button as both native SDKs stroke it (iOS
224
+ * `strokeBorder` in the button's background, Android `Modifier.border`), so it insets nothing: the
225
+ * halves fill the whole 96 × 44 button and the glyphs sit where native puts them. Online, iOS draws
226
+ * none and Android strokes it in the fill's own colour, so none is drawn here.
227
+ */
228
+ const ButtonBorder: React.FC<{ color: string }> = ({ color }) => (
229
+ <View
230
+ pointerEvents="none"
231
+ style={{
232
+ position: "absolute",
233
+ top: 0,
234
+ bottom: 0,
235
+ left: 0,
236
+ right: 0,
237
+ borderRadius: buttonFrame.borderRadius,
238
+ borderWidth: 1,
239
+ borderColor: color,
240
+ }}
241
+ />
242
+ );
243
+
244
+ // No border of their own: an offline outline is `ButtonBorder`, which takes no room.
245
+ const buttonFrame = {
228
246
  width: 96,
229
247
  height: 44,
230
248
  borderRadius: 22,
231
- borderWidth: 1,
232
249
  alignItems: "center" as const,
233
250
  justifyContent: "center" as const,
234
251
  };
235
252
 
236
- const baseSplitButtonStyle = {
237
- width: 96,
238
- height: 44,
239
- borderRadius: 22,
240
- borderWidth: 1,
253
+ const splitFrame = {
254
+ ...buttonFrame,
241
255
  flexDirection: "row" as const,
242
- alignItems: "center" as const,
243
- justifyContent: "center" as const,
244
256
  overflow: "hidden" as const,
245
257
  };
246
258
 
247
- const baseSplitAudioStyle = {
259
+ const halfFrame = {
248
260
  flex: 1,
249
261
  height: 44,
250
262
  alignItems: "center" as const,
251
263
  justifyContent: "center" as const,
252
264
  };
253
265
 
254
- const baseSplitSubtitlesStyle = {
255
- flex: 1,
256
- height: 44,
257
- alignItems: "center" as const,
258
- justifyContent: "center" as const,
259
- };
260
-
261
- const COLORS_SCHEME = {
262
- orange: "#f56230",
263
- dividerOnOrange: "#ffffff80",
264
- borderGrayLight: "#d1d1d6",
265
- borderGrayDark: "#5a5a60",
266
- };
267
-
268
- export const ButtonStyles = {
269
- paused: {
270
- light: {
271
- ...baseButtonStyle,
272
- backgroundColor: COLORS_SCHEME.orange,
273
- borderColor: "transparent",
274
- },
275
- dark: {
276
- ...baseButtonStyle,
277
- backgroundColor: COLORS_SCHEME.orange,
278
- borderColor: "transparent",
279
- },
280
- },
281
-
282
- playing: {
283
- light: {
284
- ...baseButtonStyle,
285
- backgroundColor: COLORS_SCHEME.orange,
286
- borderColor: "transparent",
287
- },
288
- dark: {
289
- ...baseButtonStyle,
290
- backgroundColor: COLORS_SCHEME.orange,
291
- borderColor: "transparent",
292
- },
293
- },
294
-
295
- offline: {
296
- light: {
297
- ...baseButtonStyle,
298
- backgroundColor: "#ffffff",
299
- borderColor: COLORS_SCHEME.borderGrayLight,
300
- },
301
- dark: {
302
- ...baseButtonStyle,
303
- backgroundColor: "#212429",
304
- borderColor: COLORS_SCHEME.borderGrayDark,
305
- },
306
- },
307
- };
308
-
309
- export const SplitButtonStyles = {
310
- paused: {
311
- light: {
312
- container: {
313
- ...baseSplitButtonStyle,
314
- backgroundColor: COLORS_SCHEME.orange,
315
- borderColor: "transparent",
316
- },
317
- audio: baseSplitAudioStyle,
318
- subtitles: baseSplitSubtitlesStyle,
319
- },
320
- dark: {
321
- container: {
322
- ...baseSplitButtonStyle,
323
- backgroundColor: COLORS_SCHEME.orange,
324
- borderColor: "transparent",
325
- },
326
- audio: baseSplitAudioStyle,
327
- subtitles: baseSplitSubtitlesStyle,
328
- },
329
- },
330
-
331
- playing: {
332
- light: {
333
- container: {
334
- ...baseSplitButtonStyle,
335
- backgroundColor: COLORS_SCHEME.orange,
336
- borderColor: "transparent",
337
- },
338
- audio: baseSplitAudioStyle,
339
- subtitles: baseSplitSubtitlesStyle,
340
- },
341
- dark: {
342
- container: {
343
- ...baseSplitButtonStyle,
344
- backgroundColor: COLORS_SCHEME.orange,
345
- borderColor: "transparent",
346
- },
347
- audio: baseSplitAudioStyle,
348
- subtitles: baseSplitSubtitlesStyle,
349
- },
350
- },
351
-
352
- offline: {
353
- light: {
354
- container: {
355
- ...baseSplitButtonStyle,
356
- backgroundColor: "#ffffff",
357
- borderColor: COLORS_SCHEME.borderGrayLight,
358
- },
359
- audio: baseSplitAudioStyle,
360
- subtitles: baseSplitSubtitlesStyle,
361
- },
362
- dark: {
363
- container: {
364
- ...baseSplitButtonStyle,
365
- backgroundColor: "#212429",
366
- borderColor: COLORS_SCHEME.borderGrayDark,
367
- },
368
- audio: baseSplitAudioStyle,
369
- subtitles: baseSplitSubtitlesStyle,
370
- },
371
- },
266
+ // 26 tall, 9 from the top and bottom of the 44 button, as in both native SDKs.
267
+ const dividerFrame = {
268
+ width: 1,
269
+ height: 26,
372
270
  };
373
271
 
374
272
  export default PlayButtonView;