diff --git a/app/lib/html_view_screen.dart b/app/lib/html_view_screen.dart index e7001df..18d32f6 100644 --- a/app/lib/html_view_screen.dart +++ b/app/lib/html_view_screen.dart @@ -1,4 +1,5 @@ import 'dart:html'; +import 'dart:html' as html; import 'dart:ui_web' as ui; import 'package:flutter/material.dart'; @@ -26,9 +27,26 @@ class HtmlViewScreen extends StatelessWidget { }, ); + // Function to download the content + void downloadContent() { + final blob = html.Blob([htmlContent]); + final url = html.Url.createObjectUrlFromBlob(blob); + final anchor = html.AnchorElement(href: url) + ..setAttribute("download", "${appName}.html") + ..click(); + html.Url.revokeObjectUrl(url); + } + return Scaffold( appBar: AppBar( title: Text(appName), + actions: [ + IconButton( + icon: Icon(Icons.download), + onPressed: downloadContent, // Trigger the download + tooltip: 'Download Code', + ), + ], ), body: HtmlElementView( key: ValueKey(contentKey), // Use the unique key for the HtmlElementView diff --git a/app/lib/paint_window.dart b/app/lib/paint_window.dart index ff881ae..bd0aa21 100644 --- a/app/lib/paint_window.dart +++ b/app/lib/paint_window.dart @@ -189,6 +189,15 @@ class _PaintWindowState extends State { setState(() { isLoading = false; }); + + clear(); + } + + void clear() { + nameController.clear(); + setState(() { + points.clear(); + }); } @override @@ -198,7 +207,7 @@ class _PaintWindowState extends State { } return AlertDialog( - title: const Text('Paint Window'), + title: const Text('Magic Window'), content: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, @@ -251,11 +260,7 @@ class _PaintWindowState extends State { else TextButton( child: const Text('Clear'), - onPressed: () { - setState(() { - points.clear(); - }); - }, + onPressed: clear, ), TextButton( child: const Text('Build'),