From a66f7d5a53339baea69b871631f947983cb5f0e9 Mon Sep 17 00:00:00 2001 From: Rustem Kakimov Date: Thu, 12 Aug 2021 11:12:13 +0300 Subject: [PATCH] Export project (#219) * Backup project option * Bump version --- lib/home/ui/project_thumbnail.dart | 15 +++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/home/ui/project_thumbnail.dart b/lib/home/ui/project_thumbnail.dart index 77f4f8db..b2b48ba6 100644 --- a/lib/home/ui/project_thumbnail.dart +++ b/lib/home/ui/project_thumbnail.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'package:archive/archive_io.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:mooltik/common/data/project/project.dart'; @@ -6,6 +7,7 @@ import 'package:mooltik/common/ui/labeled_icon_button.dart'; import 'package:mooltik/common/ui/popup_with_arrow.dart'; import 'package:mooltik/drawing/ui/frame_window.dart'; import 'package:provider/provider.dart'; +import 'package:share_plus/share_plus.dart'; import '../data/gallery_model.dart'; @@ -110,6 +112,12 @@ class _ProjectThumbnailState extends State { color: Theme.of(context).colorScheme.onPrimary, onTap: _moveToBin, ), + LabeledIconButton( + icon: FontAwesomeIcons.fileArchive, + label: 'Backup', + color: Theme.of(context).colorScheme.onPrimary, + onTap: _exportBackup, + ), ], ), ); @@ -128,6 +136,13 @@ class _ProjectThumbnailState extends State { void _moveToBin() { context.read().moveProjectToBin(context.read()); } + + void _exportBackup() async { + final project = context.read(); + final zipEncoder = ZipFileEncoder(); + zipEncoder.zipDirectory(project.directory); + await Share.shareFiles([zipEncoder.zip_path]); + } } class _Thumbnail extends StatelessWidget { diff --git a/pubspec.yaml b/pubspec.yaml index 6fffcd3e..52ebe8f2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.14.1 +version: 1.15.0 environment: sdk: '>=2.12.0 <3.0.0'