π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix selection reconciliation after sync
Prateek Sunala0a3fecfcfd6
diff --git a/mobile/apps/auth/lib/store/code_display_store.dart b/mobile/apps/auth/lib/store/code_display_store.dartindex bd7b03ce8b..944cd86686 100644--- a/mobile/apps/auth/lib/store/code_display_store.dart+++ b/mobile/apps/auth/lib/store/code_display_store.dart@@ -18,27 +18,72 @@ class CodeDisplayStore {final ValueNotifier<Set<String>> selectedCodeIds = ValueNotifier(<String>{});// toggles the selection status of a code- void toggleSelection(String codeId){+ void toggleSelection(String codeId) {final newSelection = Set<String>.from(selectedCodeIds.value);- if(newSelection.contains(codeId)){+ if (newSelection.contains(codeId)) {newSelection.remove(codeId);- }-- else{+ } else {newSelection.add(codeId);}- selectedCodeIds.value = newSelection; //if we selected atleast one code, then we're in selection mode.. else: exit selection mode+ selectedCodeIds.value =+ newSelection; //if we selected atleast one code, then we're in selection mode.. else: exit selection modeisSelectionModeActive.value = newSelection.isNotEmpty;}//method to clear the entire selection- void clearSelection(){+ void clearSelection() {selectedCodeIds.value = <String>{};isSelectionModeActive.value = false;}+ /// Reconcile current selections with the provided list of codes.+ /// This keeps the selection state consistent when codes receive a+ /// generatedID during sync or are removed locally.+ void reconcileSelections(Iterable<Code> codes) {+ final currentSelection = selectedCodeIds.value;+ if (currentSelection.isEmpty) {+ return;+ }++ final Set<String> validSelectionKeys = <String>{};+ final Map<String, String> fallbackSelectionKeys = <String, String>{};++ for (final code in codes) {+ if (code.hasError) {+ continue;+ }+ final key = code.selectionKey;+ validSelectionKeys.add(key);+ fallbackSelectionKeys[code.rawData] = key;+ final generatedID = code.generatedID;+ if (generatedID != null) {+ fallbackSelectionKeys[generatedID.toString()] = key;+ }+ }++ bool hasChanges = false;+ final Set<String> updatedSelection = <String>{};++ for (final selectedKey in currentSelection) {+ if (validSelectionKeys.contains(selectedKey)) {+ updatedSelection.add(selectedKey);+ continue;+ }+ final remappedKey = fallbackSelectionKeys[selectedKey];+ if (remappedKey != null) {+ updatedSelection.add(remappedKey);+ }+ hasChanges = true;+ }++ if (hasChanges) {+ selectedCodeIds.value = updatedSelection;+ isSelectionModeActive.value = updatedSelection.isNotEmpty;+ }+ }+Future<void> init() async {_codeStore = CodeStore.instance;}diff --git a/mobile/apps/auth/lib/ui/home_page.dart b/mobile/apps/auth/lib/ui/home_page.dartindex c7733d5e4a..67c42cb475 100644--- a/mobile/apps/auth/lib/ui/home_page.dart+++ b/mobile/apps/auth/lib/ui/home_page.dart@@ -130,528 +130,431 @@ class _HomePageState extends State<HomePage> {}void _onAddTagPressed() {- final selectedIds = _codeDisplayStore.selectedCodeIds.value;- final selectedCodes =- _allCodes?.where((c) => selectedIds.contains(c.selectionKey)).toList() ??- [];+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ final selectedCodes = _allCodes+ ?.where((c) => selectedIds.contains(c.selectionKey))+ .toList() ??+ [];- if (selectedCodes.isEmpty) return;+ if (selectedCodes.isEmpty) return;- showModalBottomSheet(- context: context,- isScrollControlled: true,- builder: (_) {- return AddTagSheet(selectedCodes: selectedCodes);- },- ).then((_) {- _codeDisplayStore.clearSelection();- });-}+ 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();+ Future<void> _onRestoreSelectedPressed() async {+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;- try {- final codesToRestore = _allCodes- ?.where((c) => selectedIds.contains(c.selectionKey))- .toList() ??- [];- for (final code in codesToRestore) {- final updatedCode = code.copyWith(display: code.display.copyWith(trashed: false));- unawaited(CodeStore.instance.addCode(updatedCode));- }- } catch (e) {- if (mounted) {- showGenericErrorDialog(context: context, error: e).ignore();+ FocusScope.of(context).requestFocus();++ try {+ final codesToRestore = _allCodes+ ?.where((c) => selectedIds.contains(c.selectionKey))+ .toList() ??+ [];+ for (final code in codesToRestore) {+ final updatedCode =+ code.copyWith(display: code.display.copyWith(trashed: false));+ unawaited(CodeStore.instance.addCode(updatedCode));+ }+ } catch (e) {+ if (mounted) {+ showGenericErrorDialog(context: context, error: e).ignore();+ }+ } finally {+ _codeDisplayStore.clearSelection();}- } finally {- _codeDisplayStore.clearSelection();}-}-Future<void> _onDeleteForeverPressed() async {- final l10n = context.l10n;- final selectedIds = _codeDisplayStore.selectedCodeIds.value;- if (selectedIds.isEmpty) return;+ Future<void> _onDeleteForeverPressed() async {+ final l10n = context.l10n;+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;- bool isAuthSuccessful =- await LocalAuthenticationService.instance.requestLocalAuthentication(+ bool isAuthSuccessful =+ await LocalAuthenticationService.instance.requestLocalAuthentication(context,context.l10n.deleteCodeAuthMessage,);- if (!isAuthSuccessful) return;+ 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.selectionKey))- .toList() ??- [];- for (final code in codesToDelete) {- await CodeStore.instance.removeCode(code);- }- }- catch (e) {- if (mounted) {- showGenericErrorDialog(context: context, error: e).ignore();+ 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.selectionKey))+ .toList() ??+ [];+ for (final code in codesToDelete) {+ await CodeStore.instance.removeCode(code);+ }+ } catch (e) {+ if (mounted) {+ showGenericErrorDialog(context: context, error: e).ignore();+ }+ } finally {+ _codeDisplayStore.clearSelection();}- }-- 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(- context.l10n.restore,- _onRestoreSelectedPressed,- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedRestoreBin,- size: 21,- color: getEnteColorScheme(context).textBase,+ 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(+ context.l10n.restore,+ _onRestoreSelectedPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedRestoreBin,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),),- ),- _buildClearActionButton(- context.l10n.delete,- _onDeleteForeverPressed,- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedDelete04,- size: 21,- color: getEnteColorScheme(context).textBase,+ _buildClearActionButton(+ context.l10n.delete,+ _onDeleteForeverPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedDelete04,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),),- ),- ],- ),- );-}+ ],+ ),+ );+ }List<Code> _selectedCodesForContextMenu() {- final selectedIds = _codeDisplayStore.selectedCodeIds.value;- if (selectedIds.isEmpty) return const <Code>[];+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return const <Code>[];- return _allCodes- ?.where((code) => selectedIds.contains(code.selectionKey))- .toList() ??- const <Code>[];-}+ return _allCodes+ ?.where((code) => selectedIds.contains(code.selectionKey))+ .toList() ??+ const <Code>[];+ }int _calculateGridColumnCount(BuildContext context) {- final double width = MediaQuery.sizeOf(context).width;- final double tileWidth = isCompactMode ? 320 : 400;- final int computedCount = width ~/ tileWidth;- return computedCount <= 0 ? 1 : computedCount;-}+ final double width = MediaQuery.sizeOf(context).width;+ final double tileWidth = isCompactMode ? 320 : 400;+ final int computedCount = width ~/ tileWidth;+ return computedCount <= 0 ? 1 : computedCount;+ }Future<void> _onPinSelectedPressed() async {- final selectedIds = _codeDisplayStore.selectedCodeIds.value;- if (selectedIds.isEmpty) return;+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;- final codesToUpdate = _allCodes- ?.where((c) => selectedIds.contains(c.selectionKey))- .toList() ??- [];- if (codesToUpdate.isEmpty) return;+ final codesToUpdate = _allCodes+ ?.where((c) => selectedIds.contains(c.selectionKey))+ .toList() ??+ [];+ if (codesToUpdate.isEmpty) return;- // Determine the state of the current selection (pinned/unpinned)- final bool allArePinned = codesToUpdate.every((code) => code.isPinned);+ // 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.addCode(updatedCode));- }+ 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.addCode(updatedCode));+ }- if (codesToUpdate.length == 1) {- showToast(context, context.l10n.unpinnedCodeMessage(codesToUpdate.first.issuer));+ if (codesToUpdate.length == 1) {+ showToast(context,+ context.l10n.unpinnedCodeMessage(codesToUpdate.first.issuer));+ } else {+ showToast(context, 'Unpinned ${codesToUpdate.length} item(s)');+ }} 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.addCode(updatedCode));- pinnedCount++;+ 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.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)');+ 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();}- _codeDisplayStore.clearSelection();-}+ Future<void> _onUnpinSelectedPressed() async {+ final selectedIds = _codeDisplayStore.selectedCodeIds.value;+ if (selectedIds.isEmpty) return;+ final codesToUpdate = _allCodes+ ?.where((c) => selectedIds.contains(c.selectionKey))+ .toList() ??+ [];+ if (codesToUpdate.isEmpty) return;- Future<void> _onUnpinSelectedPressed() async {- final selectedIds = _codeDisplayStore.selectedCodeIds.value;- if (selectedIds.isEmpty) return;-- final codesToUpdate = _allCodes- ?.where((c) => selectedIds.contains(c.selectionKey))- .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.addCode(updatedCode));- unpinnedCount++;+ 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.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)');- }+ 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();-}+ _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;- 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.selectionKey == 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.selectionKey))- .toList() ??- [];-- for (final code in codesToTrash) {- final updatedCode = code.copyWith(- display: code.display.copyWith(trashed: true),- );- unawaited(CodeStore.instance.addCode(updatedCode));+ FocusScope.of(context).requestFocus();+ await showChoiceActionSheet(+ context,+ title: l10n.trashCode,+ body: (() {+ if (selectedIds.length == 1) {+ final code =+ _allCodes!.firstWhere((c) => c.selectionKey == selectedIds.first);+ final issuerAccount = code.account.isNotEmpty+ ? '${code.issuer} (${code.account})'+ : code.issuer;+ return l10n.trashCodeMessage(issuerAccount);+ } else {+ return l10n.moveMultipleToTrashMessage(selectedIds.length);}- } catch (e) {- _logger.severe('Failed to trash code(s): ${e.toString()}');- if (mounted) {- showGenericErrorDialog(context: context, error: e).ignore();+ })(),+ firstButtonLabel: l10n.trash,+ isCritical: true,+ firstButtonOnTap: () async {+ try {+ final codesToTrash = _allCodes+ ?.where((c) => selectedIds.contains(c.selectionKey))+ .toList() ??+ [];++ for (final code in codesToTrash) {+ final updatedCode = code.copyWith(+ display: code.display.copyWith(trashed: true),+ );+ 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();}- } 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;-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);+ },+ ),+ );- _codeDisplayStore.clearSelection();- final Code? updatedCode = await Navigator.of(context).push(- MaterialPageRoute(- builder: (BuildContext context) {- return SetupEnterSecretKeyPage(code: code);- },- ),- );+ if (updatedCode != null) {+ await CodeStore.instance.addCode(updatedCode);+ }+ }- if (updatedCode != null){- 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;-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);-}+ _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);- },- ),- );-}+ Future<void> _onShowQrPressed(Code code) async {+ bool isAuthSuccessful = await LocalAuthenticationService.instance+ .requestLocalAuthentication(context, context.l10n.showQRAuthMessage);+ await PlatformUtil.refocusWindows();+ if (!isAuthSuccessful) return;-Widget _buildClearActionButton(- String label,- VoidCallback onTap,- {IconData? icon, Widget? iconWidget,}-) {- 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: [- iconWidget ?? Icon(icon!, color: colorScheme.textBase, size: 21),- const SizedBox(height: 8),- Text(label, style: textTheme.small.copyWith(color: colorScheme.textBase, fontSize: 11)),- ],- ),+ _codeDisplayStore.clearSelection();+ await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return ViewQrPage(code: code);+ },),- ),- );-}-Widget _buildSingleSelectActions(Code code) {- final colorScheme = getEnteColorScheme(context);- return Column(- key: const ValueKey('single_select_actions'),- mainAxisSize: MainAxisSize.min,- children: [- Row(- children: [- _buildActionButton(- context.l10n.edit,- () => _onEditPressed(code),- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedEdit03,- size: 21,- color: getEnteColorScheme(context).textBase,- ),- ),- const SizedBox(width: 10),- _buildActionButton(- context.l10n.share,- () => _onSharePressed(code),- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedNavigation03,- size: 21,- color: getEnteColorScheme(context).textBase,- ),- ),- const SizedBox(width: 10),- _buildActionButton(- context.l10n.qrCode,- () => _onShowQrPressed(code),- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedQrCode,- size: 21,- color: getEnteColorScheme(context).textBase,- ),+ );+ }++ Widget _buildClearActionButton(+ String label,+ VoidCallback onTap, {+ IconData? icon,+ Widget? iconWidget,+ }) {+ 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: [+ iconWidget ?? Icon(icon!, color: colorScheme.textBase, size: 21),+ const SizedBox(height: 8),+ Text(label,+ style: textTheme.small+ .copyWith(color: colorScheme.textBase, fontSize: 11)),+ ],),- ],- ),- const SizedBox(height: 16),- Container(- decoration: BoxDecoration(- color: Theme.of(context).brightness == Brightness.dark- ? colorScheme.backgroundElevated2- : const Color(0xFFF7F7F7),- borderRadius: BorderRadius.circular(12),),- child: Row(+ ),+ );+ }++ Widget _buildSingleSelectActions(Code code) {+ final colorScheme = getEnteColorScheme(context);+ return Column(+ key: const ValueKey('single_select_actions'),+ mainAxisSize: MainAxisSize.min,+ children: [+ 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.selectionKey))- .toList() ??- [];- if (selectedCodes.isEmpty) return const Expanded(child: SizedBox.shrink());- final bool allArePinned = selectedCodes.every((code) => code.isPinned);-- return _buildClearActionButton(- allArePinned ? context.l10n.unpinText : context.l10n.pinText,- _onPinSelectedPressed,- iconWidget: HugeIcon(- icon: allArePinned- ? HugeIcons.strokeRoundedPinOff- : HugeIcons.strokeRoundedPin,- size: 21,- color: getEnteColorScheme(context).textBase,- ),- );- },+ _buildActionButton(+ context.l10n.edit,+ () => _onEditPressed(code),+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedEdit03,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),),- _buildClearActionButton(- context.l10n.addTag,- _onAddTagPressed,+ const SizedBox(width: 10),+ _buildActionButton(+ context.l10n.share,+ () => _onSharePressed(code),iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedTags,+ icon: HugeIcons.strokeRoundedNavigation03,size: 21,color: getEnteColorScheme(context).textBase,),),- _buildClearActionButton(- context.l10n.trash,- _onTrashSelectedPressed,+ const SizedBox(width: 10),+ _buildActionButton(+ context.l10n.qrCode,+ () => _onShowQrPressed(code),iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,+ icon: HugeIcons.strokeRoundedQrCode,size: 21,color: getEnteColorScheme(context).textBase,),),],),- ),- ],- );-}--Widget _buildMultiSelectActions(Set<String> selectedIds) {- final colorScheme = getEnteColorScheme(context);- return Container(- key: const ValueKey('multi_select_actions'),- 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.selectionKey))- .toList() ??- [];- if (selectedCodes.isEmpty) return const SizedBox.shrink();-- final bool allArePinned = selectedCodes.every((code) => code.isPinned);- final bool isMixed = !allArePinned && !selectedCodes.every((code) => !code.isPinned);-- if (isMixed) {- // Mixed state: when selection contains both pinned and unpinned codes- return Row(- children: [- _buildClearActionButton(- context.l10n.pinText,- _onPinSelectedPressed,- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedPin,- size: 21,- color: getEnteColorScheme(context).textBase,- ),- ),- _buildClearActionButton(- context.l10n.unpinText,- _onUnpinSelectedPressed,- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedPinOff,- size: 21,- color: getEnteColorScheme(context).textBase,- ),- ),- _buildClearActionButton(- context.l10n.addTag,- _onAddTagPressed,- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedTags,- size: 21,- color: getEnteColorScheme(context).textBase,- ),- ),- _buildClearActionButton(- context.l10n.trash,- _onTrashSelectedPressed,- iconWidget: HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,- size: 21,- color: getEnteColorScheme(context).textBase,- ),- ),- ],- );- } else {- // When selection contains either only pinned OR only unpinned codes- return Row(- children: [- _buildClearActionButton(- allArePinned ? context.l10n.unpinText : context.l10n.pinText,- _onPinSelectedPressed,- iconWidget: HugeIcon(- icon: allArePinned- ? HugeIcons.strokeRoundedPinOff- : HugeIcons.strokeRoundedPin,- size: 21,- color: getEnteColorScheme(context).textBase,- ),+ const SizedBox(height: 16),+ Container(+ decoration: BoxDecoration(+ color: Theme.of(context).brightness == Brightness.dark+ ? colorScheme.backgroundElevated2+ : const Color(0xFFF7F7F7),+ 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.selectionKey))+ .toList() ??+ [];+ if (selectedCodes.isEmpty)+ return const Expanded(child: SizedBox.shrink());+ final bool allArePinned =+ selectedCodes.every((code) => code.isPinned);++ return _buildClearActionButton(+ allArePinned+ ? context.l10n.unpinText+ : context.l10n.pinText,+ _onPinSelectedPressed,+ iconWidget: HugeIcon(+ icon: allArePinned+ ? HugeIcons.strokeRoundedPinOff+ : HugeIcons.strokeRoundedPin,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ );+ },),_buildClearActionButton(context.l10n.addTag,@@ -672,268 +575,385 @@ Widget _buildMultiSelectActions(Set<String> selectedIds) {),),],- );- }- },- ),- );-}+ ),+ ),+ ],+ );+ }- Widget _buildActionButton(- String label,- VoidCallback onTap,- {IconData? icon, Widget? iconWidget,}-) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);-- return Expanded(- child: Container(+ Widget _buildMultiSelectActions(Set<String> selectedIds) {+ final colorScheme = getEnteColorScheme(context);+ return Container(+ key: const ValueKey('multi_select_actions'),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: [- iconWidget ?? Icon(icon!, color: colorScheme.textBase, size: 21),- const SizedBox(height: 8),- Text(- label,- style: textTheme.small.copyWith(color: colorScheme.textBase, fontSize: 11),- textAlign: TextAlign.center,- ),- ],+ 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.selectionKey))+ .toList() ??+ [];+ if (selectedCodes.isEmpty) return const SizedBox.shrink();++ final bool allArePinned =+ selectedCodes.every((code) => code.isPinned);+ final bool isMixed =+ !allArePinned && !selectedCodes.every((code) => !code.isPinned);++ if (isMixed) {+ // Mixed state: when selection contains both pinned and unpinned codes+ return Row(+ children: [+ _buildClearActionButton(+ context.l10n.pinText,+ _onPinSelectedPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedPin,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ ),+ _buildClearActionButton(+ context.l10n.unpinText,+ _onUnpinSelectedPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedPinOff,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ ),+ _buildClearActionButton(+ context.l10n.addTag,+ _onAddTagPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedTags,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ ),+ _buildClearActionButton(+ context.l10n.trash,+ _onTrashSelectedPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedDelete02,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ ),+ ],+ );+ } else {+ // When selection contains either only pinned OR only unpinned codes+ return Row(+ children: [+ _buildClearActionButton(+ allArePinned ? context.l10n.unpinText : context.l10n.pinText,+ _onPinSelectedPressed,+ iconWidget: HugeIcon(+ icon: allArePinned+ ? HugeIcons.strokeRoundedPinOff+ : HugeIcons.strokeRoundedPin,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ ),+ _buildClearActionButton(+ context.l10n.addTag,+ _onAddTagPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedTags,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ ),+ _buildClearActionButton(+ context.l10n.trash,+ _onTrashSelectedPressed,+ iconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedDelete02,+ size: 21,+ color: getEnteColorScheme(context).textBase,+ ),+ ),+ ],+ );+ }+ },+ ),+ );+ }++ Widget _buildActionButton(+ String label,+ VoidCallback onTap, {+ IconData? icon,+ Widget? iconWidget,+ }) {+ 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: [+ iconWidget ??+ Icon(icon!, color: colorScheme.textBase, size: 21),+ 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();- }- final Widget actionWidget;- if (selectedIds.length == 1) {- final selectedCode = _allCodes?.firstWhereOrNull(- (c) => c.selectionKey == selectedIds.first,+ Widget _buildActionButtons() {+ if (_isTrashOpen) {+ return _buildTrashSelectActions();+ }+ return ValueListenableBuilder<Set<String>>(+ valueListenable: _codeDisplayStore.selectedCodeIds,+ builder: (context, selectedIds, child) {+ if (selectedIds.isEmpty) {+ return const SizedBox.shrink();+ }++ final Widget actionWidget;+ if (selectedIds.length == 1) {+ final selectedCode = _allCodes?.firstWhereOrNull(+ (c) => c.selectionKey == selectedIds.first,+ );+ if (selectedCode == null) return const SizedBox.shrink();+ actionWidget = _buildSingleSelectActions(selectedCode);+ } else {+ actionWidget = _buildMultiSelectActions(selectedIds);+ }+ final double containerHeight;+ if (selectedIds.isEmpty) {+ containerHeight = 0.0;+ } else if (selectedIds.length == 1) {+ containerHeight = 160.0;+ } else {+ containerHeight = 80.0;+ }++ return AnimatedContainer(+ duration: const Duration(milliseconds: 250),+ curve: Curves.easeInOut,+ height: containerHeight,+ child: SingleChildScrollView(+ physics: const NeverScrollableScrollPhysics(),+ child: ConstrainedBox(+ constraints: BoxConstraints(+ minHeight: containerHeight,+ maxHeight: containerHeight,+ ),+ child: actionWidget,+ ),+ ),);- if (selectedCode == null) return const SizedBox.shrink();- actionWidget = _buildSingleSelectActions(selectedCode);- } else {- actionWidget = _buildMultiSelectActions(selectedIds);- }- final double containerHeight;- if (selectedIds.isEmpty) {- containerHeight = 0.0;- } else if (selectedIds.length == 1) {- containerHeight = 160.0;- } else {- containerHeight = 80.0;+ },+ );}- return AnimatedContainer(- duration: const Duration(milliseconds: 250),- curve: Curves.easeInOut,- height: containerHeight,- child: SingleChildScrollView(- physics: const NeverScrollableScrollPhysics(),- child: ConstrainedBox(+ Widget _buildSelectionActionBar() {+ final bottomPadding = MediaQuery.of(context).padding.bottom;+ final colorScheme = getEnteColorScheme(context);+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;++ return ConstrainedBox(constraints: BoxConstraints(- minHeight: containerHeight,- maxHeight: containerHeight,+ maxHeight: MediaQuery.of(context).size.height * 0.4,),- child: actionWidget,- ),- ),-);- },- );-}-- Widget _buildSelectionActionBar() {- final bottomPadding = MediaQuery.of(context).padding.bottom;- final colorScheme = getEnteColorScheme(context);- final isDarkMode = Theme.of(context).brightness == Brightness.dark;-- return ConstrainedBox(- constraints: BoxConstraints(- maxHeight: MediaQuery.of(context).size.height * 0.4,- ),- child: Card(- margin: EdgeInsets.zero,-- shape: RoundedRectangleBorder(- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(16),- topRight: Radius.circular(16),- ),- side: BorderSide(- color: colorScheme.strokeMuted.withValues(alpha: 0.1),- width: 1,+ child: Card(+ margin: EdgeInsets.zero,+ shape: RoundedRectangleBorder(+ borderRadius: const BorderRadius.only(+ topLeft: Radius.circular(16),+ topRight: Radius.circular(16),+ ),+ side: BorderSide(+ color: colorScheme.strokeMuted.withValues(alpha: 0.1),+ width: 1,+ ),),- ),- shadowColor: isDarkMode- ? Colors.black.withValues(alpha: 0.7)- : Colors.grey.withValues(alpha: 0.5),- elevation: 4,- color: isDarkMode- ? colorScheme.fillFaint- : colorScheme.backgroundElevated2,- child: Padding(- padding: EdgeInsets.fromLTRB(16, 16, 16, 28 + 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.selectionKey)- .toSet();- _codeDisplayStore.selectedCodeIds.value = allVisibleCodeIds;- },- child: Padding(- padding:- const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- Text(context.l10n.selectAll,- style: const TextStyle(fontSize: 11),),- const SizedBox(width: 6),- const HugeIcon(- icon: HugeIcons.strokeRoundedTickDouble02,- color: Colors.grey,- size: 15,- ),- ],+ shadowColor: isDarkMode+ ? Colors.black.withValues(alpha: 0.7)+ : Colors.grey.withValues(alpha: 0.5),+ elevation: 4,+ color: isDarkMode+ ? colorScheme.fillFaint+ : colorScheme.backgroundElevated2,+ child: Padding(+ padding: EdgeInsets.fromLTRB(16, 16, 16, 28 + 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.selectionKey).toSet();+ _codeDisplayStore.selectedCodeIds.value =+ allVisibleCodeIds;+ },+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: 12.0, vertical: 8.0),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ context.l10n.selectAll,+ style: const TextStyle(fontSize: 11),+ ),+ const SizedBox(width: 6),+ const HugeIcon(+ icon: HugeIcons.strokeRoundedTickDouble02,+ color: Colors.grey,+ size: 15,+ ),+ ],+ ),),),),- ),- // Center code logo icon- Expanded(- child: ValueListenableBuilder<Set<String>>(+ // 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.selectionKey),+ )+ .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) {- if (selectedIds.isEmpty) {- return const SizedBox.shrink();- }- final selectedCodes = _allCodes- ?.where(- (c) => selectedIds.contains(c.selectionKey),- )- .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(),- ),+ 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,+ ),+ ],),- ],+ ),+ ),);},),- ),-- // 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(),- ],+ ],+ ),+ const SizedBox(height: 16),+ _buildActionButtons(),+ ],+ ),),),),- ),- );-}+ );+ }bool _handleKeyEvent(KeyEvent event) {if (event is KeyDownEvent) {@@ -971,6 +991,7 @@ Widget _buildActionButtons() {void _loadCodes() {CodeStore.instance.getAllCodes().then((codes) {_allCodes = codes;+ CodeDisplayStore.instance.reconcileSelections(codes);hasTrashedCodes = false;hasNonTrashedCodes = false;@@ -1237,215 +1258,217 @@ Widget _buildActionButtons() {}@override-Widget build(BuildContext context) {- LockScreenSettings.instance- .setLightMode(getEnteColorScheme(context).isLightTheme);- final l10n = context.l10n;- isCompactMode = PreferenceService.instance.isCompactMode();-- return ValueListenableBuilder<bool>(- valueListenable: _codeDisplayStore.isSelectionModeActive,- builder: (context, isSelecting, child) {- final bool isDesktop = PlatformUtil.isDesktop();- final appBar = isDesktop && isSelecting && _currentGridColumns > 1- ? _buildDesktopSelectionAppBar(l10n)- : _buildStandardAppBar(l10n, isDesktop);- return PopScope(- canPop: false,- onPopInvokedWithResult: (_, result) async {- if (isSelecting) {- _codeDisplayStore.clearSelection();- return;- }+ Widget build(BuildContext context) {+ LockScreenSettings.instance+ .setLightMode(getEnteColorScheme(context).isLightTheme);+ final l10n = context.l10n;+ isCompactMode = PreferenceService.instance.isCompactMode();++ return ValueListenableBuilder<bool>(+ valueListenable: _codeDisplayStore.isSelectionModeActive,+ builder: (context, isSelecting, child) {+ final bool isDesktop = PlatformUtil.isDesktop();+ final appBar = isDesktop && isSelecting && _currentGridColumns > 1+ ? _buildDesktopSelectionAppBar(l10n)+ : _buildStandardAppBar(l10n, isDesktop);+ return PopScope(+ canPop: false,+ onPopInvokedWithResult: (_, result) async {+ if (isSelecting) {+ _codeDisplayStore.clearSelection();+ return;+ }- if (_isSettingsOpen) {- scaffoldKey.currentState!.closeDrawer();- return;- } else if (!Platform.isAndroid) {- Navigator.of(context).pop();- return;- }- await MoveToBackground.moveTaskToBack();- },- child: Scaffold(- key: scaffoldKey,- drawerEnableOpenDragGesture: !Platform.isAndroid,- drawer: Drawer(- width: 428,- child: _settingsPage,+ if (_isSettingsOpen) {+ scaffoldKey.currentState!.closeDrawer();+ return;+ } else if (!Platform.isAndroid) {+ Navigator.of(context).pop();+ return;+ }+ await MoveToBackground.moveTaskToBack();+ },+ child: Scaffold(+ key: scaffoldKey,+ drawerEnableOpenDragGesture: !Platform.isAndroid,+ drawer: Drawer(+ width: 428,+ child: _settingsPage,+ ),+ onDrawerChanged: (isOpened) => _isSettingsOpen = isOpened,+ body: SafeArea(+ bottom: false,+ child: Builder(+ builder: (context) {+ return _getBody();+ },+ ),+ ),+ bottomNavigationBar:+ isSelecting && (!isDesktop || _currentGridColumns <= 1)+ ? _buildSelectionActionBar()+ : null,+ resizeToAvoidBottomInset: false,+ appBar: appBar,+ floatingActionButton: isSelecting+ ? null+ : (!_hasLoaded ||+ (_allCodes?.isEmpty ?? true) ||+ !PreferenceService.instance.hasShownCoachMark()+ ? null+ : _getFab()),),- onDrawerChanged: (isOpened) => _isSettingsOpen = isOpened,- body: SafeArea(- bottom: false,- child: Builder(- builder: (context) {- return _getBody();+ );+ },+ );+ }++ PreferredSizeWidget _buildStandardAppBar(+ AppLocalizations l10n,+ bool isDesktop,+ ) {+ return AppBar(+ backgroundColor: Theme.of(context).scaffoldBackgroundColor,+ surfaceTintColor: Colors.transparent,+ title: !_showSearchBox+ ? const Text('Ente Auth', style: brandStyleMedium)+ : TextField(+ autocorrect: false,+ enableSuggestions: false,+ autofocus: _autoFocusSearch,+ controller: _textController,+ onChanged: (val) {+ _searchText = val;+ _applyFilteringAndRefresh();+ },+ decoration: InputDecoration(+ hintText: l10n.searchHint,+ border: InputBorder.none,+ focusedBorder: InputBorder.none,+ ),+ focusNode: searchBoxFocusNode,+ ),+ centerTitle: isDesktop ? false : true,+ actions: <Widget>[+ Padding(+ padding: const EdgeInsets.all(8.0),+ child: SortCodeMenuWidget(+ currentKey: PreferenceService.instance.codeSortKey(),+ onSelected: (newOrder) async {+ await PreferenceService.instance.setCodeSortKey(newOrder);+ if (newOrder == CodeSortKey.manual && newOrder == _codeSortKey) {+ await navigateToReorderPage(_allCodes!);+ }+ setState(() {+ _codeSortKey = newOrder;+ });+ if (mounted) {+ _applyFilteringAndRefresh();+ }},),- ),- bottomNavigationBar: isSelecting && (!isDesktop || _currentGridColumns <= 1)- ? _buildSelectionActionBar()- : null,- resizeToAvoidBottomInset: false,- appBar: appBar,- floatingActionButton: isSelecting- ? null- : (!_hasLoaded ||- (_allCodes?.isEmpty ?? true) ||- !PreferenceService.instance.hasShownCoachMark()- ? null- : _getFab()),),- );- },- );-}--PreferredSizeWidget _buildStandardAppBar(- AppLocalizations l10n,- bool isDesktop,-) {- return AppBar(- backgroundColor: Theme.of(context).scaffoldBackgroundColor,- surfaceTintColor: Colors.transparent,- title: !_showSearchBox- ? const Text('Ente Auth', style: brandStyleMedium)- : TextField(- autocorrect: false,- enableSuggestions: false,- autofocus: _autoFocusSearch,- controller: _textController,- onChanged: (val) {- _searchText = val;- _applyFilteringAndRefresh();+ if (isDesktop)+ IconButton(+ icon: const Icon(Icons.lock),+ tooltip: l10n.appLock,+ padding: const EdgeInsets.all(8.0),+ onPressed: () async {+ await navigateToLockScreen();},- decoration: InputDecoration(- hintText: l10n.searchHint,- border: InputBorder.none,- focusedBorder: InputBorder.none,- ),- focusNode: searchBoxFocusNode,),- centerTitle: isDesktop ? false : true,- actions: <Widget>[- Padding(- padding: const EdgeInsets.all(8.0),- child: SortCodeMenuWidget(- currentKey: PreferenceService.instance.codeSortKey(),- onSelected: (newOrder) async {- await PreferenceService.instance.setCodeSortKey(newOrder);- if (newOrder == CodeSortKey.manual && newOrder == _codeSortKey) {- await navigateToReorderPage(_allCodes!);- }- setState(() {- _codeSortKey = newOrder;- });- if (mounted) {- _applyFilteringAndRefresh();- }- },- ),- ),- if (isDesktop)IconButton(- icon: const Icon(Icons.lock),- tooltip: l10n.appLock,+ icon: _showSearchBox+ ? const Icon(Icons.clear)+ : const Icon(Icons.search),+ tooltip: l10n.search,padding: const EdgeInsets.all(8.0),- onPressed: () async {- await navigateToLockScreen();+ onPressed: () {+ setState(() {+ _showSearchBox = !_showSearchBox;+ if (!_showSearchBox) {+ _textController.clear();+ _searchText = "";+ } else {+ _searchText = _textController.text;+ searchBoxFocusNode.requestFocus();+ }+ _applyFilteringAndRefresh();+ });},),- IconButton(- icon:- _showSearchBox ? const Icon(Icons.clear) : const Icon(Icons.search),- tooltip: l10n.search,- padding: const EdgeInsets.all(8.0),- onPressed: () {- setState(() {- _showSearchBox = !_showSearchBox;- if (!_showSearchBox) {- _textController.clear();- _searchText = "";- } else {- _searchText = _textController.text;- searchBoxFocusNode.requestFocus();- }- _applyFilteringAndRefresh();- });- },- ),- ],- );-}+ ],+ );+ }-PreferredSizeWidget _buildDesktopSelectionAppBar(- AppLocalizations l10n,-) {- final visibleIds = _filteredCodes.map((c) => c.selectionKey).toSet();- return PreferredSize(- preferredSize: const Size.fromHeight(kToolbarHeight),- child: ValueListenableBuilder<Set<String>>(- valueListenable: _codeDisplayStore.selectedCodeIds,- builder: (context, selectedIds, _) {- final bool allVisibleSelected =- visibleIds.isNotEmpty && selectedIds.containsAll(visibleIds);- return AppBar(- backgroundColor: Theme.of(context).scaffoldBackgroundColor,- surfaceTintColor: Colors.transparent,- leadingWidth: 220,- leading: Padding(- padding: const EdgeInsets.only(left: 8.0),- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- IconButton(- icon: const Icon(Icons.close),- tooltip: l10n.cancel,- onPressed: () => _codeDisplayStore.clearSelection(),- ),- const SizedBox(width: 8),- Text(- '${selectedIds.length} ${l10n.selected}',- style: Theme.of(context)- .textTheme- .titleMedium- ?.copyWith(fontWeight: FontWeight.w600),- ),- ],- ),- ),- title: _buildDesktopActionRow(context),- centerTitle: true,- actions: [- _buildSelectAllChip(- context: context,- enabled: !allVisibleSelected,- onPressed: allVisibleSelected- ? null- : () {- final newSelection = Set<String>.from(visibleIds);- _codeDisplayStore.selectedCodeIds.value = newSelection;- _codeDisplayStore.isSelectionModeActive.value =- newSelection.isNotEmpty;- },+ PreferredSizeWidget _buildDesktopSelectionAppBar(+ AppLocalizations l10n,+ ) {+ final visibleIds = _filteredCodes.map((c) => c.selectionKey).toSet();+ return PreferredSize(+ preferredSize: const Size.fromHeight(kToolbarHeight),+ child: ValueListenableBuilder<Set<String>>(+ valueListenable: _codeDisplayStore.selectedCodeIds,+ builder: (context, selectedIds, _) {+ final bool allVisibleSelected =+ visibleIds.isNotEmpty && selectedIds.containsAll(visibleIds);+ return AppBar(+ backgroundColor: Theme.of(context).scaffoldBackgroundColor,+ surfaceTintColor: Colors.transparent,+ leadingWidth: 220,+ leading: Padding(+ padding: const EdgeInsets.only(left: 8.0),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ IconButton(+ icon: const Icon(Icons.close),+ tooltip: l10n.cancel,+ onPressed: () => _codeDisplayStore.clearSelection(),+ ),+ const SizedBox(width: 8),+ Text(+ '${selectedIds.length} ${l10n.selected}',+ style: Theme.of(context)+ .textTheme+ .titleMedium+ ?.copyWith(fontWeight: FontWeight.w600),+ ),+ ],+ ),),- const SizedBox(width: 12),- ],- );- },- ),- );-}+ title: _buildDesktopActionRow(context),+ centerTitle: true,+ actions: [+ _buildSelectAllChip(+ context: context,+ enabled: !allVisibleSelected,+ onPressed: allVisibleSelected+ ? null+ : () {+ final newSelection = Set<String>.from(visibleIds);+ _codeDisplayStore.selectedCodeIds.value = newSelection;+ _codeDisplayStore.isSelectionModeActive.value =+ newSelection.isNotEmpty;+ },+ ),+ const SizedBox(width: 12),+ ],+ );+ },+ ),+ );+ }Widget _getBody() {final l10n = context.l10n;- final crossAxisCount = _calculateGridColumnCount(context);- _currentGridColumns = crossAxisCount;- if (_hasLoaded) {- if (_filteredCodes.isEmpty && _searchText.isEmpty) {- return HomeEmptyStateWidget(- onScanTap: _redirectToScannerPage,- onManuallySetupTap: _redirectToManualEntryPage,+ final crossAxisCount = _calculateGridColumnCount(context);+ _currentGridColumns = crossAxisCount;+ if (_hasLoaded) {+ if (_filteredCodes.isEmpty && _searchText.isEmpty) {+ return HomeEmptyStateWidget(+ onScanTap: _redirectToScannerPage,+ onManuallySetupTap: _redirectToManualEntryPage,);} else {final anyCodeHasError =@@ -1706,7 +1729,8 @@ PreferredSizeWidget _buildDesktopSelectionAppBar(final List<Widget> actionButtons = [];- void addButton(String tooltip, IconData icon, VoidCallback? onPressed, {Widget? iconWidget}) {+ void addButton(String tooltip, IconData icon, VoidCallback? onPressed,+ {Widget? iconWidget}) {if (actionButtons.isNotEmpty) {actionButtons.add(const SizedBox(width: 12));}@@ -1723,7 +1747,8 @@ PreferredSizeWidget _buildDesktopSelectionAppBar(if (!allTrashed) {if (isMixedPinned) {- addButton(context.l10n.pinText, Icons.push_pin, () => _onPinSelectedPressed());+ addButton(context.l10n.pinText, Icons.push_pin,+ () => _onPinSelectedPressed());addButton(context.l10n.unpinText,Icons.push_pin,@@ -1738,20 +1763,28 @@ PreferredSizeWidget _buildDesktopSelectionAppBar(iconWidget: _buildUnpinIcon(context),);} else {- addButton(context.l10n.pinText, Icons.push_pin, () => _onPinSelectedPressed());+ addButton(context.l10n.pinText, Icons.push_pin,+ () => _onPinSelectedPressed());}- addButton(context.l10n.addTag, Icons.local_offer_outlined, _onAddTagPressed);- addButton(context.l10n.trash, Icons.delete_outline, () => _onTrashSelectedPressed());+ addButton(+ context.l10n.addTag, Icons.local_offer_outlined, _onAddTagPressed);+ addButton(context.l10n.trash, Icons.delete_outline,+ () => _onTrashSelectedPressed());if (singleCode != null) {- addButton(context.l10n.share, Icons.adaptive.share_outlined, () => _onSharePressed(singleCode));- addButton(context.l10n.qr, Icons.qr_code_2_outlined, () => _onShowQrPressed(singleCode));- addButton(context.l10n.edit, Icons.edit_outlined, () => _onEditPressed(singleCode));+ addButton(context.l10n.share, Icons.adaptive.share_outlined,+ () => _onSharePressed(singleCode));+ addButton(context.l10n.qr, Icons.qr_code_2_outlined,+ () => _onShowQrPressed(singleCode));+ addButton(context.l10n.edit, Icons.edit_outlined,+ () => _onEditPressed(singleCode));}} else {- addButton(context.l10n.restore, Icons.restore_outlined, () => _onRestoreSelectedPressed());- addButton(context.l10n.delete, Icons.delete_forever_outlined, () => _onDeleteForeverPressed());+ addButton(context.l10n.restore, Icons.restore_outlined,+ () => _onRestoreSelectedPressed());+ addButton(context.l10n.delete, Icons.delete_forever_outlined,+ () => _onDeleteForeverPressed());}return Row(@@ -1781,7 +1814,8 @@ PreferredSizeWidget _buildDesktopSelectionAppBar(child: Material(color: Colors.transparent,child: InkWell(- customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),+ customBorder:+ RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),onTap: onPressed,child: Container(decoration: BoxDecoration(@@ -1879,7 +1913,7 @@ PreferredSizeWidget _buildDesktopSelectionAppBar(animationCurve: Curves.elasticInOut,children: [SpeedDialChild(- child: const HugeIcon(icon: HugeIcons.strokeRoundedQrCode),+ child: const HugeIcon(icon: HugeIcons.strokeRoundedQrCode),foregroundColor: Theme.of(context).colorScheme.fabForegroundColor,backgroundColor: Theme.of(context).colorScheme.fabBackgroundColor,labelWidget: SpeedDialLabelWidget(context.l10n.scanAQrCode),@@ -1894,7 +1928,7 @@ PreferredSizeWidget _buildDesktopSelectionAppBar(),if (PlatformUtil.isMobile())SpeedDialChild(- child: const HugeIcon(icon: HugeIcons.strokeRoundedAlbum02),+ child: const HugeIcon(icon: HugeIcons.strokeRoundedAlbum02),backgroundColor: Theme.of(context).colorScheme.fabBackgroundColor,foregroundColor: Theme.of(context).colorScheme.fabForegroundColor,labelWidget: SpeedDialLabelWidget(context.l10n.importFromGallery),