Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Share individual legacy kit sheets

Neeraj Gupta1a6505b435cf
diff --git a/mobile/packages/legacy/lib/components/legacy_kit_icons.dart b/mobile/packages/legacy/lib/components/legacy_kit_icons.dart
index 015fe170d4..6775843f66 100644
--- a/mobile/packages/legacy/lib/components/legacy_kit_icons.dart
+++ b/mobile/packages/legacy/lib/components/legacy_kit_icons.dart
@@ -24,6 +24,27 @@ class LegacyKitDownloadIcon extends StatelessWidget {
}
}
+class LegacyKitShareIcon extends StatelessWidget {
+ final Color color;
+ final double size;
+
+ const LegacyKitShareIcon({
+ required this.color,
+ this.size = 18,
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ return HugeIcon(
+ icon: HugeIcons.strokeRoundedShare08,
+ color: color,
+ size: size,
+ strokeWidth: _hugeIconStrokeWidth,
+ );
+ }
+}
+
class LegacyKitEditIcon extends StatelessWidget {
final Color color;
final double size;
diff --git a/mobile/packages/legacy/lib/pages/legacy_kit_page.dart b/mobile/packages/legacy/lib/pages/legacy_kit_page.dart
index 6f24e90b1a..91a8a36a52 100644
--- a/mobile/packages/legacy/lib/pages/legacy_kit_page.dart
+++ b/mobile/packages/legacy/lib/pages/legacy_kit_page.dart
@@ -17,6 +17,7 @@ import "package:ente_utils/file_saver_util.dart";
import "package:file_saver/file_saver.dart";
import "package:flutter/material.dart";
import "package:intl/intl.dart";
+import "package:share_plus/share_plus.dart";
typedef LegacyKitAuthenticator = Future<bool> Function(
BuildContext context,
@@ -168,7 +169,7 @@ class _LegacyKitPageState extends State<LegacyKitPage> {
cardColor: cardColor,
avatarColor: _avatarColor(index),
onTap: () async {
- await _downloadPart(_kit.parts[index]);
+ await _sharePart(_kit.parts[index]);
},
),
if (index < _kit.parts.length - 1) const SizedBox(height: 8),
@@ -337,7 +338,7 @@ class _LegacyKitPageState extends State<LegacyKitPage> {
}
}
- Future<void> _downloadPart(LegacyKitPart part) async {
+ Future<void> _sharePart(LegacyKitPart part) async {
if (!await _authenticate(context.strings.authToManageLegacyKit)) {
return;
}
@@ -357,14 +358,12 @@ class _LegacyKitPageState extends State<LegacyKitPage> {
share: share,
allShares: shares,
);
- final saved = await _savePdf(bytes, _kit, part: part);
await dialog.hide();
- if (!saved) {
+ final result = await _sharePdf(bytes, _kit, part: part);
+ if (!mounted || result.status != ShareResultStatus.unavailable) {
return;
}
- if (mounted) {
- showShortToast(context, context.strings.legacyKitSheetDownloaded);
- }
+ showShortToast(context, context.strings.somethingWentWrong);
} catch (_) {
await dialog.hide();
if (mounted) {
@@ -539,6 +538,28 @@ class _LegacyKitPageState extends State<LegacyKitPage> {
);
}
+ Future<ShareResult> _sharePdf(
+ Uint8List bytes,
+ LegacyKit kit, {
+ LegacyKitPart? part,
+ }) {
+ final size = MediaQuery.sizeOf(context);
+ return SharePlus.instance.share(
+ ShareParams(
+ files: [
+ XFile.fromData(
+ bytes,
+ mimeType: "application/pdf",
+ ),
+ ],
+ fileNameOverrides: [
+ "${_fileNameForKit(kit, part: part)}.pdf",
+ ],
+ sharePositionOrigin: Offset.zero & size,
+ ),
+ );
+ }
+
LegacyKitPart _partForShare(LegacyKitShare share) {
return _kit.parts.firstWhereOrNull(
(part) => part.index == share.shareIndex,
@@ -811,7 +832,7 @@ class _LegacyKitPartRow extends StatelessWidget {
height: 40,
width: 40,
child: Center(
- child: LegacyKitDownloadIcon(
+ child: LegacyKitShareIcon(
color: colorScheme.textBase,
),
),
diff --git a/mobile/packages/legacy/pubspec.lock b/mobile/packages/legacy/pubspec.lock
index b701157851..ca9fd4f6d9 100644
--- a/mobile/packages/legacy/pubspec.lock
+++ b/mobile/packages/legacy/pubspec.lock
@@ -976,7 +976,7 @@ packages:
source: hosted
version: "8.14.2"
share_plus:
- dependency: transitive
+ dependency: "direct main"
description:
name: share_plus
sha256: d7dc0630a923883c6328ca31b89aa682bacbf2f8304162d29f7c6aaff03a27a1
diff --git a/mobile/packages/legacy/pubspec.yaml b/mobile/packages/legacy/pubspec.yaml
index 8871b86f60..74db822762 100644
--- a/mobile/packages/legacy/pubspec.yaml
+++ b/mobile/packages/legacy/pubspec.yaml
@@ -44,6 +44,7 @@ dependencies:
password_strength: 0.2.0
pdf: 3.11.3
pointycastle: 3.9.1
+ share_plus: 11.1.0
uuid: 4.5.2
dev_dependencies: