Skip to content

Commit

Permalink
Fix(PresenterOverlay): move PresenterOverlay to a different component…
Browse files Browse the repository at this point in the history
… and add grabbing effects

Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Mar 22, 2024
1 parent 5a28d95 commit 9159c0f
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 59 deletions.
75 changes: 16 additions & 59 deletions src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,14 @@
:shared-data="sharedDatas[shownRemoteScreenPeerId]"
is-big />
<!-- presenter overlay -->
<VueDraggableResizable v-if="shouldShowPresenterOverlay"
:key="presenterOverlaySize"
parent
:resizable="false"
:h="presenterOverlaySize"
:w="presenterOverlaySize"
:x="10"
:y="10">
<VideoVue class="presenter-overlay__video"
:token="token"
:model="shownRemoteScreenCallParticipantModel"
:shared-data="sharedDatas[shownRemoteScreenPeerId]"
is-presenter-overlay
un-selectable
hide-bottom-bar
@click-presenter="toggleShowPresenterOverlay" />
</VueDraggableResizable>
<!-- presenter button when presenter overlay is collapsed -->
<NcButton v-else-if="isPresenterCollapsed"
:aria-label="t('spreed', 'Show presenter')"
:title="t('spreed', 'Show presenter')"
class="presenter-overlay--collapse"
type="tertiary-no-background"
@click="toggleShowPresenterOverlay">
<template #icon>
<AccountBox fill-color="#ffffff" :size="20" />
</template>
</NcButton>
<PresenterOverlay v-if="shouldShowPresenterOverlay || isPresenterCollapsed"
:class="{'presenter-overlay--collapsed': isPresenterCollapsed }"
:token="token"
:model="shownRemoteScreenCallParticipantModel"
:shared-data="sharedDatas[shownRemoteScreenPeerId]"
:is-collapsed="isPresenterCollapsed"
@click="toggleShowPresenterOverlay" />
</template>

<!-- Promoted "autopilot" mode -->
<VideoVue v-else-if="promotedParticipantModel"
:key="promotedParticipantModel.attributes.peerId"
Expand Down Expand Up @@ -159,19 +137,15 @@
<script>
import debounce from 'debounce'
import VueDraggableResizable from 'vue-draggable-resizable'
import AccountBox from 'vue-material-design-icons/AccountBoxOutline.vue'
import { getCapabilities } from '@nextcloud/capabilities'
import { showMessage } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import Grid from './Grid/Grid.vue'
import EmptyCallView from './shared/EmptyCallView.vue'
import LocalVideo from './shared/LocalVideo.vue'
import PresenterOverlay from './shared/PresenterOverlay.vue'
import ReactionToaster from './shared/ReactionToaster.vue'
import Screen from './shared/Screen.vue'
import VideoVue from './shared/VideoVue.vue'
Expand All @@ -190,13 +164,11 @@ export default {
name: 'CallView',
components: {
AccountBox,
EmptyCallView,
ViewerOverlayCallView,
VueDraggableResizable,
Grid,
LocalVideo,
NcButton,
PresenterOverlay,
ReactionToaster,
Screen,
VideoVue,
Expand Down Expand Up @@ -242,9 +214,9 @@ export default {
isBackgroundBlurred: true,
showPresenterOverlay: true,
debounceFetchPeers: () => {},
presenterOverlaySize: 128,
}
},
computed: {
promotedParticipantModel() {
return this.callParticipantModels.find((callParticipantModel) => this.sharedDatas[callParticipantModel.attributes.peerId].promoted)
Expand Down Expand Up @@ -380,6 +352,7 @@ export default {
return this.sharedDatas[this.shownRemoteScreenPeerId]?.remoteVideoBlocker?.isVideoEnabled()
},
},
watch: {
'localCallParticipantModel.attributes.peerId'(newValue, previousValue) {
const index = this.screens.indexOf(previousValue)
Expand Down Expand Up @@ -462,12 +435,14 @@ export default {
this.showPresenterOverlay = value
},
},
created() {
// Ensure that data is properly initialized before mounting the
// subviews.
this.updateDataFromCallParticipantModels(this.callParticipantModels)
this.isBackgroundBlurred = BrowserStorage.getItem('background-blurred') !== 'false'
},
mounted() {
this.debounceFetchPeers = debounce(this.fetchPeers, 1500)
EventBus.$on('refresh-peer-list', this.debounceFetchPeers)
Expand All @@ -476,9 +451,8 @@ export default {
subscribe('switch-screen-to-id', this._switchScreenToId)
subscribe('set-background-blurred', this.setBackgroundBlurred)
window.addEventListener('resize', this.updateSize)
},
beforeDestroy() {
this.debounceFetchPeers.clear?.()
EventBus.$off('refresh-peer-list', this.debounceFetchPeers)
Expand All @@ -487,9 +461,8 @@ export default {
unsubscribe('switch-screen-to-id', this._switchScreenToId)
unsubscribe('set-background-blurred', this.setBackgroundBlurred)
window.removeEventListener('resize', this.updateSize)
},
methods: {
/**
* Updates data properties that depend on the CallParticipantModels.
Expand Down Expand Up @@ -769,9 +742,6 @@ export default {
}
},
updateSize() {
this.presenterOverlaySize = Math.min(Math.max(window.innerWidth * 0.1, 100), 242)
},
},
}
</script>
Expand All @@ -796,20 +766,7 @@ export default {
}
}
.presenter-overlay__video {
position: relative;
--max-size: 242px;
--min-size: 100px;
width: 10vw;
height: 10vw;
max-width: var(--max-size);
max-height: var(--max-size);
min-width: var(--min-size);
min-height: var(--min-size);
z-index: 10;
}
.presenter-overlay--collapse {
.presenter-overlay--collapsed {
position: absolute !important;
opacity: .7;
bottom: 48px;
Expand Down
146 changes: 146 additions & 0 deletions src/components/CallView/shared/PresenterOverlay.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<!--
- @copyright Copyright (c) 2024 Dorra Jaouad <dorra.jaoued1@gmail.com>
-
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<template>
<VueDraggableResizable v-if="!isCollapsed"
:key="presenterOverlaySize"
parent
:resizable="false"
:h="presenterOverlaySize"
:w="presenterOverlaySize"
:x="10"
:y="10"
@dragging="isDragging = true"
@dragstop="isDragging = false">
<VideoVue :token="token"
:class="{ 'dragging': isDragging }"
class="presenter-overlay__video"
:model="model"
:shared-data="sharedData"
is-presenter-overlay
un-selectable
hide-bottom-bar
@click-presenter="$emit('click')" />
</VueDraggableResizable>

<!-- presenter button when presenter overlay is collapsed -->
<NcButton v-else
:aria-label="t('spreed', 'Show presenter')"
:title="t('spreed', 'Show presenter')"
class="presenter-overlay--collapse"
type="tertiary-no-background"
@click="$emit('click')">
<template #icon>
<AccountBox fill-color="#ffffff" :size="20" />
</template>
</NcButton>
</template>

<script>
import VueDraggableResizable from 'vue-draggable-resizable'
import AccountBox from 'vue-material-design-icons/AccountBoxOutline.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import VideoVue from './VideoVue.vue'
export default {
name: 'PresenterOverlay',
components: {
AccountBox,
VueDraggableResizable,
NcButton,
VideoVue,
},
props: {
token: {
type: String,
required: true,
},
model: {
type: Object,
required: true,
},
sharedData: {
type: Object,
required: true,
},
isCollapsed: {
type: Boolean,
required: true,
},
},
emits: ['click'],
data() {
return {
presenterOverlaySize: 128,
isDragging: false,
}
},
mounted() {
window.addEventListener('resize', this.updateSize)
},
beforeDestroy() {
window.removeEventListener('resize', this.updateSize)
},
methods: {
updateSize() {
this.presenterOverlaySize = Math.min(Math.max(window.innerWidth * 0.1, 100), 242)
},
},
}
</script>

<style lang="scss" scoped>
.presenter-overlay__video {
position: relative;
--max-size: 242px;
--min-size: 100px;
width: 10vw;
height: 10vw;
max-width: var(--max-size);
max-height: var(--max-size);
min-width: var(--min-size);
min-height: var(--min-size);
z-index: 10;
&:hover {
cursor: grab;
}
&.dragging {
cursor: grabbing;
}
}
:deep(div) {
cursor: inherit;
}
</style>

0 comments on commit 9159c0f

Please sign in to comment.