mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 15:30:40 +00:00
[auth] Hide pin concept in custom sort mode
This commit is contained in:
parent
95127e6bcd
commit
60bb28668d
@ -451,10 +451,10 @@
|
|||||||
"customEndpoint": "Connected to {endpoint}",
|
"customEndpoint": "Connected to {endpoint}",
|
||||||
"pinText": "Pin",
|
"pinText": "Pin",
|
||||||
"unpinText": "Unpin",
|
"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",
|
"tags": "Tags",
|
||||||
"createNewTag": "Create New Tag",
|
"createNewTag": "Create New Tag",
|
||||||
"tag": "Tag",
|
"tag": "Tag",
|
||||||
|
@ -57,6 +57,7 @@ class _CodeWidgetState extends State<CodeWidget> {
|
|||||||
bool isMaskingEnabled = false;
|
bool isMaskingEnabled = false;
|
||||||
int _codeTimeStep = -1;
|
int _codeTimeStep = -1;
|
||||||
int lastRefreshTime = 0;
|
int lastRefreshTime = 0;
|
||||||
|
bool ignorePin = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -99,6 +100,7 @@ class _CodeWidgetState extends State<CodeWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
ignorePin = widget.sortKey == null || widget.sortKey == CodeSortKey.manual;
|
||||||
final colorScheme = getEnteColorScheme(context);
|
final colorScheme = getEnteColorScheme(context);
|
||||||
if (isMaskingEnabled != PreferenceService.instance.shouldHideCodes()) {
|
if (isMaskingEnabled != PreferenceService.instance.shouldHideCodes()) {
|
||||||
isMaskingEnabled = PreferenceService.instance.shouldHideCodes();
|
isMaskingEnabled = PreferenceService.instance.shouldHideCodes();
|
||||||
@ -117,7 +119,7 @@ class _CodeWidgetState extends State<CodeWidget> {
|
|||||||
Widget getCardContents(AppLocalizations l10n) {
|
Widget getCardContents(AppLocalizations l10n) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
if (widget.code.isPinned)
|
if (!ignorePin && widget.code.isPinned)
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
@ -171,7 +173,7 @@ class _CodeWidgetState extends State<CodeWidget> {
|
|||||||
: const SizedBox(height: 32),
|
: const SizedBox(height: 32),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (widget.code.isPinned) ...[
|
if (!ignorePin && widget.code.isPinned) ...[
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@ -224,6 +226,7 @@ class _CodeWidgetState extends State<CodeWidget> {
|
|||||||
builder: (_) {
|
builder: (_) {
|
||||||
return BottomActionBarWidget(
|
return BottomActionBarWidget(
|
||||||
code: widget.code,
|
code: widget.code,
|
||||||
|
showPin: !ignorePin,
|
||||||
onEdit: () => _onEditPressed(true),
|
onEdit: () => _onEditPressed(true),
|
||||||
onShare: () => _onSharePressed(true),
|
onShare: () => _onSharePressed(true),
|
||||||
onPin: () => _onPinPressed(true),
|
onPin: () => _onPinPressed(true),
|
||||||
@ -272,7 +275,7 @@ class _CodeWidgetState extends State<CodeWidget> {
|
|||||||
icon: Icons.notes_outlined,
|
icon: Icons.notes_outlined,
|
||||||
onSelected: () => _onShowNotesPressed(null),
|
onSelected: () => _onShowNotesPressed(null),
|
||||||
),
|
),
|
||||||
if (!widget.code.isTrashed)
|
if (!widget.code.isTrashed && !ignorePin)
|
||||||
MenuItem(
|
MenuItem(
|
||||||
label:
|
label:
|
||||||
widget.code.isPinned ? l10n.unpinText : l10n.pinText,
|
widget.code.isPinned ? l10n.unpinText : l10n.pinText,
|
||||||
@ -602,8 +605,8 @@ class _CodeWidgetState extends State<CodeWidget> {
|
|||||||
(value) => showToast(
|
(value) => showToast(
|
||||||
context,
|
context,
|
||||||
!currentlyPinned
|
!currentlyPinned
|
||||||
? context.l10n.favoritedCodeMessage(widget.code.issuer)
|
? context.l10n.pinnedCodeMessage(widget.code.issuer)
|
||||||
: context.l10n.unfavoritedCodeMessage(widget.code.issuer),
|
: context.l10n.unpinnedCodeMessage(widget.code.issuer),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -19,10 +19,12 @@ class BottomActionBarWidget extends StatelessWidget {
|
|||||||
final VoidCallback? onRestore;
|
final VoidCallback? onRestore;
|
||||||
final VoidCallback? onDelete;
|
final VoidCallback? onDelete;
|
||||||
final VoidCallback? onTrashed;
|
final VoidCallback? onTrashed;
|
||||||
|
final bool showPin;
|
||||||
|
|
||||||
const BottomActionBarWidget({
|
const BottomActionBarWidget({
|
||||||
required this.code,
|
required this.code,
|
||||||
this.onCancel,
|
this.onCancel,
|
||||||
|
this.showPin = true,
|
||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
super.key,
|
super.key,
|
||||||
this.onShare,
|
this.onShare,
|
||||||
@ -65,6 +67,7 @@ class BottomActionBarWidget extends StatelessWidget {
|
|||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
CodeSelectionActionsWidget(
|
CodeSelectionActionsWidget(
|
||||||
code: code,
|
code: code,
|
||||||
|
showPin: showPin,
|
||||||
onShare: onShare,
|
onShare: onShare,
|
||||||
onPin: onPin,
|
onPin: onPin,
|
||||||
onShowQR: onShowQR,
|
onShowQR: onShowQR,
|
||||||
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
class CodeSelectionActionsWidget extends StatefulWidget {
|
class CodeSelectionActionsWidget extends StatefulWidget {
|
||||||
final Code code;
|
final Code code;
|
||||||
|
final bool showPin;
|
||||||
final VoidCallback? onShare;
|
final VoidCallback? onShare;
|
||||||
final VoidCallback? onPin;
|
final VoidCallback? onPin;
|
||||||
final VoidCallback? onShowQR;
|
final VoidCallback? onShowQR;
|
||||||
@ -16,6 +17,7 @@ class CodeSelectionActionsWidget extends StatefulWidget {
|
|||||||
const CodeSelectionActionsWidget({
|
const CodeSelectionActionsWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.code,
|
required this.code,
|
||||||
|
this.showPin = true,
|
||||||
this.onShare,
|
this.onShare,
|
||||||
this.onPin,
|
this.onPin,
|
||||||
this.onShowQR,
|
this.onShowQR,
|
||||||
@ -54,16 +56,18 @@ class _CodeSelectionActionsWidgetState
|
|||||||
onTap: widget.onShare,
|
onTap: widget.onShare,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (widget.showPin) {
|
||||||
items.add(
|
items.add(
|
||||||
SelectionActionButton(
|
SelectionActionButton(
|
||||||
labelText: widget.code.isPinned
|
labelText: widget.code.isPinned
|
||||||
? context.l10n.unpinText
|
? context.l10n.unpinText
|
||||||
: context.l10n.pinText,
|
: context.l10n.pinText,
|
||||||
icon: widget.code.isPinned ? Icons.push_pin_outlined : Icons.pin,
|
icon:
|
||||||
|
widget.code.isPinned ? Icons.push_pin : Icons.push_pin_outlined,
|
||||||
onTap: widget.onPin,
|
onTap: widget.onPin,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
SelectionActionButton(
|
SelectionActionButton(
|
||||||
|
@ -80,9 +80,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
bool hasTrashedCodes = false;
|
bool hasTrashedCodes = false;
|
||||||
bool hasNonTrashedCodes = false;
|
bool hasNonTrashedCodes = false;
|
||||||
bool isCompactMode = false;
|
bool isCompactMode = false;
|
||||||
bool _isFavouriteOpen = false;
|
|
||||||
bool hasFavouriteCodes = false;
|
|
||||||
bool hasNonFavouriteCodes = false;
|
|
||||||
late CodeSortKey _codeSortKey;
|
late CodeSortKey _codeSortKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -117,8 +115,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
_allCodes = codes;
|
_allCodes = codes;
|
||||||
hasTrashedCodes = false;
|
hasTrashedCodes = false;
|
||||||
hasNonTrashedCodes = false;
|
hasNonTrashedCodes = false;
|
||||||
hasNonFavouriteCodes = false;
|
|
||||||
hasFavouriteCodes = false;
|
|
||||||
|
|
||||||
for (final c in _allCodes ?? []) {
|
for (final c in _allCodes ?? []) {
|
||||||
if (c.isTrashed) {
|
if (c.isTrashed) {
|
||||||
@ -126,17 +122,8 @@ class _HomePageState extends State<HomePage> {
|
|||||||
} else {
|
} else {
|
||||||
hasNonTrashedCodes = true;
|
hasNonTrashedCodes = true;
|
||||||
}
|
}
|
||||||
if (!c.isTrashed) {
|
|
||||||
if (c.isPinned) {
|
if (hasTrashedCodes && hasNonTrashedCodes) {
|
||||||
hasFavouriteCodes = true;
|
|
||||||
} else {
|
|
||||||
hasNonFavouriteCodes = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasTrashedCodes &&
|
|
||||||
hasNonTrashedCodes &&
|
|
||||||
hasFavouriteCodes &&
|
|
||||||
hasNonFavouriteCodes) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,12 +133,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
if (!hasNonTrashedCodes && hasTrashedCodes) {
|
if (!hasNonTrashedCodes && hasTrashedCodes) {
|
||||||
_isTrashOpen = true;
|
_isTrashOpen = true;
|
||||||
}
|
}
|
||||||
if (!hasFavouriteCodes) {
|
|
||||||
_isFavouriteOpen = false;
|
|
||||||
}
|
|
||||||
if (!hasNonFavouriteCodes && hasFavouriteCodes) {
|
|
||||||
_isFavouriteOpen = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeDisplayStore.instance.getAllTags(allCodes: _allCodes).then((value) {
|
CodeDisplayStore.instance.getAllTags(allCodes: _allCodes).then((value) {
|
||||||
tags = value;
|
tags = value;
|
||||||
@ -182,8 +163,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
if (codeState.hasError ||
|
if (codeState.hasError ||
|
||||||
selectedTag != "" &&
|
selectedTag != "" &&
|
||||||
!codeState.display.tags.contains(selectedTag) ||
|
!codeState.display.tags.contains(selectedTag) ||
|
||||||
(codeState.isTrashed != _isTrashOpen) ||
|
(codeState.isTrashed != _isTrashOpen)) {
|
||||||
(codeState.isPinned != _isFavouriteOpen && val.isEmpty)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,14 +182,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
)
|
)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
[];
|
[];
|
||||||
} else if (_isFavouriteOpen) {
|
|
||||||
_filteredCodes = _allCodes
|
|
||||||
?.where(
|
|
||||||
(element) =>
|
|
||||||
!element.hasError && !element.isTrashed && element.isPinned,
|
|
||||||
)
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
} else {
|
} else {
|
||||||
_filteredCodes = _allCodes
|
_filteredCodes = _allCodes
|
||||||
?.where(
|
?.where(
|
||||||
@ -404,7 +376,8 @@ class _HomePageState extends State<HomePage> {
|
|||||||
currentKey: PreferenceService.instance.codeSortKey(),
|
currentKey: PreferenceService.instance.codeSortKey(),
|
||||||
onSelected: (newOrder) async {
|
onSelected: (newOrder) async {
|
||||||
await PreferenceService.instance.setCodeSortKey(newOrder);
|
await PreferenceService.instance.setCodeSortKey(newOrder);
|
||||||
if (newOrder == CodeSortKey.manual && newOrder == _codeSortKey) {
|
if (newOrder == CodeSortKey.manual &&
|
||||||
|
newOrder == _codeSortKey) {
|
||||||
await navigateToReorderPage(_allCodes!);
|
await navigateToReorderPage(_allCodes!);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -474,8 +447,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
_allCodes?.firstWhereOrNull((element) => element.hasError) != null;
|
_allCodes?.firstWhereOrNull((element) => element.hasError) != null;
|
||||||
final indexOffset = anyCodeHasError ? 1 : 0;
|
final indexOffset = anyCodeHasError ? 1 : 0;
|
||||||
final itemCount = (hasNonTrashedCodes ? tags.length + 1 : 0) +
|
final itemCount = (hasNonTrashedCodes ? tags.length + 1 : 0) +
|
||||||
(hasTrashedCodes ? 1 : 0) +
|
(hasTrashedCodes ? 1 : 0);
|
||||||
(hasFavouriteCodes ? 1 : 0);
|
|
||||||
|
|
||||||
final list = Column(
|
final list = Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -494,36 +466,19 @@ class _HomePageState extends State<HomePage> {
|
|||||||
if (index == 0 && hasNonTrashedCodes) {
|
if (index == 0 && hasNonTrashedCodes) {
|
||||||
return TagChip(
|
return TagChip(
|
||||||
label: l10n.all,
|
label: l10n.all,
|
||||||
state: selectedTag == "" &&
|
state: selectedTag == "" && _isTrashOpen == false
|
||||||
_isTrashOpen == false &&
|
|
||||||
_isFavouriteOpen == false
|
|
||||||
? TagChipState.selected
|
? TagChipState.selected
|
||||||
: TagChipState.unselected,
|
: TagChipState.unselected,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
selectedTag = "";
|
selectedTag = "";
|
||||||
_isTrashOpen = false;
|
_isTrashOpen = false;
|
||||||
_isFavouriteOpen = false;
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
_applyFilteringAndRefresh();
|
_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) {
|
if (index == itemCount - 1 && hasTrashedCodes) {
|
||||||
return TagChip(
|
return TagChip(
|
||||||
label: l10n.trash,
|
label: l10n.trash,
|
||||||
@ -533,15 +488,13 @@ class _HomePageState extends State<HomePage> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
selectedTag = "";
|
selectedTag = "";
|
||||||
_isTrashOpen = !_isTrashOpen;
|
_isTrashOpen = !_isTrashOpen;
|
||||||
_isFavouriteOpen = false;
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
_applyFilteringAndRefresh();
|
_applyFilteringAndRefresh();
|
||||||
},
|
},
|
||||||
iconData: Icons.delete,
|
iconData: Icons.delete,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final customTagIndex =
|
final customTagIndex = index - 1;
|
||||||
hasFavouriteCodes ? index - 2 : index - 1;
|
|
||||||
if (customTagIndex >= 0 && customTagIndex < tags.length) {
|
if (customTagIndex >= 0 && customTagIndex < tags.length) {
|
||||||
return TagChip(
|
return TagChip(
|
||||||
label: tags[customTagIndex],
|
label: tags[customTagIndex],
|
||||||
@ -551,7 +504,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
: TagChipState.unselected,
|
: TagChipState.unselected,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_isTrashOpen = false;
|
_isTrashOpen = false;
|
||||||
_isFavouriteOpen = false;
|
|
||||||
if (selectedTag == tags[customTagIndex]) {
|
if (selectedTag == tags[customTagIndex]) {
|
||||||
selectedTag = "";
|
selectedTag = "";
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user