From 774c7451309e9773dde3be592d45eb47c3560ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Fri, 20 Dec 2024 14:30:34 +0100 Subject: [PATCH] feat: Add action to share on mobile device --- src/components/notes/List/NoteRow.jsx | 12 ++++++++++-- src/targets/browser/index.jsx | 6 ++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/notes/List/NoteRow.jsx b/src/components/notes/List/NoteRow.jsx index 9a0248df..63b5ecfe 100644 --- a/src/components/notes/List/NoteRow.jsx +++ b/src/components/notes/List/NoteRow.jsx @@ -10,7 +10,11 @@ import { Breakpoints } from 'types/enums' import { withClient } from 'cozy-client' import { CozyFile } from 'cozy-doctypes' -import { SharedRecipients } from 'cozy-sharing' +import { + SharedRecipients, + useNativeFileSharing, + shareNative +} from 'cozy-sharing' import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu' import { makeActions } from 'cozy-ui/transpiled/react/ActionsMenu/Actions' import Icon from 'cozy-ui/transpiled/react/Icon' @@ -33,6 +37,8 @@ const NoteRow = ({ note, f, t, client }) => { const { filename, extension } = CozyFile.splitFilename(note) const [isMenuOpen, setMenuOpen] = useState(false) const { showAlert } = useAlert() + const { isNativeFileSharingAvailable, shareFilesNative } = + useNativeFileSharing() const openMenu = useCallback( e => { @@ -67,8 +73,10 @@ const NoteRow = ({ note, f, t, client }) => { }) } - const actions = makeActions([shareNote, deleteNote], { + const actions = makeActions([shareNote, shareNative, deleteNote], { onDeleteNote, + isNativeFileSharingAvailable, + shareFilesNative, onShareNote, t }) diff --git a/src/targets/browser/index.jsx b/src/targets/browser/index.jsx index e9d1e522..c58dc69b 100644 --- a/src/targets/browser/index.jsx +++ b/src/targets/browser/index.jsx @@ -29,7 +29,7 @@ import { Document } from 'cozy-doctypes' import flag from 'cozy-flags' import { WebviewIntentProvider } from 'cozy-intent' import { RealtimePlugin } from 'cozy-realtime' -import SharingProvider from 'cozy-sharing' +import SharingProvider, { NativeFileSharingProvider } from 'cozy-sharing' import 'cozy-sharing/dist/stylesheet.css' import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme' import I18n from 'cozy-ui/transpiled/react/providers/I18n' @@ -89,7 +89,9 @@ const renderApp = function (appLocale, client, isPublic) { previewPath={SHARING_LOCATION} isPublic={isPublic} > - + + +