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
@@ -1,92 +1,386 @@
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 React, { useState } from 'react';
13
- import { View, Text, StyleSheet, TouchableOpacity, useColorScheme, Image } from 'react-native';
14
- import { COLORS } from '../util/Colors';
15
- import { type PlayingState } from '../util/PlayingState';
15
+ import {
16
+ View,
17
+ Text,
18
+ StyleSheet,
19
+ TouchableOpacity,
20
+ useColorScheme,
21
+ useWindowDimensions,
22
+ Image,
23
+ Platform,
24
+ type AccessibilityActionEvent,
25
+ type AccessibilityValue,
26
+ type TextStyle,
27
+ type ViewProps,
28
+ } from 'react-native';
29
+ import {
30
+ type CellAccessibility,
31
+ type CellActionKind,
32
+ type CellMuteMark,
33
+ type CellStatus,
34
+ } from '../sdk/LiveVoiceState';
35
+ import { type LiveVoicePlayingState } from '../sdk/Models';
16
36
  import PlayButtonView from './PlayButtonView';
17
37
 
18
38
 
19
39
  export interface ChannelProps {
20
40
  channelName: string;
21
- playingState: PlayingState;
22
- muted: boolean;
41
+ playingState: LiveVoicePlayingState;
23
42
  isOnline: boolean;
24
43
  hasAudio: boolean;
25
44
  hasSubtitles: boolean;
45
+ /** The status line under the name, as native computed it (bridge.md 2.4); `null` for none. */
46
+ status?: CellStatus | null;
47
+ /** The mute mark at the end of the row, as native computed it (bridge.md 2.4); `null` for none. */
48
+ muteMark?: CellMuteMark | null;
49
+ /** A password-protected channel: the lock at the end of the row. */
50
+ isPasswordProtected?: boolean;
26
51
  isDarkMode?: boolean;
52
+ /**
53
+ * Drawn at half strength while the connection briefly recovers. The audio tap still reaches
54
+ * the SDK, which decides; the subtitle tap does nothing meanwhile.
55
+ */
56
+ isDimmed?: boolean;
57
+ /** The event's brand colour for this appearance; LiveVoice orange when `null`. */
58
+ brandColor?: string | null;
59
+ /** Whether this channel's subtitles are the open ones: the play button marks its subtitle half. */
60
+ subtitlesOpen?: boolean;
61
+ /**
62
+ * The row's accessibility as native computed it (bridge.md 2.4). With it the row is one
63
+ * accessibility element that renders exactly this; without it the row has none, as before.
64
+ */
65
+ accessibility?: CellAccessibility | null;
27
66
  onAudioPress?: () => void;
28
67
  onSubtitlesPress?: () => void;
29
68
  }
30
69
 
70
+ /**
71
+ * The default channel cell, drawn as the native SDK of the platform draws its row (iOS
72
+ * `ChannelCellView` in the `.sdk` mode, Android `DefaultChannel`; change them together). Where
73
+ * the two natives differed in behaviour, both follow iOS: the status rule, the expanded name, the
74
+ * dimming during the reconnect grace.
75
+ */
31
76
  export const ChannelView: React.FC<ChannelProps> = ({
32
77
  channelName,
33
78
  playingState,
34
- muted,
35
79
  isOnline,
36
80
  hasAudio,
37
81
  hasSubtitles,
82
+ status = null,
83
+ muteMark = null,
84
+ isPasswordProtected = false,
38
85
  isDarkMode = useColorScheme() === 'dark',
86
+ isDimmed = false,
87
+ brandColor = null,
88
+ subtitlesOpen = false,
89
+ accessibility = null,
39
90
  onAudioPress,
40
91
  onSubtitlesPress,
41
92
  }) => {
42
93
 
43
- const [collapsed, setCollapsed] = useState(true);
94
+ const [isExpanded, setExpanded] = useState(false);
95
+ /** How many lines the whole name takes at the column's width. */
96
+ const [nameLines, setNameLines] = useState(1);
97
+ // As iOS: a tap opens a name that does not fit one line to at most 4, and the row then aligns
98
+ // to the top; one that fits stays as it is.
99
+ const isOpen = isExpanded && nameLines > 1;
100
+
101
+ const look = cellLook(isDarkMode, useWindowDimensions().fontScale);
44
102
 
45
- const iconColor = isDarkMode ? COLORS.white : COLORS.black
103
+ const onSubtitles = isDimmed ? () => {} : onSubtitlesPress;
104
+ // An accessibility action does what a tap on the matching half does.
105
+ const run = (kind: CellActionKind | null) => {
106
+ if (kind === 'toggleAudio') onAudioPress?.();
107
+ else if (kind === 'toggleSubtitles') onSubtitles?.();
108
+ };
46
109
 
47
110
  return (
48
- <View style={styles.container}>
49
- <PlayButtonView
50
- playingState={playingState}
51
- onAudioPress={onAudioPress}
52
- onSubtitlesPress={onSubtitlesPress}
53
- isDarkMode={isDarkMode}
54
- isChannelOnline={isOnline}
55
- hasAudio={hasAudio}
56
- hasSubtitles={hasSubtitles}
57
- />
111
+ <View {...(accessibility === null ? null : rowAccessibility(accessibility, run))}>
112
+ <View
113
+ style={[styles.container, { alignItems: isOpen ? 'flex-start' : 'center' }]}
114
+ {...(accessibility === null ? null : hiddenFromAccessibility)}
115
+ >
116
+ {/* Only the button dims during the reconnect grace. */}
117
+ <View style={[styles.button, { opacity: isDimmed ? 0.5 : 1 }]}>
118
+ <PlayButtonView
119
+ playingState={playingState}
120
+ onAudioPress={onAudioPress}
121
+ onSubtitlesPress={onSubtitles}
122
+ isDarkMode={isDarkMode}
123
+ isChannelOnline={isOnline}
124
+ hasAudio={hasAudio}
125
+ hasSubtitles={hasSubtitles}
126
+ brandColor={brandColor}
127
+ subtitlesOpen={subtitlesOpen}
128
+ />
129
+ </View>
58
130
 
59
- {/* Channel Name */}
60
- <View style={{ flex: 1, marginLeft: 10 }}>
61
- <TouchableOpacity onPress={() => setCollapsed(!collapsed)} activeOpacity={1}>
62
- <Text numberOfLines={collapsed ? 1 : undefined} ellipsizeMode='tail' style={[styles.text, { color: isDarkMode ? COLORS.white : COLORS.black }]}>
63
- {channelName}
64
- </Text>
131
+ <TouchableOpacity style={look.title} onPress={() => setExpanded(!isExpanded)} activeOpacity={1}>
132
+ <View>
133
+ <Text numberOfLines={isOpen ? 4 : 1} ellipsizeMode='tail' style={look.name}>
134
+ {channelName}
135
+ </Text>
136
+ {/* The whole name, unseen, to tell whether it fits one line. */}
137
+ <Text
138
+ style={[look.name, styles.measure]}
139
+ importantForAccessibility='no-hide-descendants'
140
+ accessibilityElementsHidden
141
+ onTextLayout={event => setNameLines(event.nativeEvent.lines.length)}
142
+ >
143
+ {channelName}
144
+ </Text>
145
+ </View>
146
+ {status !== null && (
147
+ <View style={look.statusRow}>
148
+ {status.showsAiIcon && (
149
+ <Image source={look.cpu.source} style={[look.cpu.style, { tintColor: look.status.color }]} />
150
+ )}
151
+ <Text numberOfLines={1} style={[look.status, status.showsAiIcon ? look.cpu.text : null]}>
152
+ {status.showsAiIcon ? look.cpu.before : ''}{status.text}
153
+ </Text>
154
+ </View>
155
+ )}
65
156
  </TouchableOpacity>
157
+ {look.spacer && <View style={styles.spacer} />}
158
+ {muteMark !== null && (
159
+ <View style={look.mute.frame}>
160
+ <Image source={look.mute[muteMark].source} style={look.mute[muteMark].style} />
161
+ </View>
162
+ )}
163
+ {isPasswordProtected && (
164
+ <View style={look.lock.frame}>
165
+ <Image source={look.lock.source} style={look.lock.style} />
166
+ </View>
167
+ )}
66
168
  </View>
67
- {
68
- muted &&
69
- <Image
70
- source={require('../icons/mic.png')}
71
- style={{ tintColor: iconColor, width: 20, height: 20, resizeMode: 'contain' }} />
72
- }
73
169
  </View>
74
170
  );
75
171
  };
76
172
 
173
+ /** The system grey of the mute mark and the lock: iOS `.gray`, Android `RawColors.systemGray`. */
174
+ const systemGray = '#8E8E93';
175
+
176
+ /**
177
+ * The row's type, colours and marks on this platform.
178
+ *
179
+ * - iOS (`ChannelCellView.swift`): the name `.headline` (17 pt semibold) in `.primary`; the status
180
+ * `.caption` (12 pt) in `.secondary`, `Text(Image("cpu")) + " " + Text(status)` for an AI
181
+ * speaker; the mute mark `mic.slash.fill` or `video.slash.fill` and the lock `lock.fill`, each at
182
+ * its natural size centred in a 30 pt frame, 12 apart and 12 after the flexible space (at least
183
+ * 8) that follows the name. The glyphs are UIKit's renders at `.body` and `.caption`, sized by
184
+ * their point sizes.
185
+ * - Android (`DefaultChannel.kt`, `ChannelNameAndStatus.kt`, `ChannelMuteIcon.kt`): the name
186
+ * `titleMedium` (16 sp, 500, line height 24, letter spacing 0.15) in `onBackground`; the status
187
+ * `bodySmall` (12 sp, line height 16, letter spacing 0.4) in `onBackgroundInactive`,
188
+ * `livevoice_ic_cpu` 16 dp and 4 dp before an AI speaker's; the mute mark
189
+ * `livevoice_ic_microphone_off` or `livevoice_ic_camera_off` 24 dp right after the name; the
190
+ * lock `livevoice_ic_lock` in a 30 dp frame with 5 dp padding, 12 dp after.
191
+ *
192
+ * `fontScale` is the system text size React Native applies to text; only the iOS `cpu` uses it, to
193
+ * keep its baseline on the text's.
194
+ */
195
+ function cellLook(isDarkMode: boolean, fontScale: number) {
196
+ if (Platform.OS === 'ios') {
197
+ // The `cpu` symbol in the caption line, as `Text(Image)`: its baseline, 2.33 above its bottom,
198
+ // on the text's, which lies the caption font's ascender (11.43 at 12 pt) below the line's top.
199
+ // Whichever of the two would start higher starts the row; the other moves down.
200
+ const cpuTop = 11.43 * fontScale - (40 / 3 - 7 / 3);
201
+ return {
202
+ name: { fontSize: 17, fontWeight: '600', color: isDarkMode ? '#FFFFFF' : '#000000' } as TextStyle,
203
+ status: {
204
+ fontSize: 12,
205
+ fontWeight: '400',
206
+ color: isDarkMode ? 'rgba(235, 235, 245, 0.6)' : 'rgba(60, 60, 67, 0.6)',
207
+ } as TextStyle,
208
+ statusRow: styles.statusIos,
209
+ cpu: {
210
+ source: require('../icons/cpu-ios.png'),
211
+ style: { width: 44 / 3, height: 40 / 3, marginTop: Math.max(0, cpuTop) },
212
+ text: { marginTop: Math.max(0, -cpuTop) },
213
+ // The space of `+ " " +`, in the caption font.
214
+ before: ' ',
215
+ },
216
+ // As wide as the name needs; the flexible space after it takes the rest.
217
+ title: styles.titleShrinks,
218
+ spacer: true,
219
+ mute: {
220
+ frame: styles.iosMark,
221
+ microphone: { source: require('../icons/mic-slash-ios.png'), style: { width: 17, height: 20, tintColor: systemGray } },
222
+ camera: { source: require('../icons/video-slash-ios.png'), style: { width: 25, height: 67 / 3, tintColor: systemGray } },
223
+ },
224
+ lock: {
225
+ frame: styles.iosMark,
226
+ source: require('../icons/lock-ios.png'),
227
+ style: { width: 16, height: 55 / 3, tintColor: systemGray },
228
+ },
229
+ };
230
+ }
231
+ return {
232
+ name: {
233
+ fontSize: 16,
234
+ fontWeight: '500',
235
+ lineHeight: 24,
236
+ letterSpacing: 0.15,
237
+ includeFontPadding: false,
238
+ color: isDarkMode ? '#FFFFFF' : '#191919',
239
+ } as TextStyle,
240
+ status: {
241
+ fontSize: 12,
242
+ fontWeight: '400',
243
+ lineHeight: 16,
244
+ letterSpacing: 0.4,
245
+ includeFontPadding: false,
246
+ color: isDarkMode ? '#8B9299' : '#6D757D',
247
+ } as TextStyle,
248
+ statusRow: styles.statusAndroid,
249
+ cpu: {
250
+ source: require('../icons/cpu-android.png'),
251
+ style: { width: 16, height: 16, marginRight: 4 },
252
+ text: null,
253
+ before: '',
254
+ },
255
+ // The rest of the row (`weight(1f)`), so the mute mark sits at its end.
256
+ title: styles.titleFills,
257
+ spacer: false,
258
+ mute: {
259
+ frame: styles.androidMute,
260
+ microphone: { source: require('../icons/mic-off-android.png'), style: { width: 24, height: 24, tintColor: systemGray } },
261
+ camera: { source: require('../icons/camera-off-android.png'), style: { width: 24, height: 24, tintColor: systemGray } },
262
+ },
263
+ lock: {
264
+ frame: styles.androidLock,
265
+ source: require('../icons/lock-android.png'),
266
+ style: { width: 20, height: 20, tintColor: systemGray },
267
+ },
268
+ };
269
+ }
270
+
271
+ /** The row's parts, which the row's own element speaks for. */
272
+ const hiddenFromAccessibility: ViewProps = {
273
+ importantForAccessibility: 'no-hide-descendants',
274
+ accessibilityElementsHidden: true,
275
+ };
276
+
277
+ /**
278
+ * React Native clears an Android view's whole content description, label included, when its
279
+ * `accessibilityValue` goes away, and keeps a stale value when one without `text` replaces it. An
280
+ * empty value is therefore a value whose `text` is `null`: no value on either platform.
281
+ */
282
+ const noValue = { text: null } as unknown as AccessibilityValue;
283
+
284
+ /**
285
+ * The row as one accessibility element, exactly as native computed it: its label, value, button
286
+ * role and selected state, what a double tap does, and the named actions in the native order.
287
+ *
288
+ * - iOS: VoiceOver's double tap is `onAccessibilityTap`, a no-op without an activation (the
289
+ * default would tap the row's middle). Every named action is a custom action, as the native row
290
+ * lists play or stop beside the double tap.
291
+ * - Android: TalkBack's double tap is the click, named after the activation's own action, as the
292
+ * native row's click label; TalkBack lists it with the actions, so the activation's entry
293
+ * becomes that click instead of a second action of the same name.
294
+ */
295
+ function rowAccessibility(accessibility: CellAccessibility, run: (kind: CellActionKind | null) => void): ViewProps {
296
+ const { activation } = accessibility;
297
+ const click = Platform.OS === 'android' && activation !== null
298
+ ? accessibility.actions.findIndex(action => action.kind === activation)
299
+ : -1;
300
+ const actions: Array<NonNullable<ViewProps['accessibilityActions']>[number]> = accessibility.actions.map((action, index) => ({
301
+ name: index === click ? 'activate' : action.kind,
302
+ label: action.name,
303
+ }));
304
+ if (Platform.OS === 'android' && activation !== null && click < 0) actions.unshift({ name: 'activate' });
305
+ return {
306
+ accessible: true,
307
+ accessibilityLabel: accessibility.label,
308
+ accessibilityValue: accessibility.value === '' ? noValue : { text: accessibility.value },
309
+ accessibilityRole: accessibility.isButton ? 'button' : undefined,
310
+ accessibilityState: { selected: accessibility.isSelected },
311
+ accessibilityActions: actions,
312
+ onAccessibilityTap: () => run(activation),
313
+ onAccessibilityAction: ({ nativeEvent: { actionName } }: AccessibilityActionEvent) => {
314
+ if (actionName === 'activate') run(activation);
315
+ else if (actionName === 'toggleAudio' || actionName === 'toggleSubtitles') run(actionName);
316
+ },
317
+ };
318
+ }
319
+
77
320
  const styles = StyleSheet.create({
321
+ // 12 at the sides (iOS `defaultCellInsets`, Android `padding(horizontal = 12.dp)`), 8 above and below.
78
322
  container: {
323
+ flexDirection: 'row',
324
+ paddingHorizontal: 12,
325
+ paddingVertical: 8,
326
+ },
327
+ // 2 above and below the button, so a row is 64 tall, and 12 to the name.
328
+ button: {
329
+ paddingVertical: 2,
330
+ marginRight: 12,
331
+ },
332
+ // The name and the status line.
333
+ titleShrinks: {
334
+ flexShrink: 1,
335
+ },
336
+ // Android: the rest of the row, 20 clear of the marks as iOS's spacing of 12 and Spacer of 8.
337
+ titleFills: {
338
+ flex: 1,
339
+ marginRight: 20,
340
+ },
341
+ measure: {
342
+ position: 'absolute',
343
+ left: 0,
344
+ right: 0,
345
+ top: 0,
346
+ opacity: 0,
347
+ },
348
+ // iOS: the `cpu` placed on the text's baseline from the top; Android: centred, as its `Row`.
349
+ statusIos: {
350
+ flexDirection: 'row',
351
+ alignItems: 'flex-start',
352
+ marginTop: 2,
353
+ },
354
+ statusAndroid: {
79
355
  flexDirection: 'row',
80
356
  alignItems: 'center',
81
- padding: 10,
357
+ marginTop: 2,
82
358
  },
83
- text: {
84
- fontSize: 16,
85
- fontWeight: '500',
359
+ // iOS's `Spacer()`: at least the default spacing of 8, 12 from the name beside it.
360
+ spacer: {
361
+ flexGrow: 1,
362
+ minWidth: 8,
363
+ marginLeft: 12,
364
+ },
365
+ iosMark: {
366
+ width: 30,
367
+ height: 30,
368
+ marginLeft: 12,
369
+ alignItems: 'center',
370
+ justifyContent: 'center',
371
+ },
372
+ // `ChannelMuteIcon`: the 24 dp glyph centred in a 30 dp frame, 12 after the name's gap.
373
+ androidMute: {
374
+ width: 30,
375
+ height: 30,
376
+ marginLeft: 12,
377
+ alignItems: 'center',
378
+ justifyContent: 'center',
86
379
  },
87
- aiText: {
88
- fontSize: 12,
89
- fontWeight: '400',
90
- marginLeft: 4,
380
+ androidLock: {
381
+ width: 30,
382
+ height: 30,
383
+ padding: 5,
384
+ marginLeft: 12,
91
385
  },
92
386
  });
@@ -1,31 +1,32 @@
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 React from 'react';
13
15
  import { View, Text, useColorScheme, StyleSheet, TouchableOpacity } from 'react-native';
14
16
  import { COLORS } from '../util/Colors';
15
17
  import { Translations } from '../util/Translations';
16
- import { type ErrorState } from '../util/UIState';
17
18
 
18
19
  export interface ErrorProps {
19
20
  isDarkMode?: boolean;
20
- state: ErrorState
21
- onPress: () => void;
21
+ /** The localised text of the error. */
22
+ message: string;
23
+ /** Present exactly when the error is retryable; shows the retry button. */
24
+ onRetry: (() => void) | null;
22
25
  }
23
26
 
27
+ /** The default error part. */
24
28
  export const ErrorView: React.FC<ErrorProps> = (props) => {
25
29
  const isDarkMode = props.isDarkMode ?? useColorScheme() === 'dark';
26
- const state = props.state;
27
-
28
- const canBeRetried = (state.type === 'error' && state.canBeRetried)
29
30
 
30
31
  return (
31
32
  <View
@@ -34,14 +35,12 @@ export const ErrorView: React.FC<ErrorProps> = (props) => {
34
35
  isDarkMode ? { backgroundColor: COLORS.cardBgDark } : { backgroundColor: COLORS.cardBg }
35
36
  ]}>
36
37
 
37
- <Text
38
- style={[styles.text, state.type === 'error' ? styles.dangerText : (isDarkMode ? styles.darkText : styles.lightText)]}>
39
- {state.message}
38
+ <Text style={[styles.text, styles.dangerText]}>
39
+ {props.message}
40
40
  </Text>
41
41
 
42
-
43
- {canBeRetried && (
44
- <TouchableOpacity onPress={props.onPress} activeOpacity={0.9} style={[styles.button, isDarkMode ? { backgroundColor: '#fff' } : { backgroundColor: '#191919' }]}>
42
+ {props.onRetry != null && (
43
+ <TouchableOpacity onPress={props.onRetry} activeOpacity={0.9} style={[styles.button, isDarkMode ? { backgroundColor: '#fff' } : { backgroundColor: '#191919' }]}>
45
44
  {/* text should be centered */}
46
45
  <Text style={[styles.buttonText, isDarkMode ? styles.lightText : styles.darkText]}>
47
46
  {Translations.errorRetryNowButton()}
@@ -0,0 +1,87 @@
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 React, { useEffect, useState } from "react";
15
+ import { StyleSheet, View } from "react-native";
16
+
17
+ const BAR_COUNT = 8;
18
+ /** Milliseconds per revolution. */
19
+ const PERIOD_MS = 1000;
20
+ /** Opacities by how many steps a bar is behind the lit one: the lit bar, then the two fading behind it. */
21
+ const OPACITIES = [1, 0.55, 0.25];
22
+ const TRACK_OPACITY = 0.15;
23
+ /** Bar width and length as fractions of the diameter; the mark's bars are about a quarter as wide as the shortest is tall. */
24
+ const BAR_WIDTH = 0.15;
25
+ const BAR_LENGTH = 0.32;
26
+
27
+ export interface LiveVoiceSpinnerProps {
28
+ /** The diameter, in points. */
29
+ size: number;
30
+ color: string;
31
+ }
32
+
33
+ /**
34
+ * A spinner in LiveVoice's own hand: the rounded bars of the mark, set around
35
+ * a circle like the iOS spinner's spokes. The lit bar steps round once a
36
+ * second, and the two bars behind it fade out over a faint track of the
37
+ * others. It keeps turning with reduced motion, like the system spinners.
38
+ *
39
+ * Mirrors the native SDKs' and the Flutter spinner; change them together.
40
+ */
41
+ export const LiveVoiceSpinner: React.FC<LiveVoiceSpinnerProps> = ({ size, color }) => {
42
+ const [lit, setLit] = useState(0);
43
+ useEffect(() => {
44
+ const timer = setInterval(
45
+ () => setLit((current) => (current + 1) % BAR_COUNT),
46
+ PERIOD_MS / BAR_COUNT,
47
+ );
48
+ return () => clearInterval(timer);
49
+ }, []);
50
+
51
+ const barWidth = size * BAR_WIDTH;
52
+ return (
53
+ <View
54
+ style={{ width: size, height: size }}
55
+ accessibilityElementsHidden
56
+ importantForAccessibility="no-hide-descendants"
57
+ >
58
+ {Array.from({ length: BAR_COUNT }, (_, index) => {
59
+ const behind = (lit - index + BAR_COUNT) % BAR_COUNT;
60
+ return (
61
+ <View
62
+ key={index}
63
+ style={[
64
+ StyleSheet.absoluteFill,
65
+ styles.spoke,
66
+ { transform: [{ rotate: `${(index * 360) / BAR_COUNT}deg` }] },
67
+ ]}
68
+ >
69
+ <View
70
+ style={{
71
+ width: barWidth,
72
+ height: size * BAR_LENGTH,
73
+ borderRadius: barWidth / 2,
74
+ backgroundColor: color,
75
+ opacity: OPACITIES[behind] ?? TRACK_OPACITY,
76
+ }}
77
+ />
78
+ </View>
79
+ );
80
+ })}
81
+ </View>
82
+ );
83
+ };
84
+
85
+ const styles = StyleSheet.create({
86
+ spoke: { alignItems: "center" },
87
+ });