1- import React , { useState } from 'react' ;
1+ import React , { useState , useContext } from 'react' ;
2+ import { AppsContext } from '../../services/AppsContext/AppsContext.jsx' ;
23import DesktopIcon from '../DesktopIcon/DesktopIcon.jsx' ;
3- import DesktopAppsList from '../../lists/DesktopAppsList.jsx' ;
44import { GRID_GAP , TOP_MARGIN , LEFT_MARGIN } from '../../configs/DesktopIconConfig/DesktopIconConfig.jsx' ;
55import { GRID_SIZE } from '../../configs/DesktopIconConfig/DesktopIconConfig.jsx' ;
66import './Desktop.css' ;
@@ -12,17 +12,15 @@ import { FocusWrapper } from '../../interactions/FocusControl/FocusControl.jsx';
1212 */
1313function getPositionFromPriority ( priority ) {
1414 const safePriority = priority && priority > 0 ? priority : 1 ;
15-
1615 // Single-column approach: each subsequent icon moves (GRID_SIZE + GRID_GAP) down
1716 const effectiveCellSize = GRID_SIZE + GRID_GAP ;
18-
1917 const x = LEFT_MARGIN ;
2018 const y = TOP_MARGIN + ( safePriority - 1 ) * effectiveCellSize ;
21-
2219 return { x, y } ;
2320}
2421
2522function Desktop ( { onOpenApp } ) {
23+ const { apps } = useContext ( AppsContext ) ;
2624 const [ selectedIcon , setSelectedIcon ] = useState ( null ) ;
2725
2826 const handleWallpaperClick = ( ) => {
@@ -36,7 +34,7 @@ function Desktop({ onOpenApp }) {
3634 return (
3735 < FocusWrapper name = "Desktop" >
3836 < div className = "desktop" onClick = { handleWallpaperClick } >
39- { DesktopAppsList . map ( ( iconConfig ) => {
37+ { apps . filter ( iconConfig => ! iconConfig . indock ) . map ( ( iconConfig ) => {
4038 // Convert the icon's priority into an (x,y) position,
4139 // now using GRID_GAP to keep them spaced out.
4240 const position = getPositionFromPriority ( iconConfig . priority ) ;
@@ -49,7 +47,7 @@ function Desktop({ onOpenApp }) {
4947 isSelected = { selectedIcon === iconConfig . id }
5048 onClick = { ( ) => handleIconClick ( iconConfig . id ) }
5149 onDoubleClick = { ( ) => onOpenApp ( iconConfig . id ) }
52- position = { position }
50+ position = { position }
5351 />
5452 ) ;
5553 } ) }
0 commit comments