Add expandable window controls and fullscreen support
- Add expandable window controls in header (hover to expand) - Fullscreen toggle (F11) - Exit immersive (Esc) - Close app - Move Repeat button to left group: Fav | Shuffle | Repeat - Remove QualityBadge from player controls - Add F11 keyboard shortcut for fullscreen toggle - Use Tauri window API for fullscreen functionality
This commit is contained in:
1 parent
df0cd9e1dd
commit
e1cd13bd19
5 files changed
+216
-55
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { X, Disc3, LayoutGrid, Mic2, ListMusic, Music2, Info, Radio } from 'lucide-svelte';
|
||||
import { Disc3, LayoutGrid, Mic2, ListMusic, Music2, Info, Radio, Maximize, Minimize, ChevronDown, X } from 'lucide-svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
|
||||
export type ImmersiveTab = 'lyrics' | 'trackInfo' | 'suggestions' | 'queue';
|
||||
export type DisplayMode = 'coverflow' | 'split' | 'lyrics-focus' | 'queue-focus';
|
||||
@@ -11,10 +12,13 @@
|
||||
onTabChange: (tab: ImmersiveTab) => void;
|
||||
onDisplayModeChange: (mode: DisplayMode) => void;
|
||||
onClose: () => void;
|
||||
onCloseApp?: () => void;
|
||||
visible?: boolean;
|
||||
hasLyrics?: boolean;
|
||||
hasTrackInfo?: boolean;
|
||||
hasSuggestions?: boolean;
|
||||
isFullscreen?: boolean;
|
||||
onToggleFullscreen?: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -23,12 +27,42 @@
|
||||
onTabChange,
|
||||
onDisplayModeChange,
|
||||
onClose,
|
||||
onCloseApp,
|
||||
visible = true,
|
||||
hasLyrics = true,
|
||||
hasTrackInfo = true,
|
||||
hasSuggestions = true
|
||||
hasSuggestions = true,
|
||||
isFullscreen = false,
|
||||
onToggleFullscreen
|
||||
}: Props = $props();
|
||||
|
||||
// Expandable window controls state
|
||||
let isWindowControlsExpanded = $state(false);
|
||||
let collapseTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
function handleWindowControlsEnter() {
|
||||
if (collapseTimeout) {
|
||||
clearTimeout(collapseTimeout);
|
||||
collapseTimeout = null;
|
||||
}
|
||||
isWindowControlsExpanded = true;
|
||||
}
|
||||
|
||||
function handleWindowControlsLeave() {
|
||||
collapseTimeout = setTimeout(() => {
|
||||
isWindowControlsExpanded = false;
|
||||
}, 300);
|
||||
}
|
||||
|
||||
async function handleCloseApp() {
|
||||
if (onCloseApp) {
|
||||
onCloseApp();
|
||||
} else {
|
||||
const window = getCurrentWindow();
|
||||
await window.close();
|
||||
}
|
||||
}
|
||||
|
||||
const tabs = $derived([
|
||||
{ id: 'lyrics' as const, label: $t('player.lyrics'), icon: Music2, enabled: hasLyrics },
|
||||
{ id: 'trackInfo' as const, label: $t('player.trackInfo') || 'Track Info', icon: Info, enabled: hasTrackInfo },
|
||||
@@ -82,11 +116,50 @@
|
||||
<div class="tabs-placeholder"></div>
|
||||
{/if}
|
||||
|
||||
<!-- Right: Close button -->
|
||||
<!-- Right: Expandable Window Controls -->
|
||||
<div class="header-actions">
|
||||
<button class="action-btn" onclick={onClose} title={$t('actions.close') + ' (Esc)'}>
|
||||
<X size={20} />
|
||||
</button>
|
||||
<div
|
||||
class="window-controls"
|
||||
class:expanded={isWindowControlsExpanded}
|
||||
onmouseenter={handleWindowControlsEnter}
|
||||
onmouseleave={handleWindowControlsLeave}
|
||||
role="group"
|
||||
aria-label="Window controls"
|
||||
>
|
||||
<!-- Expanded buttons (appear on hover) -->
|
||||
<div class="expanded-buttons">
|
||||
<button
|
||||
class="window-btn"
|
||||
onclick={onToggleFullscreen}
|
||||
title={isFullscreen ? 'Exit Fullscreen (F11)' : 'Fullscreen (F11)'}
|
||||
>
|
||||
{#if isFullscreen}
|
||||
<Minimize size={16} />
|
||||
{:else}
|
||||
<Maximize size={16} />
|
||||
{/if}
|
||||
</button>
|
||||
<button
|
||||
class="window-btn"
|
||||
onclick={onClose}
|
||||
title="Exit Immersive (Esc)"
|
||||
>
|
||||
<ChevronDown size={16} />
|
||||
</button>
|
||||
<button
|
||||
class="window-btn close"
|
||||
onclick={handleCloseApp}
|
||||
title="Close App"
|
||||
>
|
||||
<X size={16} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Default icon (window) -->
|
||||
<button class="window-trigger" title="Window Controls">
|
||||
<img src="/window.svg" alt="Window" class="window-icon" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -199,23 +272,87 @@
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
/* Expandable Window Controls */
|
||||
.window-controls {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border: 1px solid var(--alpha-10, rgba(255, 255, 255, 0.1));
|
||||
border-radius: 20px;
|
||||
padding: 4px;
|
||||
overflow: hidden;
|
||||
transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.window-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border: 1px solid var(--alpha-10, rgba(255, 255, 255, 0.1));
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.window-trigger:hover {
|
||||
background: var(--alpha-10, rgba(255, 255, 255, 0.1));
|
||||
}
|
||||
|
||||
.window-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
filter: invert(1) opacity(0.7);
|
||||
transition: filter 150ms ease;
|
||||
}
|
||||
|
||||
.window-trigger:hover .window-icon {
|
||||
filter: invert(1) opacity(1);
|
||||
}
|
||||
|
||||
.expanded-buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
max-width: 0;
|
||||
opacity: 0;
|
||||
overflow: hidden;
|
||||
transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.window-controls.expanded .expanded-buttons {
|
||||
max-width: 120px;
|
||||
opacity: 1;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.window-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
color: var(--alpha-70, rgba(255, 255, 255, 0.7));
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.action-btn:hover {
|
||||
.window-btn:hover {
|
||||
color: var(--text-primary, white);
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
background: var(--alpha-15, rgba(255, 255, 255, 0.15));
|
||||
}
|
||||
|
||||
.window-btn.close:hover {
|
||||
color: white;
|
||||
background: rgba(239, 68, 68, 0.8);
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { startActiveLineUpdates } from '$lib/stores/lyricsStore';
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import ImmersiveBackground from './ImmersiveBackground.svelte';
|
||||
import ImmersiveArtwork from './ImmersiveArtwork.svelte';
|
||||
import ImmersiveHeader, { type ImmersiveTab, type DisplayMode } from './ImmersiveHeader.svelte';
|
||||
@@ -117,10 +118,25 @@
|
||||
let activeTab: ImmersiveTab = $state('lyrics');
|
||||
let showUI = $state(true);
|
||||
let hideTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
let isFullscreen = $state(false);
|
||||
|
||||
const hasLyrics = $derived(lyricsLines.length > 0 || lyricsLoading);
|
||||
const AUTO_HIDE_DELAY = 4000;
|
||||
|
||||
// Fullscreen toggle
|
||||
async function toggleFullscreen() {
|
||||
const window = getCurrentWindow();
|
||||
const currentFullscreen = await window.isFullscreen();
|
||||
await window.setFullscreen(!currentFullscreen);
|
||||
isFullscreen = !currentFullscreen;
|
||||
}
|
||||
|
||||
// Check fullscreen state on open
|
||||
async function checkFullscreenState() {
|
||||
const window = getCurrentWindow();
|
||||
isFullscreen = await window.isFullscreen();
|
||||
}
|
||||
|
||||
// Auto-hide UI after inactivity
|
||||
function resetHideTimer() {
|
||||
showUI = true;
|
||||
@@ -141,6 +157,10 @@
|
||||
case 'Escape':
|
||||
onClose();
|
||||
break;
|
||||
case 'F11':
|
||||
e.preventDefault();
|
||||
toggleFullscreen();
|
||||
break;
|
||||
case ' ':
|
||||
e.preventDefault();
|
||||
onTogglePlay();
|
||||
@@ -197,6 +217,7 @@
|
||||
$effect(() => {
|
||||
if (isOpen) {
|
||||
resetHideTimer();
|
||||
checkFullscreenState();
|
||||
document.addEventListener('keydown', handleKeydown);
|
||||
|
||||
return () => {
|
||||
@@ -237,6 +258,8 @@
|
||||
hasLyrics={true}
|
||||
hasTrackInfo={enableCredits}
|
||||
hasSuggestions={enableSuggestions}
|
||||
{isFullscreen}
|
||||
onToggleFullscreen={toggleFullscreen}
|
||||
/>
|
||||
|
||||
<!-- Content based on display mode -->
|
||||
@@ -324,9 +347,6 @@
|
||||
{isShuffle}
|
||||
{repeatMode}
|
||||
{isFavorite}
|
||||
{quality}
|
||||
{bitDepth}
|
||||
{samplingRate}
|
||||
{onTogglePlay}
|
||||
{onSkipBack}
|
||||
{onSkipForward}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
VolumeX,
|
||||
MoreHorizontal
|
||||
} from 'lucide-svelte';
|
||||
import QualityBadge from '$lib/components/QualityBadge.svelte';
|
||||
|
||||
interface Props {
|
||||
visible?: boolean;
|
||||
@@ -22,9 +21,6 @@
|
||||
isShuffle: boolean;
|
||||
repeatMode: 'off' | 'all' | 'one';
|
||||
isFavorite: boolean;
|
||||
quality?: string;
|
||||
bitDepth?: number;
|
||||
samplingRate?: number;
|
||||
onTogglePlay: () => void;
|
||||
onSkipBack?: () => void;
|
||||
onSkipForward?: () => void;
|
||||
@@ -45,9 +41,6 @@
|
||||
isShuffle,
|
||||
repeatMode,
|
||||
isFavorite,
|
||||
quality,
|
||||
bitDepth,
|
||||
samplingRate,
|
||||
onTogglePlay,
|
||||
onSkipBack,
|
||||
onSkipForward,
|
||||
@@ -138,16 +131,19 @@
|
||||
</script>
|
||||
|
||||
<div class="controls-wrapper" class:visible>
|
||||
<!-- Quality Badge above player -->
|
||||
<div class="quality-row">
|
||||
<QualityBadge {quality} {bitDepth} {samplingRate} />
|
||||
</div>
|
||||
|
||||
<div class="player-bar">
|
||||
<!-- All Controls in Single Row -->
|
||||
<div class="controls-row">
|
||||
<!-- Left: Shuffle + Heart -->
|
||||
<!-- Left: Fav + Shuffle + Repeat -->
|
||||
<div class="controls-group left">
|
||||
<button
|
||||
class="control-btn"
|
||||
class:active={isFavorite}
|
||||
onclick={onToggleFavorite}
|
||||
title={isFavorite ? 'Remove from Favorites' : 'Add to Favorites'}
|
||||
>
|
||||
<Heart size={12} fill={isFavorite ? 'currentColor' : 'none'} />
|
||||
</button>
|
||||
<button
|
||||
class="control-btn"
|
||||
class:active={isShuffle}
|
||||
@@ -158,11 +154,14 @@
|
||||
</button>
|
||||
<button
|
||||
class="control-btn"
|
||||
class:active={isFavorite}
|
||||
onclick={onToggleFavorite}
|
||||
title={isFavorite ? 'Remove from Favorites' : 'Add to Favorites'}
|
||||
class:active={repeatMode !== 'off'}
|
||||
onclick={onToggleRepeat}
|
||||
title={repeatMode === 'off' ? 'Repeat' : repeatMode === 'all' ? 'Repeat All' : 'Repeat One'}
|
||||
>
|
||||
<Heart size={12} fill={isFavorite ? 'currentColor' : 'none'} />
|
||||
<Repeat size={12} />
|
||||
{#if repeatMode === 'one'}
|
||||
<span class="repeat-one">1</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -203,20 +202,8 @@
|
||||
<span class="time-text">{formatTime(duration)}</span>
|
||||
</div>
|
||||
|
||||
<!-- Right: Repeat + Volume + Menu + Expand -->
|
||||
<!-- Right: Volume + Menu -->
|
||||
<div class="controls-group right">
|
||||
<button
|
||||
class="control-btn"
|
||||
class:active={repeatMode !== 'off'}
|
||||
onclick={onToggleRepeat}
|
||||
title={repeatMode === 'off' ? 'Repeat' : repeatMode === 'all' ? 'Repeat All' : 'Repeat One'}
|
||||
>
|
||||
<Repeat size={12} />
|
||||
{#if repeatMode === 'one'}
|
||||
<span class="repeat-one">1</span>
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<div class="volume-group">
|
||||
<button
|
||||
class="control-btn"
|
||||
@@ -283,10 +270,6 @@
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 300ms ease, transform 300ms ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.controls-wrapper.visible {
|
||||
@@ -294,11 +277,6 @@
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.quality-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.player-bar {
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(40px);
|
||||
|
||||
Reference in new issue
Block a user