From 34d22f19d3b15bf5a10ba4977288e6c285aba36b Mon Sep 17 00:00:00 2001 From: =?utf8?q?John=20Molakvo=C3=A6?= Date: Fri, 7 Apr 2023 13:32:11 +0200 Subject: [PATCH] feat(files): responsive design for mobile and narrow screens MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/src/components/FileEntry.vue | 20 +++++++-- .../src/components/FilesListHeaderActions.vue | 24 +++++++++-- .../files/src/components/FilesListVirtual.vue | 21 ++++++++- apps/files/src/mixins/clientWidth.ts | 43 +++++++++++++++++++ apps/files/src/models/Setting.js | 2 +- apps/files/src/store/actionsmenu.ts | 1 - apps/files/src/types.ts | 3 +- 7 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 apps/files/src/mixins/clientWidth.ts diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 47ed5729a8d..58b86886319 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -115,6 +115,7 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' +import isMobileMixin from '@nextcloud/vue/dist/Mixins/isMobile.js' import Vue from 'vue' import { getFileActions } from '../services/FileAction.ts' @@ -146,6 +147,10 @@ export default Vue.extend({ NcLoadingIcon, }, + mixins: [ + isMobileMixin, + ], + props: { active: { type: Boolean, @@ -295,13 +300,20 @@ export default Vue.extend({ }, enabledInlineActions() { + if (this.isMobile) { + return [] + } return this.enabledActions.filter(action => action?.inline?.(this.source, this.currentView)) }, enabledMenuActions() { + if (this.isMobile) { + return this.enabledActions + } + return [ ...this.enabledInlineActions, - ...actions.filter(action => !action.inline), + ...this.enabledActions.filter(action => !action.inline), ] }, @@ -311,10 +323,10 @@ export default Vue.extend({ openedMenu: { get() { - return this.actionsMenuStore.opened === this + return this.actionsMenuStore.opened === this.uniqueId }, set(opened) { - this.actionsMenuStore.opened = opened ? this : null + this.actionsMenuStore.opened = opened ? this.uniqueId : null }, }, }, @@ -515,7 +527,7 @@ export default Vue.extend({ // If the clicked row is in the selection, open global menu const isMoreThanOneSelected = this.selectedFiles.length > 1 - this.actionsMenuStore.opened = this.isSelected && isMoreThanOneSelected ? 'global' : this + this.actionsMenuStore.opened = this.isSelected && isMoreThanOneSelected ? 'global' : this.uniqueId // Prevent any browser defaults event.preventDefault() diff --git a/apps/files/src/components/FilesListHeaderActions.vue b/apps/files/src/components/FilesListHeaderActions.vue index f136e281f09..13e24ec77e6 100644 --- a/apps/files/src/components/FilesListHeaderActions.vue +++ b/apps/files/src/components/FilesListHeaderActions.vue @@ -1,7 +1,7 @@