@@ -12,9 +12,10 @@ import { useState } from "react";
1212import VolumeZones from "@/components/VolumeZones/VolumeZones" ;
1313import Card from "@/components/Card/Card" ;
1414import StreamsModal from "@/components/StreamsModal/StreamsModal" ;
15+ import ZonesModal from "@/components/ZonesModal/ZonesModal" ;
1516import { getSourceInputType } from "@/utils/getSourceInputType" ;
1617import Chip from "@/components/Chip/Chip" ;
17- import Grid from "@mui/material/Grid/Grid"
18+ import Grid from "@mui/material/Grid/Grid" ;
1819import selectActiveSource from "@/utils/selectActiveSource" ;
1920import Box from "@mui/material/Box/Box" ;
2021
@@ -24,8 +25,9 @@ import { getFittestRep } from "@/utils/GroupZoneFiltering";
2425
2526const Player = ( ) => {
2627 const [ streamsModalOpen , setStreamsModalOpen ] = React . useState ( false ) ;
28+ const [ zonesModalOpen , setZonesModalOpen ] = React . useState ( false ) ;
2729 const selectedSourceId = usePersistentStore ( ( s ) => s . selectedSource ) ;
28- // TODO: dont index into sources. id isn't guarenteed to line up with order
30+ // TODO: Don't index into sources. id isn't guaranteed to line up with order
2931 const img_url = useStatusStore (
3032 ( s ) => s . status . sources [ selectedSourceId ] . info . img_url
3133 ) ;
@@ -62,6 +64,12 @@ const Player = () => {
6264 // This is a bootleg XOR statement, only works if there is exactly one zone or exactly one group, no more than that and not both
6365 const alone = ( ( usedGroups . length == 1 ) || ( zonesLeft . length == 1 ) ) && ! ( ( usedGroups . length > 0 ) && ( zonesLeft . length > 0 ) ) ;
6466
67+ React . useEffect ( ( ) => {
68+ if ( zonesLeft . length == 0 && usedGroups . length == 0 ) {
69+ setExpanded ( false ) ;
70+ }
71+ } , [ zonesLeft . length , usedGroups . length ] ) ; // Automatically unexpand when no zones or groups are connected
72+
6573 selectActiveSource ( ) ;
6674
6775 function DropdownArrow ( ) {
@@ -85,11 +93,19 @@ const Player = () => {
8593 onClose = { ( ) => setStreamsModalOpen ( false ) }
8694 />
8795 ) }
96+
97+ { zonesModalOpen && (
98+ < ZonesModal
99+ sourceId = { selectedSourceId }
100+ setZoneModalOpen = { setZonesModalOpen }
101+ onClose = { ( ) => setZonesModalOpen ( false ) }
102+ />
103+ ) }
88104 < Grid
89- container
90- direction = "column"
91- justifyContent = "center"
92- alignItems = "center"
105+ container
106+ direction = "column"
107+ justifyContent = "center"
108+ alignItems = "center"
93109 >
94110 < Grid item xs = { 2 } sm = { 4 } md = { 4 } >
95111 < div className = "stream-title" >
@@ -102,9 +118,9 @@ const Player = () => {
102118 < Box
103119 className = "album-art-container"
104120 sx = { {
105- display : ' flex' ,
106- justifyContent : ' center' ,
107- alignItems : ' center' ,
121+ display : " flex" ,
122+ justifyContent : " center" ,
123+ alignItems : " center" ,
108124 } }
109125 >
110126 < img src = { img_url } className = "player-album-art" />
@@ -116,26 +132,21 @@ const Player = () => {
116132 < div className = { alone ? "solo-media-controls" : "grouped-media-controls" } >
117133 < MediaControl selectedSource = { selectedSourceId } />
118134 </ div >
119- { ( ! is_streamer && zones . length > 0 ) ? (
120- ( alone ) ? (
121- < div className = "player-volume-container" >
122- < VolumeZones alone open sourceId = { selectedSourceId } zones = { zonesLeft } groups = { usedGroups } groupsLeft = { groupsLeft } />
123- </ div >
124- ) : (
125- < Card className = "player-volume-container" >
135+ { ! is_streamer && (
136+ < Card className = "player-volume-container" >
137+ { ( zones . length > 0 ) && (
126138 < div className = "player-volume-header" >
127139 < CardVolumeSlider sourceId = { selectedSourceId } />
128140 < IconButton onClick = { ( ) => setExpanded ( ! expanded ) } >
129141 < DropdownArrow />
130142 </ IconButton >
131143 </ div >
132-
133- < div className = { `player-volume-body pill-scrollbar ${ expanded ? "expanded-volume-body" : "" } ` } >
134- < VolumeZones open = { ( expanded ) } sourceId = { selectedSourceId } zones = { zonesLeft } groups = { usedGroups } groupsLeft = { groupsLeft } />
135- </ div >
136- </ Card >
137- )
138- ) : null }
144+ ) }
145+ < div className = { `player-volume-body ${ ( expanded ) && "expanded-volume-body pill-scrollbar scrollable" } ` } >
146+ < VolumeZones setZonesModalOpen = { setZonesModalOpen } open = { ( expanded ) } sourceId = { selectedSourceId } zones = { zonesLeft } groups = { usedGroups } groupsLeft = { groupsLeft } />
147+ </ div >
148+ </ Card >
149+ ) }
139150 </ div >
140151 ) ;
141152} ;
0 commit comments