Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refactor utils

vishnukvmd8a9f73ada5ea
diff --git a/mobile/packages/utils/lib/share_utils.dart b/mobile/packages/utils/lib/share_utils.dart
index c7cf0e8de5..884901c442 100644
--- a/mobile/packages/utils/lib/share_utils.dart
+++ b/mobile/packages/utils/lib/share_utils.dart
@@ -1,7 +1,57 @@
+import 'dart:io';
+
+import 'package:ente_strings/extensions.dart';
+import 'package:ente_ui/components/buttons/button_widget.dart';
+import 'package:ente_ui/components/buttons/models/button_type.dart';
+import 'package:ente_ui/components/dialog_widget.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:share_plus/share_plus.dart';
+Future<void> shareDialog(
+ BuildContext context,
+ String title, {
+ required Function saveAction,
+ required Function sendAction,
+}) async {
+ final l10n = context.strings;
+ await showDialogWidget(
+ context: context,
+ title: title,
+ body: Platform.isLinux || Platform.isWindows
+ ? l10n.saveOnlyDescription
+ : l10n.saveOrSendDescription,
+ buttons: [
+ ButtonWidget(
+ isInAlert: true,
+ buttonType: ButtonType.neutral,
+ labelText: l10n.save,
+ buttonAction: ButtonAction.first,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ await saveAction();
+ },
+ ),
+ if (!Platform.isWindows && !Platform.isLinux)
+ ButtonWidget(
+ isInAlert: true,
+ buttonType: ButtonType.secondary,
+ labelText: l10n.send,
+ buttonAction: ButtonAction.second,
+ onTap: () async {
+ await sendAction();
+ },
+ ),
+ ButtonWidget(
+ isInAlert: true,
+ buttonType: ButtonType.secondary,
+ labelText: l10n.cancel,
+ buttonAction: ButtonAction.cancel,
+ ),
+ ],
+ );
+}
+
Rect _sharePosOrigin(BuildContext? context, GlobalKey? key) {
late final Rect rect;
if (context != null) {
diff --git a/mobile/packages/utils/pubspec.lock b/mobile/packages/utils/pubspec.lock
index 9b33654cf8..ecc483f51a 100644
--- a/mobile/packages/utils/pubspec.lock
+++ b/mobile/packages/utils/pubspec.lock
@@ -528,6 +528,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
+ modal_bottom_sheet:
+ dependency: transitive
+ description:
+ name: modal_bottom_sheet
+ sha256: eac66ef8cb0461bf069a38c5eb0fa728cee525a531a8304bd3f7b2185407c67e
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.0"
package_info_plus:
dependency: "direct main"
description: