π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] Hide pin concept in custom sort mode
Neeraj Gupta60bb28668d99
diff --git a/auth/lib/l10n/arb/app_en.arb b/auth/lib/l10n/arb/app_en.arbindex cc4139fc34..b50a464108 100644--- a/auth/lib/l10n/arb/app_en.arb+++ b/auth/lib/l10n/arb/app_en.arb@@ -451,10 +451,10 @@"customEndpoint": "Connected to {endpoint}","pinText": "Pin","unpinText": "Unpin",+ "pinnedCodeMessage": "{code} has been pinned",+ "unpinnedCodeMessage": "{code} has been unpinned",+ "pinned": "Pinned",- "favorites": "Favorites",- "favoritedCodeMessage": "{code} has been added to favorites",- "unfavoritedCodeMessage": "{code} has been removed from favorites","tags": "Tags","createNewTag": "Create New Tag","tag": "Tag",diff --git a/auth/lib/ui/code_widget.dart b/auth/lib/ui/code_widget.dartindex a350f3c67b..16c82c848b 100644--- a/auth/lib/ui/code_widget.dart+++ b/auth/lib/ui/code_widget.dart@@ -57,6 +57,7 @@ class _CodeWidgetState extends State<CodeWidget> {bool isMaskingEnabled = false;int _codeTimeStep = -1;int lastRefreshTime = 0;+ bool ignorePin = false;@overridevoid initState() {@@ -99,6 +100,7 @@ class _CodeWidgetState extends State<CodeWidget> {@overrideWidget build(BuildContext context) {+ ignorePin = widget.sortKey == null || widget.sortKey == CodeSortKey.manual;final colorScheme = getEnteColorScheme(context);if (isMaskingEnabled != PreferenceService.instance.shouldHideCodes()) {isMaskingEnabled = PreferenceService.instance.shouldHideCodes();@@ -117,7 +119,7 @@ class _CodeWidgetState extends State<CodeWidget> {Widget getCardContents(AppLocalizations l10n) {return Stack(children: [- if (widget.code.isPinned)+ if (!ignorePin && widget.code.isPinned)Align(alignment: Alignment.topRight,child: CustomPaint(@@ -171,7 +173,7 @@ class _CodeWidgetState extends State<CodeWidget> {: const SizedBox(height: 32),],),- if (widget.code.isPinned) ...[+ if (!ignorePin && widget.code.isPinned) ...[Align(alignment: Alignment.topRight,child: Padding(@@ -224,6 +226,7 @@ class _CodeWidgetState extends State<CodeWidget> {builder: (_) {return BottomActionBarWidget(code: widget.code,+ showPin: !ignorePin,onEdit: () => _onEditPressed(true),onShare: () => _onSharePressed(true),onPin: () => _onPinPressed(true),@@ -272,7 +275,7 @@ class _CodeWidgetState extends State<CodeWidget> {icon: Icons.notes_outlined,onSelected: () => _onShowNotesPressed(null),),- if (!widget.code.isTrashed)+ if (!widget.code.isTrashed && !ignorePin)MenuItem(label:widget.code.isPinned ? l10n.unpinText : l10n.pinText,@@ -602,8 +605,8 @@ class _CodeWidgetState extends State<CodeWidget> {(value) => showToast(context,!currentlyPinned- ? context.l10n.favoritedCodeMessage(widget.code.issuer)- : context.l10n.unfavoritedCodeMessage(widget.code.issuer),+ ? context.l10n.pinnedCodeMessage(widget.code.issuer)+ : context.l10n.unpinnedCodeMessage(widget.code.issuer),),),);diff --git a/auth/lib/ui/components/bottom_action_bar_widget.dart b/auth/lib/ui/components/bottom_action_bar_widget.dartindex ed25cf7308..e95ab678c2 100644--- a/auth/lib/ui/components/bottom_action_bar_widget.dart+++ b/auth/lib/ui/components/bottom_action_bar_widget.dart@@ -19,10 +19,12 @@ class BottomActionBarWidget extends StatelessWidget {final VoidCallback? onRestore;final VoidCallback? onDelete;final VoidCallback? onTrashed;+ final bool showPin;const BottomActionBarWidget({required this.code,this.onCancel,+ this.showPin = true,this.backgroundColor,super.key,this.onShare,@@ -65,6 +67,7 @@ class BottomActionBarWidget extends StatelessWidget {const SizedBox(height: 8),CodeSelectionActionsWidget(code: code,+ showPin: showPin,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.dartindex be2d17db1b..6ee1ed24fe 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 bool showPin;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.showPin = true,this.onShare,this.onPin,this.onShowQR,@@ -54,16 +56,18 @@ class _CodeSelectionActionsWidgetStateonTap: widget.onShare,),);-- items.add(- SelectionActionButton(- labelText: widget.code.isPinned- ? context.l10n.unpinText- : context.l10n.pinText,- icon: widget.code.isPinned ? Icons.push_pin_outlined : Icons.pin,- onTap: widget.onPin,- ),- );+ if (widget.showPin) {+ items.add(+ SelectionActionButton(+ labelText: widget.code.isPinned+ ? context.l10n.unpinText+ : context.l10n.pinText,+ icon:+ widget.code.isPinned ? Icons.push_pin : Icons.push_pin_outlined,+ onTap: widget.onPin,+ ),+ );+ }items.add(SelectionActionButton(diff --git a/auth/lib/ui/home_page.dart b/auth/lib/ui/home_page.dartindex 46630e5ab1..e18cfa45ae 100644--- a/auth/lib/ui/home_page.dart+++ b/auth/lib/ui/home_page.dart@@ -80,9 +80,7 @@ class _HomePageState extends State<HomePage> {bool hasTrashedCodes = false;bool hasNonTrashedCodes = false;bool isCompactMode = false;- bool _isFavouriteOpen = false;- bool hasFavouriteCodes = false;- bool hasNonFavouriteCodes = false;+late CodeSortKey _codeSortKey;@override@@ -117,8 +115,6 @@ class _HomePageState extends State<HomePage> {_allCodes = codes;hasTrashedCodes = false;hasNonTrashedCodes = false;- hasNonFavouriteCodes = false;- hasFavouriteCodes = false;for (final c in _allCodes ?? []) {if (c.isTrashed) {@@ -126,17 +122,8 @@ class _HomePageState extends State<HomePage> {} else {hasNonTrashedCodes = true;}- if (!c.isTrashed) {- if (c.isPinned) {- hasFavouriteCodes = true;- } else {- hasNonFavouriteCodes = true;- }- }- if (hasTrashedCodes &&- hasNonTrashedCodes &&- hasFavouriteCodes &&- hasNonFavouriteCodes) {++ if (hasTrashedCodes && hasNonTrashedCodes) {break;}}@@ -146,12 +133,6 @@ class _HomePageState extends State<HomePage> {if (!hasNonTrashedCodes && hasTrashedCodes) {_isTrashOpen = true;}- if (!hasFavouriteCodes) {- _isFavouriteOpen = false;- }- if (!hasNonFavouriteCodes && hasFavouriteCodes) {- _isFavouriteOpen = true;- }CodeDisplayStore.instance.getAllTags(allCodes: _allCodes).then((value) {tags = value;@@ -182,8 +163,7 @@ class _HomePageState extends State<HomePage> {if (codeState.hasError ||selectedTag != "" &&!codeState.display.tags.contains(selectedTag) ||- (codeState.isTrashed != _isTrashOpen) ||- (codeState.isPinned != _isFavouriteOpen && val.isEmpty)) {+ (codeState.isTrashed != _isTrashOpen)) {continue;}@@ -202,14 +182,6 @@ class _HomePageState extends State<HomePage> {).toList() ??[];- } else if (_isFavouriteOpen) {- _filteredCodes = _allCodes- ?.where(- (element) =>- !element.hasError && !element.isTrashed && element.isPinned,- )- .toList() ??- [];} else {_filteredCodes = _allCodes?.where(@@ -404,7 +376,8 @@ class _HomePageState extends State<HomePage> {currentKey: PreferenceService.instance.codeSortKey(),onSelected: (newOrder) async {await PreferenceService.instance.setCodeSortKey(newOrder);- if (newOrder == CodeSortKey.manual && newOrder == _codeSortKey) {+ if (newOrder == CodeSortKey.manual &&+ newOrder == _codeSortKey) {await navigateToReorderPage(_allCodes!);}setState(() {@@ -474,8 +447,7 @@ class _HomePageState extends State<HomePage> {_allCodes?.firstWhereOrNull((element) => element.hasError) != null;final indexOffset = anyCodeHasError ? 1 : 0;final itemCount = (hasNonTrashedCodes ? tags.length + 1 : 0) +- (hasTrashedCodes ? 1 : 0) +- (hasFavouriteCodes ? 1 : 0);+ (hasTrashedCodes ? 1 : 0);final list = Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -494,36 +466,19 @@ class _HomePageState extends State<HomePage> {if (index == 0 && hasNonTrashedCodes) {return TagChip(label: l10n.all,- state: selectedTag == "" &&- _isTrashOpen == false &&- _isFavouriteOpen == false+ state: selectedTag == "" && _isTrashOpen == false? TagChipState.selected: TagChipState.unselected,onTap: () {selectedTag = "";_isTrashOpen = false;- _isFavouriteOpen = false;- setState(() {});- _applyFilteringAndRefresh();- },- );- }- if (index == 1 && hasFavouriteCodes) {- return TagChip(- label: context.l10n.favorites,- state: _isFavouriteOpen- ? TagChipState.selected- : TagChipState.unselected,- onTap: () {- selectedTag = "";- _isTrashOpen = false;- _isFavouriteOpen = !_isFavouriteOpen;+setState(() {});_applyFilteringAndRefresh();},- // iconData: Icons.star,);}+if (index == itemCount - 1 && hasTrashedCodes) {return TagChip(label: l10n.trash,@@ -533,15 +488,13 @@ class _HomePageState extends State<HomePage> {onTap: () {selectedTag = "";_isTrashOpen = !_isTrashOpen;- _isFavouriteOpen = false;setState(() {});_applyFilteringAndRefresh();},iconData: Icons.delete,);}- final customTagIndex =- hasFavouriteCodes ? index - 2 : index - 1;+ final customTagIndex = index - 1;if (customTagIndex >= 0 && customTagIndex < tags.length) {return TagChip(label: tags[customTagIndex],@@ -551,7 +504,6 @@ class _HomePageState extends State<HomePage> {: TagChipState.unselected,onTap: () {_isTrashOpen = false;- _isFavouriteOpen = false;if (selectedTag == tags[customTagIndex]) {selectedTag = "";setState(() {});