Skip to content

armgit / ente

Public Imported from GitHub
0

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

add support for notes in multi-select menu + animations

Prateek Sunalab187ddfa6f9
diff --git a/mobile/apps/auth/lib/ui/code_widget.dart b/mobile/apps/auth/lib/ui/code_widget.dart
index 27e03c33f1..6fc9bb3b9b 100644
--- a/mobile/apps/auth/lib/ui/code_widget.dart
+++ b/mobile/apps/auth/lib/ui/code_widget.dart
@@ -16,7 +16,7 @@ import 'package:ente_auth/store/code_display_store.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/models/button_type.dart';
+import 'package:ente_auth/ui/components/note_dialog.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';
@@ -861,14 +861,7 @@ class _CodeWidgetState extends State<CodeWidget> {
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,
- );
+ await showNotesDialog(context, widget.code.note);
}
Future<void> _onEditPressed([bool? pop]) async {
diff --git a/mobile/apps/auth/lib/ui/components/note_dialog.dart b/mobile/apps/auth/lib/ui/components/note_dialog.dart
new file mode 100644
index 0000000000..42d944b4ec
--- /dev/null
+++ b/mobile/apps/auth/lib/ui/components/note_dialog.dart
@@ -0,0 +1,123 @@
+import 'package:clipboard/clipboard.dart';
+import 'package:ente_auth/l10n/l10n.dart';
+import 'package:ente_auth/theme/effects.dart';
+import 'package:ente_auth/theme/ente_theme.dart';
+import 'package:ente_auth/utils/toast_util.dart';
+import 'package:flutter/material.dart';
+import 'package:hugeicons/hugeicons.dart';
+
+Future<void> showNotesDialog(
+ BuildContext context,
+ String note,
+) async {
+ final trimmedNote = note.trim();
+ if (trimmedNote.isEmpty) {
+ return;
+ }
+
+ await showDialog(
+ context: context,
+ barrierDismissible: true,
+ builder: (dialogContext) {
+ final theme = Theme.of(dialogContext);
+ final colorScheme = getEnteColorScheme(dialogContext);
+ final bool isDark = theme.brightness == Brightness.dark;
+ final Color noteBackground =
+ isDark ? const Color(0x29A75CFF) : const Color(0x0AA75CFF);
+ return Dialog(
+ backgroundColor: Colors.transparent,
+ insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
+ child: Center(
+ child: Container(
+ constraints: const BoxConstraints(maxWidth: 360),
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundElevated,
+ borderRadius: BorderRadius.circular(20),
+ boxShadow: shadowFloatLight,
+ ),
+ child: Material(
+ color: Colors.transparent,
+ borderRadius: BorderRadius.circular(20),
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(24, 20, 24, 20),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Text(
+ dialogContext.l10n.notes,
+ style: TextStyle(
+ color: colorScheme.textBase,
+ fontSize: 18,
+ fontWeight: FontWeight.w600,
+ height: 1.22,
+ ),
+ ),
+ const Spacer(),
+ IconButton(
+ icon: const Icon(Icons.close),
+ onPressed: () => Navigator.of(dialogContext).pop(),
+ ),
+ ],
+ ),
+ const SizedBox(height: 8),
+ Stack(
+ children: [
+ Container(
+ width: double.infinity,
+ padding: const EdgeInsets.fromLTRB(20, 20, 20, 72),
+ decoration: ShapeDecoration(
+ color: noteBackground,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
+ ),
+ child: SelectableText(
+ trimmedNote,
+ style: TextStyle(
+ color: colorScheme.textBase,
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
+ height: 1.64,
+ ),
+ ),
+ ),
+ Positioned(
+ right: 8,
+ bottom: 8,
+ child: IconButton(
+ constraints: const BoxConstraints(
+ minHeight: 40,
+ minWidth: 40,
+ ),
+ padding: const EdgeInsets.all(8),
+ visualDensity: VisualDensity.compact,
+ tooltip: 'Copy note',
+ onPressed: () async {
+ await FlutterClipboard.copy(trimmedNote);
+ Navigator.of(dialogContext).pop();
+ showToast(
+ dialogContext,
+ dialogContext.l10n.copiedToClipboard,
+ );
+ },
+ icon: const HugeIcon(
+ icon: HugeIcons.strokeRoundedCopy01,
+ size: 22,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ },
+ );
+}
diff --git a/mobile/apps/auth/lib/ui/home_page.dart b/mobile/apps/auth/lib/ui/home_page.dart
index ea8ce8dc04..1a22ea88c9 100644
--- a/mobile/apps/auth/lib/ui/home_page.dart
+++ b/mobile/apps/auth/lib/ui/home_page.dart
@@ -29,6 +29,7 @@ import 'package:ente_auth/ui/common/loading_widget.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/dialog_widget.dart';
import 'package:ente_auth/ui/components/models/button_type.dart';
+import 'package:ente_auth/ui/components/note_dialog.dart';
import 'package:ente_auth/ui/home/add_tag_sheet.dart';
import 'package:ente_auth/ui/home/coach_mark_widget.dart';
import 'package:ente_auth/ui/home/home_empty_state.dart';
@@ -963,6 +964,23 @@ class _HomePageState extends State<HomePage> {
),
],
),
+ ValueListenableBuilder<Set<String>>(
+ valueListenable: _codeDisplayStore.selectedCodeIds,
+ builder: (context, selectedIds, _) {
+ final Code? code =
+ _getSingleSelectedCodeWithNote(selectedIds);
+ if (code == null) {
+ return const SizedBox.shrink();
+ }
+ return Padding(
+ padding: const EdgeInsets.only(top: 12),
+ child: _buildMultiSelectNotePreview(
+ note: code.note.trim(),
+ isDesktop: false,
+ ),
+ );
+ },
+ ),
const SizedBox(height: 16),
_buildActionButtons(),
],
@@ -1404,7 +1422,10 @@ class _HomePageState extends State<HomePage> {
builder: (context, selectedIds, _) {
final bool allVisibleSelected =
visibleIds.isNotEmpty && selectedIds.containsAll(visibleIds);
- return Container(
+ final Code? singleCode = _getSingleSelectedCodeWithNote(selectedIds);
+ return AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ curve: Curves.easeInOut,
decoration: BoxDecoration(
color: isDarkMode
? colorScheme.fillFaint
@@ -1426,39 +1447,75 @@ class _HomePageState extends State<HomePage> {
],
),
padding: EdgeInsets.fromLTRB(24, 20, 24, 20 + bottomPadding),
- child: Row(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- // Close button and count
- IconButton(
- icon: const Icon(Icons.close),
- tooltip: l10n.cancel,
- onPressed: () => _codeDisplayStore.clearSelection(),
- padding: const EdgeInsets.all(12),
- ),
- const SizedBox(width: 8),
- Text(
- '${selectedIds.length} ${l10n.selected}',
- style: Theme.of(context)
- .textTheme
- .titleMedium
- ?.copyWith(fontWeight: FontWeight.w600),
+ AnimatedSize(
+ duration: const Duration(milliseconds: 200),
+ curve: Curves.easeInOut,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (singleCode != null) ...[
+ Align(
+ alignment: Alignment.center,
+ child: _buildMultiSelectNotePreview(
+ note: singleCode.note.trim(),
+ isDesktop: true,
+ ),
+ ),
+ const SizedBox(height: 12),
+ ],
+ ],
+ ),
),
- const Spacer(),
- // Action buttons in center
- _buildDesktopActionRow(context),
- const Spacer(),
- // Select all chip
- _buildSelectAllChip(
- context: context,
- enabled: !allVisibleSelected,
- onPressed: allVisibleSelected
- ? null
- : () {
- final newSelection = Set<String>.from(visibleIds);
- _codeDisplayStore.selectedCodeIds.value = newSelection;
- _codeDisplayStore.isSelectionModeActive.value =
- newSelection.isNotEmpty;
- },
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ IconButton(
+ icon: const Icon(Icons.close),
+ tooltip: l10n.cancel,
+ onPressed: () => _codeDisplayStore.clearSelection(),
+ padding: const EdgeInsets.all(12),
+ ),
+ const SizedBox(width: 8),
+ Text(
+ '${selectedIds.length} ${l10n.selected}',
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium
+ ?.copyWith(fontWeight: FontWeight.w600),
+ ),
+ const Spacer(),
+ AnimatedSwitcher(
+ duration: const Duration(milliseconds: 200),
+ switchInCurve: Curves.easeInOut,
+ switchOutCurve: Curves.easeInOut,
+ transitionBuilder: (child, animation) {
+ return FadeTransition(opacity: animation, child: child);
+ },
+ child: KeyedSubtree(
+ key: ValueKey<int>(selectedIds.length),
+ child: _buildDesktopActionRow(context),
+ ),
+ ),
+ const Spacer(),
+ _buildSelectAllChip(
+ context: context,
+ enabled: !allVisibleSelected,
+ onPressed: allVisibleSelected
+ ? null
+ : () {
+ final newSelection = Set<String>.from(visibleIds);
+ _codeDisplayStore.selectedCodeIds.value =
+ newSelection;
+ _codeDisplayStore.isSelectionModeActive.value =
+ newSelection.isNotEmpty;
+ },
+ ),
+ ],
),
],
),
@@ -1486,14 +1543,13 @@ class _HomePageState extends State<HomePage> {
final bool showTrashChip = hasTrashedCodes;
final int itemCount =
(showAllChip ? 1 : 0) + tags.length + (showTrashChip ? 1 : 0);
- final bool showAllEmptyHint =
- showAllChip &&
- selectedTag.isEmpty &&
- !_isTrashOpen &&
- _filteredCodes.isEmpty &&
- _searchText.isEmpty &&
- !hasNonTrashedCodes &&
- hasTrashedCodes;
+ final bool showAllEmptyHint = showAllChip &&
+ selectedTag.isEmpty &&
+ !_isTrashOpen &&
+ _filteredCodes.isEmpty &&
+ _searchText.isEmpty &&
+ !hasNonTrashedCodes &&
+ hasTrashedCodes;
final list = Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -1582,8 +1638,7 @@ class _HomePageState extends State<HomePage> {
padding: const EdgeInsets.only(bottom: 64.0),
child: Center(
child: Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 24.0),
+ padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Text(
l10n.allTabEmptyHint,
textAlign: TextAlign.center,
@@ -1964,6 +2019,84 @@ class _HomePageState extends State<HomePage> {
);
}
+ Code? _getSingleSelectedCodeWithNote(Set<String> selectedIds) {
+ if (selectedIds.length != 1) {
+ return null;
+ }
+ final String key = selectedIds.first;
+ final Code? code =
+ _allCodes?.firstWhereOrNull((element) => element.selectionKey == key);
+ if (code == null || code.note.trim().isEmpty) {
+ return null;
+ }
+ return code;
+ }
+
+ Widget _buildMultiSelectNotePreview({
+ required String note,
+ required bool isDesktop,
+ }) {
+ final trimmedNote = note.trim();
+ if (trimmedNote.isEmpty) {
+ return const SizedBox.shrink();
+ }
+ final colorScheme = getEnteColorScheme(context);
+ final theme = Theme.of(context);
+ final bool isDark = theme.brightness == Brightness.dark;
+ final Color backgroundColor =
+ isDark ? const Color(0x29A75CFF) : const Color(0xFFFBF8FF);
+ final Color textColor = colorScheme.textBase;
+ final double maxWidth = isDesktop ? 420 : 360;
+ final Widget chip = Material(
+ color: Colors.transparent,
+ child: InkWell(
+ borderRadius: BorderRadius.circular(100),
+ onTap: () => _onSelectedNoteTapped(trimmedNote),
+ child: Container(
+ constraints: BoxConstraints(maxWidth: maxWidth),
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
+ decoration: ShapeDecoration(
+ color: backgroundColor,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(100),
+ ),
+ ),
+ child: Text(
+ trimmedNote,
+ textAlign: TextAlign.center,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ color: textColor,
+ fontSize: 12,
+ fontWeight: FontWeight.w500,
+ height: 1.25,
+ ),
+ ),
+ ),
+ ),
+ );
+
+ return Align(
+ alignment: Alignment.center,
+ heightFactor: 1,
+ child: chip,
+ );
+ }
+
+ void _onSelectedNoteTapped(String note) {
+ if (note.isEmpty) {
+ return;
+ }
+ _codeDisplayStore.clearSelection();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!mounted) {
+ return;
+ }
+ showNotesDialog(context, note);
+ });
+ }
+
Widget _getFab() {
if (PlatformUtil.isDesktop()) {
return FloatingActionButton(