Refactor utils

This commit is contained in:
vishnukvmd
2025-07-19 21:07:16 +05:30
parent 6bca1fa7d4
commit 057bda2fdb
2 changed files with 58 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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: