-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMainCallControls.vue
More file actions
217 lines (198 loc) · 7.17 KB
/
Copy pathMainCallControls.vue
File metadata and controls
217 lines (198 loc) · 7.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<template>
<div class="call-controls" :class="{ mobile: isMobile, 'landscape-mobile': isLandscapeMobile }">
<j-tooltip placement="top" :title="mediaSettings.audioEnabled ? 'Mute microphone' : 'Unmute microphone'">
<j-button
:variant="mediaSettings.audioEnabled ? '' : 'primary'"
@click="mediaDeviceStore.toggleAudio"
square
circle
:size="isMobile ? 'md' : 'lg'"
>
<j-icon :name="mediaSettings.audioEnabled ? 'mic' : 'mic-mute'" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
<j-tooltip placement="top" :title="mediaSettings.videoEnabled ? 'Disable camera' : 'Enable camera'">
<j-button
:variant="mediaSettings.videoEnabled ? '' : 'primary'"
@click="mediaDeviceStore.toggleVideo"
square
circle
:size="isMobile ? 'md' : 'lg'"
:disabled="!availableDevices.filter((d) => d.kind === 'videoinput').length"
>
<j-icon
:name="mediaSettings.videoEnabled ? 'camera-video' : 'camera-video-off'"
:size="isMobile ? 'sm' : 'md'"
/>
</j-button>
</j-tooltip>
<j-tooltip placement="top" :title="mediaSettings.screenShareEnabled ? 'Stop sharing' : 'Share screen'">
<j-button
:variant="mediaSettings.screenShareEnabled ? 'primary' : ''"
@click="mediaDeviceStore.toggleScreenShare"
square
circle
:size="isMobile ? 'md' : 'lg'"
:disabled="!inCall"
>
<j-icon name="display" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
<j-tooltip v-if="!isMobile" placement="top" :title="`${transcriptionEnabled ? 'Disable' : 'Enable'} transcription`">
<j-button
:variant="transcriptionEnabled ? '' : 'primary'"
:disabled="!inCall"
@click="aiStore.toggleTranscriptionEnabled"
square
circle
:size="isMobile ? 'md' : 'lg'"
>
<TranscriptionIcon :enabled="transcriptionEnabled" />
</j-button>
</j-tooltip>
<j-popover v-if="!isMobile" ref="emojiPopover" placement="top">
<j-tooltip slot="trigger" placement="top" title="Send reaction">
<j-button variant="transparent" square circle :disabled="!inCall" :size="isMobile ? 'md' : 'lg'">
<j-icon name="emoji-neutral" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
<div slot="content">
<j-emoji-picker class="emoji-picker" @change="onEmojiClick" />
</div>
</j-popover>
<j-tooltip v-if="!isMobile" placement="top" :title="callWindowFullscreen ? 'Shrink screen' : 'Full screen'">
<j-button @click="uiStore.toggleCallWindowFullscreen" square circle :size="isMobile ? 'md' : 'lg'">
<j-icon :name="`arrows-angle-${callWindowFullscreen ? 'contract' : 'expand'}`" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
<j-tooltip
v-if="!isMobile && inCall"
placement="top"
:title="selfViewVisible ? 'Hide my video' : 'Show my video'"
>
<j-button
:variant="selfViewVisible ? '' : 'primary'"
@click="uiStore.toggleSelfViewVisible"
square
circle
:size="isMobile ? 'md' : 'lg'"
>
<j-icon :name="selfViewVisible ? 'eye-slash' : 'eye'" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
<j-popover v-if="!isMobile" ref="videoLayoutPopover" placement="top">
<j-tooltip slot="trigger" placement="top" title="Video layout options">
<j-button variant="transparent" square circle :disabled="!inCall" :size="isMobile ? 'md' : 'lg'">
<j-icon name="grid" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
<j-menu slot="content">
<j-menu-item
v-for="option in videoLayoutOptions"
:key="option.label"
@click="() => selectVideoLayout(option)"
:selected="option.label === selectedVideoLayout.label"
>
<j-flex a="center" gap="400">
<j-icon :name="option.icon" color="ui-500" />
<j-text nomargin>{{ option.label }}</j-text>
</j-flex>
</j-menu-item>
</j-menu>
</j-popover>
<j-tooltip placement="top" :title="hasCopiedLink ? 'Copied!' : 'Copy invite link'">
<j-button @click="webrtcStore.copyCallLink" square circle :size="isMobile ? 'md' : 'lg'">
<j-icon
:name="hasCopiedLink ? 'clipboard-check' : 'link-45deg'"
:style="{
'--j-icon-size': isMobile ? (hasCopiedLink ? '1.3em' : '1.7em') : hasCopiedLink ? '1.5em' : '2em',
margin: hasCopiedLink ? '0' : '0 0 -4px 0',
}"
/>
</j-button>
</j-tooltip>
<j-tooltip placement="top" title="Call settings">
<j-button
@click="modalStore.showWebrtcSettings = !modalStore.showWebrtcSettings"
square
circle
:size="isMobile ? 'md' : 'lg'"
>
<j-icon name="gear" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
<j-tooltip placement="top" title="Leave call">
<j-button
variant="danger"
@click="webrtcStore.leaveRoom"
square
circle
:size="isMobile ? 'md' : 'lg'"
:disabled="!inCall"
>
<j-icon name="telephone-x" :size="isMobile ? 'sm' : 'md'" />
</j-button>
</j-tooltip>
</div>
</template>
<script setup lang="ts">
import TranscriptionIcon from '@/components/icons/TranscriptionIcon.vue';
import {
useAiStore,
useAppStore,
useMediaDevicesStore,
useModalStore,
useUiStore,
useWebrtcStore,
WEBRTC_EMOJI,
} from '@/stores';
import { storeToRefs } from 'pinia';
import { ref } from 'vue';
import { useVideoLayout } from '../composables/useVideoLayout';
const appStore = useAppStore();
const uiStore = useUiStore();
const webrtcStore = useWebrtcStore();
const mediaDeviceStore = useMediaDevicesStore();
const modalStore = useModalStore();
const aiStore = useAiStore();
const { me } = storeToRefs(appStore);
const { callWindowFullscreen, isMobile, isLandscapeMobile, selfViewVisible } = storeToRefs(uiStore);
const { mediaSettings, availableDevices } = storeToRefs(mediaDeviceStore);
const { transcriptionEnabled } = storeToRefs(aiStore);
const { inCall, hasCopiedLink } = storeToRefs(webrtcStore);
const { videoLayoutOptions, selectedVideoLayout, selectVideoLayout } = useVideoLayout();
const emojiPopover = ref<HTMLElement | null>(null);
function onEmojiClick(e: CustomEvent<{ native?: string }>) {
const emoji = e?.detail?.native;
const did = me.value?.did;
if (!emoji || !did) {
emojiPopover.value?.removeAttribute('open');
return;
}
webrtcStore.signalAgentsInCall(WEBRTC_EMOJI, emoji);
webrtcStore.displayEmoji(emoji, did);
emojiPopover.value?.removeAttribute('open');
}
</script>
<style scoped lang="scss">
.call-controls {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: var(--j-space-400);
font-family: var(--j-font-family);
border-radius: var(--j-border-radius);
background-color: #ffffff08;
padding: var(--j-space-400);
&.mobile {
padding: var(--j-space-300);
position: absolute;
bottom: 0;
background-color: #00000053;
}
&.landscape-mobile {
left: calc(50% - 90px);
}
}
</style>