2023-11-01 21:34:30 -04:00
|
|
|
<script lang="ts">
|
2024-02-23 06:01:19 +01:00
|
|
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
|
|
|
|
import ProgressBar, { ProgressBarStatus } from '$lib/components/shared-components/progress-bar/progress-bar.svelte';
|
|
|
|
|
import SlideshowSettings from '$lib/components/slideshow-settings.svelte';
|
2023-11-01 21:34:30 -04:00
|
|
|
import { slideshowStore } from '$lib/stores/slideshow.store';
|
2024-02-23 06:01:19 +01:00
|
|
|
import { mdiChevronLeft, mdiChevronRight, mdiClose, mdiCog, mdiPause, mdiPlay } from '@mdi/js';
|
2023-11-01 21:34:30 -04:00
|
|
|
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
|
|
|
|
|
2024-02-23 06:01:19 +01:00
|
|
|
const { restartProgress, stopProgress, slideshowDelay, showProgressBar } = slideshowStore;
|
2023-11-01 21:34:30 -04:00
|
|
|
|
|
|
|
|
let progressBarStatus: ProgressBarStatus;
|
|
|
|
|
let progressBar: ProgressBar;
|
2024-02-23 06:01:19 +01:00
|
|
|
let showSettings = false;
|
2023-11-01 21:34:30 -04:00
|
|
|
|
|
|
|
|
let unsubscribeRestart: () => void;
|
|
|
|
|
let unsubscribeStop: () => void;
|
|
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
|
next: void;
|
|
|
|
|
prev: void;
|
|
|
|
|
close: void;
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
unsubscribeRestart = restartProgress.subscribe((value) => {
|
|
|
|
|
if (value) {
|
|
|
|
|
progressBar.restart(value);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
unsubscribeStop = stopProgress.subscribe((value) => {
|
|
|
|
|
if (value) {
|
|
|
|
|
progressBar.restart(false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onDestroy(() => {
|
|
|
|
|
if (unsubscribeRestart) {
|
|
|
|
|
unsubscribeRestart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unsubscribeStop) {
|
|
|
|
|
unsubscribeStop();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="m-4 flex gap-2">
|
2024-02-23 06:01:19 +01:00
|
|
|
<CircleIconButton buttonSize="50" icon={mdiClose} on:click={() => dispatch('close')} title="Exit Slideshow" />
|
2023-11-01 21:34:30 -04:00
|
|
|
<CircleIconButton
|
2024-02-23 06:01:19 +01:00
|
|
|
buttonSize="50"
|
2023-11-01 21:34:30 -04:00
|
|
|
icon={progressBarStatus === ProgressBarStatus.Paused ? mdiPlay : mdiPause}
|
|
|
|
|
on:click={() => (progressBarStatus === ProgressBarStatus.Paused ? progressBar.play() : progressBar.pause())}
|
|
|
|
|
title={progressBarStatus === ProgressBarStatus.Paused ? 'Play' : 'Pause'}
|
|
|
|
|
/>
|
2024-02-23 06:01:19 +01:00
|
|
|
<CircleIconButton buttonSize="50" icon={mdiChevronLeft} on:click={() => dispatch('prev')} title="Previous" />
|
|
|
|
|
<CircleIconButton buttonSize="50" icon={mdiChevronRight} on:click={() => dispatch('next')} title="Next" />
|
|
|
|
|
<CircleIconButton buttonSize="50" icon={mdiCog} on:click={() => (showSettings = !showSettings)} title="Next" />
|
2023-11-01 21:34:30 -04:00
|
|
|
</div>
|
|
|
|
|
|
2024-02-23 06:01:19 +01:00
|
|
|
{#if showSettings}
|
|
|
|
|
<SlideshowSettings onClose={() => (showSettings = false)} />
|
|
|
|
|
{/if}
|
|
|
|
|
|
2023-11-01 21:34:30 -04:00
|
|
|
<ProgressBar
|
|
|
|
|
autoplay
|
2024-02-23 06:01:19 +01:00
|
|
|
hidden={!$showProgressBar}
|
|
|
|
|
duration={$slideshowDelay}
|
2023-11-01 21:34:30 -04:00
|
|
|
bind:this={progressBar}
|
|
|
|
|
bind:status={progressBarStatus}
|
|
|
|
|
on:done={() => dispatch('next')}
|
|
|
|
|
/>
|