1+ import { IconDownload , IconFullscreen } from '@/components/icons'
12import processFileParam from '@/lib/process-file-param.server'
23import { unzipCbz } from '@/lib/unzip-cbz.server'
34import { LoaderFunctionArgs } from '@remix-run/node'
4- import { useLoaderData } from '@remix-run/react'
5+ import { Link , useLoaderData , useSearchParams } from '@remix-run/react'
56import { useState , useEffect } from 'react'
67
78export async function loader ( { request } : LoaderFunctionArgs ) {
@@ -16,6 +17,8 @@ export default function Read() {
1617 const [ showControls , setShowControls ] = useState ( true )
1718 const [ isFullscreen , setIsFullscreen ] = useState ( false )
1819 const file = files [ index ]
20+ const [ searchParams ] = useSearchParams ( )
21+ const fileParam = encodeURIComponent ( searchParams . get ( 'file' ) || '' )
1922
2023 // Ocultar controles automáticamente después de 3 segundos
2124 useEffect ( ( ) => {
@@ -107,22 +110,26 @@ export default function Read() {
107110 }
108111 }
109112
113+ function handleDoubleClick ( e : React . MouseEvent ) {
114+ e . preventDefault ( )
115+ setShowControls ( ( prev ) => ! prev )
116+ }
117+
118+ function handleKeyDown ( e : React . KeyboardEvent < HTMLDivElement > ) {
119+ if ( e . key === 'Enter' || e . key === 'Space' ) {
120+ e . preventDefault ( )
121+ setShowControls ( ( prev ) => ! prev )
122+ }
123+ }
124+
110125 return (
111126 < div className = "relative w-screen h-screen bg-black overflow-hidden" >
112127 { /* Imagen principal */ }
113128 < div
114129 className = "w-full h-full flex items-center justify-center cursor-pointer"
115130 onClick = { handleImageClick }
116- onDoubleClick = { ( ev ) => {
117- ev . preventDefault ( )
118- setShowControls ( ( prev ) => ! prev )
119- } }
120- onKeyDown = { ( e ) => {
121- if ( e . key === 'Enter' || e . key === ' ' ) {
122- e . preventDefault ( )
123- setShowControls ( ( prev ) => ! prev )
124- }
125- } }
131+ onDoubleClick = { handleDoubleClick }
132+ onKeyDown = { handleKeyDown }
126133 role = "button"
127134 tabIndex = { 0 }
128135 aria-label = "Navegar por la imagen"
@@ -142,7 +149,14 @@ export default function Read() {
142149 } `}
143150 >
144151 { /* Barra superior */ }
145- < div className = "absolute top-0 left-0 right-0 h-16 bg-gradient-to-b from-black/80 to-transparent pointer-events-auto" >
152+ < div
153+ className = "absolute top-0 left-0 right-0 h-16 bg-gradient-to-b from-black/80 to-transparent pointer-events-auto"
154+ aria-label = "Barra superior"
155+ role = "button"
156+ tabIndex = { 0 }
157+ onClick = { ( ) => setShowControls ( ( prev ) => ! prev ) }
158+ onKeyDown = { handleKeyDown }
159+ >
146160 < div className = "flex items-center justify-between px-4 py-2" >
147161 < div className = "flex items-center space-x-4" >
148162 < button
@@ -156,19 +170,36 @@ export default function Read() {
156170 </ span >
157171 </ div >
158172
159- < div className = "flex items-center space-x-2" >
173+ < div className = "flex items-center gap-x-2" >
174+ < Link
175+ to = { `/download?file=${ fileParam } ` }
176+ className = "text-white hover:text-gray-300 transition-colors p-2"
177+ aria-label = "Descargar"
178+ title = "Descargar"
179+ >
180+ < IconDownload />
181+ </ Link >
160182 < button
183+ title = "Pantalla completa"
184+ aria-label = "Pantalla completa"
161185 onClick = { toggleFullscreen }
162186 className = "text-white hover:text-gray-300 transition-colors p-2"
163187 >
164- { isFullscreen ? '⛶' : '⛶' }
188+ < IconFullscreen />
165189 </ button >
166190 </ div >
167191 </ div >
168192 </ div >
169193
170194 { /* Barra inferior */ }
171- < div className = "absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-black/80 to-transparent pointer-events-auto" >
195+ < div
196+ className = "absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-black/80 to-transparent pointer-events-auto"
197+ aria-label = "Barra inferior"
198+ role = "button"
199+ tabIndex = { 0 }
200+ onClick = { ( ) => setShowControls ( ( prev ) => ! prev ) }
201+ onKeyDown = { handleKeyDown }
202+ >
172203 < div className = "flex items-center justify-between px-4 py-2" >
173204 < button
174205 onClick = { goToPrevious }
0 commit comments