2024-07-27 09:07:26 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { t } from "$lib/i18n/translations";
|
|
|
|
|
2024-07-28 13:15:22 +00:00
|
|
|
import { device } from "$lib/device";
|
2024-09-08 20:30:03 +00:00
|
|
|
import {
|
|
|
|
copyURL,
|
|
|
|
openURL,
|
|
|
|
shareURL,
|
|
|
|
openFile,
|
|
|
|
shareFile,
|
|
|
|
} from "$lib/download";
|
2024-07-27 09:07:26 +00:00
|
|
|
|
2024-09-23 09:06:57 +00:00
|
|
|
import type { CobaltFileUrlType } from "$lib/types/api";
|
|
|
|
|
2024-07-27 09:07:26 +00:00
|
|
|
import DialogContainer from "$components/dialog/DialogContainer.svelte";
|
|
|
|
|
|
|
|
import Meowbalt from "$components/misc/Meowbalt.svelte";
|
|
|
|
import DialogButtons from "$components/dialog/DialogButtons.svelte";
|
2024-09-08 18:10:21 +00:00
|
|
|
import SavingTutorial from "$components/dialog/SavingTutorial.svelte";
|
2024-07-27 09:07:26 +00:00
|
|
|
import VerticalActionButton from "$components/buttons/VerticalActionButton.svelte";
|
|
|
|
|
|
|
|
import IconShare2 from "@tabler/icons-svelte/IconShare2.svelte";
|
|
|
|
import IconDownload from "@tabler/icons-svelte/IconDownload.svelte";
|
|
|
|
import IconFileDownload from "@tabler/icons-svelte/IconFileDownload.svelte";
|
|
|
|
|
2024-07-28 17:29:32 +00:00
|
|
|
import CopyIcon from "$components/misc/CopyIcon.svelte";
|
2024-09-23 09:06:57 +00:00
|
|
|
|
2024-07-27 09:07:26 +00:00
|
|
|
export let id: string;
|
2024-08-03 18:43:24 +00:00
|
|
|
export let dismissable = true;
|
2024-09-08 20:30:03 +00:00
|
|
|
export let bodyText: string = "";
|
|
|
|
|
|
|
|
export let url: string = "";
|
|
|
|
export let file: File | undefined = undefined;
|
2024-09-23 09:06:57 +00:00
|
|
|
export let urlType: CobaltFileUrlType | undefined = undefined;
|
2024-07-27 09:07:26 +00:00
|
|
|
|
|
|
|
let close: () => void;
|
2024-07-28 17:29:32 +00:00
|
|
|
|
|
|
|
let copied = false;
|
|
|
|
|
|
|
|
$: if (copied) {
|
|
|
|
setTimeout(() => {
|
|
|
|
copied = false;
|
|
|
|
}, 1500);
|
|
|
|
}
|
2024-07-27 09:07:26 +00:00
|
|
|
</script>
|
|
|
|
|
2024-08-03 18:43:24 +00:00
|
|
|
<DialogContainer {id} {dismissable} bind:close>
|
2024-07-27 09:07:26 +00:00
|
|
|
<div class="dialog-body popup-body">
|
|
|
|
<div class="meowbalt-container">
|
|
|
|
<Meowbalt emotion="question" />
|
|
|
|
</div>
|
2024-09-08 18:10:21 +00:00
|
|
|
|
2024-07-27 09:07:26 +00:00
|
|
|
<div class="dialog-inner-container">
|
|
|
|
<div class="popup-header">
|
|
|
|
<IconFileDownload />
|
|
|
|
<h2 class="popup-title" tabindex="-1">
|
|
|
|
{$t("dialog.saving.title")}
|
|
|
|
</h2>
|
|
|
|
</div>
|
2024-09-08 20:30:03 +00:00
|
|
|
|
2024-07-27 09:07:26 +00:00
|
|
|
<div class="action-buttons">
|
2024-09-23 09:06:57 +00:00
|
|
|
{#if device.supports.directDownload && !(device.is.iOS && urlType === "redirect")}
|
2024-07-28 06:49:13 +00:00
|
|
|
<VerticalActionButton
|
|
|
|
id="save-download"
|
|
|
|
fill
|
|
|
|
elevated
|
2024-09-08 20:30:03 +00:00
|
|
|
click={() => {
|
|
|
|
if (file) {
|
|
|
|
return openFile(file);
|
|
|
|
} else if (url) {
|
|
|
|
return openURL(url);
|
|
|
|
}
|
|
|
|
}}
|
2024-07-28 06:49:13 +00:00
|
|
|
>
|
|
|
|
<IconDownload />
|
2024-08-09 08:40:30 +00:00
|
|
|
{$t("button.download")}
|
2024-07-28 06:49:13 +00:00
|
|
|
</VerticalActionButton>
|
|
|
|
{/if}
|
|
|
|
|
2024-07-28 12:59:58 +00:00
|
|
|
{#if device.supports.share}
|
2024-07-28 06:49:13 +00:00
|
|
|
<VerticalActionButton
|
|
|
|
id="save-share"
|
|
|
|
fill
|
|
|
|
elevated
|
2024-09-08 20:30:03 +00:00
|
|
|
click={async () => {
|
|
|
|
if (file) {
|
|
|
|
return await shareFile(file);
|
|
|
|
} else if (url) {
|
|
|
|
return await shareURL(url);
|
|
|
|
}
|
|
|
|
}}
|
2024-07-28 06:49:13 +00:00
|
|
|
>
|
|
|
|
<IconShare2 />
|
2024-08-09 08:40:30 +00:00
|
|
|
{$t("button.share")}
|
2024-07-28 06:49:13 +00:00
|
|
|
</VerticalActionButton>
|
|
|
|
{/if}
|
|
|
|
|
2024-09-08 20:30:03 +00:00
|
|
|
{#if !file}
|
|
|
|
<VerticalActionButton
|
|
|
|
id="save-copy"
|
|
|
|
fill
|
|
|
|
elevated
|
|
|
|
click={async () => {
|
|
|
|
copyURL(url);
|
|
|
|
copied = true;
|
|
|
|
}}
|
|
|
|
ariaLabel={copied ? $t("button.copied") : ""}
|
|
|
|
>
|
|
|
|
<CopyIcon check={copied} />
|
|
|
|
{$t("button.copy")}
|
|
|
|
</VerticalActionButton>
|
|
|
|
{/if}
|
2024-07-27 09:07:26 +00:00
|
|
|
</div>
|
2024-07-28 17:29:32 +00:00
|
|
|
|
2024-09-08 18:10:21 +00:00
|
|
|
{#if device.is.iOS}
|
|
|
|
<SavingTutorial />
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if bodyText}
|
|
|
|
<div class="body-text">
|
|
|
|
{bodyText}
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2024-07-28 17:29:32 +00:00
|
|
|
|
2024-07-27 09:07:26 +00:00
|
|
|
<DialogButtons
|
|
|
|
buttons={[
|
|
|
|
{
|
2024-08-09 08:40:30 +00:00
|
|
|
text: $t("button.done"),
|
2024-07-27 09:07:26 +00:00
|
|
|
main: true,
|
|
|
|
action: () => {},
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
closeFunc={close}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</DialogContainer>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.popup-body,
|
|
|
|
.dialog-inner-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: var(--padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
.dialog-inner-container {
|
|
|
|
overflow-y: scroll;
|
|
|
|
gap: 8px;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.popup-body {
|
|
|
|
max-width: 340px;
|
|
|
|
width: calc(100% - var(--padding) - var(--dialog-padding) * 2);
|
2024-09-08 18:10:21 +00:00
|
|
|
max-height: 70%;
|
2024-07-27 09:07:26 +00:00
|
|
|
margin: calc(var(--padding) / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
.meowbalt-container {
|
|
|
|
position: absolute;
|
|
|
|
top: -126px;
|
|
|
|
right: 0;
|
|
|
|
/* simulate meowbalt being behind the popup */
|
|
|
|
clip-path: inset(0px 0px 14px 0px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.popup-header {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: center;
|
|
|
|
gap: calc(var(--padding) / 2);
|
|
|
|
color: var(--secondary);
|
|
|
|
}
|
|
|
|
|
|
|
|
.popup-header :global(svg) {
|
|
|
|
height: 21px;
|
|
|
|
width: 21px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.popup-title {
|
|
|
|
color: var(--secondary);
|
|
|
|
font-size: 19px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.popup-title:focus-visible {
|
|
|
|
box-shadow: none !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.action-buttons {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
gap: calc(var(--padding) / 2);
|
2024-09-08 18:10:21 +00:00
|
|
|
position: relative;
|
2024-07-27 09:07:26 +00:00
|
|
|
}
|
2024-07-28 13:15:22 +00:00
|
|
|
|
|
|
|
.body-text {
|
|
|
|
font-size: 13px;
|
|
|
|
font-weight: 500;
|
|
|
|
line-height: 1.5;
|
|
|
|
color: var(--gray);
|
|
|
|
white-space: pre-wrap;
|
|
|
|
user-select: text;
|
|
|
|
-webkit-user-select: text;
|
|
|
|
}
|
2024-07-27 09:07:26 +00:00
|
|
|
</style>
|