2024-02-23 06:01:19 +01:00
|
|
|
<script lang="ts">
|
2024-11-14 08:43:25 -06:00
|
|
|
import SettingInputField from '$lib/components/shared-components/settings/setting-input-field.svelte';
|
2024-02-23 06:01:19 +01:00
|
|
|
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
|
2025-05-15 18:31:33 -04:00
|
|
|
import { SettingInputFieldType } from '$lib/constants';
|
2025-09-16 14:31:22 -04:00
|
|
|
import type { RenderedOption } from '$lib/elements/Dropdown.svelte';
|
2025-06-20 20:05:39 +02:00
|
|
|
import { Button, HStack, Modal, ModalBody, ModalFooter } from '@immich/ui';
|
2024-04-21 06:06:49 +02:00
|
|
|
import {
|
|
|
|
|
mdiArrowDownThin,
|
|
|
|
|
mdiArrowUpThin,
|
|
|
|
|
mdiFitToPageOutline,
|
|
|
|
|
mdiFitToScreenOutline,
|
|
|
|
|
mdiPanorama,
|
|
|
|
|
mdiShuffle,
|
|
|
|
|
} from '@mdi/js';
|
2025-05-15 18:31:33 -04:00
|
|
|
import { t } from 'svelte-i18n';
|
2025-06-02 20:22:22 +02:00
|
|
|
import SettingDropdown from '../components/shared-components/settings/setting-dropdown.svelte';
|
2024-04-19 12:49:29 +02:00
|
|
|
import { SlideshowLook, SlideshowNavigation, slideshowStore } from '../stores/slideshow.store';
|
2024-02-23 06:01:19 +01:00
|
|
|
|
2025-06-02 16:45:39 +02:00
|
|
|
const {
|
|
|
|
|
slideshowDelay,
|
|
|
|
|
showProgressBar,
|
|
|
|
|
slideshowNavigation,
|
|
|
|
|
slideshowLook,
|
|
|
|
|
slideshowTransition,
|
|
|
|
|
slideshowAutoplay,
|
|
|
|
|
} = slideshowStore;
|
2024-02-23 06:01:19 +01:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
2025-06-02 20:22:22 +02:00
|
|
|
onClose: () => void;
|
2024-11-14 08:43:25 -06:00
|
|
|
}
|
|
|
|
|
|
2025-06-02 20:22:22 +02:00
|
|
|
let { onClose }: Props = $props();
|
2024-03-02 16:50:02 +01:00
|
|
|
|
2025-05-18 02:39:15 +05:30
|
|
|
// Temporary variables to hold the settings - marked as reactive with $state() but initialized with store values
|
|
|
|
|
let tempSlideshowDelay = $state($slideshowDelay);
|
|
|
|
|
let tempShowProgressBar = $state($showProgressBar);
|
|
|
|
|
let tempSlideshowNavigation = $state($slideshowNavigation);
|
|
|
|
|
let tempSlideshowLook = $state($slideshowLook);
|
|
|
|
|
let tempSlideshowTransition = $state($slideshowTransition);
|
2025-06-02 16:45:39 +02:00
|
|
|
let tempSlideshowAutoplay = $state($slideshowAutoplay);
|
2025-05-18 02:39:15 +05:30
|
|
|
|
2024-04-19 12:49:29 +02:00
|
|
|
const navigationOptions: Record<SlideshowNavigation, RenderedOption> = {
|
2024-06-04 21:53:00 +02:00
|
|
|
[SlideshowNavigation.Shuffle]: { icon: mdiShuffle, title: $t('shuffle') },
|
|
|
|
|
[SlideshowNavigation.AscendingOrder]: { icon: mdiArrowUpThin, title: $t('backward') },
|
|
|
|
|
[SlideshowNavigation.DescendingOrder]: { icon: mdiArrowDownThin, title: $t('forward') },
|
2024-03-02 16:50:02 +01:00
|
|
|
};
|
|
|
|
|
|
2024-04-19 12:49:29 +02:00
|
|
|
const lookOptions: Record<SlideshowLook, RenderedOption> = {
|
2024-06-04 21:53:00 +02:00
|
|
|
[SlideshowLook.Contain]: { icon: mdiFitToScreenOutline, title: $t('contain') },
|
|
|
|
|
[SlideshowLook.Cover]: { icon: mdiFitToPageOutline, title: $t('cover') },
|
|
|
|
|
[SlideshowLook.BlurredBackground]: { icon: mdiPanorama, title: $t('blurred_background') },
|
2024-04-19 12:49:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleToggle = <Type extends SlideshowNavigation | SlideshowLook>(
|
|
|
|
|
record: RenderedOption,
|
|
|
|
|
options: Record<Type, RenderedOption>,
|
|
|
|
|
): undefined | Type => {
|
2024-03-02 16:50:02 +01:00
|
|
|
for (const [key, option] of Object.entries(options)) {
|
2024-04-19 12:49:29 +02:00
|
|
|
if (option === record) {
|
|
|
|
|
return key as Type;
|
2024-03-02 16:50:02 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-05-18 02:39:15 +05:30
|
|
|
|
|
|
|
|
const applyChanges = () => {
|
|
|
|
|
$slideshowDelay = tempSlideshowDelay;
|
|
|
|
|
$showProgressBar = tempShowProgressBar;
|
|
|
|
|
$slideshowNavigation = tempSlideshowNavigation;
|
|
|
|
|
$slideshowLook = tempSlideshowLook;
|
|
|
|
|
$slideshowTransition = tempSlideshowTransition;
|
2025-06-02 16:45:39 +02:00
|
|
|
$slideshowAutoplay = tempSlideshowAutoplay;
|
2025-05-18 02:39:15 +05:30
|
|
|
onClose();
|
|
|
|
|
};
|
2024-02-23 06:01:19 +01:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-19 09:32:23 -05:00
|
|
|
<Modal size="small" title={$t('slideshow_settings')} onClose={() => onClose()}>
|
|
|
|
|
<ModalBody>
|
2025-09-17 12:12:51 -04:00
|
|
|
<div class="flex flex-col gap-4 text-primary">
|
2025-05-19 09:32:23 -05:00
|
|
|
<SettingDropdown
|
|
|
|
|
title={$t('direction')}
|
|
|
|
|
options={Object.values(navigationOptions)}
|
|
|
|
|
selectedOption={navigationOptions[tempSlideshowNavigation]}
|
|
|
|
|
onToggle={(option) => {
|
|
|
|
|
tempSlideshowNavigation = handleToggle(option, navigationOptions) || tempSlideshowNavigation;
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<SettingDropdown
|
|
|
|
|
title={$t('look')}
|
|
|
|
|
options={Object.values(lookOptions)}
|
|
|
|
|
selectedOption={lookOptions[tempSlideshowLook]}
|
|
|
|
|
onToggle={(option) => {
|
|
|
|
|
tempSlideshowLook = handleToggle(option, lookOptions) || tempSlideshowLook;
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-06-02 16:45:39 +02:00
|
|
|
<SettingSwitch title={$t('autoplay_slideshow')} bind:checked={tempSlideshowAutoplay} />
|
2025-05-19 09:32:23 -05:00
|
|
|
<SettingSwitch title={$t('show_progress_bar')} bind:checked={tempShowProgressBar} />
|
|
|
|
|
<SettingSwitch title={$t('show_slideshow_transition')} bind:checked={tempSlideshowTransition} />
|
|
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.NUMBER}
|
|
|
|
|
label={$t('duration')}
|
|
|
|
|
description={$t('admin.slideshow_duration_description')}
|
|
|
|
|
min={1}
|
|
|
|
|
bind:value={tempSlideshowDelay}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</ModalBody>
|
|
|
|
|
<ModalFooter>
|
2025-06-20 20:05:39 +02:00
|
|
|
<HStack fullWidth>
|
2025-05-19 09:32:23 -05:00
|
|
|
<Button color="secondary" shape="round" fullWidth onclick={() => onClose()}>{$t('cancel')}</Button>
|
|
|
|
|
<Button fullWidth color="primary" shape="round" onclick={applyChanges}>{$t('confirm')}</Button>
|
2025-06-20 20:05:39 +02:00
|
|
|
</HStack>
|
2025-05-19 09:32:23 -05:00
|
|
|
</ModalFooter>
|
|
|
|
|
</Modal>
|