agora-appbuilder-core 4.1.12 → 4.1.13-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/defaultConfig.js +2 -2
- package/template/src/assets/font-styles.css +4 -0
- package/template/src/assets/fonts/icomoon.ttf +0 -0
- package/template/src/assets/selection.json +1 -1
- package/template/src/atoms/ActionMenu.tsx +1 -1
- package/template/src/atoms/CustomIcon.tsx +1 -0
- package/template/src/atoms/Popup.tsx +1 -1
- package/template/src/components/Controls.tsx +21 -32
- package/template/src/language/default-labels/videoCallScreenLabels.ts +9 -9
- package/template/src/pages/VideoCall.tsx +2 -1
- package/template/src/pages/video-call/ActionSheetContent.tsx +0 -7
- package/template/src/pages/video-call/SidePanelHeader.tsx +80 -63
- package/template/src/rtm-events/constants.ts +9 -0
- package/template/src/subComponents/caption/Caption.tsx +4 -20
- package/template/src/subComponents/caption/CaptionContainer.tsx +262 -250
- package/template/src/subComponents/caption/CaptionIcon.tsx +6 -4
- package/template/src/subComponents/caption/CaptionText.tsx +26 -20
- package/template/src/subComponents/caption/LanguageSelectorPopup.tsx +30 -142
- package/template/src/subComponents/caption/Transcript.tsx +77 -32
- package/template/src/subComponents/caption/TranscriptIcon.tsx +7 -6
- package/template/src/subComponents/caption/TranslateActionMenu.tsx +128 -0
- package/template/src/subComponents/caption/useCaption.tsx +666 -480
- package/template/src/subComponents/caption/useSTTAPI.tsx +25 -4
- package/template/src/subComponents/caption/useStreamMessageUtils.native.ts +1 -1
- package/template/src/subComponents/caption/useStreamMessageUtils.ts +1 -1
- package/template/src/subComponents/caption/utils.ts +48 -40
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StyleSheet,
|
|
3
|
-
Text,
|
|
4
3
|
TextStyle,
|
|
5
4
|
useWindowDimensions,
|
|
6
5
|
View,
|
|
7
6
|
ViewStyle,
|
|
8
7
|
} from 'react-native';
|
|
9
8
|
import React from 'react';
|
|
10
|
-
|
|
9
|
+
import {useRoomInfo} from 'customization-api';
|
|
11
10
|
import Caption from './Caption';
|
|
12
|
-
import {useCaption
|
|
11
|
+
import {useCaption} from './useCaption';
|
|
13
12
|
import ThemeConfig from '../../../src/theme';
|
|
14
13
|
import {
|
|
15
14
|
calculatePosition,
|
|
16
15
|
isMobileUA,
|
|
17
|
-
isWeb,
|
|
18
16
|
isWebInternal,
|
|
19
17
|
useIsDesktop,
|
|
20
18
|
useIsSmall,
|
|
21
19
|
} from '../../utils/common';
|
|
22
20
|
import IconButton from '../../../src/atoms/IconButton';
|
|
23
|
-
|
|
24
21
|
import ActionMenu, {ActionMenuItem} from '../../../src/atoms/ActionMenu';
|
|
25
|
-
|
|
26
22
|
import LanguageSelectorPopup from './LanguageSelectorPopup';
|
|
27
|
-
import useSTTAPI from './useSTTAPI';
|
|
28
|
-
import useGetName from '../../utils/useGetName';
|
|
29
|
-
import {useRoomInfo} from 'customization-api';
|
|
30
|
-
import {useLocalUid} from '../../../agora-rn-uikit';
|
|
31
|
-
import {getLanguageLabel} from './utils';
|
|
32
23
|
import {
|
|
33
24
|
SIDE_PANEL_MAX_WIDTH,
|
|
34
25
|
SIDE_PANEL_GAP,
|
|
@@ -37,7 +28,7 @@ import {
|
|
|
37
28
|
MOBILE_CAPTION_CONTAINER_HEIGHT,
|
|
38
29
|
} from '../../../src/components/CommonStyles';
|
|
39
30
|
import useCaptionWidth from './useCaptionWidth';
|
|
40
|
-
import {
|
|
31
|
+
import {getLanguageLabel, LanguageType} from './utils';
|
|
41
32
|
import hexadecimalTransparency from '../../utils/hexadecimalTransparency';
|
|
42
33
|
import {useString} from '../../utils/useString';
|
|
43
34
|
import {
|
|
@@ -47,6 +38,7 @@ import {
|
|
|
47
38
|
toolbarItemCaptionText,
|
|
48
39
|
} from '../../language/default-labels/videoCallScreenLabels';
|
|
49
40
|
import {logger, LogSource} from '../../logger/AppBuilderLogger';
|
|
41
|
+
import {TranslateActionMenu} from './TranslateActionMenu';
|
|
50
42
|
|
|
51
43
|
interface CaptionContainerProps {
|
|
52
44
|
containerStyle?: ViewStyle;
|
|
@@ -60,11 +52,9 @@ const CaptionContainer: React.FC<CaptionContainerProps> = ({
|
|
|
60
52
|
captionTextStyle = {},
|
|
61
53
|
}) => {
|
|
62
54
|
const moreIconRef = React.useRef<View>(null);
|
|
63
|
-
const langSelectIconRef = React.useRef<View>(null);
|
|
64
55
|
const [actionMenuVisible, setActionMenuVisible] =
|
|
65
56
|
React.useState<boolean>(false);
|
|
66
|
-
|
|
67
|
-
React.useState<boolean>(false);
|
|
57
|
+
React.useState<boolean>(false);
|
|
68
58
|
const [isHovered, setIsHovered] = React.useState<boolean>(false);
|
|
69
59
|
const isDesktop = useIsDesktop();
|
|
70
60
|
const isSmall = useIsSmall();
|
|
@@ -277,13 +267,9 @@ const CaptionsActionMenu = (props: CaptionsActionMenuProps) => {
|
|
|
277
267
|
const {actionMenuVisible, setActionMenuVisible, btnRef} = props;
|
|
278
268
|
const {
|
|
279
269
|
setIsCaptionON,
|
|
280
|
-
// language: prevLang,
|
|
281
270
|
isLangChangeInProgress,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
updateSTTBotSession,
|
|
285
|
-
translationConfig,
|
|
286
|
-
handleTranslateConfigChange,
|
|
271
|
+
selectedTranslationLanguage,
|
|
272
|
+
confirmSpokenLanguageChange,
|
|
287
273
|
captionViewMode,
|
|
288
274
|
setCaptionViewMode,
|
|
289
275
|
} = useCaption();
|
|
@@ -293,49 +279,48 @@ const CaptionsActionMenu = (props: CaptionsActionMenuProps) => {
|
|
|
293
279
|
const {width: globalWidth, height: globalHeight} = useWindowDimensions();
|
|
294
280
|
const [isLanguagePopupOpen, setLanguagePopup] =
|
|
295
281
|
React.useState<boolean>(false);
|
|
282
|
+
const [isTranslateMenuOpen, setTranslateMenuOpen] =
|
|
283
|
+
React.useState<boolean>(false);
|
|
284
|
+
|
|
296
285
|
// const {restart} = useSTTAPI();
|
|
297
286
|
// const username = useGetName();
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
// } = useRoomInfo();
|
|
287
|
+
const {
|
|
288
|
+
data: {isHost},
|
|
289
|
+
} = useRoomInfo();
|
|
302
290
|
|
|
303
|
-
const
|
|
291
|
+
const updateSpokenLangLabel = useString<boolean>(
|
|
304
292
|
sttChangeSpokenLanguageText,
|
|
305
293
|
)();
|
|
306
|
-
const sttStopTranslationLabel = useString<boolean>(sttStopTranslationText)();
|
|
307
294
|
const sttOriginalTranslatedLabel = useString(sttOriginalTranslatedText)();
|
|
308
295
|
|
|
309
296
|
const hideCaptionLabel = useString<boolean>(toolbarItemCaptionText)(true);
|
|
310
297
|
|
|
311
298
|
// Anyone can start/stop stt
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
299
|
+
isHost &&
|
|
300
|
+
actionMenuitems.push({
|
|
301
|
+
icon: 'globe',
|
|
302
|
+
iconColor: $config.SECONDARY_ACTION_COLOR,
|
|
303
|
+
textColor: $config.FONT_COLOR,
|
|
304
|
+
title: updateSpokenLangLabel + ' ',
|
|
305
|
+
disabled: isLangChangeInProgress,
|
|
306
|
+
onPress: () => {
|
|
307
|
+
setActionMenuVisible(false);
|
|
308
|
+
setLanguagePopup(true);
|
|
309
|
+
},
|
|
310
|
+
});
|
|
323
311
|
|
|
324
312
|
// Stop Translation (not STT bot, pass empty targets)
|
|
325
|
-
actionMenuitems.push({
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
});
|
|
337
|
-
},
|
|
338
|
-
});
|
|
313
|
+
// actionMenuitems.push({
|
|
314
|
+
// icon: 'lang-select',
|
|
315
|
+
// iconColor: $config.SECONDARY_ACTION_COLOR,
|
|
316
|
+
// textColor: $config.FONT_COLOR,
|
|
317
|
+
// title: sttStopTranslationLabel,
|
|
318
|
+
// disabled: isLangChangeInProgress,
|
|
319
|
+
// onPress: async () => {
|
|
320
|
+
// setSelectedTranslationLanguage(null);
|
|
321
|
+
// setActionMenuVisible(false);
|
|
322
|
+
// },
|
|
323
|
+
// });
|
|
339
324
|
|
|
340
325
|
// Hide Caption Panel
|
|
341
326
|
actionMenuitems.push({
|
|
@@ -349,31 +334,49 @@ const CaptionsActionMenu = (props: CaptionsActionMenuProps) => {
|
|
|
349
334
|
},
|
|
350
335
|
});
|
|
351
336
|
|
|
352
|
-
// View Mode Options
|
|
353
337
|
actionMenuitems.push({
|
|
354
|
-
icon: 'lang-
|
|
338
|
+
icon: 'lang-select',
|
|
355
339
|
iconColor: $config.SECONDARY_ACTION_COLOR,
|
|
356
|
-
endIcon:
|
|
357
|
-
captionViewMode === 'original-and-translated' ? 'tick-fill' : undefined,
|
|
358
|
-
endIconColor: $config.SEMANTIC_SUCCESS,
|
|
359
340
|
textColor: $config.FONT_COLOR,
|
|
360
|
-
title:
|
|
341
|
+
title: `Translate to: ${
|
|
342
|
+
selectedTranslationLanguage
|
|
343
|
+
? getLanguageLabel([selectedTranslationLanguage])
|
|
344
|
+
: 'OFF'
|
|
345
|
+
}`,
|
|
346
|
+
endIcon: 'arrow-right',
|
|
347
|
+
endIconColor: $config.SECONDARY_ACTION_COLOR,
|
|
348
|
+
disabled: isLangChangeInProgress,
|
|
361
349
|
onPress: () => {
|
|
362
|
-
setCaptionViewMode(
|
|
363
|
-
captionViewMode === 'translated'
|
|
364
|
-
? 'original-and-translated'
|
|
365
|
-
: 'translated',
|
|
366
|
-
);
|
|
367
350
|
setActionMenuVisible(false);
|
|
351
|
+
setTranslateMenuOpen(true);
|
|
368
352
|
},
|
|
369
353
|
});
|
|
370
354
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
355
|
+
// View Mode Options
|
|
356
|
+
selectedTranslationLanguage &&
|
|
357
|
+
actionMenuitems.push({
|
|
358
|
+
icon: 'lang-translate',
|
|
359
|
+
iconColor: $config.SECONDARY_ACTION_COLOR,
|
|
360
|
+
endIcon:
|
|
361
|
+
captionViewMode === 'original-and-translated' ? 'tick-fill' : undefined,
|
|
362
|
+
endIconColor: $config.SEMANTIC_SUCCESS,
|
|
363
|
+
textColor: $config.FONT_COLOR,
|
|
364
|
+
title: sttOriginalTranslatedLabel,
|
|
365
|
+
disabled: isLangChangeInProgress,
|
|
366
|
+
onPress: () => {
|
|
367
|
+
setCaptionViewMode(
|
|
368
|
+
captionViewMode === 'translated'
|
|
369
|
+
? 'original-and-translated'
|
|
370
|
+
: 'translated',
|
|
371
|
+
);
|
|
372
|
+
setActionMenuVisible(false);
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const onLanguageChange = async (newSpokenLang: LanguageType) => {
|
|
374
377
|
setLanguagePopup(false);
|
|
375
378
|
try {
|
|
376
|
-
await
|
|
379
|
+
await confirmSpokenLanguageChange(newSpokenLang);
|
|
377
380
|
} catch (error) {}
|
|
378
381
|
};
|
|
379
382
|
|
|
@@ -413,193 +416,202 @@ const CaptionsActionMenu = (props: CaptionsActionMenuProps) => {
|
|
|
413
416
|
modalPosition={modalPosition}
|
|
414
417
|
items={actionMenuitems}
|
|
415
418
|
/>
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
{isLanguagePopupOpen && (
|
|
420
|
+
<LanguageSelectorPopup
|
|
421
|
+
modalVisible={isLanguagePopupOpen}
|
|
422
|
+
setModalVisible={setLanguagePopup}
|
|
423
|
+
onConfirm={onLanguageChange}
|
|
424
|
+
/>
|
|
425
|
+
)}
|
|
426
|
+
{isTranslateMenuOpen && (
|
|
427
|
+
<TranslateActionMenu
|
|
428
|
+
actionMenuVisible={isTranslateMenuOpen}
|
|
429
|
+
setActionMenuVisible={setTranslateMenuOpen}
|
|
430
|
+
btnRef={btnRef}
|
|
431
|
+
/>
|
|
432
|
+
)}
|
|
421
433
|
</>
|
|
422
434
|
);
|
|
423
435
|
};
|
|
424
436
|
|
|
425
|
-
export interface TranslateActionMenuProps {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
export const TranslateActionMenu = (props: TranslateActionMenuProps) => {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
};
|
|
437
|
+
// export interface TranslateActionMenuProps {
|
|
438
|
+
// actionMenuVisible: boolean;
|
|
439
|
+
// setActionMenuVisible: (actionMenuVisible: boolean) => void;
|
|
440
|
+
// btnRef: React.RefObject<View>;
|
|
441
|
+
// }
|
|
442
|
+
|
|
443
|
+
// export const TranslateActionMenu = (props: TranslateActionMenuProps) => {
|
|
444
|
+
// const {actionMenuVisible, setActionMenuVisible, btnRef} = props;
|
|
445
|
+
// const [modalPosition, setModalPosition] = React.useState({});
|
|
446
|
+
// const [isPosCalculated, setIsPosCalculated] = React.useState(false);
|
|
447
|
+
// const {width: globalWidth, height: globalHeight} = useWindowDimensions();
|
|
448
|
+
// const {
|
|
449
|
+
// language: currentSpokenLanguages,
|
|
450
|
+
// selectedTranslationLanguage,
|
|
451
|
+
// setSelectedTranslationLanguage,
|
|
452
|
+
// setMeetingTranscript,
|
|
453
|
+
// translationConfig,
|
|
454
|
+
// } = useCaption();
|
|
455
|
+
// const {update} = useSTTAPI();
|
|
456
|
+
// const localUid = useLocalUid();
|
|
457
|
+
// const {sttLanguage} = useRoomInfo();
|
|
458
|
+
|
|
459
|
+
// // Reset selected translation language if there are no targets configured
|
|
460
|
+
// const targetLanguages = translationConfig?.targets || [];
|
|
461
|
+
// React.useEffect(() => {
|
|
462
|
+
// if (targetLanguages.length === 0 && selectedTranslationLanguage !== '') {
|
|
463
|
+
// setSelectedTranslationLanguage('');
|
|
464
|
+
// }
|
|
465
|
+
// }, [
|
|
466
|
+
// targetLanguages.length,
|
|
467
|
+
// selectedTranslationLanguage,
|
|
468
|
+
// setSelectedTranslationLanguage,
|
|
469
|
+
// ]);
|
|
470
|
+
|
|
471
|
+
// const actionMenuitems: ActionMenuItem[] = [];
|
|
472
|
+
|
|
473
|
+
// actionMenuitems.push({
|
|
474
|
+
// iconColor: $config.SECONDARY_ACTION_COLOR,
|
|
475
|
+
// textColor: $config.FONT_COLOR,
|
|
476
|
+
// title: 'Add Another Translation',
|
|
477
|
+
// iconPosition: 'end',
|
|
478
|
+
// disabled: true,
|
|
479
|
+
// onPress: () => {},
|
|
480
|
+
// });
|
|
481
|
+
|
|
482
|
+
// const handleTranslationToggle = (targetLanguage: string) => {
|
|
483
|
+
// // Simply update the selected translation language locally
|
|
484
|
+
// // No API call needed - we're just switching between already-configured target languages
|
|
485
|
+
// // const prevTranslationLanguage = selectedTranslationLanguage;
|
|
486
|
+
// setSelectedTranslationLanguage(targetLanguage);
|
|
487
|
+
|
|
488
|
+
// // // Add translation language change notification to transcript
|
|
489
|
+
// // const getLanguageName = (langCode: string) => {
|
|
490
|
+
// // if (!langCode) return '';
|
|
491
|
+
// // const lang = langData.find(data => data.value === langCode);
|
|
492
|
+
// // return lang ? lang.label : langCode;
|
|
493
|
+
// // };
|
|
494
|
+
|
|
495
|
+
// // const actionText =
|
|
496
|
+
// // targetLanguage === ''
|
|
497
|
+
// // ? 'turned off translation'
|
|
498
|
+
// // : prevTranslationLanguage === ''
|
|
499
|
+
// // ? `set the translation language to "${getLanguageName(targetLanguage)}"`
|
|
500
|
+
// // : `changed the translation language from "${getLanguageName(
|
|
501
|
+
// // prevTranslationLanguage,
|
|
502
|
+
// // )}" to "${getLanguageName(targetLanguage)}"`;
|
|
503
|
+
|
|
504
|
+
// // setMeetingTranscript(prev => [
|
|
505
|
+
// // ...prev,
|
|
506
|
+
// // {
|
|
507
|
+
// // name: 'translationUpdate',
|
|
508
|
+
// // time: new Date().getTime(),
|
|
509
|
+
// // uid: `translationUpdate-${localUid}`,
|
|
510
|
+
// // text: actionText,
|
|
511
|
+
// // },
|
|
512
|
+
// // ]);
|
|
513
|
+
|
|
514
|
+
// setActionMenuVisible(false);
|
|
515
|
+
// };
|
|
516
|
+
|
|
517
|
+
// // Check if there are any target languages configured
|
|
518
|
+
// if (targetLanguages.length === 0) {
|
|
519
|
+
// // No target languages - show a disabled message
|
|
520
|
+
// actionMenuitems.push({
|
|
521
|
+
// icon: undefined,
|
|
522
|
+
// iconColor: $config.FONT_COLOR,
|
|
523
|
+
// textColor: $config.FONT_COLOR + hexadecimalTransparency['50%'],
|
|
524
|
+
// title: 'No languages configured',
|
|
525
|
+
// iconPosition: 'end',
|
|
526
|
+
// disabled: true,
|
|
527
|
+
// onPress: () => {},
|
|
528
|
+
// });
|
|
529
|
+
// } else {
|
|
530
|
+
// // Show "Off" option and target languages
|
|
531
|
+
// actionMenuitems.push({
|
|
532
|
+
// icon: selectedTranslationLanguage === '' ? 'tick-fill' : undefined,
|
|
533
|
+
// iconColor: $config.PRIMARY_ACTION_BRAND_COLOR,
|
|
534
|
+
// textColor: $config.FONT_COLOR,
|
|
535
|
+
// title: 'Off',
|
|
536
|
+
// iconPosition: 'end',
|
|
537
|
+
// onPress: () => handleTranslationToggle(''),
|
|
538
|
+
// });
|
|
539
|
+
|
|
540
|
+
// // Add selected translation language right after "Off" if one is selected
|
|
541
|
+
// if (selectedTranslationLanguage && selectedTranslationLanguage !== '') {
|
|
542
|
+
// const selectedLanguage = langData.find(
|
|
543
|
+
// lang => lang.value === selectedTranslationLanguage,
|
|
544
|
+
// );
|
|
545
|
+
// if (selectedLanguage) {
|
|
546
|
+
// actionMenuitems.push({
|
|
547
|
+
// icon: 'tick-fill',
|
|
548
|
+
// iconColor: $config.PRIMARY_ACTION_BRAND_COLOR,
|
|
549
|
+
// textColor: $config.FONT_COLOR,
|
|
550
|
+
// title: selectedLanguage.label,
|
|
551
|
+
// iconPosition: 'end',
|
|
552
|
+
// onPress: () => handleTranslationToggle(selectedLanguage.value),
|
|
553
|
+
// });
|
|
554
|
+
// }
|
|
555
|
+
// }
|
|
556
|
+
|
|
557
|
+
// // Add remaining Translation language options from translationConfig.targets (excluding the selected one)
|
|
558
|
+
// targetLanguages.forEach(targetLangCode => {
|
|
559
|
+
// if (targetLangCode !== selectedTranslationLanguage) {
|
|
560
|
+
// const language = langData.find(lang => lang.value === targetLangCode);
|
|
561
|
+
// if (language) {
|
|
562
|
+
// actionMenuitems.push({
|
|
563
|
+
// icon: undefined,
|
|
564
|
+
// iconColor: $config.PRIMARY_ACTION_BRAND_COLOR,
|
|
565
|
+
// textColor: $config.FONT_COLOR,
|
|
566
|
+
// title: language.label,
|
|
567
|
+
// iconPosition: 'end',
|
|
568
|
+
// onPress: () => handleTranslationToggle(language.value),
|
|
569
|
+
// });
|
|
570
|
+
// }
|
|
571
|
+
// }
|
|
572
|
+
// });
|
|
573
|
+
// }
|
|
574
|
+
|
|
575
|
+
// React.useEffect(() => {
|
|
576
|
+
// if (actionMenuVisible) {
|
|
577
|
+
// btnRef?.current?.measure(
|
|
578
|
+
// (
|
|
579
|
+
// _fx: number,
|
|
580
|
+
// _fy: number,
|
|
581
|
+
// localWidth: number,
|
|
582
|
+
// localHeight: number,
|
|
583
|
+
// px: number,
|
|
584
|
+
// py: number,
|
|
585
|
+
// ) => {
|
|
586
|
+
// const data = calculatePosition({
|
|
587
|
+
// px,
|
|
588
|
+
// py,
|
|
589
|
+
// localWidth,
|
|
590
|
+
// localHeight,
|
|
591
|
+
// globalHeight,
|
|
592
|
+
// globalWidth,
|
|
593
|
+
// });
|
|
594
|
+
// setModalPosition(data);
|
|
595
|
+
// setIsPosCalculated(true);
|
|
596
|
+
// },
|
|
597
|
+
// );
|
|
598
|
+
// }
|
|
599
|
+
// }, [actionMenuVisible]);
|
|
600
|
+
|
|
601
|
+
// return (
|
|
602
|
+
// <ActionMenu
|
|
603
|
+
// from={'translation'}
|
|
604
|
+
// actionMenuVisible={actionMenuVisible && isPosCalculated}
|
|
605
|
+
// setActionMenuVisible={setActionMenuVisible}
|
|
606
|
+
// modalPosition={modalPosition}
|
|
607
|
+
// items={actionMenuitems}
|
|
608
|
+
// containerStyle={{
|
|
609
|
+
// maxHeight: Math.min(440, globalHeight * 0.6),
|
|
610
|
+
// width: 220,
|
|
611
|
+
// }}
|
|
612
|
+
// />
|
|
613
|
+
// );
|
|
614
|
+
// };
|
|
603
615
|
|
|
604
616
|
export default CaptionContainer;
|
|
605
617
|
|
|
@@ -7,6 +7,7 @@ import useSTTAPI from './useSTTAPI';
|
|
|
7
7
|
import {useString} from '../../utils/useString';
|
|
8
8
|
import {toolbarItemCaptionText} from '../../language/default-labels/videoCallScreenLabels';
|
|
9
9
|
import {useToolbarProps} from '../../atoms/ToolbarItem';
|
|
10
|
+
import {LanguageType} from './utils';
|
|
10
11
|
|
|
11
12
|
interface CaptionIconProps {
|
|
12
13
|
plainIconHoverEffect?: boolean;
|
|
@@ -31,7 +32,8 @@ const CaptionIcon = (props: CaptionIconProps) => {
|
|
|
31
32
|
setIsCaptionON,
|
|
32
33
|
isSTTActive,
|
|
33
34
|
isSTTError,
|
|
34
|
-
|
|
35
|
+
sttDepsReady,
|
|
36
|
+
confirmSpokenLanguageChange,
|
|
35
37
|
} = useCaption();
|
|
36
38
|
|
|
37
39
|
const [isLanguagePopupOpen, setLanguagePopup] =
|
|
@@ -62,7 +64,7 @@ const CaptionIcon = (props: CaptionIconProps) => {
|
|
|
62
64
|
};
|
|
63
65
|
const iconButtonProps: IconButtonProps = {
|
|
64
66
|
onPress: onPressCustom || onPress,
|
|
65
|
-
disabled:
|
|
67
|
+
disabled: !sttDepsReady,
|
|
66
68
|
iconProps: {
|
|
67
69
|
name: isCaptionON ? 'captions-off' : 'captions',
|
|
68
70
|
iconBackgroundColor: isCaptionON
|
|
@@ -87,12 +89,12 @@ const CaptionIcon = (props: CaptionIconProps) => {
|
|
|
87
89
|
iconButtonProps.toolTipMessage = label;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
const onConfirm = async (
|
|
92
|
+
const onConfirm = async (newSpokenLang: LanguageType) => {
|
|
91
93
|
try {
|
|
92
94
|
closeActionSheet();
|
|
93
95
|
setLanguagePopup(false);
|
|
94
96
|
setIsCaptionON(prev => !prev);
|
|
95
|
-
await
|
|
97
|
+
await confirmSpokenLanguageChange(newSpokenLang);
|
|
96
98
|
} catch (error) {
|
|
97
99
|
setIsCaptionON(false);
|
|
98
100
|
console.log('error in starting stt', error);
|