Reubencf commited on
Commit
b60520b
·
1 Parent(s): 9523283

Fixing many errors

Browse files
Files changed (1) hide show
  1. app/components/FlutterRunner.tsx +26 -4
app/components/FlutterRunner.tsx CHANGED
@@ -6,7 +6,8 @@ import {
6
  Download,
7
  SidebarSimple,
8
  FileCode,
9
- CaretDown
 
10
 
11
  } from '@phosphor-icons/react'
12
  import Window from './Window'
@@ -243,6 +244,14 @@ export function FlutterRunner({ onClose, onMinimize, onMaximize, initialCode }:
243
  a.download = activeFileName || 'main.dart'
244
  a.click()
245
  URL.revokeObjectURL(url)
 
 
 
 
 
 
 
 
246
  }
247
 
248
  return (
@@ -311,6 +320,14 @@ export function FlutterRunner({ onClose, onMinimize, onMaximize, initialCode }:
311
 
312
  <div className="flex items-center gap-2">
313
  <button
 
 
 
 
 
 
 
 
314
  onClick={handleDownload}
315
  className="p-1.5 text-gray-400 hover:text-white hover:bg-[#3e3e42] rounded transition-colors"
316
  title="Download Code"
@@ -367,9 +384,12 @@ export function FlutterRunner({ onClose, onMinimize, onMaximize, initialCode }:
367
  <div className="w-24" /> {/* Spacer for centering */}
368
  </div>
369
  <div className="flex-1 bg-[#1e1e1e] relative overflow-hidden">
 
 
 
370
  <iframe
371
 
372
- src={`https://dartpad.dev/embed-flutter.html?theme=dark&run=true&split=50&code=${encodeURIComponent(code)}`}
373
  className="w-full h-full border-0"
374
  sandbox="allow-scripts allow-same-origin allow-popups"
375
  title="Flutter Preview"
@@ -386,14 +406,16 @@ export function FlutterRunner({ onClose, onMinimize, onMaximize, initialCode }:
386
  <div className="flex-1 overflow-y-auto py-2">
387
  <div className="px-2">
388
  <div className="flex items-center gap-1 py-1 px-2 text-sm text-gray-300 hover:bg-[#2a2d2e] rounded cursor-pointer">
389
- <CaretDown size={12} weight="bold" />
 
390
  <span className="font-bold">Flutter App</span>
391
  </div>
392
  <div className="pl-4">
393
  {files.map(file => (
394
  <div key={file.id}>
395
  <div className="flex items-center gap-2 py-1 px-2 text-sm hover:bg-[#2a2d2e] rounded cursor-pointer text-blue-400">
396
- <CaretDown size={12} weight="bold" />
 
397
  {file.name}
398
  </div>
399
  {file.children?.map(child => (
 
6
  Download,
7
  SidebarSimple,
8
  FileCode,
9
+ CaretDown,
10
+ Copy
11
 
12
  } from '@phosphor-icons/react'
13
  import Window from './Window'
 
244
  a.download = activeFileName || 'main.dart'
245
  a.click()
246
  URL.revokeObjectURL(url)
247
+
248
+ const handleCopyCode = () => {
249
+ navigator.clipboard.writeText(code).then(() => {
250
+ console.log("Code copied to clipboard!")
251
+ }).catch(err => {
252
+ console.error("Failed to copy:", err)
253
+ })
254
+ }
255
  }
256
 
257
  return (
 
320
 
321
  <div className="flex items-center gap-2">
322
  <button
323
+ <button
324
+ onClick={handleCopyCode}
325
+ className="flex items-center gap-1 px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white rounded text-xs font-medium transition-colors"
326
+ title="Copy Code to Clipboard"
327
+ >
328
+ <Copy size={14} weight="bold" />
329
+ Copy Code
330
+ </button>
331
  onClick={handleDownload}
332
  className="p-1.5 text-gray-400 hover:text-white hover:bg-[#3e3e42] rounded transition-colors"
333
  title="Download Code"
 
384
  <div className="w-24" /> {/* Spacer for centering */}
385
  </div>
386
  <div className="flex-1 bg-[#1e1e1e] relative overflow-hidden">
387
+ <div className="absolute top-0 left-0 right-0 bg-blue-900/90 backdrop-blur-sm px-4 py-2 z-10 border-b border-blue-700">
388
+ <p className="text-blue-100 text-sm font-medium">📋 Click "Copy Code" button, then paste into DartPad editor</p>
389
+ </div>
390
  <iframe
391
 
392
+ src="https://dartpad.dev/embed-flutter.html?theme=dark&split=50"
393
  className="w-full h-full border-0"
394
  sandbox="allow-scripts allow-same-origin allow-popups"
395
  title="Flutter Preview"
 
406
  <div className="flex-1 overflow-y-auto py-2">
407
  <div className="px-2">
408
  <div className="flex items-center gap-1 py-1 px-2 text-sm text-gray-300 hover:bg-[#2a2d2e] rounded cursor-pointer">
409
+ <CaretDown,
410
+ Copy size={12} weight="bold" />
411
  <span className="font-bold">Flutter App</span>
412
  </div>
413
  <div className="pl-4">
414
  {files.map(file => (
415
  <div key={file.id}>
416
  <div className="flex items-center gap-2 py-1 px-2 text-sm hover:bg-[#2a2d2e] rounded cursor-pointer text-blue-400">
417
+ <CaretDown,
418
+ Copy size={12} weight="bold" />
419
  {file.name}
420
  </div>
421
  {file.children?.map(child => (