2024-01-07 01:15:25 +01:00
|
|
|
<script lang="ts">
|
2024-02-22 15:36:14 +01:00
|
|
|
import type { ComboBoxOption } from '$lib/components/shared-components/combobox.svelte';
|
|
|
|
|
import SettingCombobox from '$lib/components/shared-components/settings/setting-combobox.svelte';
|
|
|
|
|
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
|
2025-06-02 16:09:13 -05:00
|
|
|
import SettingsLanguageSelector from '$lib/components/shared-components/settings/settings-language-selector.svelte';
|
|
|
|
|
import { fallbackLocale, locales } from '$lib/constants';
|
2025-04-29 17:44:09 -04:00
|
|
|
import { themeManager } from '$lib/managers/theme-manager.svelte';
|
2024-05-14 21:31:47 +02:00
|
|
|
import {
|
|
|
|
|
alwaysLoadOriginalFile,
|
2025-10-15 17:24:47 +02:00
|
|
|
autoPlayVideo,
|
2024-05-14 21:31:47 +02:00
|
|
|
locale,
|
|
|
|
|
loopVideo,
|
|
|
|
|
playVideoThumbnailOnHover,
|
|
|
|
|
showDeleteModal,
|
|
|
|
|
} from '$lib/stores/preferences.store';
|
2025-08-11 23:50:34 +02:00
|
|
|
import { createDateFormatter, findLocale } from '$lib/utils';
|
2024-02-22 15:36:14 +01:00
|
|
|
import { onMount } from 'svelte';
|
2025-06-02 16:09:13 -05:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-01-07 01:15:25 +01:00
|
|
|
import { fade } from 'svelte/transition';
|
|
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let time = $state(new Date());
|
2024-02-22 15:36:14 +01:00
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
const interval = setInterval(() => {
|
|
|
|
|
time = new Date();
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
clearInterval(interval);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getAllLanguages = (): ComboBoxOption[] => {
|
|
|
|
|
return locales
|
|
|
|
|
.filter(({ code }) => Intl.NumberFormat.supportedLocalesOf(code).length > 0)
|
|
|
|
|
.map((locale) => ({
|
|
|
|
|
label: locale.name,
|
|
|
|
|
value: locale.code,
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleToggleLocaleBrowser = () => {
|
2025-06-04 03:27:23 +08:00
|
|
|
$locale = $locale === 'default' ? fallbackLocale.code : 'default';
|
2024-02-22 15:36:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleLocaleChange = (newLocale: string | undefined) => {
|
2024-06-06 13:47:22 +02:00
|
|
|
if (newLocale) {
|
|
|
|
|
$locale = newLocale;
|
|
|
|
|
}
|
2024-02-22 15:36:14 +01:00
|
|
|
};
|
2024-11-14 08:43:25 -06:00
|
|
|
let editedLocale = $derived(findLocale($locale).code);
|
2025-08-11 23:50:34 +02:00
|
|
|
let selectedDate: string = $derived(createDateFormatter(editedLocale).formatDateTime(time));
|
2024-11-14 08:43:25 -06:00
|
|
|
let selectedOption = $derived({
|
|
|
|
|
value: findLocale(editedLocale).code || fallbackLocale.code,
|
|
|
|
|
label: findLocale(editedLocale).name || fallbackLocale.name,
|
|
|
|
|
});
|
2024-01-07 01:15:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<section class="my-4">
|
|
|
|
|
<div in:fade={{ duration: 500 }}>
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4 mt-4 flex flex-col gap-4">
|
|
|
|
|
<div class="ms-4">
|
2024-01-07 01:15:25 +01:00
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('theme_selection')}
|
|
|
|
|
subtitle={$t('theme_selection_description')}
|
2025-04-29 17:44:09 -04:00
|
|
|
checked={themeManager.theme.system}
|
|
|
|
|
onToggle={(isChecked) => themeManager.setSystem(isChecked)}
|
2024-01-07 01:15:25 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
2024-02-22 10:14:11 -05:00
|
|
|
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4">
|
2025-06-02 16:09:13 -05:00
|
|
|
<SettingsLanguageSelector showSettingDescription />
|
2024-06-04 21:53:00 +02:00
|
|
|
</div>
|
|
|
|
|
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4">
|
2024-02-22 15:36:14 +01:00
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('default_locale')}
|
|
|
|
|
subtitle={$t('default_locale_description')}
|
2025-06-04 03:27:23 +08:00
|
|
|
checked={$locale == 'default'}
|
2024-09-21 00:24:46 +02:00
|
|
|
onToggle={handleToggleLocaleBrowser}
|
2024-02-22 15:36:14 +01:00
|
|
|
>
|
2024-02-22 19:08:55 +01:00
|
|
|
<p class="mt-2 dark:text-gray-400">{selectedDate}</p>
|
2024-02-22 15:36:14 +01:00
|
|
|
</SettingSwitch>
|
|
|
|
|
</div>
|
2025-06-04 03:27:23 +08:00
|
|
|
{#if $locale !== 'default'}
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4">
|
2024-02-22 15:36:14 +01:00
|
|
|
<SettingCombobox
|
2024-06-04 21:53:00 +02:00
|
|
|
comboboxPlaceholder={$t('searching_locales')}
|
2024-02-22 15:36:14 +01:00
|
|
|
{selectedOption}
|
|
|
|
|
options={getAllLanguages()}
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('custom_locale')}
|
|
|
|
|
subtitle={$t('custom_locale_description')}
|
2024-02-22 15:36:14 +01:00
|
|
|
onSelect={(combobox) => handleLocaleChange(combobox?.value)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-02-22 10:14:11 -05:00
|
|
|
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4">
|
2024-02-22 10:14:11 -05:00
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('display_original_photos')}
|
|
|
|
|
subtitle={$t('display_original_photos_setting_description')}
|
2024-02-22 10:14:11 -05:00
|
|
|
bind:checked={$alwaysLoadOriginalFile}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4">
|
2024-03-11 12:45:01 -04:00
|
|
|
<SettingSwitch
|
2024-06-12 12:54:40 +02:00
|
|
|
title={$t('video_hover_setting')}
|
2024-06-04 21:53:00 +02:00
|
|
|
subtitle={$t('video_hover_setting_description')}
|
2024-03-11 12:45:01 -04:00
|
|
|
bind:checked={$playVideoThumbnailOnHover}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-10-15 17:24:47 +02:00
|
|
|
<div class="ms-4">
|
|
|
|
|
<SettingSwitch
|
|
|
|
|
title={$t('setting_video_viewer_auto_play_title')}
|
|
|
|
|
subtitle={$t('setting_video_viewer_auto_play_subtitle')}
|
|
|
|
|
bind:checked={$autoPlayVideo}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4">
|
2025-06-04 03:27:23 +08:00
|
|
|
<SettingSwitch title={$t('loop_videos')} subtitle={$t('loop_videos_description')} bind:checked={$loopVideo} />
|
2024-05-14 21:31:47 +02:00
|
|
|
</div>
|
2024-03-11 12:45:01 -04:00
|
|
|
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="ms-4">
|
2024-03-11 12:45:01 -04:00
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('permanent_deletion_warning')}
|
|
|
|
|
subtitle={$t('permanent_deletion_warning_setting_description')}
|
2024-03-11 12:45:01 -04:00
|
|
|
bind:checked={$showDeleteModal}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-01-07 01:15:25 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|