Skip to content

Commit

Permalink
feat: Add action to share on mobile device
Browse files Browse the repository at this point in the history
  • Loading branch information
zatteo committed Dec 20, 2024
1 parent 6665d4f commit 774c745
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/components/notes/List/NoteRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 => {
Expand Down Expand Up @@ -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
})
Expand Down
6 changes: 4 additions & 2 deletions src/targets/browser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -89,7 +89,9 @@ const renderApp = function (appLocale, client, isPublic) {
previewPath={SHARING_LOCATION}
isPublic={isPublic}
>
<App isPublic={isPublic} />
<NativeFileSharingProvider>
<App isPublic={isPublic} />
</NativeFileSharingProvider>
</SharingProvider>
</IsPublicContext.Provider>
</CozyTheme>
Expand Down

0 comments on commit 774c745

Please sign in to comment.