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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/template/defaultConfig.js +2 -2
  3. package/template/src/assets/font-styles.css +4 -0
  4. package/template/src/assets/fonts/icomoon.ttf +0 -0
  5. package/template/src/assets/selection.json +1 -1
  6. package/template/src/atoms/ActionMenu.tsx +1 -1
  7. package/template/src/atoms/CustomIcon.tsx +1 -0
  8. package/template/src/atoms/Popup.tsx +1 -1
  9. package/template/src/components/Controls.tsx +21 -32
  10. package/template/src/language/default-labels/videoCallScreenLabels.ts +9 -9
  11. package/template/src/pages/VideoCall.tsx +2 -1
  12. package/template/src/pages/video-call/ActionSheetContent.tsx +0 -7
  13. package/template/src/pages/video-call/SidePanelHeader.tsx +80 -63
  14. package/template/src/rtm-events/constants.ts +9 -0
  15. package/template/src/subComponents/caption/Caption.tsx +4 -20
  16. package/template/src/subComponents/caption/CaptionContainer.tsx +262 -250
  17. package/template/src/subComponents/caption/CaptionIcon.tsx +6 -4
  18. package/template/src/subComponents/caption/CaptionText.tsx +26 -20
  19. package/template/src/subComponents/caption/LanguageSelectorPopup.tsx +30 -142
  20. package/template/src/subComponents/caption/Transcript.tsx +77 -32
  21. package/template/src/subComponents/caption/TranscriptIcon.tsx +7 -6
  22. package/template/src/subComponents/caption/TranslateActionMenu.tsx +128 -0
  23. package/template/src/subComponents/caption/useCaption.tsx +666 -480
  24. package/template/src/subComponents/caption/useSTTAPI.tsx +25 -4
  25. package/template/src/subComponents/caption/useStreamMessageUtils.native.ts +1 -1
  26. package/template/src/subComponents/caption/useStreamMessageUtils.ts +1 -1
  27. 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, LanguageTranslationConfig} from './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 {LanguageType, langData, mergeTranslationConfigs} from './utils';
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
- const [langActionMenuVisible, setLangActionMenuVisible] =
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
- // setLanguage,
283
- // selectedTranslationLanguage,
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
- // const {
299
- // data: {isHost},
300
- // sttLanguage,
301
- // } = useRoomInfo();
287
+ const {
288
+ data: {isHost},
289
+ } = useRoomInfo();
302
290
 
303
- const changeSpokenLangLabel = useString<boolean>(
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
- actionMenuitems.push({
313
- icon: 'globe',
314
- iconColor: $config.SECONDARY_ACTION_COLOR,
315
- textColor: $config.FONT_COLOR,
316
- title: changeSpokenLangLabel + ' ',
317
- disabled: isLangChangeInProgress,
318
- onPress: () => {
319
- setActionMenuVisible(false);
320
- setLanguagePopup(true);
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
- icon: 'lang-select',
327
- iconColor: $config.SECONDARY_ACTION_COLOR,
328
- textColor: $config.FONT_COLOR,
329
- title: sttStopTranslationLabel,
330
- disabled: isLangChangeInProgress,
331
- onPress: async () => {
332
- setActionMenuVisible(false);
333
- await updateSTTBotSession({
334
- source: translationConfig.source,
335
- targets: [], // Empty targets = no translation
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-translate',
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: sttOriginalTranslatedLabel,
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
- const onLanguageChange = async (
372
- inputTranslateConfig: LanguageTranslationConfig,
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 handleTranslateConfigChange(inputTranslateConfig);
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
- <LanguageSelectorPopup
417
- modalVisible={isLanguagePopupOpen}
418
- setModalVisible={setLanguagePopup}
419
- onConfirm={onLanguageChange}
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
- actionMenuVisible: boolean;
427
- setActionMenuVisible: (actionMenuVisible: boolean) => void;
428
- btnRef: React.RefObject<View>;
429
- }
430
-
431
- export const TranslateActionMenu = (props: TranslateActionMenuProps) => {
432
- const {actionMenuVisible, setActionMenuVisible, btnRef} = props;
433
- const [modalPosition, setModalPosition] = React.useState({});
434
- const [isPosCalculated, setIsPosCalculated] = React.useState(false);
435
- const {width: globalWidth, height: globalHeight} = useWindowDimensions();
436
- const {
437
- language: currentSpokenLanguages,
438
- selectedTranslationLanguage,
439
- setSelectedTranslationLanguage,
440
- setMeetingTranscript,
441
- translationConfig,
442
- } = useCaption();
443
- const {update} = useSTTAPI();
444
- const localUid = useLocalUid();
445
- const {sttLanguage} = useRoomInfo();
446
-
447
- // Reset selected translation language if there are no targets configured
448
- const targetLanguages = translationConfig?.targets || [];
449
- React.useEffect(() => {
450
- if (targetLanguages.length === 0 && selectedTranslationLanguage !== '') {
451
- setSelectedTranslationLanguage('');
452
- }
453
- }, [
454
- targetLanguages.length,
455
- selectedTranslationLanguage,
456
- setSelectedTranslationLanguage,
457
- ]);
458
-
459
- const actionMenuitems: ActionMenuItem[] = [];
460
-
461
- actionMenuitems.push({
462
- iconColor: $config.SECONDARY_ACTION_COLOR,
463
- textColor: $config.FONT_COLOR,
464
- title: 'Add Another Translation',
465
- iconPosition: 'end',
466
- disabled: true,
467
- onPress: () => {},
468
- });
469
-
470
- const handleTranslationToggle = (targetLanguage: string) => {
471
- // Simply update the selected translation language locally
472
- // No API call needed - we're just switching between already-configured target languages
473
- // const prevTranslationLanguage = selectedTranslationLanguage;
474
- setSelectedTranslationLanguage(targetLanguage);
475
-
476
- // // Add translation language change notification to transcript
477
- // const getLanguageName = (langCode: string) => {
478
- // if (!langCode) return '';
479
- // const lang = langData.find(data => data.value === langCode);
480
- // return lang ? lang.label : langCode;
481
- // };
482
-
483
- // const actionText =
484
- // targetLanguage === ''
485
- // ? 'turned off translation'
486
- // : prevTranslationLanguage === ''
487
- // ? `set the translation language to "${getLanguageName(targetLanguage)}"`
488
- // : `changed the translation language from "${getLanguageName(
489
- // prevTranslationLanguage,
490
- // )}" to "${getLanguageName(targetLanguage)}"`;
491
-
492
- // setMeetingTranscript(prev => [
493
- // ...prev,
494
- // {
495
- // name: 'translationUpdate',
496
- // time: new Date().getTime(),
497
- // uid: `translationUpdate-${localUid}`,
498
- // text: actionText,
499
- // },
500
- // ]);
501
-
502
- setActionMenuVisible(false);
503
- };
504
-
505
- // Check if there are any target languages configured
506
- if (targetLanguages.length === 0) {
507
- // No target languages - show a disabled message
508
- actionMenuitems.push({
509
- icon: undefined,
510
- iconColor: $config.FONT_COLOR,
511
- textColor: $config.FONT_COLOR + hexadecimalTransparency['50%'],
512
- title: 'No languages configured',
513
- iconPosition: 'end',
514
- disabled: true,
515
- onPress: () => {},
516
- });
517
- } else {
518
- // Show "Off" option and target languages
519
- actionMenuitems.push({
520
- icon: selectedTranslationLanguage === '' ? 'tick-fill' : undefined,
521
- iconColor: $config.PRIMARY_ACTION_BRAND_COLOR,
522
- textColor: $config.FONT_COLOR,
523
- title: 'Off',
524
- iconPosition: 'end',
525
- onPress: () => handleTranslationToggle(''),
526
- });
527
-
528
- // Add selected translation language right after "Off" if one is selected
529
- if (selectedTranslationLanguage && selectedTranslationLanguage !== '') {
530
- const selectedLanguage = langData.find(
531
- lang => lang.value === selectedTranslationLanguage,
532
- );
533
- if (selectedLanguage) {
534
- actionMenuitems.push({
535
- icon: 'tick-fill',
536
- iconColor: $config.PRIMARY_ACTION_BRAND_COLOR,
537
- textColor: $config.FONT_COLOR,
538
- title: selectedLanguage.label,
539
- iconPosition: 'end',
540
- onPress: () => handleTranslationToggle(selectedLanguage.value),
541
- });
542
- }
543
- }
544
-
545
- // Add remaining Translation language options from translationConfig.targets (excluding the selected one)
546
- targetLanguages.forEach(targetLangCode => {
547
- if (targetLangCode !== selectedTranslationLanguage) {
548
- const language = langData.find(lang => lang.value === targetLangCode);
549
- if (language) {
550
- actionMenuitems.push({
551
- icon: undefined,
552
- iconColor: $config.PRIMARY_ACTION_BRAND_COLOR,
553
- textColor: $config.FONT_COLOR,
554
- title: language.label,
555
- iconPosition: 'end',
556
- onPress: () => handleTranslationToggle(language.value),
557
- });
558
- }
559
- }
560
- });
561
- }
562
-
563
- React.useEffect(() => {
564
- if (actionMenuVisible) {
565
- btnRef?.current?.measure(
566
- (
567
- _fx: number,
568
- _fy: number,
569
- localWidth: number,
570
- localHeight: number,
571
- px: number,
572
- py: number,
573
- ) => {
574
- const data = calculatePosition({
575
- px,
576
- py,
577
- localWidth,
578
- localHeight,
579
- globalHeight,
580
- globalWidth,
581
- });
582
- setModalPosition(data);
583
- setIsPosCalculated(true);
584
- },
585
- );
586
- }
587
- }, [actionMenuVisible]);
588
-
589
- return (
590
- <ActionMenu
591
- from={'translation'}
592
- actionMenuVisible={actionMenuVisible && isPosCalculated}
593
- setActionMenuVisible={setActionMenuVisible}
594
- modalPosition={modalPosition}
595
- items={actionMenuitems}
596
- containerStyle={{
597
- maxHeight: Math.min(440, globalHeight * 0.6),
598
- width: 220,
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
- handleTranslateConfigChange,
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: false,
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 (inputTranslateConfig: LanguageTranslationConfig) => {
92
+ const onConfirm = async (newSpokenLang: LanguageType) => {
91
93
  try {
92
94
  closeActionSheet();
93
95
  setLanguagePopup(false);
94
96
  setIsCaptionON(prev => !prev);
95
- await handleTranslateConfigChange(inputTranslateConfig);
97
+ await confirmSpokenLanguageChange(newSpokenLang);
96
98
  } catch (error) {
97
99
  setIsCaptionON(false);
98
100
  console.log('error in starting stt', error);