diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index baca96f23..0ea794aa4 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -89,6 +89,45 @@ let offlineSettings = $state(getOfflineSettings()); let isCheckingNetwork = $state(false); + // Section navigation + let settingsViewEl: HTMLDivElement; + let audioSection: HTMLElement; + let playbackSection: HTMLElement; + let offlineModeSection: HTMLElement; + let appearanceSection: HTMLElement; + let downloadsSection: HTMLElement; + let librarySection: HTMLElement; + let integrationsSection: HTMLElement; + let storageSection: HTMLElement; + let lyricsSection: HTMLElement; + let apiKeysSection: HTMLElement; + let activeSection = $state('audio'); + + interface NavSection { + id: string; + label: string; + el: HTMLElement | undefined; + } + + const navSections = $derived([ + { id: 'audio', label: 'Audio', el: audioSection }, + { id: 'playback', label: 'Playback', el: playbackSection }, + { id: 'offline', label: 'Offline', el: offlineModeSection }, + { id: 'appearance', label: 'Appearance', el: appearanceSection }, + { id: 'downloads', label: 'Downloads', el: downloadsSection }, + { id: 'library', label: 'Library', el: librarySection }, + { id: 'integrations', label: 'Integrations', el: integrationsSection }, + { id: 'storage', label: 'Storage', el: storageSection }, + { id: 'lyrics', label: 'Lyrics', el: lyricsSection }, + { id: 'api-keys', label: 'API Keys', el: apiKeysSection }, + ]); + + function scrollToSection(el: HTMLElement | undefined, id: string) { + if (!el) return; + activeSection = id; + el.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + // Audio device state let audioDevices = $state([]); let pipewireSinks = $state([]); @@ -288,8 +327,33 @@ offlineSettings = getOfflineSettings(); }); + // Scroll tracking for navigation + const handleScroll = () => { + if (!settingsViewEl) return; + const scrollTop = settingsViewEl.scrollTop; + const offset = 120; // Account for sticky nav height + + // Find which section is currently in view + for (const section of navSections) { + if (!section.el) continue; + const rect = section.el.getBoundingClientRect(); + const containerRect = settingsViewEl.getBoundingClientRect(); + const relativeTop = rect.top - containerRect.top; + + if (relativeTop <= offset + 50 && relativeTop + rect.height > offset) { + if (activeSection !== section.id) { + activeSection = section.id; + } + break; + } + } + }; + + settingsViewEl?.addEventListener('scroll', handleScroll); + return () => { unsubscribeOffline(); + settingsViewEl?.removeEventListener('scroll', handleScroll); }; }); @@ -920,7 +984,7 @@ } -
+
{#if onBack} @@ -948,8 +1012,21 @@
+ + + -
+
{$t('settings.audio.title')}
{$t('settings.audio.streamingQuality')} @@ -998,7 +1075,7 @@
-
+

{$t('settings.playback.title')}

{$t('settings.playback.gapless')} @@ -1017,7 +1094,7 @@
-
+

{$t('offline.title')}

@@ -1056,7 +1133,7 @@
-
+

{$t('settings.appearance.title')}

{$t('settings.appearance.theme')} @@ -1093,7 +1170,7 @@
-
+

Downloads

@@ -1146,7 +1223,7 @@
-
+

{$t('settings.library.title')}

@@ -1161,7 +1238,7 @@
-
+

{$t('settings.integrations.title')}

{#if lastfmConnected} @@ -1253,7 +1330,7 @@
-
+

{$t('settings.storage.title')}

{$t('settings.storage.cacheSize')} @@ -1288,7 +1365,7 @@
-
+

{$t('settings.lyrics.title')}

Provider @@ -1307,7 +1384,7 @@
-
+