added share to tile

This commit is contained in:
Danny Coates 2019-03-09 20:40:06 -08:00
parent edc95f42cb
commit bd61d2fb3e
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
4 changed files with 37 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* global AUTH_CONFIG */
/* global AUTH_CONFIG LOCALE */
import { browserName } from './utils';
async function checkCrypto() {
@ -90,7 +90,8 @@ export default async function getCapabilities() {
} catch (e) {
account = false;
}
const share = !!navigator.share;
const share =
typeof navigator.share === 'function' && LOCALE.startsWith('en'); // en until strings merge
return {
account,

View File

@ -167,8 +167,17 @@ function archiveDetails(translate, archive) {
module.exports = function(state, emit, archive) {
const copyOrShare =
platform() !== 'android'
state.capabilities.share || platform() === 'android'
? html`
<button
class="text-blue-dark hover:text-blue-darker focus:text-blue-darker self-end flex items-end"
onclick=${share}
title="Share"
>
<img src="${assets.get('share-24.svg')}" class="mr-2" />Share
</button>
`
: html`
<button
class="text-blue-dark hover:text-blue-darker focus:text-blue-darker focus:outline self-end flex items-center"
onclick=${copy}
@ -177,15 +186,6 @@ module.exports = function(state, emit, archive) {
<img src="${assets.get('copy-16.svg')}" class="mr-2" />
${state.translate('copyLinkButton')}
</button>
`
: html`
<button
class="text-blue-dark hover:text-blue-darker focus:text-blue-darker self-end flex items-center"
onclick=${share}
title="Share"
>
<img src="${assets.get('share-24.svg')}" class="mr-2" /> Share
</button>
`;
const dl =
platform() === 'web'
@ -248,9 +248,24 @@ module.exports = function(state, emit, archive) {
emit('delete', archive);
}
function share(event) {
async function share(event) {
event.stopPropagation();
Android.shareUrl(archive.url);
if (state.capabilities.share) {
try {
await navigator.share({
title: state.translate('-send-brand'),
text: `Download "${
archive.name
}" with Firefox Send: simple, safe file sharing`,
//state.translate('shareMessage', { name }),
url: archive.url
});
} catch (e) {
// ignore
}
} else {
Android.shareUrl(archive.url);
}
}
};

View File

@ -3,7 +3,7 @@ const html = require('choo/html');
/* Possible strings for l10n
shareLinkDescription = Share the link to your file:
shareLinkButton = Share link
shareMessage = Download { $name } with { -send-brand }: simple, safe file sharing
shareMessage = Download "{ $name }" with { -send-brand }: simple, safe file sharing
*/
module.exports = function(name, url) {
@ -48,14 +48,17 @@ module.exports = function(name, url) {
try {
await navigator.share({
title: state.translate('-send-brand'),
text: `Download ${name} with Firefox Send: simple, safe file sharing`,
text: `Download "${name}" with Firefox Send: simple, safe file sharing`,
//state.translate('shareMessage', { name }),
url
});
} catch (e) {
if (e.code === e.ABORT_ERR) {
return;
}
console.error(e);
}
setTimeout(close, 1000);
close();
}
};
};

View File

@ -1,4 +1,4 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M18 9a3 3 0 1 0-2.977-2.63l-6.94 3.47a3 3 0 1 0 0 4.319l6.94 3.47a3 3 0 1 0 .895-1.789l-6.94-3.47a3.03 3.03 0 0 0 0-.74l6.94-3.47C16.456 8.68 17.19 9 18 9z" fill="#0C0C0D" fill-opacity=".8"></path></svg>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M18 9a3 3 0 1 0-2.977-2.63l-6.94 3.47a3 3 0 1 0 0 4.319l6.94 3.47a3 3 0 1 0 .895-1.789l-6.94-3.47a3.03 3.03 0 0 0 0-.74l6.94-3.47C16.456 8.68 17.19 9 18 9z" fill="#0060df" fill-opacity=".8"></path></svg>

Before

Width:  |  Height:  |  Size: 559 B

After

Width:  |  Height:  |  Size: 559 B