agora-appbuilder-core 4.1.9 → 4.1.10-beta.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 (107) hide show
  1. package/package.json +2 -2
  2. package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +1 -3
  3. package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +1 -2
  4. package/template/agora-rn-uikit/src/Reducer/index.ts +0 -2
  5. package/template/agora-rn-uikit/src/Rtc/Join.tsx +11 -25
  6. package/template/agora-rn-uikit/src/RtcConfigure.tsx +1 -14
  7. package/template/bridge/rtc/webNg/RtcEngine.ts +2 -2
  8. package/template/bridge/rtm/web/index.ts +30 -0
  9. package/template/customization-api/typeDefinition.ts +1 -0
  10. package/template/defaultConfig.js +3 -2
  11. package/template/global.d.ts +1 -0
  12. package/template/src/AppRoutes.tsx +3 -3
  13. package/template/src/ai-agent/components/ControlButtons.tsx +1 -1
  14. package/template/src/assets/font-styles.css +36 -0
  15. package/template/src/assets/fonts/icomoon.ttf +0 -0
  16. package/template/src/assets/selection.json +1 -1
  17. package/template/src/atoms/CustomIcon.tsx +8 -0
  18. package/template/src/atoms/Dropdown.tsx +5 -0
  19. package/template/src/atoms/TertiaryButton.tsx +1 -1
  20. package/template/src/atoms/UserAvatar.tsx +1 -1
  21. package/template/src/components/ChatContext.ts +5 -3
  22. package/template/src/components/Controls.tsx +68 -22
  23. package/template/src/components/DeviceConfigure.tsx +1 -1
  24. package/template/src/components/EventsConfigure.tsx +22 -17
  25. package/template/src/components/Navbar.tsx +14 -11
  26. package/template/src/components/RTMConfigure.tsx +31 -1036
  27. package/template/src/components/UserGlobalPreferenceProvider.tsx +227 -0
  28. package/template/src/components/beauty-effect/useBeautyEffects.tsx +50 -13
  29. package/template/src/components/breakout-room/BreakoutRoomPanel.tsx +58 -0
  30. package/template/src/components/breakout-room/context/BreakoutRoomContext.tsx +2508 -0
  31. package/template/src/components/breakout-room/events/BreakoutRoomEventsConfigure.tsx +272 -0
  32. package/template/src/components/breakout-room/events/constants.ts +17 -0
  33. package/template/src/components/breakout-room/hoc/BreakoutRoomNameRenderer.tsx +68 -0
  34. package/template/src/components/breakout-room/hooks/useBreakoutRoomExit.ts +49 -0
  35. package/template/src/components/breakout-room/state/reducer.ts +522 -0
  36. package/template/src/components/breakout-room/state/types.ts +54 -0
  37. package/template/src/components/breakout-room/ui/BreakoutMeetingTitle.tsx +60 -0
  38. package/template/src/components/breakout-room/ui/BreakoutRoomActionMenu.tsx +136 -0
  39. package/template/src/components/breakout-room/ui/BreakoutRoomAnnouncementModal.tsx +135 -0
  40. package/template/src/components/breakout-room/ui/BreakoutRoomGroupSettings.tsx +588 -0
  41. package/template/src/components/breakout-room/ui/BreakoutRoomMainRoomUsers.tsx +142 -0
  42. package/template/src/components/breakout-room/ui/BreakoutRoomMemberActionMenu.tsx +122 -0
  43. package/template/src/components/breakout-room/ui/BreakoutRoomParticipants.tsx +124 -0
  44. package/template/src/components/breakout-room/ui/BreakoutRoomRaiseHand.tsx +65 -0
  45. package/template/src/components/breakout-room/ui/BreakoutRoomRenameModal.tsx +227 -0
  46. package/template/src/components/breakout-room/ui/BreakoutRoomSettings.tsx +140 -0
  47. package/template/src/components/breakout-room/ui/BreakoutRoomTransition.tsx +52 -0
  48. package/template/src/components/breakout-room/ui/BreakoutRoomView.tsx +193 -0
  49. package/template/src/components/breakout-room/ui/ExitBreakoutRoomIconButton.tsx +79 -0
  50. package/template/src/components/breakout-room/ui/ParticipantManualAssignmentModal.tsx +638 -0
  51. package/template/src/components/breakout-room/ui/SelectParticipantAssignmentStrategy.tsx +57 -0
  52. package/template/src/components/chat/chatConfigure.tsx +7 -1
  53. package/template/src/components/chat-messages/useChatMessages.tsx +43 -11
  54. package/template/src/components/common/Dividers.tsx +53 -0
  55. package/template/src/components/controls/toolbar-items/ExitBreakoutRoomToolbarItem.tsx +13 -0
  56. package/template/src/components/controls/useControlPermissionMatrix.tsx +32 -4
  57. package/template/src/components/participants/AllHostParticipants.tsx +10 -2
  58. package/template/src/components/participants/Participant.tsx +7 -1
  59. package/template/src/components/participants/UserActionMenuOptions.tsx +12 -2
  60. package/template/src/components/precall/joinWaitingRoomBtn.native.tsx +12 -8
  61. package/template/src/components/precall/joinWaitingRoomBtn.tsx +14 -10
  62. package/template/src/components/raise-hand/RaiseHandButton.tsx +50 -0
  63. package/template/src/components/raise-hand/RaiseHandProvider.tsx +308 -0
  64. package/template/src/components/raise-hand/index.ts +14 -0
  65. package/template/src/components/recordings/RecordingsDateTable.tsx +3 -2
  66. package/template/src/components/room-info/useCurrentRoomInfo.tsx +42 -0
  67. package/template/src/components/room-info/useSetBreakoutRoomInfo.tsx +64 -0
  68. package/template/src/components/useUserPreference.tsx +39 -12
  69. package/template/src/components/virtual-background/useVB.tsx +18 -0
  70. package/template/src/components/whiteboard/WhiteboardConfigure.tsx +27 -0
  71. package/template/src/language/default-labels/videoCallScreenLabels.ts +7 -0
  72. package/template/src/logger/AppBuilderLogger.tsx +11 -3
  73. package/template/src/pages/VideoCall.tsx +171 -518
  74. package/template/src/pages/video-call/BreakoutVideoCall.tsx +213 -0
  75. package/template/src/pages/video-call/SidePanelHeader.tsx +17 -0
  76. package/template/src/pages/video-call/VideoCallContent.tsx +211 -0
  77. package/template/src/pages/video-call/VideoCallScreen.tsx +18 -0
  78. package/template/src/pages/video-call/VideoCallScreenWrapper.tsx +0 -1
  79. package/template/src/pages/video-call/VideoCallStateWrapper.tsx +495 -0
  80. package/template/src/rtm/RTMConfigureBreakoutRoomProvider.tsx +882 -0
  81. package/template/src/rtm/RTMConfigureMainRoomProvider.tsx +757 -0
  82. package/template/src/rtm/RTMCoreProvider.tsx +419 -0
  83. package/template/src/rtm/RTMEngine.ts +188 -60
  84. package/template/src/rtm/RTMGlobalStateProvider.tsx +706 -0
  85. package/template/src/rtm/RTMStatusBanner.tsx +99 -0
  86. package/template/src/rtm/constants.ts +12 -0
  87. package/template/src/rtm/hooks/useMainRoomUserDisplayName.ts +45 -0
  88. package/template/src/rtm/rtm-presence-utils.ts +344 -0
  89. package/template/src/rtm/utils.ts +68 -1
  90. package/template/src/rtm-events/constants.ts +40 -1
  91. package/template/src/rtm-events-api/Events.ts +62 -19
  92. package/template/src/subComponents/ChatBubble.tsx +3 -3
  93. package/template/src/subComponents/ChatContainer.tsx +19 -9
  94. package/template/src/subComponents/LocalAudioMute.tsx +2 -2
  95. package/template/src/subComponents/LocalVideoMute.tsx +2 -2
  96. package/template/src/subComponents/SidePanelEnum.tsx +1 -0
  97. package/template/src/subComponents/caption/useCaption.tsx +1 -1
  98. package/template/src/subComponents/chat/ChatAnnouncementView.tsx +65 -0
  99. package/template/src/subComponents/chat/ChatSendButton.tsx +1 -0
  100. package/template/src/subComponents/screenshare/ScreenshareButton.tsx +16 -0
  101. package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +1 -1
  102. package/template/src/subComponents/waiting-rooms/WaitingRoomControls.tsx +7 -4
  103. package/template/src/utils/useDebouncedCallback.tsx +20 -0
  104. package/template/src/utils/useEndCall.ts +0 -2
  105. package/template/src/utils/useMuteToggleLocal.ts +14 -10
  106. package/template/agora-rn-uikit/src/Reducer/Spotlight.ts +0 -11
  107. package/template/agora-rn-uikit/src/Reducer/UserBanned.ts +0 -11
@@ -0,0 +1,140 @@
1
+ import React, {useState} from 'react';
2
+ import {View, StyleSheet, Text} from 'react-native';
3
+ import BreakoutRoomParticipants from './BreakoutRoomParticipants';
4
+ import SelectParticipantAssignmentStrategy from './SelectParticipantAssignmentStrategy';
5
+ import Divider from '../../common/Dividers';
6
+ import ThemeConfig from '../../../theme';
7
+ import {useBreakoutRoom} from '../context/BreakoutRoomContext';
8
+ import Toggle from '../../../atoms/Toggle';
9
+ import ParticipantManualAssignmentModal from './ParticipantManualAssignmentModal';
10
+ import {useModal} from '../../../utils/useModal';
11
+ import {RoomAssignmentStrategy} from '../state/reducer';
12
+ import TertiaryButton from '../../../atoms/TertiaryButton';
13
+
14
+ export default function BreakoutRoomSettings() {
15
+ const {
16
+ unassignedParticipants,
17
+ assignmentStrategy,
18
+ handleAssignParticipants,
19
+ canUserSwitchRoom,
20
+ toggleRoomSwitchingAllowed,
21
+ } = useBreakoutRoom();
22
+
23
+ // Local dropdown state to prevent sync conflicts
24
+ const [localAssignmentStrategy, setLocalAssignmentStrategy] =
25
+ useState(assignmentStrategy);
26
+
27
+ const disableAssignmentSelect = unassignedParticipants.length === 0;
28
+ const disableHandleAssignment =
29
+ disableAssignmentSelect ||
30
+ localAssignmentStrategy === RoomAssignmentStrategy.NO_ASSIGN;
31
+
32
+ const {
33
+ modalOpen: isManualAssignmentModalOpen,
34
+ setModalOpen: setManualAssignmentModalOpen,
35
+ } = useModal();
36
+
37
+ // Handle strategy change from dropdown
38
+ const handleStrategyChange = (newStrategy: RoomAssignmentStrategy) => {
39
+ setLocalAssignmentStrategy(newStrategy);
40
+
41
+ // Immediately call API for NO_ASSIGN strategy
42
+ if (newStrategy === RoomAssignmentStrategy.NO_ASSIGN) {
43
+ handleAssignParticipants(newStrategy);
44
+ }
45
+ };
46
+
47
+ // Handle assign participants button click
48
+ const handleAssignClick = () => {
49
+ if (localAssignmentStrategy === RoomAssignmentStrategy.MANUAL_ASSIGN) {
50
+ // Open manual assignment modal
51
+ setManualAssignmentModalOpen(true);
52
+ } else {
53
+ // Handle other assignment strategies
54
+ handleAssignParticipants(localAssignmentStrategy);
55
+ }
56
+ };
57
+
58
+ return (
59
+ <View style={style.card}>
60
+ {/* Avatar list */}
61
+ <View style={style.section}>
62
+ <BreakoutRoomParticipants participants={unassignedParticipants} />
63
+ </View>
64
+ <Divider marginTop={0} marginBottom={0} />
65
+ <View style={style.section}>
66
+ <SelectParticipantAssignmentStrategy
67
+ selectedStrategy={localAssignmentStrategy}
68
+ onStrategyChange={handleStrategyChange}
69
+ disabled={disableAssignmentSelect}
70
+ />
71
+ <TertiaryButton
72
+ disabled={disableHandleAssignment}
73
+ containerStyle={{
74
+ backgroundColor: disableHandleAssignment
75
+ ? $config.SEMANTIC_NEUTRAL
76
+ : $config.PRIMARY_ACTION_BRAND_COLOR,
77
+ borderColor: disableHandleAssignment
78
+ ? $config.SEMANTIC_NEUTRAL
79
+ : $config.PRIMARY_ACTION_BRAND_COLOR,
80
+ }}
81
+ textStyle={{color: $config.PRIMARY_ACTION_TEXT_COLOR}}
82
+ onPress={handleAssignClick}
83
+ text={'Assign participants'}
84
+ />
85
+ </View>
86
+ <Divider />
87
+ <View style={style.section}>
88
+ <View style={style.switchSection}>
89
+ <Text style={style.label}>Allow people to switch rooms</Text>
90
+ <Toggle
91
+ disabled={$config.EVENT_MODE}
92
+ isEnabled={canUserSwitchRoom}
93
+ toggleSwitch={toggleRoomSwitchingAllowed}
94
+ circleColor={$config.PRIMARY_ACTION_TEXT_COLOR}
95
+ />
96
+ </View>
97
+ </View>
98
+ {isManualAssignmentModalOpen && (
99
+ <ParticipantManualAssignmentModal
100
+ setModalOpen={setManualAssignmentModalOpen}
101
+ />
102
+ )}
103
+ </View>
104
+ );
105
+ }
106
+
107
+ const style = StyleSheet.create({
108
+ card: {
109
+ width: '100%',
110
+ padding: 16,
111
+ display: 'flex',
112
+ flexDirection: 'column',
113
+ justifyContent: 'center',
114
+ alignItems: 'center',
115
+ borderRadius: 8,
116
+ backgroundColor: $config.CARD_LAYER_2_COLOR,
117
+ borderColor: $config.CARD_LAYER_3_COLOR,
118
+ gap: 12,
119
+ },
120
+ section: {
121
+ width: '100%',
122
+ display: 'flex',
123
+ flexDirection: 'column',
124
+ gap: 12,
125
+ },
126
+ switchSection: {
127
+ width: '100%',
128
+ display: 'flex',
129
+ flexDirection: 'row',
130
+ justifyContent: 'space-between',
131
+ alignItems: 'center',
132
+ },
133
+ label: {
134
+ fontWeight: '400',
135
+ fontSize: ThemeConfig.FontSize.small,
136
+ lineHeight: 16,
137
+ color: $config.FONT_COLOR,
138
+ fontFamily: ThemeConfig.FontFamily.sansPro,
139
+ },
140
+ });
@@ -0,0 +1,52 @@
1
+ import React, {useEffect, useState} from 'react';
2
+ import Loading from '../../../subComponents/Loading';
3
+ import {View, StyleSheet} from 'react-native';
4
+
5
+ interface BreakoutRoomTransitionProps {
6
+ onTimeout: () => void;
7
+ direction?: 'enter' | 'exit';
8
+ }
9
+
10
+ const BreakoutRoomTransition = ({
11
+ onTimeout,
12
+ direction = 'enter',
13
+ }: BreakoutRoomTransitionProps) => {
14
+ const [dots, setDots] = useState('');
15
+
16
+ useEffect(() => {
17
+ const interval = setInterval(() => {
18
+ setDots(prev => (prev.length >= 3 ? '' : prev + '.'));
19
+ }, 500);
20
+
21
+ const timeout = setTimeout(onTimeout, 10000); // 10s timeout
22
+
23
+ return () => {
24
+ clearInterval(interval);
25
+ clearTimeout(timeout);
26
+ };
27
+ }, [onTimeout]);
28
+
29
+ const transitionText =
30
+ direction === 'exit' ? 'Exiting breakout room' : 'Entering breakout room';
31
+
32
+ return (
33
+ <View style={styles.transitionContainer}>
34
+ <Loading
35
+ text={`${transitionText}...${dots}`}
36
+ background={$config.CARD_LAYER_1_COLOR}
37
+ textColor={$config.FONT_COLOR}
38
+ />
39
+ </View>
40
+ );
41
+ };
42
+
43
+ export default BreakoutRoomTransition;
44
+ const styles = StyleSheet.create({
45
+ transitionContainer: {
46
+ height: '100%',
47
+ display: 'flex',
48
+ flex: 1,
49
+ alignItems: 'center',
50
+ justifyContent: 'center',
51
+ },
52
+ });
@@ -0,0 +1,193 @@
1
+ import React, {useEffect, useState, useRef} from 'react';
2
+ import {View, StyleSheet, ScrollView} from 'react-native';
3
+ import {useRoomInfo} from '../../room-info/useRoomInfo';
4
+ import {useBreakoutRoom} from './../context/BreakoutRoomContext';
5
+ import BreakoutRoomSettings from './BreakoutRoomSettings';
6
+ import BreakoutRoomGroupSettings from './BreakoutRoomGroupSettings';
7
+ import ThemeConfig from '../../../theme';
8
+ import TertiaryButton from '../../../atoms/TertiaryButton';
9
+ import {BreakoutRoomHeader} from '../../../pages/video-call/SidePanelHeader';
10
+ import BreakoutRoomRaiseHand from './BreakoutRoomRaiseHand';
11
+ import BreakoutRoomMainRoomUsers from './BreakoutRoomMainRoomUsers';
12
+ import Loading from '../../../subComponents/Loading';
13
+
14
+ interface Props {
15
+ closeSidePanel: () => void;
16
+ }
17
+ export default function BreakoutRoomView({closeSidePanel}: Props) {
18
+ const [isInitializing, setIsInitializing] = useState(true);
19
+
20
+ const {
21
+ data: {isHost},
22
+ } = useRoomInfo();
23
+
24
+ const scrollViewRef = useRef<ScrollView>(null);
25
+ const [scrollOffset, setScrollOffset] = useState(0);
26
+
27
+ const onScroll = event => {
28
+ setScrollOffset(event.nativeEvent.contentOffset.y);
29
+ };
30
+
31
+ const {
32
+ checkIfBreakoutRoomSessionExistsAPI,
33
+ createBreakoutRoomGroup,
34
+ upsertBreakoutRoomAPI,
35
+ closeAllRooms,
36
+ permissions,
37
+ isBreakoutUILocked,
38
+ } = useBreakoutRoom();
39
+
40
+ useEffect(() => {
41
+ const init = async () => {
42
+ try {
43
+ setIsInitializing(true);
44
+ const activeSession = await checkIfBreakoutRoomSessionExistsAPI();
45
+ console.log('supriya-sync-queue activeSession: ', activeSession);
46
+ if (!activeSession && isHost) {
47
+ console.log(
48
+ 'supriya-sync-queue callubg upsertBreakoutRoomAPI: ',
49
+ activeSession,
50
+ );
51
+
52
+ await upsertBreakoutRoomAPI('START');
53
+ }
54
+ } catch (error) {
55
+ console.error('Failed to check breakout session:', error);
56
+ } finally {
57
+ setIsInitializing(false);
58
+ }
59
+ };
60
+ init();
61
+ }, []);
62
+
63
+ // Disable all actions when API is in flight or another host is operating
64
+ const disableAllActions = isBreakoutUILocked;
65
+
66
+ return (
67
+ <>
68
+ <BreakoutRoomHeader />
69
+ <ScrollView
70
+ ref={scrollViewRef}
71
+ onScroll={onScroll}
72
+ scrollEventThrottle={64}
73
+ style={[style.pannelOuterBody]}
74
+ contentContainerStyle={
75
+ isInitializing ? style.contentCenter : style.contentStart
76
+ }>
77
+ {isInitializing ? (
78
+ <View style={style.panelInnerBody}>
79
+ <Loading
80
+ text={'Initializing...'}
81
+ background={$config.CARD_LAYER_1_COLOR}
82
+ textColor={$config.FONT_COLOR}
83
+ />
84
+ </View>
85
+ ) : (
86
+ <View
87
+ style={[
88
+ style.panelInnerBody,
89
+ disableAllActions ? style.disabledPannelInnerBody : {},
90
+ ]}>
91
+ {permissions?.canRaiseHands ? <BreakoutRoomRaiseHand /> : <></>}
92
+ {permissions?.canHostManageMainRoom &&
93
+ permissions.canAssignParticipants ? (
94
+ <BreakoutRoomSettings />
95
+ ) : (
96
+ <BreakoutRoomMainRoomUsers scrollOffset={scrollOffset} />
97
+ )}
98
+ <BreakoutRoomGroupSettings scrollOffset={scrollOffset} />
99
+ {permissions?.canHostManageMainRoom &&
100
+ permissions?.canCreateRooms ? (
101
+ <TertiaryButton
102
+ disabled={disableAllActions}
103
+ containerStyle={style.createBtnContainer}
104
+ textStyle={style.createBtnText}
105
+ text={'+ Create New Room'}
106
+ onPress={() => createBreakoutRoomGroup()}
107
+ />
108
+ ) : (
109
+ <></>
110
+ )}
111
+ </View>
112
+ )}
113
+ </ScrollView>
114
+ {!isInitializing &&
115
+ permissions.canHostManageMainRoom &&
116
+ permissions?.canCloseRooms ? (
117
+ <View style={style.footer}>
118
+ <View style={style.fullWidth}>
119
+ <TertiaryButton
120
+ disabled={disableAllActions}
121
+ containerStyle={{
122
+ borderColor: $config.SEMANTIC_ERROR,
123
+ }}
124
+ textStyle={{
125
+ color: $config.SEMANTIC_ERROR,
126
+ }}
127
+ onPress={() => {
128
+ try {
129
+ closeAllRooms();
130
+ closeSidePanel();
131
+ } catch (error) {
132
+ console.error('Error while closing the room', error);
133
+ }
134
+ }}
135
+ text={'Close All Rooms'}
136
+ />
137
+ </View>
138
+ </View>
139
+ ) : (
140
+ <></>
141
+ )}
142
+ </>
143
+ );
144
+ }
145
+
146
+ const style = StyleSheet.create({
147
+ footer: {
148
+ width: '100%',
149
+ padding: 12,
150
+ height: 'auto',
151
+ flexDirection: 'row',
152
+ alignItems: 'center',
153
+ justifyContent: 'center',
154
+ backgroundColor: $config.CARD_LAYER_2_COLOR,
155
+ },
156
+ contentCenter: {
157
+ height: '100%',
158
+ justifyContent: 'center',
159
+ },
160
+ contentStart: {
161
+ justifyContent: 'flex-start',
162
+ },
163
+ pannelOuterBody: {
164
+ display: 'flex',
165
+ flex: 1,
166
+ },
167
+ panelInnerBody: {
168
+ display: 'flex',
169
+ flex: 1,
170
+ padding: 12,
171
+ gap: 12,
172
+ },
173
+ fullWidth: {
174
+ display: 'flex',
175
+ flex: 1,
176
+ },
177
+ createBtnContainer: {
178
+ backgroundColor: $config.INPUT_FIELD_BACKGROUND_COLOR,
179
+ borderColor: $config.INPUT_FIELD_BORDER_COLOR,
180
+ borderRadius: 8,
181
+ },
182
+ createBtnText: {
183
+ color: $config.PRIMARY_ACTION_BRAND_COLOR,
184
+ lineHeight: 20,
185
+ fontWeight: '500',
186
+ fontSize: ThemeConfig.FontSize.normal,
187
+ },
188
+
189
+ disabledPannelInnerBody: {
190
+ opacity: 0.4,
191
+ pointerEvents: 'none',
192
+ },
193
+ });
@@ -0,0 +1,79 @@
1
+ /*
2
+ ********************************************
3
+ Copyright © 2021 Agora Lab, Inc., all rights reserved.
4
+ AppBuilder and all associated components, source code, APIs, services, and documentation
5
+ (the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
6
+ accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
7
+ Use without a license or in violation of any license terms and conditions (including use for
8
+ any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
9
+ information visit https://appbuilder.agora.io.
10
+ *********************************************
11
+ */
12
+
13
+ import React from 'react';
14
+ import IconButton, {IconButtonProps} from '../../../atoms/IconButton';
15
+ import {useToolbarMenu} from '../../../utils/useMenu';
16
+ import ToolbarMenuItem from '../../../atoms/ToolbarMenuItem';
17
+ import {useToolbarProps} from '../../../atoms/ToolbarItem';
18
+ import {useActionSheet} from '../../../utils/useActionSheet';
19
+ import {useBreakoutRoom} from '../context/BreakoutRoomContext';
20
+ import BreakoutRoomNameRenderer from '../hoc/BreakoutRoomNameRenderer';
21
+
22
+ export interface ScreenshareButtonProps {
23
+ render?: (onPress: () => void) => JSX.Element;
24
+ }
25
+
26
+ const ExitBreakoutRoomIconButton = (props: ScreenshareButtonProps) => {
27
+ const {label = null, onPress: onPressCustom = null} = useToolbarProps();
28
+ const {isOnActionSheet, showLabel} = useActionSheet();
29
+ const {exitRoom} = useBreakoutRoom();
30
+ const {isToolbarMenuItem} = useToolbarMenu();
31
+
32
+ const onPress = () => {
33
+ exitRoom();
34
+ };
35
+
36
+ return (
37
+ <BreakoutRoomNameRenderer>
38
+ {({breakoutRoomName}) => {
39
+ const displayText = breakoutRoomName
40
+ ? `Exit ${breakoutRoomName}`
41
+ : 'Exit Room';
42
+
43
+ let iconButtonProps: IconButtonProps = {
44
+ onPress: onPressCustom || onPress,
45
+ iconProps: {
46
+ name: 'close-room',
47
+ tintColor: $config.SECONDARY_ACTION_COLOR,
48
+ },
49
+ btnTextProps: {
50
+ textColor: $config.FONT_COLOR,
51
+ text: showLabel ? label || displayText : '',
52
+ },
53
+ };
54
+
55
+ if (isOnActionSheet) {
56
+ iconButtonProps.btnTextProps.textStyle = {
57
+ color: $config.FONT_COLOR,
58
+ marginTop: 8,
59
+ fontSize: 12,
60
+ fontWeight: '400',
61
+ fontFamily: 'Source Sans Pro',
62
+ textAlign: 'center',
63
+ };
64
+ }
65
+ iconButtonProps.isOnActionSheet = isOnActionSheet;
66
+
67
+ return props?.render ? (
68
+ props.render(onPress)
69
+ ) : isToolbarMenuItem ? (
70
+ <ToolbarMenuItem {...iconButtonProps} />
71
+ ) : (
72
+ <IconButton {...iconButtonProps} />
73
+ );
74
+ }}
75
+ </BreakoutRoomNameRenderer>
76
+ );
77
+ };
78
+
79
+ export default ExitBreakoutRoomIconButton;