Skip to content

Commit

Permalink
Add export button to templates dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jun 22, 2024
1 parent d92e0f9 commit 15bdfab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/lib/dialogs/template.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -74,6 +76,23 @@ class _TemplateDialogState extends State<TemplateDialog> {
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),
Expand Down
3 changes: 2 additions & 1 deletion app/lib/views/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ class _MainPopupMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
final settingsCubit = context.read<SettingsCubit>();
final windowCubit = context.read<WindowCubit>();
return BlocBuilder<SettingsCubit, ButterflySettings>(
buildWhen: (previous, current) =>
previous.navigationRail != current.navigationRail,
Expand Down Expand Up @@ -509,7 +510,7 @@ class _MainPopupMenu extends StatelessWidget {
shortcut:
const SingleActivator(LogicalKeyboardKey.f11),
onPressed: () async {
context.read<WindowCubit>().toggleFullScreen();
windowCubit.toggleFullScreen();
},
child: Text(AppLocalizations.of(context).fullScreen),
)),
Expand Down
2 changes: 2 additions & 0 deletions metadata/en-US/changelogs/109.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 15bdfab

Please sign in to comment.