From 15bdfab931af951704a45d6538139ffddaf000a7 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Sat, 22 Jun 2024 22:41:21 +0200 Subject: [PATCH] Add export button to templates dialog --- app/lib/dialogs/template.dart | 19 +++++++++++++++++++ app/lib/views/app_bar.dart | 3 ++- metadata/en-US/changelogs/109.txt | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/lib/dialogs/template.dart b/app/lib/dialogs/template.dart index e9d81ee7be38..d06bfd277b86 100644 --- a/app/lib/dialogs/template.dart +++ b/app/lib/dialogs/template.dart @@ -1,4 +1,6 @@ +import 'package:archive/archive.dart'; import 'package:butterfly/actions/new.dart'; +import 'package:butterfly/api/save.dart'; import 'package:butterfly/cubits/settings.dart'; import 'package:butterfly/widgets/connection_button.dart'; import 'package:butterfly_api/butterfly_api.dart'; @@ -74,6 +76,23 @@ class _TemplateDialogState extends State { load(); }, ), + IconButton( + icon: const PhosphorIcon(PhosphorIconsLight.export), + tooltip: AppLocalizations.of(context).export, + onPressed: () async { + final archive = Archive(); + for (final template in await _fileSystem.getTemplates()) { + final data = template.save(); + archive.addFile( + ArchiveFile('${template.name}.bfly', data.length, data), + ); + } + final encoder = ZipEncoder(); + final bytes = encoder.encode(archive); + if (bytes == null) return; + await exportZip(context, bytes); + }, + ), IconButton( icon: const PhosphorIcon( PhosphorIconsLight.clockCounterClockwise), diff --git a/app/lib/views/app_bar.dart b/app/lib/views/app_bar.dart index 7d152820e036..0f79aa3e9098 100644 --- a/app/lib/views/app_bar.dart +++ b/app/lib/views/app_bar.dart @@ -323,6 +323,7 @@ class _MainPopupMenu extends StatelessWidget { @override Widget build(BuildContext context) { final settingsCubit = context.read(); + final windowCubit = context.read(); return BlocBuilder( buildWhen: (previous, current) => previous.navigationRail != current.navigationRail, @@ -509,7 +510,7 @@ class _MainPopupMenu extends StatelessWidget { shortcut: const SingleActivator(LogicalKeyboardKey.f11), onPressed: () async { - context.read().toggleFullScreen(); + windowCubit.toggleFullScreen(); }, child: Text(AppLocalizations.of(context).fullScreen), )), diff --git a/metadata/en-US/changelogs/109.txt b/metadata/en-US/changelogs/109.txt index 0afe1d5f47f8..4b8dc66c3d24 100644 --- a/metadata/en-US/changelogs/109.txt +++ b/metadata/en-US/changelogs/109.txt @@ -1,11 +1,13 @@ * Add erase elements property to eraser and patheraser ([#680](https://github.com/LinwoodDev/Butterfly/issues/680)) * Add shape element to normal eraser([#683](https://github.com/LinwoodDev/Butterfly/issues/683)) * Add lock layer ([#688](https://github.com/LinwoodDev/Butterfly/issues/688)) +* Add export button to templates dialog * Improve packs dialog * Fix spacer has no help page * Fix utilities state on undo/redo ([#721](https://github.com/LinwoodDev/Butterfly/issues/721)) * Fix select and eye dropper temporary tool already gets removed before doing the action * Fix asset select dialog overflows on too many assets +* Fix full screen button in top left corner menu doesn't work * Upgrade AGB to 8.5.0 in android Read more here: https://linwood.dev/butterfly/2.2.0-beta.0 \ No newline at end of file