Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2025-07-19 13:24:48 -05:00
parent 4495e043c9
commit 1238ab3b3e
2 changed files with 100 additions and 9 deletions

View File

@ -128,7 +128,7 @@ const Navigation: React.FC = () => {
{/* Player Controls */} {/* Player Controls */}
<div style={{ marginTop: 'auto', padding: '16px' }}> <div style={{ marginTop: 'auto', padding: '16px' }}>
<PlayerControls /> <PlayerControls variant="dark" />
</div> </div>
</div> </div>
); );
@ -184,7 +184,7 @@ const Navigation: React.FC = () => {
{/* Player Controls for Mobile */} {/* Player Controls for Mobile */}
<div style={{ padding: '16px' }}> <div style={{ padding: '16px' }}>
<PlayerControls /> <PlayerControls variant="dark" />
</div> </div>
</IonContent> </IonContent>
</IonMenu> </IonMenu>

View File

@ -1,19 +1,20 @@
import React from 'react'; import React from 'react';
import { IonCard, IonCardContent, IonChip, IonIcon } from '@ionic/react'; import { IonCard, IonCardContent, IonChip, IonIcon } from '@ionic/react';
import { play, pause, stop } from 'ionicons/icons'; import { play, pause, stop, settingsOutline, pauseOutline, playOutline, stopOutline } from 'ionicons/icons';
import { useAppSelector } from '../../redux';
import { selectIsAdmin, selectPlayerState, selectQueueLength, selectControllerName } from '../../redux';
import { playerService } from '../../firebase/services';
import { PlayerState } from '../../types';
import ActionButton from './ActionButton'; import ActionButton from './ActionButton';
import { useToast } from '../../hooks/useToast'; import { useAppSelector } from '../../redux';
import { selectPlayerState, selectIsAdmin, selectQueueLength, selectControllerName } from '../../redux';
import { playerService } from '../../firebase/services';
import { debugLog } from '../../utils/logger'; import { debugLog } from '../../utils/logger';
import { useToast } from '../../hooks/useToast';
import { PlayerState } from '../../types';
interface PlayerControlsProps { interface PlayerControlsProps {
className?: string; className?: string;
variant?: 'light' | 'dark';
} }
const PlayerControls: React.FC<PlayerControlsProps> = ({ className = '' }) => { const PlayerControls: React.FC<PlayerControlsProps> = ({ className = '', variant = 'light' }) => {
const isAdmin = useAppSelector(selectIsAdmin); const isAdmin = useAppSelector(selectIsAdmin);
const playerState = useAppSelector(selectPlayerState); const playerState = useAppSelector(selectPlayerState);
const queueLength = useAppSelector(selectQueueLength); const queueLength = useAppSelector(selectQueueLength);
@ -83,6 +84,96 @@ const PlayerControls: React.FC<PlayerControlsProps> = ({ className = '' }) => {
} }
}; };
const getStatusText = () => {
switch (currentState) {
case PlayerState.playing:
return 'Currently Playing';
case PlayerState.paused:
return 'Currently Paused';
default:
return 'Currently Stopped';
}
};
// Dark mode variant
if (variant === 'dark') {
return (
<div className={`bg-black text-white ${className}`}>
{/* Status Text */}
<div
className="flex items-center"
style={{ padding: '12px 0px' }}
>
<span style={{
fontWeight: '600',
fontSize: '16px',
}}>
{getStatusText()}
</span>
</div>
{/* Control Buttons */}
{currentState === PlayerState.playing ? (
<div
className="flex items-center cursor-pointer hover:bg-gray-800"
style={{ padding: '12px 0px' }}
onClick={handlePause}
>
<IonIcon
icon={pauseOutline}
style={{
marginRight: '12px',
fontSize: '20px'
}}
/>
<span style={{ fontWeight: '500' }}>Pause</span>
</div>
) : (
<div
className="flex items-center cursor-pointer hover:bg-gray-800"
style={{ padding: '12px 0px' }}
onClick={handlePlay}
>
<IonIcon
icon={playOutline}
style={{
marginRight: '12px',
fontSize: '20px'
}}
/>
<span style={{ fontWeight: '500' }}>Play</span>
</div>
)}
{currentState !== PlayerState.stopped && (
<div
className="flex items-center cursor-pointer hover:bg-gray-800"
style={{ padding: '12px 0px' }}
onClick={handleStop}
>
<IonIcon
icon={stopOutline}
style={{
marginRight: '12px',
fontSize: '20px'
}}
/>
<span style={{ fontWeight: '500' }}>Stop</span>
</div>
)}
{!hasSongsInQueue && (
<div style={{
padding: '12px 0px',
marginLeft: '32px' // Align with text after icon
}} className="text-xs text-gray-400">
Add songs to queue to enable playback controls
</div>
)}
</div>
);
}
return ( return (
<IonCard className={className}> <IonCard className={className}>
<IonCardContent> <IonCardContent>