π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Merge remote-tracking branch 'origin/main' into multiselect
a5xwin4519a887764c
diff --cc mobile/apps/auth/lib/ui/code_widget.dartindex 156b1509d3,5305ea5567..737e7fa8c7--- a/mobile/apps/auth/lib/ui/code_widget.dart+++ b/mobile/apps/auth/lib/ui/code_widget.dart@@@ -9,8 -9,8 +9,9 @@@ import 'package:ente_auth/l10n/l10n.darimport 'package:ente_auth/models/code.dart';import 'package:ente_auth/onboarding/view/setup_enter_secret_key_page.dart';import 'package:ente_auth/onboarding/view/view_qr_page.dart';+ import 'package:ente_auth/services/local_backup_service.dart';import 'package:ente_auth/services/preference_service.dart';+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';diff --cc mobile/apps/auth/lib/ui/home/add_tag_sheet.dartindex 677603505c,0000000000..fe3341dddamode 100644,000000..100644--- a/mobile/apps/auth/lib/ui/home/add_tag_sheet.dart+++ b/mobile/apps/auth/lib/ui/home/add_tag_sheet.dart@@@ -1,243 -1,0 +1,243 @@@+import 'dart:async';++import 'package:ente_auth/l10n/l10n.dart';+import 'package:ente_auth/models/code.dart';+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/components/buttons/button_widget.dart';+import 'package:ente_auth/ui/components/models/button_type.dart';+import 'package:ente_auth/ui/utils/icon_utils.dart';+import 'package:flutter/material.dart';++++class AddTagSheet extends StatefulWidget {+ final List<Code> selectedCodes;++ const AddTagSheet({+ super.key,+ required this.selectedCodes,+ });++ @override+ State<AddTagSheet> createState() => _AddTagSheetState();+}++class _AddTagSheetState extends State<AddTagSheet> {+ List<String> _allTags = [];+ final Set<String> _selectedTagsInSheet = {};+ bool _isLoading = true;++ @override+ void initState() {+ super.initState();+ _loadInitialState();+ }++ Future<void> _loadInitialState() async {+ final allTagsFromServer = await CodeDisplayStore.instance.getAllTags();+ final initialTagsForSelection = <String>{};++ for (final code in widget.selectedCodes) {+ initialTagsForSelection.addAll(code.display.tags);+ }++ if (mounted) {+ setState(() {+ _allTags = allTagsFromServer;+ _selectedTagsInSheet.addAll(initialTagsForSelection);+ _isLoading = false;+ });+ }+ }++ Future<void> _onDonePressed() async {+ final List<Future> updateFutures = [];+ for (final code in widget.selectedCodes) {+ final updatedCode = code.copyWith(+ display: code.display.copyWith(tags: _selectedTagsInSheet.toList()),+ );- updateFutures.add(CodeStore.instance.updateCode(code, updatedCode));++ updateFutures.add(CodeStore.instance.addCode(updatedCode));+ }+ await Future.wait(updateFutures);+ if (mounted) {+ Navigator.of(context).pop();+ }+ }++ Future<void> _showCreateTagDialog() async {+ final textController = TextEditingController();+ final newTag = await showDialog<String>(+ context: context,+ builder: (context) {+ return StatefulBuilder(+ builder: (context, setState) {+ return AlertDialog(+ title: Text(context.l10n.createNewTag),+ content: TextField(+ controller: textController,+ autofocus: true,+ onChanged: (_) => setState(() {}),+ ),+ actions: [+ Row(+ children: [+ Expanded(+ child: ButtonWidget(+ buttonType: ButtonType.secondary,+ labelText: context.l10n.cancel,+ onTap: () async => Navigator.of(context).pop(),+ ),+ ),+ const SizedBox(width: 8),+ Expanded(+ child: ButtonWidget(+ buttonType: ButtonType.primary,+ labelText: context.l10n.create,+ isDisabled: textController.text.trim().isEmpty,+ onTap: () async => Navigator.of(context).pop(textController.text.trim()),+ ),+ ),+ ],+ ),+ ],+ );+ },+ );+ },+ );++ if (newTag != null && newTag.isNotEmpty) {+ setState(() {+ if (!_allTags.contains(newTag)) {+ _allTags.add(newTag);+ _allTags.sort();+ }+ _selectedTagsInSheet.add(newTag);+ });+ }+ }++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ final bottomPadding = MediaQuery.of(context).padding.bottom;++ return Padding(+ padding: EdgeInsets.fromLTRB(16, 16, 16, 16 + bottomPadding),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ Text(+ '${widget.selectedCodes.length} ${context.l10n.selected}',+ style: textTheme.large,+ ),+ IconButton(+ icon: const Icon(Icons.close),+ onPressed: () => Navigator.of(context).pop(),+ ),+ ],+ ),+ const SizedBox(height: 16),+ SizedBox(+ height: 80,+ child: ListView.separated(+ scrollDirection: Axis.horizontal,+ itemCount: widget.selectedCodes.length,+ separatorBuilder: (_, __) => const SizedBox(width: 16),+ itemBuilder: (context, index) {+ final code = widget.selectedCodes[index];+ final iconData =+ code.display.isCustomIcon ? code.display.iconID : code.issuer;++ return SizedBox(+ width: 60,+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ IconUtils.instance.getIcon(context, iconData.trim(), width: 40),+ const SizedBox(height: 8),+ Text(+ code.issuer,+ overflow: TextOverflow.ellipsis,+ style: textTheme.mini.copyWith(color: colorScheme.textMuted,),+ ),+ ],+ ),+ );+ },+ ),+ ),+ const SizedBox(height: 24),+ Text(context.l10n.tags, style: textTheme.body),+ const SizedBox(height: 12),+ Flexible(+ child: SingleChildScrollView(+ child: _isLoading+ ? const Center(child: CircularProgressIndicator())+ : Wrap(+ spacing: 8.0,+ runSpacing: 4.0,+ children: [+ ..._allTags.map((tag) {+ final isSelected = _selectedTagsInSheet.contains(tag);+ return ChoiceChip(+ label: Text(tag),+ selected: isSelected,+ onSelected: (selected) {+ setState(() {+ if (selected) {+ _selectedTagsInSheet.add(tag);+ } else {+ _selectedTagsInSheet.remove(tag);+ }+ });+ },+ selectedColor: colorScheme.primary400,+ backgroundColor: colorScheme.fillFaint,+ labelStyle: TextStyle(+ color: isSelected ? Colors.white : colorScheme.textBase,+ ),+ avatar: isSelected ? const Icon(Icons.check, color: Colors.white, size: 16) : null,+ side: BorderSide.none,+ shape: const StadiumBorder(),+ );+ }),+ ActionChip(+ avatar: const Icon(Icons.add, size: 18),+ label: Text(context.l10n.addNew),+ onPressed: _showCreateTagDialog,+ side: BorderSide.none,+ shape: const StadiumBorder(),+ backgroundColor: colorScheme.fillFaint,+ ),+ ],+ ),+ ),+ ),++ const SizedBox(height: 24),+ SizedBox(+ width: double.infinity,+ child: ElevatedButton(+ style: ElevatedButton.styleFrom(+ backgroundColor: colorScheme.fillBase,+ foregroundColor: colorScheme.backgroundBase,+ padding: const EdgeInsets.symmetric(vertical: 16),+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),+ ),+ onPressed: _onDonePressed,+ child: Text(context.l10n.done),+ ),+ ),+ ],+ ),+ );+ }+}diff --cc mobile/apps/auth/lib/ui/home_page.dartindex cf9b8be206,5daaee0bba..b3859fe520--- a/mobile/apps/auth/lib/ui/home_page.dart+++ b/mobile/apps/auth/lib/ui/home_page.dart@@@ -14,7 -14,7 +14,8 @@@ import 'package:ente_auth/models/code.dimport 'package:ente_auth/onboarding/model/tag_enums.dart';import 'package:ente_auth/onboarding/view/common/tag_chip.dart';import 'package:ente_auth/onboarding/view/setup_enter_secret_key_page.dart';+import 'package:ente_auth/onboarding/view/view_qr_page.dart';+ import 'package:ente_auth/services/local_backup_service.dart';import 'package:ente_auth/services/preference_service.dart';import 'package:ente_auth/store/code_display_store.dart';import 'package:ente_auth/store/code_store.dart';@@@ -127,631 -120,6 +127,631 @@@ class _HomePageState extends State<HomeServicesBinding.instance.keyboard.addHandler(_handleKeyEvent);}+ void _onAddTagPressed() {+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ final selectedCodes = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];++ if (selectedCodes.isEmpty) return;++ showModalBottomSheet(+ context: context,+ isScrollControlled: true,+ builder: (_) {+ return AddTagSheet(selectedCodes: selectedCodes);+ },+ ).then((_) {+ _codeDisplayStore.clearSelection();+ });+}++Future<void> _onRestoreSelectedPressed() async {+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;++ FocusScope.of(context).requestFocus();++ try {+ final codesToRestore = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];+ for (final code in codesToRestore) {+ final updatedCode = code.copyWith(display: code.display.copyWith(trashed: false));- unawaited(CodeStore.instance.updateCode(code, updatedCode));++ unawaited(CodeStore.instance.addCode(updatedCode));+ }+ } catch (e) {+ if (mounted) {+ showGenericErrorDialog(context: context, error: e).ignore();+ }+ } finally {+ _codeDisplayStore.clearSelection();+ }+}++Future<void> _onDeleteForeverPressed() async {+ final l10n = context.l10n;+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;++ bool isAuthSuccessful =+ await LocalAuthenticationService.instance.requestLocalAuthentication(+ context,+ context.l10n.deleteCodeAuthMessage,+ );++ if (!isAuthSuccessful) return;++ FocusScope.of(context).requestFocus();+ await showChoiceActionSheet(+ context,+ title: l10n.deleteCodeTitle,+ body: l10n.deleteCodeMessage,+ firstButtonLabel: l10n.delete,+ isCritical: true,+ firstButtonOnTap: () async {+ try {+ final codesToDelete = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];+ for (final code in codesToDelete) {+ await CodeStore.instance.removeCode(code);+ }+ }+ catch (e) {+ if (mounted) {+ showGenericErrorDialog(context: context, error: e).ignore();+ }+ }++ finally {+ _codeDisplayStore.clearSelection();+ }+ },+ );+}++Widget _buildTrashSelectActions() {+ return Container(+ decoration: BoxDecoration(+ color: Theme.of(context).brightness == Brightness.light+ ? const Color(0xFFF7F7F7)+ : const Color(0xFF1E1E1E),+ borderRadius: BorderRadius.circular(12),+ ),+ child: Row(+ children: [+ _buildClearActionButton(Icons.restore,context.l10n.restore, _onRestoreSelectedPressed,),+ _buildClearActionButton(Icons.delete_forever,context.l10n.delete, _onDeleteForeverPressed),+ ],+ ),+ );+}++ Future<void> _onPinSelectedPressed() async {+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;++ final codesToUpdate = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];+ if (codesToUpdate.isEmpty) return;++ // Determine the state of the current selection (pinned/unpinned)+ final bool allArePinned = codesToUpdate.every((code) => code.isPinned);++ if (allArePinned) {+ // if all are pinned, unpin all+ for (final code in codesToUpdate) {+ final updatedCode = code.copyWith(display: code.display.copyWith(pinned: false));- unawaited(CodeStore.instance.updateCode(code, updatedCode));++ unawaited(CodeStore.instance.addCode(updatedCode));+ }++ if (codesToUpdate.length == 1) {+ showToast(context, context.l10n.unpinnedCodeMessage(codesToUpdate.first.issuer));+ } else {+ showToast(context, 'Unpinned ${codesToUpdate.length} item(s)');+ }+ } else {+ int pinnedCount = 0;+ for (final code in codesToUpdate) {+ if (!code.isPinned) { // Only pin the codes that are currently unpinned+ final updatedCode = code.copyWith(display: code.display.copyWith(pinned: true));- unawaited(CodeStore.instance.updateCode(code, updatedCode));++ unawaited(CodeStore.instance.addCode(updatedCode));+ pinnedCount++;+ }+ }++ if (pinnedCount == 1) {+ final pinnedCode = codesToUpdate.firstWhere((c) => !c.isPinned);+ showToast(context, context.l10n.pinnedCodeMessage(pinnedCode.issuer));+ } else if (pinnedCount > 0) {+ showToast(context, 'Pinned $pinnedCount item(s)');+ }+ }++ _codeDisplayStore.clearSelection();+}+++ Future<void> _onUnpinSelectedPressed() async {+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;++ final codesToUpdate = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];+ if (codesToUpdate.isEmpty) return;++ int unpinnedCount = 0;+ for (final code in codesToUpdate) {+ if (code.isPinned) { // only unpin the codes that are currently pinned+ final updatedCode = code.copyWith(display: code.display.copyWith(pinned: false));- unawaited(CodeStore.instance.updateCode(code, updatedCode));++ unawaited(CodeStore.instance.addCode(updatedCode));+ unpinnedCount++;+ }+ }++ if (unpinnedCount == 1) {+ final unpinnedCode = codesToUpdate.firstWhere((c) => c.isPinned);+ showToast(context, context.l10n.unpinnedCodeMessage(unpinnedCode.issuer));+ } else if (unpinnedCount > 0) {+ showToast(context, 'Unpinned $unpinnedCount item(s)');+ }++ _codeDisplayStore.clearSelection();+}++++ Future<void> _onTrashSelectedPressed() async {+ final l10n = context.l10n;+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;++ bool isAuthSuccessful =+ await LocalAuthenticationService.instance.requestLocalAuthentication(+ context,+ context.l10n.deleteCodeAuthMessage,+ );+ if (!isAuthSuccessful) return;++ FocusScope.of(context).requestFocus();+ await showChoiceActionSheet(+ context,+ title: l10n.trashCode,++ body: ((){+ if (selectedIds.length == 1){+ final code = _allCodes!.firstWhere((c) => c.secret == selectedIds.first);+ final issuerAccount = code.account.isNotEmpty ? '${code.issuer} (${code.account})' : code.issuer;+ return l10n.trashCodeMessage(issuerAccount);+ }+ else{+ return l10n.moveMultipleToTrashMessage(selectedIds.length);+ }+ })(),++ firstButtonLabel: l10n.trash,+ isCritical: true,+ firstButtonOnTap: () async {+ try {+ final codesToTrash = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];++ for (final code in codesToTrash) {+ final updatedCode = code.copyWith(+ display: code.display.copyWith(trashed: true),+ );- unawaited(CodeStore.instance.updateCode(code, updatedCode));++ unawaited(CodeStore.instance.addCode(updatedCode));+ }+ } catch (e) {+ _logger.severe('Failed to trash code(s): ${e.toString()}');+ if (mounted) {+ showGenericErrorDialog(context: context, error: e).ignore();+ }+ } finally {+ _codeDisplayStore.clearSelection();+ }+ },+ );+}+++Future<void> _onEditPressed(Code code) async {+ bool isAuthSuccessful = await LocalAuthenticationService.instance+ .requestLocalAuthentication(context, context.l10n.editCodeAuthMessage);+ await PlatformUtil.refocusWindows();+ if (!isAuthSuccessful) return;++ _codeDisplayStore.clearSelection();+ final Code? updatedCode = await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return SetupEnterSecretKeyPage(code: code);+ },+ ),+ );++ if (updatedCode != null){- await CodeStore.instance.updateCode(code, updatedCode);++ await CodeStore.instance.addCode(updatedCode);+ }+}++Future<void> _onSharePressed(Code code) async {+ bool isAuthSuccessful = await LocalAuthenticationService.instance+ .requestLocalAuthentication(context, context.l10n.authenticateGeneric);+ await PlatformUtil.refocusWindows();+ if (!isAuthSuccessful) return;++ _codeDisplayStore.clearSelection();+ showShareDialog(context, code);+}++Future<void> _onShowQrPressed(Code code) async {+ bool isAuthSuccessful = await LocalAuthenticationService.instance+ .requestLocalAuthentication(context, context.l10n.showQRAuthMessage);+ await PlatformUtil.refocusWindows();+ if (!isAuthSuccessful) return;++ _codeDisplayStore.clearSelection();+ await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return ViewQrPage(code: code);+ },+ ),+ );+}++Widget _buildClearActionButton(IconData icon, String label, VoidCallback onTap) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);++ return Expanded(+ child: InkWell(+ onTap: onTap,+ borderRadius: BorderRadius.circular(12),+ highlightColor: colorScheme.textBase.withValues(alpha: 0.1),+ splashColor: colorScheme.textBase.withValues(alpha: 0.1),+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 12.0),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Icon(icon, color: colorScheme.textBase, size: 18), //bottom row icon props+ const SizedBox(height: 8),+ Text(label, style: textTheme.small.copyWith(color: colorScheme.textBase, fontSize: 11)),+ ],+ ),+ ),+ ),+ );+}+Widget _buildSingleSelectActions(Code code) {+ final colorScheme = getEnteColorScheme(context);+ return Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Row(+ children: [+ _buildActionButton(Icons.edit_outlined, context.l10n.edit, () => _onEditPressed(code)),+ const SizedBox(width: 10),+ _buildActionButton(Icons.share_outlined, context.l10n.share, () => _onSharePressed(code)),+ const SizedBox(width: 10),+ _buildActionButton(Icons.qr_code, context.l10n.qrCode, () => _onShowQrPressed(code)),+ ],+ ),+ const SizedBox(height: 16),+ Container(+ decoration: BoxDecoration(+ color: Theme.of(context).brightness == Brightness.dark+ ? colorScheme.backgroundElevated2+ : const Color(0xFFF7F7F7),+ //color of the bottom button row on single select+ borderRadius: BorderRadius.circular(12),+ ),+ child: Row(+ children: [+ ValueListenableBuilder<Set<String>>(+ valueListenable: _codeDisplayStore.selectedCodeIds,+ builder: (context, selectedIds, child) {+ if (selectedIds.isEmpty) return const Expanded(child: SizedBox.shrink());++ final selectedCodes = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];+ if (selectedCodes.isEmpty) return const Expanded(child: SizedBox.shrink());++ final bool allArePinned = selectedCodes.every((code) => code.isPinned);++ return _buildClearActionButton(+ allArePinned ? Icons.push_pin : Icons.push_pin_outlined,+ allArePinned ? context.l10n.unpinText : context.l10n.pinText,+ _onPinSelectedPressed,+ );+ },+),+ _buildClearActionButton(Icons.label_outline, context.l10n.addTag, _onAddTagPressed),+ _buildClearActionButton(Icons.delete_outline, context.l10n.trash, _onTrashSelectedPressed),+ ],+ ),+ ),+ ],+ );+}++Widget _buildMultiSelectActions(Set<String> selectedIds) {+ final colorScheme = getEnteColorScheme(context);+ return Container(+ decoration: BoxDecoration(+ color: Theme.of(context).brightness == Brightness.dark+ ? colorScheme.backgroundElevated2+ : const Color(0xFFF7F7F7),+ borderRadius: BorderRadius.circular(12),+ ),+ child: ValueListenableBuilder<Set<String>>(+ valueListenable: _codeDisplayStore.selectedCodeIds,+ builder: (context, selectedIds, child) {+ if (selectedIds.isEmpty) return const SizedBox.shrink();++ final selectedCodes = _allCodes?.where((c) => selectedIds.contains(c.secret)).toList() ?? [];+ if (selectedCodes.isEmpty) return const SizedBox.shrink();++ final bool allArePinned = selectedCodes.every((code) => code.isPinned);+ final bool allAreUnpinned = selectedCodes.every((code) => !code.isPinned);+ final bool isMixed = !allArePinned && !allAreUnpinned;++ if (isMixed) {+ //mixed state: when selection contains both pinned and unpinned codes+ return Row(+ children: [+ _buildClearActionButton(+ Icons.push_pin_outlined,+ context.l10n.pinText,+ _onPinSelectedPressed,+ ),+ _buildClearActionButton(+ Icons.push_pin,+ context.l10n.unpinText,+ _onUnpinSelectedPressed,+ ),+ _buildClearActionButton(+ Icons.label_outline,+ context.l10n.addTag,+ _onAddTagPressed,+ ),+ _buildClearActionButton(+ Icons.delete_outline,+ context.l10n.trash,+ _onTrashSelectedPressed,+ ),+ ],+ );+ } else {+ //when selection contains either only pinned OR only unpinned codes+ return Row(+ children: [+ _buildClearActionButton(+ allArePinned ? Icons.push_pin : Icons.push_pin_outlined,+ allArePinned ? context.l10n.unpinText : context.l10n.pinText,+ _onPinSelectedPressed,+ ),+ _buildClearActionButton(+ Icons.label_outline,+ context.l10n.addTag,+ _onAddTagPressed,+ ),+ _buildClearActionButton(+ Icons.delete_outline,+ context.l10n.trash,+ _onTrashSelectedPressed,+ ),+ ],+ );+ }+ },+ ),+ );+}++ Widget _buildActionButton(IconData icon, String label, VoidCallback onTap) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);++ return Expanded(+ child: Container(+ decoration: BoxDecoration(+ color: Theme.of(context).brightness == Brightness.dark+ ? colorScheme.backgroundElevated2+ : const Color(0xFFF7F7F7),++ borderRadius: BorderRadius.circular(12),+ ),+ child: InkWell(+ onTap: onTap,+ borderRadius: BorderRadius.circular(12),+ highlightColor: colorScheme.textBase.withValues(alpha: 0.7),+ splashColor: colorScheme.textBase.withValues(alpha: 0.7),+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 12.0),+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ mainAxisSize: MainAxisSize.min,+ children: [+ Icon(icon, color: colorScheme.textBase, size: 18), //top row icon props+ const SizedBox(height: 8),+ Text(+ label,+ style: textTheme.small.copyWith(color: colorScheme.textBase, fontSize: 11),+ textAlign: TextAlign.center,+ ),+ ],+ ),+ ),+ ),+ ),+ );+}++Widget _buildActionButtons() {+ if (_isTrashOpen) {+ return _buildTrashSelectActions();+ }+ return ValueListenableBuilder<Set<String>>(+ valueListenable: _codeDisplayStore.selectedCodeIds,+ builder: (context, selectedIds, child) {+ if (selectedIds.isEmpty) {+ return const SizedBox.shrink();+ }++ if (selectedIds.length == 1) {+ final selectedCode = _allCodes?.firstWhereOrNull(+ (c) => c.secret == selectedIds.first,+ );+ if (selectedCode == null) return const SizedBox.shrink();+ return _buildSingleSelectActions(selectedCode);+ } else {+ return _buildMultiSelectActions(selectedIds);+ }+ },+ );+}++ Widget _buildSelectionActionBar() {+ final bottomPadding = MediaQuery.of(context).padding.bottom;+ final colorScheme = getEnteColorScheme(context);++ return ConstrainedBox(+ constraints: BoxConstraints(+ maxHeight: MediaQuery.of(context).size.height * 0.4,+ ),+ child: Card(+ margin: EdgeInsets.zero,+ shape: const RoundedRectangleBorder(+ borderRadius: BorderRadius.only(+ topLeft: Radius.circular(16),+ topRight: Radius.circular(16),+ ),+ ),+ elevation: 4,+ color: Theme.of(context).brightness == Brightness.dark+ ? colorScheme.fillFaint+ : colorScheme.backgroundElevated2,+ child: Padding(+ padding: EdgeInsets.fromLTRB(16, 16, 16, 16 + bottomPadding),+ child: SingleChildScrollView(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Row(+ children: [+ //Select all pill+ Material(+ shape: StadiumBorder(+ side: BorderSide(color: colorScheme.strokeMuted, width: 0.5),+ ),+ color: colorScheme.backgroundElevated2,+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ onTap: () {+ final allVisibleCodeIds =+ _filteredCodes.map((c) => c.secret).toSet();+ _codeDisplayStore.selectedCodeIds.value = allVisibleCodeIds;+ },+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ const Icon(+ Icons.check_circle_outline_outlined,+ color: Colors.grey,+ size: 15,+ ),+ const SizedBox(width: 6),+ Text(context.l10n.selectAll, style: const TextStyle(fontSize: 11)),+ ],+ ),+ ),+ ),+ ),++ // Center code logo icon+ Expanded(+ child: ValueListenableBuilder<Set<String>>(+ valueListenable: _codeDisplayStore.selectedCodeIds,+ builder: (context, selectedIds, child) {+ if (selectedIds.isEmpty) {+ return const SizedBox.shrink();+ }+ final selectedCodes = _allCodes+ ?.where((c) => selectedIds.contains(c.secret))+ .toList() ??+ [];+ final codesToShow = selectedCodes.take(3).toList();+ return Row(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ ...codesToShow.map((code) {+ final iconData = code.display.isCustomIcon+ ? code.display.iconID+ : code.issuer;+ return Padding(+ padding: const EdgeInsets.symmetric(horizontal: 4.0),+ child: IconUtils.instance+ .getIcon(context, iconData.trim(), width: 17),+ );+ }),+ if (selectedIds.length > 3)+ Padding(+ padding: const EdgeInsets.only(left: 4.0),+ child: Text(+ '+${selectedIds.length - 3}',+ style: const TextStyle(),+ ),+ ),+ ],+ );+ },+ ),+ ),++ // N selected pill+ ValueListenableBuilder<Set<String>>(+ valueListenable: _codeDisplayStore.selectedCodeIds,+ builder: (context, selectedIds, child) {+ return Material(+ shape: StadiumBorder(+ side: BorderSide(color: colorScheme.strokeMuted, width: 0.5),+ ),+ color: colorScheme.backgroundElevated2,+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ onTap: () {+ _codeDisplayStore.clearSelection();+ },+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ '${selectedIds.length} selected',+ style: const TextStyle(fontSize: 11),+ ),+ const SizedBox(width: 6),+ const Icon(+ Icons.close,+ size: 15,+ color: Colors.grey,+ ),+ ],+ ),+ ),+ ),+ );+ },+ ),+ ],+),+ const SizedBox(height: 16),+ _buildActionButtons(),+ ],+ ),+ ),+ ),+ ),+ );+}+bool _handleKeyEvent(KeyEvent event) {if (event is KeyDownEvent) {_pressedKeys.add(event.logicalKey);