diff --git a/filcnaplo_mobile_ui/lib/screens/summary/pages/personality_page.dart b/filcnaplo_mobile_ui/lib/screens/summary/pages/personality_page.dart index 8782272..a7a02ad 100644 --- a/filcnaplo_mobile_ui/lib/screens/summary/pages/personality_page.dart +++ b/filcnaplo_mobile_ui/lib/screens/summary/pages/personality_page.dart @@ -9,6 +9,7 @@ import 'package:provider/provider.dart'; import 'package:screenshot/screenshot.dart'; import 'package:share_plus/share_plus.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:image_gallery_saver/image_gallery_saver.dart'; class PersonalityBody extends StatefulWidget { const PersonalityBody({Key? key}) : super(key: key); @@ -28,6 +29,9 @@ class _PersonalityBodyState extends State { await screenshotController.capture().then((image) async { if (image != null) { final directory = await getApplicationDocumentsDirectory(); + if (await File('${directory.path}/refilc_personality.png').exists()) { + await File('${directory.path}/refilc_personality.png').delete(); + } final imagePath = await File('${directory.path}/refilc_personality.png').create(); await imagePath.writeAsBytes(image); @@ -39,6 +43,16 @@ class _PersonalityBodyState extends State { }); } + savePersonality() async { + await screenshotController.capture().then((image) async { + if (image != null) { + await ImageGallerySaver.saveImage(image, name: 'refilc_personality'); + } + }).catchError((err) { + throw err; + }); + } + @override Widget build(BuildContext context) { user = Provider.of(context); @@ -67,19 +81,40 @@ class _PersonalityBodyState extends State { ), const SizedBox(height: 40), Center( - child: IconButton( - onPressed: () async { - await sharePersonality(); - }, - icon: const Icon( - FeatherIcons.share2, - color: Colors.white, - size: 20, - ), - style: ButtonStyle( - backgroundColor: - MaterialStateProperty.all(Colors.white.withOpacity(0.5)), - ), + child: Row( + children: [ + IconButton( + onPressed: () async { + await sharePersonality(); + }, + icon: const Icon( + FeatherIcons.share, + color: Colors.white, + size: 30, + ), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.white.withOpacity(0.2)), + ), + ), + const SizedBox( + width: 10, + ), + IconButton( + onPressed: () async { + await savePersonality(); + }, + icon: const Icon( + FeatherIcons.bookmark, + color: Colors.white, + size: 30, + ), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.white.withOpacity(0.2)), + ), + ), + ], ), ), const SizedBox(height: 60), diff --git a/filcnaplo_mobile_ui/pubspec.yaml b/filcnaplo_mobile_ui/pubspec.yaml index e518617..ced8ee0 100755 --- a/filcnaplo_mobile_ui/pubspec.yaml +++ b/filcnaplo_mobile_ui/pubspec.yaml @@ -42,6 +42,7 @@ dependencies: package_info_plus: ^4.0.2 dotted_border: ^2.0.0+3 screenshot: ^2.1.0 + image_gallery_saver: ^2.0.2 dev_dependencies: flutter_lints: ^1.0.0