Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: add show notes for mobile and desktop menu

Prateek Sunal1bfa7b199845
diff --git a/auth/lib/ui/code_widget.dart b/auth/lib/ui/code_widget.dart
index 83f73dde43..6447c47de4 100644
--- a/auth/lib/ui/code_widget.dart
+++ b/auth/lib/ui/code_widget.dart
@@ -15,6 +15,7 @@ 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/components/models/button_type.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';
@@ -219,6 +220,7 @@ class _CodeWidgetState extends State<CodeWidget> {
builder: (_) {
return BottomActionBarWidget(
code: widget.code,
+ onNotes: () => _onShowNotesPressed(true),
onEdit: () => _onEditPressed(true),
onShare: () => _onSharePressed(true),
onPin: () => _onPinPressed(true),
@@ -261,6 +263,12 @@ class _CodeWidgetState extends State<CodeWidget> {
icon: Icons.qr_code_2_outlined,
onSelected: () => _onShowQrPressed(null),
),
+ if (widget.code.note.isNotEmpty)
+ MenuItem(
+ label: context.l10n.notes,
+ icon: Icons.notes_outlined,
+ onSelected: () => _onShowNotesPressed(null),
+ ),
if (!widget.code.isTrashed)
MenuItem(
label:
@@ -485,6 +493,20 @@ class _CodeWidgetState extends State<CodeWidget> {
}
}
+ Future<void> _onShowNotesPressed([bool? pop]) async {
+ if (mounted && pop == true) {
+ Navigator.of(context).pop();
+ }
+ await showChoiceDialog(
+ context,
+ title: context.l10n.notes,
+ body: widget.code.note,
+ firstButtonLabel: context.l10n.close,
+ firstButtonType: ButtonType.secondary,
+ secondButtonLabel: null,
+ );
+ }
+
Future<void> _onEditPressed([bool? pop]) async {
if (mounted && pop == true) {
Navigator.of(context).pop();
diff --git a/auth/lib/ui/components/bottom_action_bar_widget.dart b/auth/lib/ui/components/bottom_action_bar_widget.dart
index ed25cf7308..bc062161be 100644
--- a/auth/lib/ui/components/bottom_action_bar_widget.dart
+++ b/auth/lib/ui/components/bottom_action_bar_widget.dart
@@ -12,6 +12,7 @@ class BottomActionBarWidget extends StatelessWidget {
final Code code;
final VoidCallback? onCancel;
final Color? backgroundColor;
+ final VoidCallback? onNotes;
final VoidCallback? onShare;
final VoidCallback? onPin;
final VoidCallback? onShowQR;
@@ -25,6 +26,7 @@ class BottomActionBarWidget extends StatelessWidget {
this.onCancel,
this.backgroundColor,
super.key,
+ this.onNotes,
this.onShare,
this.onPin,
this.onShowQR,
@@ -65,6 +67,7 @@ class BottomActionBarWidget extends StatelessWidget {
const SizedBox(height: 8),
CodeSelectionActionsWidget(
code: code,
+ onNotes: onNotes,
onShare: onShare,
onPin: onPin,
onShowQR: onShowQR,
diff --git a/auth/lib/ui/components/code_selection_actions_widget.dart b/auth/lib/ui/components/code_selection_actions_widget.dart
index 9cf514f7c2..821693ef02 100644
--- a/auth/lib/ui/components/code_selection_actions_widget.dart
+++ b/auth/lib/ui/components/code_selection_actions_widget.dart
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
class CodeSelectionActionsWidget extends StatefulWidget {
final Code code;
+ final VoidCallback? onNotes;
final VoidCallback? onShare;
final VoidCallback? onPin;
final VoidCallback? onShowQR;
@@ -16,6 +17,7 @@ class CodeSelectionActionsWidget extends StatefulWidget {
const CodeSelectionActionsWidget({
super.key,
required this.code,
+ this.onNotes,
this.onShare,
this.onPin,
this.onShowQR,
@@ -74,6 +76,16 @@ class _CodeSelectionActionsWidgetState
);
}
+ if (widget.code.note.isNotEmpty) {
+ items.add(
+ SelectionActionButton(
+ labelText: context.l10n.notes,
+ icon: Icons.notes_outlined,
+ onTap: widget.onNotes,
+ ),
+ );
+ }
+
if (widget.code.isTrashed) {
items.add(
SelectionActionButton(
diff --git a/auth/lib/ui/components/dialog_widget.dart b/auth/lib/ui/components/dialog_widget.dart
index ab96a0dbe8..a9daf59e33 100644
--- a/auth/lib/ui/components/dialog_widget.dart
+++ b/auth/lib/ui/components/dialog_widget.dart
@@ -77,17 +77,19 @@ class DialogWidget extends StatelessWidget {
color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.all(16),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- ContentContainer(
- title: title,
- body: body,
- icon: icon,
- ),
- const SizedBox(height: 36),
- Actions(buttons),
- ],
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ ContentContainer(
+ title: title,
+ body: body,
+ icon: icon,
+ ),
+ const SizedBox(height: 36),
+ Actions(buttons),
+ ],
+ ),
),
),
),
diff --git a/auth/lib/utils/dialog_util.dart b/auth/lib/utils/dialog_util.dart
index fd2111abfd..ffe08b42ac 100644
--- a/auth/lib/utils/dialog_util.dart
+++ b/auth/lib/utils/dialog_util.dart
@@ -239,7 +239,7 @@ Future<ButtonResult?> showChoiceDialog(
required String title,
String? body,
required String firstButtonLabel,
- String secondButtonLabel = "Cancel",
+ String? secondButtonLabel = "Cancel",
ButtonType firstButtonType = ButtonType.neutral,
ButtonType secondButtonType = ButtonType.secondary,
ButtonAction firstButtonAction = ButtonAction.first,
@@ -258,13 +258,14 @@ Future<ButtonResult?> showChoiceDialog(
onTap: firstButtonOnTap,
buttonAction: firstButtonAction,
),
- ButtonWidget(
- buttonType: secondButtonType,
- labelText: secondButtonLabel,
- isInAlert: true,
- onTap: secondButtonOnTap,
- buttonAction: secondButtonAction,
- ),
+ if (secondButtonLabel != null)
+ ButtonWidget(
+ buttonType: secondButtonType,
+ labelText: secondButtonLabel,
+ isInAlert: true,
+ onTap: secondButtonOnTap,
+ buttonAction: secondButtonAction,
+ ),
];
return showDialogWidget(
context: context,