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
+215
-54
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} />
|
||||
<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);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg fill="#000000" height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
|
||||
<g id="Responsive-scales">
|
||||
<path d="M44.8451996,18.5058994h-8c-0.5527,0-1,0.4473-1,1s0.4473,1,1,1h5.5859985L32.4310989,30.5069008l1.4141006,1.4139996
|
||||
l10-10.0008011V27.5049c0,0.5527992,0.4473,1,1,1s1-0.4472008,1-1v-7.9990005
|
||||
C45.8451996,18.9531994,45.3978996,18.5058994,44.8451996,18.5058994z"/>
|
||||
<path d="M22.3178005,42.0918007L10.8451996,53.5644989v-6.0585976c0-0.5527-0.4473-1-1-1s-1,0.4473-1,1v7.9990005
|
||||
c0,0.5527992,0.4473,1,1,1h8c0.5527,0,1-0.4472008,1-1c0-0.5527-0.4473-1-1-1h-5.1122999l10.9989996-10.9990005
|
||||
L22.3178005,42.0918007z"/>
|
||||
<path d="M57.3041992,0H16.7884998C13.4946003,0,10.8139,2.6807001,10.8139,5.9747v4.1181002H6.6947999
|
||||
c-3.2939,0-5.9735999,2.6807003-5.9735999,5.9745998v41.9580002C0.7212,61.3194008,3.4008999,64,6.6947999,64h40.5165977
|
||||
c3.2938995,0,5.9746017-2.6805992,5.9746017-5.9746017v-2.6766968h4.1181984c3.2938995,0,5.9746017-2.6807022,5.9746017-5.9746017
|
||||
V5.9747C63.278801,2.6807001,60.5980988,0,57.3041992,0z M51.1860008,58.0253983
|
||||
C51.1860008,60.2168007,49.4028015,62,47.2113991,62H6.6947999C4.5033998,62,2.7212,60.2168007,2.7212,58.0253983V16.0674
|
||||
c0-2.1913996,1.7821999-3.9745998,3.9735999-3.9745998h40.5165977c2.1914024,0,3.9746017,1.7832003,3.9746017,3.9745998V58.0253983
|
||||
z M61.278801,49.3740997c0,2.1913986-1.7831993,3.9746017-3.9746017,3.9746017h-4.1181984V16.0674
|
||||
c0-3.2938995-2.6807022-5.9745998-5.9746017-5.9745998H12.8139V5.9747C12.8139,3.7832999,14.5971003,2,16.7884998,2h40.5157013
|
||||
c2.1914024,0,3.9746017,1.7832999,3.9746017,3.9747V49.3740997z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg fill="#000000" width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M21.0071085,18.508331 C21.0071085,19.8890429 19.8878203,21.008331 18.5071085,21.008331 L5.5,21.008331 C4.11928813,21.008331 3,19.8890429 3,18.508331 L3,5.5 C3,4.11928813 4.11928813,3 5.5,3 L18.5071085,3 C19.8878203,3 21.0071085,4.11928813 21.0071085,5.5 L21.0071085,18.508331 Z M20.0071085,7 L20.0071085,5.5 C20.0071085,4.67157288 19.3355356,4 18.5071085,4 L5.5,4 C4.67157288,4 4,4.67157288 4,5.5 L4,7 L20.0071085,7 Z M20.0071085,8 L4,8 L4,18.508331 C4,19.3367581 4.67157288,20.008331 5.5,20.008331 L18.5071085,20.008331 C19.3355356,20.008331 20.0071085,19.3367581 20.0071085,18.508331 L20.0071085,8 Z M5,5 L6,5 L6,6 L5,6 L5,5 Z M7,5 L8,5 L8,6 L7,6 L7,5 Z M9,5 L10,5 L10,6 L9,6 L9,5 Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 929 B |
Reference in new issue
Block a user