react-native-visit-rn-sdk 6.0.4 → 7.1.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 (79) hide show
  1. package/README.md +297 -191
  2. package/android/build.gradle +4 -1
  3. package/android/gradle.properties +4 -4
  4. package/android/src/main/AndroidManifest.xml +11 -5
  5. package/android/src/main/AndroidManifestNew.xml +11 -5
  6. package/android/src/main/java/com/visitrnsdk/VisitFitnessModule.kt +642 -0
  7. package/android/src/main/java/com/visitrnsdk/VisitRnSdkPackage.kt +1 -1
  8. package/android/src/main/java/com/visitrnsdk/VisitSessionStorage.kt +50 -0
  9. package/ios/VisitRnSdkViewManager.h +23 -1
  10. package/ios/VisitRnSdkViewManager.m +1259 -8
  11. package/lib/commonjs/index.android.js +328 -205
  12. package/lib/commonjs/index.android.js.map +1 -1
  13. package/lib/commonjs/index.ios.js +159 -116
  14. package/lib/commonjs/index.ios.js.map +1 -1
  15. package/lib/module/index.android.js +328 -206
  16. package/lib/module/index.android.js.map +1 -1
  17. package/lib/module/index.ios.js +161 -117
  18. package/lib/module/index.ios.js.map +1 -1
  19. package/lib/typescript/index.android.d.ts +8 -3
  20. package/lib/typescript/index.android.d.ts.map +1 -1
  21. package/lib/typescript/index.ios.d.ts +6 -3
  22. package/lib/typescript/index.ios.d.ts.map +1 -1
  23. package/package.json +18 -26
  24. package/react-native-visit-rn-sdk.podspec +2 -1
  25. package/src/index.android.js +579 -0
  26. package/src/index.ios.js +284 -0
  27. package/android/src/main/java/com/visitrnsdk/VisitRnSdkLocationModule.kt +0 -37
  28. package/lib/commonjs/assets/video-call/connecting-lottie.gif +0 -0
  29. package/lib/commonjs/assets/video-call/end-call.png +0 -0
  30. package/lib/commonjs/assets/video-call/mic-off.png +0 -0
  31. package/lib/commonjs/assets/video-call/reconnecting.gif +0 -0
  32. package/lib/commonjs/assets/video-call/switch-camera.png +0 -0
  33. package/lib/commonjs/assets/video-call/toggle-down.png +0 -0
  34. package/lib/commonjs/assets/video-call/toggle-up.png +0 -0
  35. package/lib/commonjs/assets/video-call/video-off.png +0 -0
  36. package/lib/commonjs/components/VideoCallComponent.js +0 -1088
  37. package/lib/commonjs/components/VideoCallComponent.js.map +0 -1
  38. package/lib/commonjs/index.js +0 -6
  39. package/lib/commonjs/index.js.map +0 -1
  40. package/lib/commonjs/shims.d.js +0 -2
  41. package/lib/commonjs/shims.d.js.map +0 -1
  42. package/lib/commonjs/types.js +0 -2
  43. package/lib/commonjs/types.js.map +0 -1
  44. package/lib/module/assets/video-call/connecting-lottie.gif +0 -0
  45. package/lib/module/assets/video-call/end-call.png +0 -0
  46. package/lib/module/assets/video-call/mic-off.png +0 -0
  47. package/lib/module/assets/video-call/reconnecting.gif +0 -0
  48. package/lib/module/assets/video-call/switch-camera.png +0 -0
  49. package/lib/module/assets/video-call/toggle-down.png +0 -0
  50. package/lib/module/assets/video-call/toggle-up.png +0 -0
  51. package/lib/module/assets/video-call/video-off.png +0 -0
  52. package/lib/module/components/VideoCallComponent.js +0 -1081
  53. package/lib/module/components/VideoCallComponent.js.map +0 -1
  54. package/lib/module/index.js +0 -2
  55. package/lib/module/index.js.map +0 -1
  56. package/lib/module/shims.d.js +0 -2
  57. package/lib/module/shims.d.js.map +0 -1
  58. package/lib/module/types.js +0 -2
  59. package/lib/module/types.js.map +0 -1
  60. package/lib/typescript/components/VideoCallComponent.d.ts +0 -79
  61. package/lib/typescript/components/VideoCallComponent.d.ts.map +0 -1
  62. package/lib/typescript/index.d.ts +0 -17
  63. package/lib/typescript/index.d.ts.map +0 -1
  64. package/lib/typescript/types.d.ts +0 -24
  65. package/lib/typescript/types.d.ts.map +0 -1
  66. package/src/assets/video-call/connecting-lottie.gif +0 -0
  67. package/src/assets/video-call/end-call.png +0 -0
  68. package/src/assets/video-call/mic-off.png +0 -0
  69. package/src/assets/video-call/reconnecting.gif +0 -0
  70. package/src/assets/video-call/switch-camera.png +0 -0
  71. package/src/assets/video-call/toggle-down.png +0 -0
  72. package/src/assets/video-call/toggle-up.png +0 -0
  73. package/src/assets/video-call/video-off.png +0 -0
  74. package/src/components/VideoCallComponent.tsx +0 -1484
  75. package/src/index.android.tsx +0 -459
  76. package/src/index.ios.tsx +0 -238
  77. package/src/index.tsx +0 -25
  78. package/src/shims.d.ts +0 -49
  79. package/src/types.ts +0 -25
@@ -1,1484 +0,0 @@
1
- import React, {
2
- forwardRef,
3
- useCallback,
4
- useEffect,
5
- useImperativeHandle,
6
- useRef,
7
- useState,
8
- type Ref,
9
- } from 'react';
10
- import {
11
- Alert,
12
- Animated,
13
- Dimensions,
14
- Image,
15
- LayoutAnimation,
16
- Linking,
17
- PanResponder,
18
- PermissionsAndroid,
19
- Platform,
20
- Pressable,
21
- StatusBar,
22
- StyleSheet,
23
- Text,
24
- TouchableOpacity,
25
- UIManager,
26
- View,
27
- type ImageSourcePropType,
28
- type StyleProp,
29
- type ViewStyle,
30
- } from 'react-native';
31
- import {
32
- TwilioVideo,
33
- TwilioVideoLocalView,
34
- TwilioVideoParticipantView,
35
- } from '@twilio/video-react-native-sdk';
36
-
37
- const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('screen');
38
- const LOCAL_PREVIEW_WIDTH = 120;
39
- const LOCAL_PREVIEW_HEIGHT = 180;
40
- const LOCAL_PREVIEW_SIDE_MARGIN = 16;
41
- const LOCAL_PREVIEW_MAX_BOTTOM_OFFSET = 224;
42
- const LOCAL_PREVIEW_BOTTOM_DRAG_ALLOWANCE = 56;
43
- const VIDEO_CALL_ERROR_STATUS = Object.freeze({
44
- MISSING_ROOM_NAME_OR_ACCESS_TOKEN: 'MISSING_ROOM_NAME_OR_ACCESS_TOKEN',
45
- PERMISSIONS_REQUIRED: 'PERMISSIONS_REQUIRED',
46
- PERMISSION_CHECK_FAILED: 'PERMISSION_CHECK_FAILED',
47
- INVALID_OR_EXPIRED_TOKEN: 'INVALID_OR_EXPIRED_TOKEN',
48
- CONNECT_FAILED: 'CONNECT_FAILED',
49
- });
50
-
51
- export type VideoCallErrorStatus =
52
- (typeof VIDEO_CALL_ERROR_STATUS)[keyof typeof VIDEO_CALL_ERROR_STATUS];
53
-
54
- export type VideoCallStartParams = {
55
- roomName: string;
56
- accessToken: string;
57
- doctorName?: string;
58
- visibleDoctorName?: string;
59
- userName?: string;
60
- };
61
-
62
- export type VideoCallConnectedInfo = {
63
- roomName?: string;
64
- };
65
-
66
- export type VideoCallEndedInfo = {
67
- reason?: string;
68
- error?: unknown;
69
- };
70
-
71
- export type VideoCallErrorInfo = {
72
- status: VideoCallErrorStatus;
73
- error?: unknown;
74
- metadata?: Record<string, unknown>;
75
- };
76
-
77
- export type VideoCallLowNetworkQualityInfo = {
78
- quality: number;
79
- participant: 'local' | 'remote';
80
- };
81
-
82
- type RemoteTrackIdentifier = {
83
- participantSid: string;
84
- videoTrackSid: string;
85
- };
86
-
87
- type CallStatus =
88
- | 'idle'
89
- | 'connecting'
90
- | 'connected'
91
- | 'participantDisconnected';
92
-
93
- type VideoCallState = {
94
- isVisible: boolean;
95
- loading: boolean;
96
- status: CallStatus;
97
- roomName: string;
98
- accessToken: string;
99
- remoteTrackSid: string;
100
- remoteTrackIdentifier: RemoteTrackIdentifier | null;
101
- participantVideoEnabled: boolean;
102
- participantAudioEnabled: boolean;
103
- isMuted: boolean;
104
- isVideoEnabled: boolean;
105
- isFrontCameraEnabled: boolean;
106
- signalStrength: number | null;
107
- participantSignalStrength: number | null;
108
- showLowSignalStrengthMessage: boolean;
109
- showParticipantReconnectingScreen: boolean;
110
- showUserReconnectingScreen: boolean;
111
- showBottomBar: boolean;
112
- durationMins: string;
113
- durationSecs: string;
114
- doctorName: string;
115
- visibleDoctorName: string;
116
- userName: string;
117
- };
118
-
119
- export type VideoCallComponentProps = {
120
- onCallConnected?: (info: VideoCallConnectedInfo) => void;
121
- onCallEnded?: (info: VideoCallEndedInfo) => void;
122
- onError?: (info: VideoCallErrorInfo) => void;
123
- onLowNetworkQuality?: (info: VideoCallLowNetworkQualityInfo) => void;
124
- onStateChange?: (state: VideoCallState) => void;
125
- style?: StyleProp<ViewStyle>;
126
- };
127
-
128
- export type VideoCallComponentHandle = {
129
- startVideoCall: (params: VideoCallStartParams) => void;
130
- endCall: () => void;
131
- isConnected: () => boolean;
132
- };
133
-
134
- type CallRef = {
135
- roomJoined: boolean;
136
- unmounted: boolean;
137
- onCallEnded?: (info: VideoCallEndedInfo) => void;
138
- };
139
-
140
- type TwilioVideoHandle = {
141
- connect: (options: Record<string, unknown>) => void;
142
- disconnect: () => void;
143
- setLocalAudioEnabled: (enabled: boolean) => Promise<boolean>;
144
- setLocalVideoEnabled: (enabled: boolean) => Promise<boolean>;
145
- flipCamera: () => void;
146
- };
147
-
148
- type TrackEvent = {
149
- participant?: { sid?: string };
150
- track?: { trackSid?: string; enabled?: boolean };
151
- };
152
-
153
- type RoomConnectEvent = {
154
- roomName?: string;
155
- error?: unknown;
156
- message?: string;
157
- };
158
-
159
- type NetworkQualityEvent = {
160
- isLocalUser?: boolean;
161
- quality: number;
162
- };
163
-
164
- type SignalStrengthIndicatorProps = {
165
- strength: number;
166
- participantLabel: string;
167
- };
168
-
169
- type ControlButtonProps = {
170
- label: string;
171
- onPress: () => void;
172
- danger?: boolean;
173
- icon?: ImageSourcePropType;
174
- customIconText?: string;
175
- active?: boolean;
176
- iconSize?: number;
177
- useTouchableOpacity?: boolean;
178
- };
179
-
180
- const ICONS = {
181
- mute: require('../assets/video-call/mic-off.png') as ImageSourcePropType,
182
- videoOff:
183
- require('../assets/video-call/video-off.png') as ImageSourcePropType,
184
- flip: require('../assets/video-call/switch-camera.png') as ImageSourcePropType,
185
- end: require('../assets/video-call/end-call.png') as ImageSourcePropType,
186
- connecting:
187
- require('../assets/video-call/connecting-lottie.gif') as ImageSourcePropType,
188
- reconnecting:
189
- require('../assets/video-call/reconnecting.gif') as ImageSourcePropType,
190
- toggleUp:
191
- require('../assets/video-call/toggle-up.png') as ImageSourcePropType,
192
- toggleDown:
193
- require('../assets/video-call/toggle-down.png') as ImageSourcePropType,
194
- };
195
-
196
- const initialCallState: VideoCallState = {
197
- isVisible: false,
198
- loading: false,
199
- status: 'idle',
200
- roomName: '',
201
- accessToken: '',
202
- remoteTrackSid: '',
203
- remoteTrackIdentifier: null,
204
- participantVideoEnabled: false,
205
- participantAudioEnabled: true,
206
- isMuted: false,
207
- isVideoEnabled: true,
208
- isFrontCameraEnabled: true,
209
- signalStrength: null,
210
- participantSignalStrength: null,
211
- showLowSignalStrengthMessage: false,
212
- showParticipantReconnectingScreen: false,
213
- showUserReconnectingScreen: false,
214
- showBottomBar: true,
215
- durationMins: '00',
216
- durationSecs: '00',
217
- doctorName: '',
218
- visibleDoctorName: '',
219
- userName: '',
220
- };
221
-
222
- const VideoCallComponent = forwardRef(function VideoCallComponentInner(
223
- {
224
- onCallConnected,
225
- onCallEnded,
226
- onError,
227
- onLowNetworkQuality,
228
- onStateChange,
229
- style,
230
- }: VideoCallComponentProps,
231
- ref: Ref<VideoCallComponentHandle>
232
- ) {
233
- const twilioVideoRef = useRef<TwilioVideoHandle | null>(null);
234
- const durationTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);
235
- const timerRunningRef = useRef(false);
236
- const reconnectingTimerRef = useRef<ReturnType<typeof setInterval> | null>(
237
- null
238
- );
239
- const localPreviewRefreshTimeoutRef = useRef<ReturnType<
240
- typeof setTimeout
241
- > | null>(null);
242
- const localPreviewSecondRefreshTimeoutRef = useRef<ReturnType<
243
- typeof setTimeout
244
- > | null>(null);
245
- const localPreviewDrag = useRef(new Animated.ValueXY({ x: 0, y: 0 })).current;
246
- const localPreviewDragOffsetRef = useRef({ x: 0, y: 0 });
247
- const callRef = useRef<CallRef>({ roomJoined: false, unmounted: false });
248
- callRef.current.onCallEnded = onCallEnded;
249
- const [state, setState] = useState<VideoCallState>(initialCallState);
250
- const [localPreviewRefreshKey, setLocalPreviewRefreshKey] = useState(0);
251
-
252
- const maxHorizontalDrag =
253
- SCREEN_WIDTH - LOCAL_PREVIEW_WIDTH - LOCAL_PREVIEW_SIDE_MARGIN * 2;
254
- const maxUpwardDrag = Math.max(
255
- 0,
256
- SCREEN_HEIGHT - LOCAL_PREVIEW_HEIGHT - LOCAL_PREVIEW_MAX_BOTTOM_OFFSET
257
- );
258
- const maxDownwardDrag = LOCAL_PREVIEW_BOTTOM_DRAG_ALLOWANCE;
259
- const clampDrag = useCallback(
260
- (value: number, min: number, max: number) =>
261
- Math.min(Math.max(value, min), max),
262
- []
263
- );
264
-
265
- const localPreviewPanResponder = useRef(
266
- PanResponder.create({
267
- onMoveShouldSetPanResponder: (_, gestureState) =>
268
- Math.abs(gestureState.dx) > 2 || Math.abs(gestureState.dy) > 2,
269
- onPanResponderMove: (_, gestureState) => {
270
- const nextX = clampDrag(
271
- localPreviewDragOffsetRef.current.x + gestureState.dx,
272
- -maxHorizontalDrag,
273
- 0
274
- );
275
- const nextY = clampDrag(
276
- localPreviewDragOffsetRef.current.y + gestureState.dy,
277
- -maxUpwardDrag,
278
- maxDownwardDrag
279
- );
280
- localPreviewDrag.setValue({ x: nextX, y: nextY });
281
- },
282
- onPanResponderRelease: (_, gestureState) => {
283
- const nextX = clampDrag(
284
- localPreviewDragOffsetRef.current.x + gestureState.dx,
285
- -maxHorizontalDrag,
286
- 0
287
- );
288
- const nextY = clampDrag(
289
- localPreviewDragOffsetRef.current.y + gestureState.dy,
290
- -maxUpwardDrag,
291
- maxDownwardDrag
292
- );
293
- localPreviewDragOffsetRef.current = { x: nextX, y: nextY };
294
- localPreviewDrag.setValue(localPreviewDragOffsetRef.current);
295
- },
296
- })
297
- ).current;
298
-
299
- useEffect(() => {
300
- if (
301
- Platform.OS === 'android' &&
302
- UIManager.setLayoutAnimationEnabledExperimental
303
- ) {
304
- UIManager.setLayoutAnimationEnabledExperimental(true);
305
- }
306
- }, []);
307
-
308
- const clearDurationTimer = useCallback(() => {
309
- timerRunningRef.current = false;
310
- if (durationTimerRef.current) {
311
- clearInterval(durationTimerRef.current);
312
- durationTimerRef.current = null;
313
- }
314
- }, []);
315
-
316
- const clearReconnectTimer = useCallback(() => {
317
- if (reconnectingTimerRef.current) {
318
- clearInterval(reconnectingTimerRef.current);
319
- reconnectingTimerRef.current = null;
320
- }
321
- }, []);
322
-
323
- const clearLocalPreviewRefreshTimers = useCallback(() => {
324
- if (localPreviewRefreshTimeoutRef.current) {
325
- clearTimeout(localPreviewRefreshTimeoutRef.current);
326
- localPreviewRefreshTimeoutRef.current = null;
327
- }
328
- if (localPreviewSecondRefreshTimeoutRef.current) {
329
- clearTimeout(localPreviewSecondRefreshTimeoutRef.current);
330
- localPreviewSecondRefreshTimeoutRef.current = null;
331
- }
332
- }, []);
333
-
334
- const refreshLocalPreview = useCallback(() => {
335
- setLocalPreviewRefreshKey((prev) => prev + 1);
336
- }, []);
337
-
338
- const emitState = useCallback(
339
- (nextState: VideoCallState) => {
340
- if (onStateChange) {
341
- onStateChange(nextState);
342
- }
343
- },
344
- [onStateChange]
345
- );
346
-
347
- const emitErrorStatus = useCallback(
348
- (
349
- status: VideoCallErrorStatus,
350
- error?: unknown,
351
- metadata: Record<string, unknown> = {}
352
- ) => {
353
- if (!onError) {
354
- return;
355
- }
356
- onError({
357
- status,
358
- error,
359
- metadata,
360
- });
361
- },
362
- [onError]
363
- );
364
-
365
- const updateState = useCallback(
366
- (
367
- updater:
368
- | Partial<VideoCallState>
369
- | ((prev: VideoCallState) => VideoCallState)
370
- ) => {
371
- setState((prev) => {
372
- const next =
373
- typeof updater === 'function'
374
- ? updater(prev)
375
- : { ...prev, ...updater };
376
- emitState(next);
377
- return next;
378
- });
379
- },
380
- [emitState]
381
- );
382
-
383
- const leaveVideo = useCallback(
384
- (reason?: string, error?: unknown) => {
385
- clearDurationTimer();
386
- clearReconnectTimer();
387
- clearLocalPreviewRefreshTimers();
388
- if (callRef.current.unmounted) {
389
- return;
390
- }
391
- callRef.current.roomJoined = false;
392
- setState(() => {
393
- const finalState = JSON.parse(
394
- JSON.stringify(initialCallState)
395
- ) as VideoCallState;
396
- emitState(finalState);
397
- return finalState;
398
- });
399
- if (onCallEnded) {
400
- onCallEnded({ reason, error });
401
- }
402
- },
403
- [
404
- clearDurationTimer,
405
- clearReconnectTimer,
406
- clearLocalPreviewRefreshTimers,
407
- emitState,
408
- onCallEnded,
409
- ]
410
- );
411
-
412
- const startDurationTimer = useCallback(() => {
413
- timerRunningRef.current = true;
414
- if (durationTimerRef.current) {
415
- return;
416
- }
417
- durationTimerRef.current = setInterval(() => {
418
- if (!timerRunningRef.current) {
419
- return;
420
- }
421
- updateState((prev) => {
422
- let secs = parseInt(prev.durationSecs, 10) + 1;
423
- let mins = parseInt(prev.durationMins, 10);
424
- if (secs >= 60) {
425
- mins += 1;
426
- secs = 0;
427
- }
428
- return {
429
- ...prev,
430
- durationMins: mins < 10 ? `0${mins}` : String(mins),
431
- durationSecs: secs < 10 ? `0${secs}` : String(secs),
432
- };
433
- });
434
- }, 1000);
435
- }, [updateState]);
436
-
437
- const checkAndroidVideoPermissions = useCallback(async () => {
438
- if (Platform.OS !== 'android') {
439
- return true;
440
- }
441
-
442
- try {
443
- const cameraPermission = PermissionsAndroid.PERMISSIONS.CAMERA!;
444
- const micPermission = PermissionsAndroid.PERMISSIONS.RECORD_AUDIO!;
445
-
446
- const hasCamera = await PermissionsAndroid.check(cameraPermission);
447
- const hasMic = await PermissionsAndroid.check(micPermission);
448
- if (hasCamera && hasMic) {
449
- return true;
450
- }
451
-
452
- const permissionResults = await PermissionsAndroid.requestMultiple([
453
- cameraPermission,
454
- micPermission,
455
- ]);
456
- const isCameraGranted =
457
- permissionResults[cameraPermission] ===
458
- PermissionsAndroid.RESULTS.GRANTED;
459
- const isMicGranted =
460
- permissionResults[micPermission] === PermissionsAndroid.RESULTS.GRANTED;
461
- if (isCameraGranted && isMicGranted) {
462
- return true;
463
- }
464
-
465
- const missing = [];
466
- if (!isCameraGranted) {
467
- missing.push('camera');
468
- }
469
- if (!isMicGranted) {
470
- missing.push('microphone');
471
- }
472
-
473
- Alert.alert(
474
- 'Permissions required',
475
- `Please allow ${missing.join(
476
- ' and '
477
- )} access to start a video call. You can enable this in Settings.`,
478
- [
479
- { text: 'Cancel', style: 'cancel' },
480
- { text: 'Open Settings', onPress: () => Linking.openSettings() },
481
- ]
482
- );
483
-
484
- emitErrorStatus(
485
- VIDEO_CALL_ERROR_STATUS.PERMISSIONS_REQUIRED,
486
- new Error(
487
- 'Camera and microphone permissions are required to start a video call.'
488
- )
489
- );
490
- return false;
491
- } catch (error) {
492
- Alert.alert(
493
- 'Permission error',
494
- 'Unable to check camera and microphone permissions. Please try again or open Settings to grant access.',
495
- [
496
- { text: 'Cancel', style: 'cancel' },
497
- { text: 'Open Settings', onPress: () => Linking.openSettings() },
498
- ]
499
- );
500
- emitErrorStatus(VIDEO_CALL_ERROR_STATUS.PERMISSION_CHECK_FAILED, error, {
501
- message: 'Unable to check camera and microphone permissions.',
502
- });
503
- return false;
504
- }
505
- }, [emitErrorStatus]);
506
-
507
- const connectToRoom = useCallback(
508
- async ({
509
- roomName,
510
- accessToken,
511
- doctorName,
512
- visibleDoctorName,
513
- userName,
514
- }: VideoCallStartParams) => {
515
- if (!roomName || !accessToken) {
516
- const err = new Error('roomName and accessToken are required');
517
- emitErrorStatus(
518
- VIDEO_CALL_ERROR_STATUS.MISSING_ROOM_NAME_OR_ACCESS_TOKEN,
519
- err
520
- );
521
- return;
522
- }
523
-
524
- const canStartCall = await checkAndroidVideoPermissions();
525
- if (!canStartCall) {
526
- return;
527
- }
528
-
529
- callRef.current.roomJoined = false;
530
- callRef.current.unmounted = false;
531
- localPreviewDragOffsetRef.current = { x: 0, y: 0 };
532
- localPreviewDrag.setValue({ x: 0, y: 0 });
533
- refreshLocalPreview();
534
- const visible =
535
- visibleDoctorName != null && visibleDoctorName !== ''
536
- ? visibleDoctorName
537
- : doctorName || '';
538
- updateState((prev) => ({
539
- ...prev,
540
- isVisible: true,
541
- loading: true,
542
- status: 'connecting',
543
- roomName,
544
- accessToken,
545
- doctorName: doctorName || '',
546
- visibleDoctorName: visible,
547
- userName: userName || '',
548
- durationMins: '00',
549
- durationSecs: '00',
550
- }));
551
- setTimeout(() => {
552
- twilioVideoRef.current?.connect({
553
- accessToken,
554
- roomName,
555
- cameraType: 'front',
556
- enableNetworkQualityReporting: true,
557
- });
558
- }, 600);
559
- },
560
- [
561
- localPreviewDrag,
562
- refreshLocalPreview,
563
- checkAndroidVideoPermissions,
564
- updateState,
565
- emitErrorStatus,
566
- ]
567
- );
568
-
569
- const endCall = useCallback(() => {
570
- twilioVideoRef.current?.disconnect();
571
- leaveVideo('ended-by-user');
572
- }, [leaveVideo]);
573
-
574
- useImperativeHandle(
575
- ref,
576
- (): VideoCallComponentHandle => ({
577
- startVideoCall: ({
578
- roomName,
579
- accessToken,
580
- doctorName,
581
- visibleDoctorName,
582
- userName,
583
- }) =>
584
- connectToRoom({
585
- roomName,
586
- accessToken,
587
- doctorName,
588
- visibleDoctorName,
589
- userName,
590
- }),
591
- endCall,
592
- isConnected: () => state.isVisible,
593
- }),
594
- [connectToRoom, endCall, state.isVisible]
595
- );
596
-
597
- useEffect(() => {
598
- callRef.current.unmounted = false;
599
- return () => {
600
- const wasJoined = callRef.current.roomJoined;
601
- callRef.current.unmounted = true;
602
- callRef.current.roomJoined = false;
603
- clearDurationTimer();
604
- clearReconnectTimer();
605
- clearLocalPreviewRefreshTimers();
606
- // Intentionally read current refs on unmount to disconnect an active room.
607
- // eslint-disable-next-line react-hooks/exhaustive-deps
608
- twilioVideoRef.current?.disconnect();
609
- if (wasJoined) {
610
- // eslint-disable-next-line react-hooks/exhaustive-deps
611
- callRef.current.onCallEnded?.({ reason: 'component-unmount' });
612
- }
613
- };
614
- }, [clearDurationTimer, clearReconnectTimer, clearLocalPreviewRefreshTimers]);
615
-
616
- const onRoomDidConnect = ({ roomName }: RoomConnectEvent) => {
617
- console.log('onRoomDidConnect', roomName);
618
- callRef.current.roomJoined = true;
619
- updateState((prev) => ({
620
- ...prev,
621
- loading: false,
622
- status: 'connected',
623
- showUserReconnectingScreen: false,
624
- }));
625
- clearReconnectTimer();
626
- if (onCallConnected) {
627
- onCallConnected({ roomName });
628
- }
629
-
630
- // Twilio local preview can miss the first bind on some Android devices.
631
- // Force a couple of refresh passes right after connect.
632
- clearLocalPreviewRefreshTimers();
633
- refreshLocalPreview();
634
- localPreviewRefreshTimeoutRef.current = setTimeout(() => {
635
- twilioVideoRef.current?.setLocalVideoEnabled(true);
636
- refreshLocalPreview();
637
- }, 220);
638
- localPreviewSecondRefreshTimeoutRef.current = setTimeout(() => {
639
- refreshLocalPreview();
640
- }, 700);
641
- };
642
-
643
- const onRoomDidDisconnect = ({ error }: RoomConnectEvent) => {
644
- leaveVideo('room-disconnected', error);
645
- };
646
-
647
- const onRoomDidFailToConnect = (error: RoomConnectEvent) => {
648
- const errorMessage = String(error?.error || error?.message || '');
649
-
650
- const hasTokenError = errorMessage?.toLowerCase()?.includes('token');
651
- if (hasTokenError) {
652
- Alert.alert(
653
- 'Unable to join call',
654
- 'Your video session token is invalid or has expired.',
655
- [{ text: 'OK' }]
656
- );
657
- emitErrorStatus(VIDEO_CALL_ERROR_STATUS.INVALID_OR_EXPIRED_TOKEN, error);
658
- leaveVideo('connect-failed', error);
659
- return;
660
- }
661
- emitErrorStatus(VIDEO_CALL_ERROR_STATUS.CONNECT_FAILED, error);
662
- leaveVideo('connect-failed', error);
663
- };
664
-
665
- const onParticipantAddedVideoTrack = ({ participant, track }: TrackEvent) => {
666
- updateState((prev) => {
667
- if (prev.remoteTrackSid) {
668
- return prev;
669
- }
670
- return {
671
- ...prev,
672
- remoteTrackSid: track?.trackSid ?? '',
673
- remoteTrackIdentifier: {
674
- participantSid: participant?.sid ?? '',
675
- videoTrackSid: track?.trackSid ?? '',
676
- },
677
- participantVideoEnabled: !!track?.enabled,
678
- loading: false,
679
- status: 'connected',
680
- };
681
- });
682
- startDurationTimer();
683
- };
684
-
685
- const onParticipantRemovedVideoTrack = ({ track }: TrackEvent) => {
686
- updateState((prev) => {
687
- if (track?.trackSid !== prev.remoteTrackSid) {
688
- return prev;
689
- }
690
- timerRunningRef.current = false;
691
- return {
692
- ...prev,
693
- remoteTrackSid: '',
694
- remoteTrackIdentifier: null,
695
- status: 'participantDisconnected',
696
- };
697
- });
698
- };
699
-
700
- const onParticipantDisabledVideoTrack = (event: TrackEvent) => {
701
- updateState((prev) => ({
702
- ...prev,
703
- participantVideoEnabled: !!event.track?.enabled,
704
- }));
705
- };
706
-
707
- const onParticipantEnabledVideoTrack = (event: TrackEvent) => {
708
- updateState((prev) => ({
709
- ...prev,
710
- participantVideoEnabled: !!event.track?.enabled,
711
- }));
712
- };
713
-
714
- const onParticipantAudioToggled = (event: TrackEvent) => {
715
- updateState((prev) => ({
716
- ...prev,
717
- participantAudioEnabled: !!event.track?.enabled,
718
- }));
719
- };
720
-
721
- const onNetworkQualityLevelsChanged = (payload: NetworkQualityEvent) => {
722
- if (payload.isLocalUser) {
723
- const isLow = payload.quality > 0 && payload.quality < 3;
724
- updateState((prev) => ({
725
- ...prev,
726
- signalStrength: payload.quality,
727
- showLowSignalStrengthMessage: isLow,
728
- showUserReconnectingScreen: false,
729
- }));
730
- if (isLow && onLowNetworkQuality) {
731
- onLowNetworkQuality({ quality: payload.quality, participant: 'local' });
732
- }
733
- } else {
734
- updateState((prev) => ({
735
- ...prev,
736
- participantSignalStrength: payload.quality,
737
- showParticipantReconnectingScreen: payload.quality <= 1,
738
- }));
739
- }
740
- };
741
-
742
- const onMuteButtonPress = () => {
743
- twilioVideoRef.current
744
- ?.setLocalAudioEnabled(state.isMuted)
745
- .then((enabled: boolean) => {
746
- updateState((prev) => ({ ...prev, isMuted: !enabled }));
747
- });
748
- };
749
-
750
- const onVideoToggle = () => {
751
- twilioVideoRef.current
752
- ?.setLocalVideoEnabled(!state.isVideoEnabled)
753
- .then((enabled: boolean) => {
754
- console.log('onVideoToggle', enabled);
755
- updateState((prev) => ({ ...prev, isVideoEnabled: enabled }));
756
- })
757
- .catch((error: unknown) => {
758
- console.error('Error toggling video:', error);
759
- });
760
- };
761
-
762
- const onFlipButtonPress = () => {
763
- twilioVideoRef.current?.flipCamera();
764
- updateState((prev) => ({
765
- ...prev,
766
- isFrontCameraEnabled: !prev.isFrontCameraEnabled,
767
- }));
768
- };
769
-
770
- const onRoomReconnectingWithError = () => {
771
- updateState((prev) => ({
772
- ...prev,
773
- showUserReconnectingScreen: true,
774
- }));
775
- clearReconnectTimer();
776
- reconnectingTimerRef.current = setInterval(() => {
777
- const { accessToken, roomName, isMuted, isVideoEnabled } = state;
778
- if (!accessToken || !roomName) {
779
- return;
780
- }
781
- twilioVideoRef.current?.connect({
782
- accessToken,
783
- roomName,
784
- enableAudio: !isMuted,
785
- enableVideo: isVideoEnabled,
786
- enableNetworkQualityReporting: true,
787
- });
788
- }, 3000);
789
- };
790
-
791
- if (!state.isVisible) {
792
- return (
793
- <TwilioVideo
794
- ref={twilioVideoRef as never}
795
- onRoomDidConnect={onRoomDidConnect}
796
- onRoomDidDisconnect={onRoomDidDisconnect}
797
- onRoomDidFailToConnect={onRoomDidFailToConnect}
798
- onParticipantAddedVideoTrack={onParticipantAddedVideoTrack}
799
- onParticipantDisabledVideoTrack={onParticipantDisabledVideoTrack}
800
- onParticipantEnabledVideoTrack={onParticipantEnabledVideoTrack}
801
- onParticipantRemovedVideoTrack={onParticipantRemovedVideoTrack}
802
- onParticipantAddedAudioTrack={onParticipantAudioToggled}
803
- onParticipantEnabledAudioTrack={onParticipantAudioToggled}
804
- onParticipantDisabledAudioTrack={onParticipantAudioToggled}
805
- onNetworkQualityLevelsChanged={onNetworkQualityLevelsChanged}
806
- onRoomReconnectingWithError={onRoomReconnectingWithError}
807
- onRoomParticipantIsReconnecting={() =>
808
- updateState((prev) => ({
809
- ...prev,
810
- showParticipantReconnectingScreen: true,
811
- }))
812
- }
813
- onRoomParticipantReconnected={() =>
814
- updateState((prev) => ({
815
- ...prev,
816
- showParticipantReconnectingScreen: false,
817
- }))
818
- }
819
- />
820
- );
821
- }
822
-
823
- const isReconnecting =
824
- state.showParticipantReconnectingScreen || state.showUserReconnectingScreen;
825
- const isConnecting = state.loading || state.status === 'connecting';
826
- const showDoctorInitial =
827
- state.status === 'participantDisconnected' ||
828
- (!isReconnecting && !isConnecting);
829
-
830
- return (
831
- <View style={[styles.container, style]}>
832
- <StatusBar barStyle="light-content" />
833
- <View style={styles.topHeader}>
834
- <View style={styles.headerTitleWrap}>
835
- <Text style={styles.nameText}>{state.doctorName || 'Doctor'}</Text>
836
- <Text style={styles.timerText}>
837
- {state.durationMins}:{state.durationSecs}
838
- </Text>
839
- </View>
840
- {(state.signalStrength !== null ||
841
- state.participantSignalStrength !== null) && (
842
- <View style={styles.signalHeaderRow}>
843
- {state.participantSignalStrength !== null ? (
844
- <SignalStrengthIndicator
845
- strength={state.participantSignalStrength}
846
- participantLabel="Doctor"
847
- />
848
- ) : null}
849
- {state.signalStrength !== null ? (
850
- <View style={styles.signalItemSpacer}>
851
- <SignalStrengthIndicator
852
- strength={state.signalStrength}
853
- participantLabel="Patient"
854
- />
855
- </View>
856
- ) : null}
857
- </View>
858
- )}
859
- </View>
860
-
861
- {state.remoteTrackIdentifier &&
862
- state.participantVideoEnabled &&
863
- !state.showParticipantReconnectingScreen &&
864
- !state.showUserReconnectingScreen ? (
865
- <TwilioVideoParticipantView
866
- style={styles.remoteVideo}
867
- key={state?.remoteTrackSid}
868
- trackIdentifier={state.remoteTrackIdentifier}
869
- />
870
- ) : (
871
- <View style={styles.remotePlaceholder}>
872
- {isReconnecting || isConnecting ? (
873
- <View
874
- style={[
875
- styles.connectingView,
876
- { backgroundColor: 'rgba(164, 171, 180, 0.36)' },
877
- ]}
878
- >
879
- <Image
880
- style={styles.connectingGif}
881
- source={isReconnecting ? ICONS.reconnecting : ICONS.connecting}
882
- />
883
- <Text style={styles.connectingText}>
884
- {isReconnecting ? 'Reconnecting...' : 'Connecting...'}
885
- </Text>
886
- </View>
887
- ) : (
888
- <Text
889
- style={[
890
- styles.placeholderText,
891
- showDoctorInitial ? styles.placeholderInitialText : null,
892
- ]}
893
- >
894
- {(state.visibleDoctorName || state.doctorName || 'Doctor')
895
- .trim()
896
- .charAt(0)
897
- .toUpperCase()}
898
- </Text>
899
- )}
900
- </View>
901
- )}
902
-
903
- {!isConnecting ? (
904
- <Animated.View
905
- style={[
906
- styles.localPreview,
907
- state.showLowSignalStrengthMessage
908
- ? state.showBottomBar
909
- ? styles.localPreviewAboveLowSignalExpanded
910
- : styles.localPreviewAboveLowSignalCollapsed
911
- : state.showBottomBar
912
- ? styles.localPreviewAboveControls
913
- : styles.localPreviewAboveCollapsedControls,
914
- { transform: localPreviewDrag.getTranslateTransform() },
915
- ]}
916
- {...localPreviewPanResponder.panHandlers}
917
- >
918
- <View style={styles.localPreviewInner}>
919
- {state.isVideoEnabled ? (
920
- <TwilioVideoLocalView
921
- key={`local-preview-${localPreviewRefreshKey}`}
922
- enabled
923
- style={styles.localVideo}
924
- />
925
- ) : (
926
- <View style={[styles.localVideo, styles.localVideoOff]}>
927
- <Text style={styles.localVideoOffText}>
928
- {(state.userName || 'Patient').charAt(0).toUpperCase()}
929
- </Text>
930
- </View>
931
- )}
932
- </View>
933
- </Animated.View>
934
- ) : null}
935
-
936
- {!state.participantAudioEnabled && !state.showLowSignalStrengthMessage ? (
937
- <View
938
- style={[
939
- styles.participantMicOffBadge,
940
- state.showBottomBar
941
- ? styles.participantMicOffBadgeAboveControls
942
- : styles.participantMicOffBadgeAboveCollapsed,
943
- ]}
944
- >
945
- <Image
946
- source={ICONS.mute}
947
- style={styles.participantMicOffIcon}
948
- resizeMode="contain"
949
- />
950
- </View>
951
- ) : null}
952
-
953
- {state.showLowSignalStrengthMessage ? (
954
- <View
955
- style={[
956
- styles.lowSignalBanner,
957
- state.showBottomBar
958
- ? styles.lowSignalBannerAboveControls
959
- : styles.lowSignalBannerAboveCollapsed,
960
- ]}
961
- >
962
- <Text style={styles.lowSignalText}>
963
- Poor connection detected. Try moving for better signal.
964
- </Text>
965
- <Pressable
966
- onPress={() =>
967
- updateState((prev) => ({
968
- ...prev,
969
- showLowSignalStrengthMessage: false,
970
- }))
971
- }
972
- >
973
- <Text style={styles.lowSignalDismiss}>Dismiss</Text>
974
- </Pressable>
975
- </View>
976
- ) : null}
977
-
978
- <View style={styles.bottomBarContainer}>
979
- <View
980
- style={[
981
- styles.controls,
982
- !state.showBottomBar ? styles.controlsCollapsed : null,
983
- ]}
984
- >
985
- <TouchableOpacity
986
- activeOpacity={0.8}
987
- style={styles.controlsTopLineTouch}
988
- onPress={() => {
989
- LayoutAnimation.configureNext(
990
- LayoutAnimation.Presets.easeInEaseOut
991
- );
992
- updateState((prev) => ({
993
- ...prev,
994
- showBottomBar: !prev.showBottomBar,
995
- }));
996
- }}
997
- >
998
- <View style={styles.controlsTogglePill}>
999
- <Image
1000
- source={state.showBottomBar ? ICONS.toggleDown : ICONS.toggleUp}
1001
- style={styles.controlsToggleIcon}
1002
- resizeMode="contain"
1003
- />
1004
- </View>
1005
- </TouchableOpacity>
1006
-
1007
- {state.showBottomBar ? (
1008
- <>
1009
- <ControlButton
1010
- label="Mute"
1011
- icon={ICONS.mute}
1012
- onPress={onMuteButtonPress}
1013
- active={state.isMuted}
1014
- />
1015
- <ControlButton
1016
- label="Video on"
1017
- icon={ICONS.videoOff}
1018
- onPress={onVideoToggle}
1019
- active={!state.isVideoEnabled}
1020
- />
1021
- <ControlButton
1022
- label="Flip Camera"
1023
- icon={ICONS.flip}
1024
- onPress={onFlipButtonPress}
1025
- useTouchableOpacity
1026
- />
1027
- <ControlButton
1028
- label="End Call"
1029
- icon={ICONS.end}
1030
- onPress={endCall}
1031
- danger
1032
- iconSize={18}
1033
- useTouchableOpacity
1034
- />
1035
- </>
1036
- ) : null}
1037
- </View>
1038
- </View>
1039
-
1040
- <TwilioVideo
1041
- ref={twilioVideoRef as never}
1042
- onRoomDidConnect={onRoomDidConnect}
1043
- onRoomDidDisconnect={onRoomDidDisconnect}
1044
- onRoomDidFailToConnect={onRoomDidFailToConnect}
1045
- onParticipantAddedVideoTrack={onParticipantAddedVideoTrack}
1046
- onParticipantDisabledVideoTrack={onParticipantDisabledVideoTrack}
1047
- onParticipantEnabledVideoTrack={onParticipantEnabledVideoTrack}
1048
- onParticipantRemovedVideoTrack={onParticipantRemovedVideoTrack}
1049
- onParticipantAddedAudioTrack={onParticipantAudioToggled}
1050
- onParticipantEnabledAudioTrack={onParticipantAudioToggled}
1051
- onParticipantDisabledAudioTrack={onParticipantAudioToggled}
1052
- onNetworkQualityLevelsChanged={onNetworkQualityLevelsChanged}
1053
- onRoomReconnectingWithError={onRoomReconnectingWithError}
1054
- onRoomParticipantIsReconnecting={() =>
1055
- updateState((prev) => ({
1056
- ...prev,
1057
- showParticipantReconnectingScreen: true,
1058
- }))
1059
- }
1060
- onRoomParticipantReconnected={() =>
1061
- updateState((prev) => ({
1062
- ...prev,
1063
- showParticipantReconnectingScreen: false,
1064
- }))
1065
- }
1066
- />
1067
- </View>
1068
- );
1069
- });
1070
-
1071
- const SignalStrengthIndicator = ({
1072
- strength,
1073
- participantLabel,
1074
- }: SignalStrengthIndicatorProps) => {
1075
- const bars = [1, 2, 3, 4, 5];
1076
- const barColor =
1077
- strength <= 1
1078
- ? '#f04d5a'
1079
- : strength === 2
1080
- ? '#f48f31'
1081
- : strength === 3
1082
- ? '#f9ca24'
1083
- : '#5dd670';
1084
-
1085
- return (
1086
- <View style={styles.signalContainer}>
1087
- <View style={styles.signalBars}>
1088
- {bars.map((bar, idx) => (
1089
- <View
1090
- key={`bar-${bar}`}
1091
- style={[
1092
- styles.signalBar,
1093
- {
1094
- backgroundColor: strength >= bar ? barColor : '#6f6f6f',
1095
- height: idx === 0 ? 2 : idx * 4,
1096
- marginRight: idx === 4 ? 0 : 3,
1097
- },
1098
- ]}
1099
- />
1100
- ))}
1101
- </View>
1102
- <Text style={styles.signalLabel}>{participantLabel}</Text>
1103
- </View>
1104
- );
1105
- };
1106
-
1107
- const ControlButton = ({
1108
- onPress,
1109
- danger,
1110
- icon,
1111
- customIconText,
1112
- active,
1113
- iconSize,
1114
- useTouchableOpacity,
1115
- }: ControlButtonProps) => {
1116
- const content = (
1117
- <View
1118
- style={[
1119
- styles.controlIconShell,
1120
- active ? styles.controlIconShellActive : null,
1121
- danger ? styles.controlButtonDanger : null,
1122
- ]}
1123
- >
1124
- {icon ? (
1125
- <Image
1126
- source={icon}
1127
- style={[
1128
- styles.controlButtonIcon,
1129
- iconSize ? { width: iconSize, height: iconSize } : null,
1130
- active ? styles.controlButtonIconActive : null,
1131
- danger ? styles.controlButtonIconDanger : null,
1132
- ]}
1133
- resizeMode="contain"
1134
- />
1135
- ) : (
1136
- <Text
1137
- style={[
1138
- styles.controlFallbackIcon,
1139
- active ? styles.controlFallbackIconActive : null,
1140
- ]}
1141
- >
1142
- {customIconText || '?'}
1143
- </Text>
1144
- )}
1145
- </View>
1146
- );
1147
-
1148
- if (useTouchableOpacity) {
1149
- return (
1150
- <TouchableOpacity
1151
- style={styles.controlButton}
1152
- onPress={onPress}
1153
- activeOpacity={0.65}
1154
- >
1155
- {content}
1156
- </TouchableOpacity>
1157
- );
1158
- }
1159
-
1160
- return (
1161
- <Pressable style={styles.controlButton} onPress={onPress}>
1162
- {content}
1163
- </Pressable>
1164
- );
1165
- };
1166
-
1167
- const styles = StyleSheet.create({
1168
- container: {
1169
- position: 'absolute',
1170
- top: 0,
1171
- left: 0,
1172
- right: 0,
1173
- bottom: 0,
1174
- zIndex: 99,
1175
- backgroundColor: '#000',
1176
- justifyContent: 'space-between',
1177
- },
1178
- topHeader: {
1179
- position: 'absolute',
1180
- top: 0,
1181
- left: 0,
1182
- right: 0,
1183
- zIndex: 10,
1184
- flexDirection: 'row',
1185
- justifyContent: 'space-between',
1186
- alignItems: 'flex-end',
1187
- paddingHorizontal: 16,
1188
- paddingTop: 56,
1189
- },
1190
- headerTitleWrap: {
1191
- flex: 1,
1192
- paddingRight: 12,
1193
- },
1194
- nameText: {
1195
- color: '#fff',
1196
- fontSize: 24,
1197
- fontWeight: '700',
1198
- },
1199
- timerText: {
1200
- color: '#fff',
1201
- marginTop: 4,
1202
- fontSize: 13,
1203
- },
1204
- closeButton: {
1205
- paddingVertical: 8,
1206
- paddingHorizontal: 12,
1207
- borderRadius: 16,
1208
- backgroundColor: 'rgba(255,255,255,0.2)',
1209
- },
1210
- closeButtonText: {
1211
- color: '#fff',
1212
- fontWeight: '700',
1213
- },
1214
- remoteVideo: {
1215
- position: 'absolute',
1216
- top: 0,
1217
- left: 0,
1218
- right: 0,
1219
- bottom: 0,
1220
- width: SCREEN_WIDTH,
1221
- height: SCREEN_HEIGHT,
1222
- },
1223
- remotePlaceholder: {
1224
- flex: 1,
1225
- alignItems: 'center',
1226
- justifyContent: 'center',
1227
- paddingHorizontal: 32,
1228
- },
1229
- placeholderText: {
1230
- color: '#fff',
1231
- fontSize: 18,
1232
- textAlign: 'center',
1233
- },
1234
- placeholderInitialText: {
1235
- fontSize: 40,
1236
- fontWeight: '700',
1237
- width: 120,
1238
- height: 120,
1239
- lineHeight: 120,
1240
- textAlign: 'center',
1241
- textAlignVertical: 'center',
1242
- includeFontPadding: false,
1243
- borderRadius: 60,
1244
- backgroundColor: 'rgb(113, 79, 255)',
1245
- overflow: 'hidden',
1246
- },
1247
- connectingView: {
1248
- minHeight: 200,
1249
- width: 271,
1250
- borderRadius: 16,
1251
- paddingVertical: 32,
1252
- paddingHorizontal: 24,
1253
- alignItems: 'center',
1254
- justifyContent: 'center',
1255
- alignSelf: 'center',
1256
- position: 'absolute',
1257
- top: 0.35 * SCREEN_HEIGHT,
1258
- },
1259
- connectingGif: {
1260
- width: 108,
1261
- height: 108,
1262
- },
1263
- connectingText: {
1264
- marginTop: 14,
1265
- color: '#fff',
1266
- fontSize: 16,
1267
- fontWeight: '600',
1268
- textAlign: 'center',
1269
- },
1270
- localPreview: {
1271
- position: 'absolute',
1272
- top: 'auto',
1273
- right: 16,
1274
- width: LOCAL_PREVIEW_WIDTH,
1275
- height: LOCAL_PREVIEW_HEIGHT,
1276
- zIndex: 999,
1277
- },
1278
- localPreviewInner: {
1279
- flex: 1,
1280
- backgroundColor: '#1b1b1b',
1281
- },
1282
- localPreviewAboveControls: {
1283
- bottom: 140,
1284
- },
1285
- localPreviewAboveCollapsedControls: {
1286
- bottom: 78,
1287
- },
1288
- localPreviewAboveLowSignalExpanded: {
1289
- bottom: 224,
1290
- },
1291
- localPreviewAboveLowSignalCollapsed: {
1292
- bottom: 162,
1293
- },
1294
- localVideo: {
1295
- width: '100%',
1296
- height: '100%',
1297
- backgroundColor: '#1b1b1b',
1298
- },
1299
- localVideoOff: {
1300
- alignItems: 'center',
1301
- justifyContent: 'center',
1302
- },
1303
- localVideoOffText: {
1304
- color: '#fff',
1305
- fontSize: 28,
1306
- fontWeight: '700',
1307
- width: 60,
1308
- height: 60,
1309
- lineHeight: 60,
1310
- textAlign: 'center',
1311
- textAlignVertical: 'center',
1312
- includeFontPadding: false,
1313
- borderRadius: 40,
1314
- backgroundColor: 'rgb(113, 79, 255)',
1315
- overflow: 'hidden',
1316
- },
1317
- controls: {
1318
- zIndex: 20,
1319
- flexDirection: 'row',
1320
- justifyContent: 'space-around',
1321
- alignItems: 'flex-start',
1322
- width: SCREEN_WIDTH,
1323
- paddingHorizontal: 10,
1324
- paddingBottom: 20,
1325
- paddingTop: 30,
1326
- marginBottom: 0,
1327
- borderTopLeftRadius: 24,
1328
- borderTopRightRadius: 24,
1329
- borderWidth: 0.5,
1330
- borderColor: 'rgba(129, 186, 255, 0.18)',
1331
- backgroundColor: 'rgba(164, 171, 180, 0.36)',
1332
- },
1333
- controlsCollapsed: {
1334
- paddingTop: 16,
1335
- paddingBottom: 24,
1336
- },
1337
- bottomBarContainer: {
1338
- position: 'absolute',
1339
- left: 0,
1340
- right: 0,
1341
- bottom: 0,
1342
- zIndex: 20,
1343
- alignItems: 'center',
1344
- justifyContent: 'flex-end',
1345
- pointerEvents: 'box-none',
1346
- },
1347
- controlsTopLineTouch: {
1348
- position: 'absolute',
1349
- top: 6,
1350
- alignSelf: 'center',
1351
- width: 72,
1352
- height: 16,
1353
- alignItems: 'center',
1354
- justifyContent: 'center',
1355
- zIndex: 5,
1356
- },
1357
- controlsTogglePill: {
1358
- width: 40,
1359
- height: 24,
1360
- borderRadius: 12,
1361
- alignItems: 'center',
1362
- justifyContent: 'center',
1363
- },
1364
- controlsToggleIcon: {
1365
- width: 20,
1366
- height: 20,
1367
- tintColor: '#fff',
1368
- },
1369
- controlButton: {
1370
- alignItems: 'center',
1371
- width: 72,
1372
- },
1373
- controlButtonDanger: {
1374
- backgroundColor: '#f04d5a',
1375
- },
1376
- controlIconShell: {
1377
- width: 64,
1378
- height: 64,
1379
- borderRadius: 32,
1380
- alignItems: 'center',
1381
- justifyContent: 'center',
1382
- backgroundColor: 'rgba(255,255,255,0.25)',
1383
- },
1384
- controlIconShellActive: {
1385
- backgroundColor: '#ffffff',
1386
- },
1387
- controlButtonIcon: {
1388
- width: 30,
1389
- height: 30,
1390
- tintColor: '#ffffff',
1391
- },
1392
- controlButtonIconActive: {
1393
- tintColor: 'rgba(70,70,70,0.8)',
1394
- },
1395
- controlButtonIconDanger: {
1396
- tintColor: '#ffffff',
1397
- },
1398
- controlFallbackIcon: {
1399
- color: '#fff',
1400
- fontSize: 28,
1401
- fontWeight: '700',
1402
- },
1403
- controlFallbackIconActive: {
1404
- color: 'rgba(70,70,70,0.8)',
1405
- },
1406
- signalHeaderRow: {
1407
- flexDirection: 'row',
1408
- alignItems: 'flex-end',
1409
- marginTop: 0,
1410
- },
1411
- signalContainer: {
1412
- alignItems: 'center',
1413
- },
1414
- signalItemSpacer: {
1415
- marginLeft: 10,
1416
- },
1417
- signalBars: {
1418
- flexDirection: 'row',
1419
- alignItems: 'flex-end',
1420
- },
1421
- signalBar: {
1422
- width: 3,
1423
- borderRadius: 2,
1424
- },
1425
- signalLabel: {
1426
- color: '#fff',
1427
- fontSize: 10,
1428
- marginTop: 3,
1429
- textAlign: 'center',
1430
- width: '100%',
1431
- },
1432
- participantMicOffBadge: {
1433
- position: 'absolute',
1434
- alignSelf: 'center',
1435
- zIndex: 21,
1436
- width: 52,
1437
- height: 52,
1438
- alignItems: 'center',
1439
- justifyContent: 'center',
1440
- },
1441
- participantMicOffBadgeAboveControls: {
1442
- bottom: 118,
1443
- },
1444
- participantMicOffBadgeAboveCollapsed: {
1445
- bottom: 58,
1446
- },
1447
- participantMicOffIcon: {
1448
- width: 22,
1449
- height: 22,
1450
- tintColor: '#fff',
1451
- },
1452
- lowSignalBanner: {
1453
- position: 'absolute',
1454
- left: 16,
1455
- right: 16,
1456
- zIndex: 20,
1457
- borderRadius: 12,
1458
- backgroundColor: 'rgba(0,0,0,0.6)',
1459
- paddingHorizontal: 12,
1460
- paddingVertical: 10,
1461
- flexDirection: 'row',
1462
- alignItems: 'center',
1463
- justifyContent: 'space-between',
1464
- },
1465
- lowSignalBannerAboveControls: {
1466
- bottom: 130,
1467
- },
1468
- lowSignalBannerAboveCollapsed: {
1469
- bottom: 68,
1470
- },
1471
- lowSignalText: {
1472
- color: '#fff',
1473
- fontSize: 12,
1474
- flex: 1,
1475
- paddingRight: 8,
1476
- },
1477
- lowSignalDismiss: {
1478
- color: '#7ec8ff',
1479
- fontWeight: '700',
1480
- fontSize: 12,
1481
- },
1482
- });
1483
-
1484
- export default VideoCallComponent;