Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(bottom-sheet): use ente photos like bottom bar

Prateek Sunal6c603cb012ba
diff --git a/auth/lib/ui/code_widget.dart b/auth/lib/ui/code_widget.dart
index 6ce7c2ad79..058c1f3d7c 100644
--- a/auth/lib/ui/code_widget.dart
+++ b/auth/lib/ui/code_widget.dart
@@ -14,6 +14,7 @@ import 'package:ente_auth/services/preference_service.dart';
import 'package:ente_auth/store/code_store.dart';
import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/code_timer_progress.dart';
+import 'package:ente_auth/ui/components/bottom_action_bar_widget.dart';
import 'package:ente_auth/ui/share/code_share.dart';
import 'package:ente_auth/ui/utils/icon_utils.dart';
import 'package:ente_auth/utils/dialog_util.dart';
@@ -212,47 +213,27 @@ class _CodeWidgetState extends State<CodeWidget> {
}
: null,
onLongPress: () {
- showOptionsForCode(
- context,
- isPinned: widget.code.isPinned,
- isTrashed: widget.code.isTrashed,
- onEdit: () async {
- Future.delayed(
- const Duration(milliseconds: 200),
- () => _onEditPressed(null),
- );
- },
- onShare: () async {
- Future.delayed(
- const Duration(milliseconds: 200),
- () => _onSharePressed(null),
- );
- },
- onPin: () async {
- await _onPinPressed(null);
- },
- onTrashed: () async {
- Future.delayed(
- const Duration(milliseconds: 200),
- () => _onTrashPressed(null),
- );
- },
- onDelete: () async {
- Future.delayed(
- const Duration(milliseconds: 200),
- () => _onDeletePressed(null),
- );
- },
- onRestore: () async {
- _onRestoreClicked(null);
- },
- onShowQR: () async {
- Future.delayed(
- const Duration(milliseconds: 200),
- () => _onShowQrPressed(null),
+ showModalBottomSheet(
+ context: context,
+ builder: (_) {
+ return BottomActionBarWidget(
+ code: widget.code,
+ onEdit: () => _onEditPressed(true),
+ onShare: () => _onSharePressed(true),
+ onPin: () => _onPinPressed(true),
+ onTrashed: () => _onTrashPressed(true),
+ onDelete: () => _onDeletePressed(true),
+ onRestore: () => _onRestoreClicked(true),
+ onShowQR: () => _onShowQrPressed(true),
+ onCancel: () => Navigator.of(context).pop(),
);
},
);
+ // showOptionsForCode(
+ // context,
+ // isPinned: widget.code.isPinned,
+ // isTrashed: widget.code.isTrashed,
+ // );
// _copyCurrentOTPToClipboard();
},
child: getCardContents(l10n),
@@ -509,7 +490,10 @@ class _CodeWidgetState extends State<CodeWidget> {
}
}
- Future<void> _onEditPressed(_) async {
+ Future<void> _onEditPressed([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
bool isAuthSuccessful = await LocalAuthenticationService.instance
.requestLocalAuthentication(context, context.l10n.editCodeAuthMessage);
await PlatformUtil.refocusWindows();
@@ -530,7 +514,10 @@ class _CodeWidgetState extends State<CodeWidget> {
}
}
- Future<void> _onShowQrPressed(_) async {
+ Future<void> _onShowQrPressed([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
bool isAuthSuccessful = await LocalAuthenticationService.instance
.requestLocalAuthentication(context, context.l10n.showQRAuthMessage);
await PlatformUtil.refocusWindows();
@@ -547,7 +534,10 @@ class _CodeWidgetState extends State<CodeWidget> {
);
}
- Future<void> _onSharePressed(_) async {
+ Future<void> _onSharePressed([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
bool isAuthSuccessful = await LocalAuthenticationService.instance
.requestLocalAuthentication(context, context.l10n.authenticateGeneric);
await PlatformUtil.refocusWindows();
@@ -557,7 +547,10 @@ class _CodeWidgetState extends State<CodeWidget> {
showShareDialog(context, widget.code);
}
- Future<void> _onPinPressed(_) async {
+ Future<void> _onPinPressed([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
bool currentlyPinned = widget.code.isPinned;
final display = widget.code.display;
final Code code = widget.code.copyWith(
@@ -575,7 +568,10 @@ class _CodeWidgetState extends State<CodeWidget> {
);
}
- void _onDeletePressed(_) async {
+ void _onDeletePressed([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
if (!widget.code.isTrashed) {
showToast(context, 'Code can only be deleted from trash');
return;
@@ -602,7 +598,10 @@ class _CodeWidgetState extends State<CodeWidget> {
);
}
- void _onTrashPressed(_) async {
+ void _onTrashPressed([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
if (widget.code.isTrashed) {
showToast(context, 'Code is already trashed');
return;
@@ -639,7 +638,10 @@ class _CodeWidgetState extends State<CodeWidget> {
);
}
- void _onRestoreClicked(_) async {
+ void _onRestoreClicked([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
if (!widget.code.isTrashed) {
showToast(context, 'Code is already restored');
return;
diff --git a/auth/lib/ui/components/actions_bar_widget.dart b/auth/lib/ui/components/actions_bar_widget.dart
new file mode 100644
index 0000000000..ad52244e8a
--- /dev/null
+++ b/auth/lib/ui/components/actions_bar_widget.dart
@@ -0,0 +1,61 @@
+import 'package:ente_auth/l10n/l10n.dart';
+import 'package:ente_auth/models/code.dart';
+import 'package:ente_auth/theme/ente_theme.dart';
+import 'package:flutter/material.dart';
+
+class ActionBarWidget extends StatefulWidget {
+ final VoidCallback? onCancel;
+ final Code code;
+
+ const ActionBarWidget({
+ required this.onCancel,
+ required this.code,
+ super.key,
+ });
+
+ @override
+ State<ActionBarWidget> createState() => _ActionBarWidgetState();
+}
+
+class _ActionBarWidgetState extends State<ActionBarWidget> {
+ @override
+ Widget build(BuildContext context) {
+ final textTheme = getEnteTextTheme(context);
+ return SizedBox(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Flexible(
+ flex: 1,
+ child: Text(
+ widget.code.issuer,
+ style: textTheme.miniMuted,
+ ),
+ ),
+ Flexible(
+ flex: 1,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 12),
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ widget.onCancel?.call();
+ },
+ child: Align(
+ alignment: Alignment.centerRight,
+ child: Text(
+ context.l10n.cancel,
+ style: textTheme.mini,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/auth/lib/ui/components/bottom_action_bar_widget.dart b/auth/lib/ui/components/bottom_action_bar_widget.dart
new file mode 100644
index 0000000000..8623396e9d
--- /dev/null
+++ b/auth/lib/ui/components/bottom_action_bar_widget.dart
@@ -0,0 +1,81 @@
+import 'package:ente_auth/models/code.dart';
+import 'package:ente_auth/theme/ente_theme.dart';
+import 'package:ente_auth/ui/components/actions_bar_widget.dart';
+import 'package:ente_auth/ui/components/code_selection_actions_widget.dart';
+import 'package:ente_auth/ui/components/components_constants.dart';
+import "package:ente_auth/ui/components/divider_widget.dart";
+import 'package:flutter/material.dart';
+
+class BottomActionBarWidget extends StatelessWidget {
+ final Code code;
+ final VoidCallback? onCancel;
+ final Color? backgroundColor;
+ final VoidCallback? onShare;
+ final VoidCallback? onPin;
+ final VoidCallback? onShowQR;
+ final VoidCallback? onEdit;
+ final VoidCallback? onRestore;
+ final VoidCallback? onDelete;
+ final VoidCallback? onTrashed;
+
+ const BottomActionBarWidget({
+ required this.code,
+ this.onCancel,
+ this.backgroundColor,
+ super.key,
+ this.onShare,
+ this.onPin,
+ this.onShowQR,
+ this.onEdit,
+ this.onRestore,
+ this.onDelete,
+ this.onTrashed,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final bottomPadding = MediaQuery.of(context).padding.bottom;
+ final widthOfScreen = MediaQuery.of(context).size.width;
+ final colorScheme = getEnteColorScheme(context);
+ final double leftRightPadding = widthOfScreen > restrictedMaxWidth
+ ? (widthOfScreen - restrictedMaxWidth) / 2
+ : 0;
+ return Container(
+ decoration: BoxDecoration(
+ color: backgroundColor ?? colorScheme.backgroundElevated2,
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(8),
+ topRight: Radius.circular(8),
+ ),
+ ),
+ padding: EdgeInsets.only(
+ top: 4,
+ bottom: bottomPadding,
+ right: leftRightPadding,
+ left: leftRightPadding,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(height: 8),
+ CodeSelectionActionsWidget(
+ code: code,
+ onShare: onShare,
+ onPin: onPin,
+ onShowQR: onShowQR,
+ onEdit: onEdit,
+ onRestore: onRestore,
+ onDelete: onDelete,
+ onTrashed: onTrashed,
+ ),
+ const DividerWidget(dividerType: DividerType.bottomBar),
+ ActionBarWidget(
+ code: code,
+ onCancel: onCancel,
+ ),
+ // const SizedBox(height: 2)
+ ],
+ ),
+ );
+ }
+}
diff --git a/auth/lib/ui/components/code_selection_actions_widget.dart b/auth/lib/ui/components/code_selection_actions_widget.dart
new file mode 100644
index 0000000000..1d730fe63f
--- /dev/null
+++ b/auth/lib/ui/components/code_selection_actions_widget.dart
@@ -0,0 +1,134 @@
+import "package:ente_auth/l10n/l10n.dart";
+import "package:ente_auth/models/code.dart";
+import "package:ente_auth/ui/components/selection_action_button.dart";
+import 'package:flutter/material.dart';
+
+class CodeSelectionActionsWidget extends StatefulWidget {
+ final Code code;
+ final VoidCallback? onShare;
+ final VoidCallback? onPin;
+ final VoidCallback? onShowQR;
+ final VoidCallback? onEdit;
+ final VoidCallback? onRestore;
+ final VoidCallback? onDelete;
+ final VoidCallback? onTrashed;
+
+ const CodeSelectionActionsWidget({
+ super.key,
+ required this.code,
+ this.onShare,
+ this.onPin,
+ this.onShowQR,
+ this.onEdit,
+ this.onRestore,
+ this.onDelete,
+ this.onTrashed,
+ });
+
+ @override
+ State<CodeSelectionActionsWidget> createState() =>
+ _CodeSelectionActionsWidgetState();
+}
+
+class _CodeSelectionActionsWidgetState
+ extends State<CodeSelectionActionsWidget> {
+ late final scrollController = ScrollController();
+ // static final _logger = Logger("CodeSelectionActionsWidget");
+
+ @override
+ void dispose() {
+ scrollController.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final List<SelectionActionButton> items = [];
+
+ items.add(
+ SelectionActionButton(
+ labelText: context.l10n.share,
+ icon: Icons.adaptive.share_outlined,
+ onTap: widget.onShare,
+ ),
+ );
+ items.add(
+ SelectionActionButton(
+ labelText: 'QR',
+ icon: Icons.qr_code_2_outlined,
+ onTap: widget.onShowQR,
+ ),
+ );
+
+ items.add(
+ SelectionActionButton(
+ labelText: widget.code.isPinned
+ ? context.l10n.unpinText
+ : context.l10n.pinText,
+ icon: widget.code.isPinned ? Icons.push_pin : Icons.push_pin_outlined,
+ onTap: widget.onPin,
+ ),
+ );
+
+ if (widget.code.isTrashed) {
+ items.add(
+ SelectionActionButton(
+ labelText: context.l10n.restore,
+ icon: Icons.restore_outlined,
+ onTap: widget.onRestore,
+ ),
+ );
+ } else {
+ items.add(
+ SelectionActionButton(
+ labelText: context.l10n.edit,
+ icon: Icons.edit,
+ onTap: widget.onEdit,
+ ),
+ );
+ }
+
+ items.add(
+ SelectionActionButton(
+ labelText:
+ widget.code.isTrashed ? context.l10n.delete : context.l10n.trash,
+ icon: widget.code.isTrashed ? Icons.delete_forever : Icons.delete,
+ onTap: widget.code.isTrashed ? widget.onDelete : widget.onTrashed,
+ ),
+ );
+
+ if (items.isNotEmpty) {
+ // h4ck: https://github.com/flutter/flutter/issues/57920#issuecomment-893970066
+ return MediaQuery(
+ data: MediaQuery.of(context).removePadding(removeBottom: true),
+ child: SafeArea(
+ child: Scrollbar(
+ radius: const Radius.circular(1),
+ thickness: 2,
+ controller: scrollController,
+ thumbVisibility: true,
+ child: SingleChildScrollView(
+ controller: scrollController,
+ physics: const BouncingScrollPhysics(
+ decelerationRate: ScrollDecelerationRate.fast,
+ ),
+ scrollDirection: Axis.horizontal,
+ child: Container(
+ padding: const EdgeInsets.only(bottom: 24),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(width: 4),
+ ...items,
+ const SizedBox(width: 4),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+ return const SizedBox();
+ }
+}
diff --git a/auth/lib/ui/components/grid_action_sheet_widget.dart b/auth/lib/ui/components/grid_action_sheet_widget.dart
deleted file mode 100644
index 696da31c48..0000000000
--- a/auth/lib/ui/components/grid_action_sheet_widget.dart
+++ /dev/null
@@ -1,89 +0,0 @@
-import 'dart:ui';
-
-import 'package:ente_auth/theme/colors.dart';
-import 'package:ente_auth/theme/effects.dart';
-import 'package:ente_auth/ui/components/action_sheet_widget.dart';
-import 'package:ente_auth/ui/components/buttons/button_widget.dart';
-import 'package:ente_auth/ui/components/components_constants.dart';
-import 'package:ente_auth/ui/components/models/button_result.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
-import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
-
-///Returns null if dismissed
-Future<ButtonResult?> showGridActionSheet({
- required BuildContext context,
- required List<ButtonWidget> buttons,
- ActionSheetType actionSheetType = ActionSheetType.defaultActionSheet,
- bool enableDrag = true,
- bool isDismissible = true,
- bool isCheckIconGreen = false,
-}) {
- return showMaterialModalBottomSheet(
- backgroundColor: Colors.transparent,
- barrierColor: backdropFaintDark,
- useRootNavigator: true,
- context: context,
- isDismissible: isDismissible,
- enableDrag: enableDrag,
- builder: (_) {
- return GridActionSheetWidget(
- actionButtons: buttons,
- actionSheetType: actionSheetType,
- isCheckIconGreen: isCheckIconGreen,
- );
- },
- );
-}
-
-class GridActionSheetWidget extends StatelessWidget {
- final List<ButtonWidget> actionButtons;
- final ActionSheetType actionSheetType;
- final bool isCheckIconGreen;
-
- const GridActionSheetWidget({
- required this.actionButtons,
- required this.actionSheetType,
- required this.isCheckIconGreen,
- super.key,
- });
-
- @override
- Widget build(BuildContext context) {
- final blur = MediaQuery.of(context).platformBrightness == Brightness.light
- ? blurMuted
- : blurBase;
- final extraWidth = MediaQuery.of(context).size.width - restrictedMaxWidth;
- final double? horizontalPadding = extraWidth > 0 ? extraWidth / 2 : null;
- return Padding(
- padding: EdgeInsets.fromLTRB(
- horizontalPadding ?? 12,
- 0,
- horizontalPadding ?? 12,
- 32,
- ),
- child: Container(
- decoration: BoxDecoration(boxShadow: shadowMenuLight),
- child: ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(8)),
- child: BackdropFilter(
- filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
- child: Container(
- color: backdropMutedDark,
- child: AlignedGridView.count(
- padding: const EdgeInsets.all(24),
- shrinkWrap: true,
- crossAxisCount: 2,
- crossAxisSpacing: 6,
- mainAxisSpacing: 6,
- physics: const AlwaysScrollableScrollPhysics(),
- itemBuilder: (_, index) => actionButtons[index % 6],
- itemCount: actionButtons.length,
- ),
- ),
- ),
- ),
- ),
- );
- }
-}
diff --git a/auth/lib/ui/components/selection_action_button.dart b/auth/lib/ui/components/selection_action_button.dart
new file mode 100644
index 0000000000..3ae296f890
--- /dev/null
+++ b/auth/lib/ui/components/selection_action_button.dart
@@ -0,0 +1,196 @@
+import 'dart:math' as math;
+
+import "package:ente_auth/theme/ente_theme.dart";
+import "package:flutter/material.dart";
+import "package:flutter_svg/svg.dart";
+
+/// Pass icon or asset path of svg
+class SelectionActionButton extends StatelessWidget {
+ final String labelText;
+ final IconData? icon;
+ final String? svgAssetPath;
+ final VoidCallback? onTap;
+ final bool shouldShow;
+
+ const SelectionActionButton({
+ required this.labelText,
+ required this.onTap,
+ this.icon,
+ this.svgAssetPath,
+ this.shouldShow = true,
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ assert(icon != null || svgAssetPath != null);
+ return AnimatedSize(
+ duration: const Duration(milliseconds: 350),
+ curve: Curves.easeInOutCirc,
+ child: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 300),
+ child: shouldShow
+ ? _Body(
+ labelText: labelText,
+ icon: icon,
+ onTap: onTap,
+ svgAssetPath: svgAssetPath,
+ )
+ : const SizedBox(
+ height: 60,
+ ),
+ ),
+ );
+ }
+}
+
+class _Body extends StatefulWidget {
+ final String labelText;
+ final IconData? icon;
+ final String? svgAssetPath;
+ final VoidCallback? onTap;
+ const _Body({
+ required this.labelText,
+ required this.onTap,
+ this.icon,
+ this.svgAssetPath,
+ });
+
+ @override
+ State<_Body> createState() => __BodyState();
+}
+
+class __BodyState extends State<_Body> {
+ static const minWidth = 64.0;
+ late double widthOfButton;
+ Color? backgroundColor;
+
+ @override
+ Widget build(BuildContext context) {
+ widthOfButton = getWidthOfButton();
+ final colorScheme = getEnteColorScheme(context);
+ return GestureDetector(
+ onTap: widget.onTap,
+ onTapDown: (details) {
+ setState(() {
+ backgroundColor = colorScheme.fillFaintPressed;
+ });
+ },
+ onTapUp: (details) {
+ setState(() {
+ backgroundColor = null;
+ });
+ },
+ onTapCancel: () {
+ setState(() {
+ backgroundColor = null;
+ });
+ },
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(8),
+ color: backgroundColor,
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
+ child: SizedBox(
+ width: widthOfButton,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (widget.icon == Icons.navigation_rounded)
+ Transform.rotate(
+ angle: math.pi / 2,
+ child: Icon(
+ widget.icon,
+ size: 24,
+ color: getEnteColorScheme(context).primary300,
+ shadows: const [
+ BoxShadow(
+ color: Color.fromARGB(12, 0, 179, 60),
+ offset: Offset(0, 2.51),
+ blurRadius: 5.02,
+ spreadRadius: 0,
+ ),
+ BoxShadow(
+ color: Color.fromARGB(24, 0, 179, 60),
+ offset: Offset(0, 1.25),
+ blurRadius: 3.76,
+ spreadRadius: 0,
+ ),
+ BoxShadow(
+ color: Color.fromARGB(24, 0, 179, 60),
+ offset: Offset(0, 0.63),
+ blurRadius: 1.88,
+ spreadRadius: 0,
+ ),
+ ],
+ ),
+ )
+ else
+ widget.svgAssetPath != null
+ ? SvgPicture.asset(
+ widget.svgAssetPath!,
+ colorFilter: ColorFilter.mode(
+ getEnteColorScheme(context).textMuted,
+ BlendMode.srcIn,
+ ),
+ width: 24,
+ height: 24,
+ )
+ : Icon(
+ widget.icon,
+ size: 24,
+ color: getEnteColorScheme(context).textMuted,
+ ),
+ const SizedBox(height: 4),
+ Text(
+ widget.labelText,
+ textAlign: TextAlign.center,
+ //textTheme in [getWidthOfLongestWord] should be same as this
+ style: getEnteTextTheme(context).miniMuted,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ getWidthOfButton() {
+ final widthOfWidestWord = getWidthOfWidestWord(
+ widget.labelText,
+ );
+ if (widthOfWidestWord > minWidth) return widthOfWidestWord;
+ return minWidth;
+ }
+
+ double getWidthOfWidestWord(String labelText) {
+ final words = labelText.split(RegExp(r'\s+'));
+ if (words.isEmpty) return 0.0;
+
+ double maxWidth = 0.0;
+ for (String word in words) {
+ final width =
+ computeWidthOfWord(word, getEnteTextTheme(context).miniMuted);
+ if (width > maxWidth) {
+ maxWidth = width;
+ }
+ }
+ return maxWidth;
+ }
+
+//Todo: this doesn't give the correct width of the word, make it right
+ double computeWidthOfWord(String text, TextStyle style) {
+ final textPainter = TextPainter(
+ text: TextSpan(text: text, style: style),
+ maxLines: 1,
+ textDirection: TextDirection.ltr,
+ textScaler: MediaQuery.textScalerOf(context),
+ )..layout();
+//buffer of 8 added as width is shorter than actual text width
+ return textPainter.size.width + 8;
+ }
+}
diff --git a/auth/lib/utils/dialog_util.dart b/auth/lib/utils/dialog_util.dart
index 8f5f04a143..6c58e1f861 100644
--- a/auth/lib/utils/dialog_util.dart
+++ b/auth/lib/utils/dialog_util.dart
@@ -11,7 +11,6 @@ import 'package:ente_auth/ui/components/action_sheet_widget.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/components_constants.dart';
import 'package:ente_auth/ui/components/dialog_widget.dart';
-import 'package:ente_auth/ui/components/grid_action_sheet_widget.dart';
import 'package:ente_auth/ui/components/models/button_result.dart';
import 'package:ente_auth/ui/components/models/button_type.dart';
import 'package:ente_auth/utils/email_util.dart';
@@ -425,75 +424,3 @@ Future<dynamic> showTextInputDialog(
},
);
}
-
-///Will return null if dismissed by tapping outside
-Future<ButtonResult?> showOptionsForCode(
- BuildContext context, {
- FutureVoidCallback? onShare,
- FutureVoidCallback? onPin,
- FutureVoidCallback? onShowQR,
- FutureVoidCallback? onEdit,
- FutureVoidCallback? onRestore,
- FutureVoidCallback? onDelete,
- FutureVoidCallback? onTrashed,
- bool isPinned = false,
- bool isTrashed = false,
-}) async {
- final buttons = [
- ButtonWidget(
- buttonType: ButtonType.neutral,
- labelText: context.l10n.share,
- isInAlert: true,
- icon: Icons.adaptive.share_outlined,
- onTap: onShare,
- buttonAction: ButtonAction.first,
- ),
- ButtonWidget(
- buttonType: ButtonType.neutral,
- isInAlert: true,
- labelText: 'QR',
- icon: Icons.qr_code_2_outlined,
- onTap: onShowQR,
- buttonAction: ButtonAction.second,
- ),
- ButtonWidget(
- buttonType: ButtonType.neutral,
- isInAlert: true,
- labelText: isPinned ? context.l10n.unpinText : context.l10n.pinText,
- icon: isPinned ? Icons.push_pin : Icons.push_pin_outlined,
- onTap: onPin,
- buttonAction: ButtonAction.third,
- ),
- if (isTrashed)
- ButtonWidget(
- isInAlert: true,
- buttonType: ButtonType.neutral,
- labelText: context.l10n.restore,
- icon: Icons.restore_outlined,
- onTap: onRestore,
- buttonAction: ButtonAction.fourth,
- )
- else
- ButtonWidget(
- isInAlert: true,
- buttonType: ButtonType.neutral,
- labelText: context.l10n.edit,
- icon: Icons.edit,
- onTap: onEdit,
- buttonAction: ButtonAction.fourth,
- ),
- ButtonWidget(
- isInAlert: true,
- buttonType: ButtonType.neutral,
- labelText: isTrashed ? context.l10n.delete : context.l10n.trash,
- icon: isTrashed ? Icons.delete_forever : Icons.delete,
- onTap: isTrashed ? onDelete : onTrashed,
- buttonAction: ButtonAction.fifth,
- ),
- ];
- return showGridActionSheet(
- context: context,
- buttons: buttons,
- isDismissible: true,
- );
-}