[auth] Rename pin/unpin to fav/unfav

This commit is contained in:
Neeraj Gupta 2024-12-04 12:17:13 +05:30
parent bdf31e99e2
commit 94b09acaaa
3 changed files with 35 additions and 32 deletions

View File

@ -447,8 +447,10 @@
"customEndpoint": "Connected to {endpoint}", "customEndpoint": "Connected to {endpoint}",
"pinText": "Pin", "pinText": "Pin",
"unpinText": "Unpin", "unpinText": "Unpin",
"pinnedCodeMessage": "{code} has been pinned", "fav": "Favorite",
"unpinnedCodeMessage": "{code} has been unpinned", "unfav": "Unfavorite",
"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",

View File

@ -113,20 +113,27 @@ class _CodeWidgetState extends State<CodeWidget> {
final l10n = context.l10n; final l10n = context.l10n;
Widget getCardContents(AppLocalizations l10n) { Widget getCardContents(AppLocalizations l10n) {
// final bool isFavorite = widget.code.isPinned;
return Stack( return Stack(
children: [ children: [
if (widget.code.isPinned) // if (isFavorite)
Align( // Align(
alignment: Alignment.topRight, // alignment: Alignment.topRight,
child: CustomPaint( // child: Icon(
painter: PinBgPainter( // Icons.star,
color: colorScheme.pinnedBgColor, // color: colorScheme.pinnedBgColor,
), // size: widget.isCompactMode ? 16 : 24,
size: widget.isCompactMode // ),
? const Size(24, 24) // //
: const Size(39, 39), // // child: CustomPaint(
), // // painter: PinBgPainter(
), // // color: colorScheme.pinnedBgColor,
// // ),
// // size: widget.isCompactMode
// // ? const Size(24, 24)
// // : const Size(39, 39),
// // ),
// ),
if (widget.code.isTrashed && kDebugMode) if (widget.code.isTrashed && kDebugMode)
Align( Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
@ -172,15 +179,10 @@ class _CodeWidgetState extends State<CodeWidget> {
if (widget.code.isPinned) ...[ if (widget.code.isPinned) ...[
Align( Align(
alignment: Alignment.topRight, alignment: Alignment.topRight,
child: Padding( child: Icon(
padding: widget.isCompactMode Icons.star,
? const EdgeInsets.only(right: 4, top: 4) color: colorScheme.primary700.withOpacity(0.4),
: const EdgeInsets.only(right: 6, top: 6), size: widget.isCompactMode ? 16 : 24,
child: SvgPicture.asset(
"assets/svg/pin-card.svg",
width: widget.isCompactMode ? 8 : null,
height: widget.isCompactMode ? 8 : null,
),
), ),
), ),
], ],
@ -272,11 +274,10 @@ class _CodeWidgetState extends State<CodeWidget> {
), ),
if (!widget.code.isTrashed) if (!widget.code.isTrashed)
MenuItem( MenuItem(
label: label: widget.code.isPinned ? l10n.unfav : l10n.fav,
widget.code.isPinned ? l10n.unpinText : l10n.pinText,
icon: widget.code.isPinned icon: widget.code.isPinned
? Icons.push_pin ? Icons.star_border
: Icons.push_pin_outlined, : Icons.star_border_outlined,
onSelected: () => _onPinPressed(null), onSelected: () => _onPinPressed(null),
), ),
if (!widget.code.isTrashed) if (!widget.code.isTrashed)
@ -579,8 +580,8 @@ class _CodeWidgetState extends State<CodeWidget> {
(value) => showToast( (value) => showToast(
context, context,
!currentlyPinned !currentlyPinned
? context.l10n.pinnedCodeMessage(widget.code.issuer) ? context.l10n.favoritedCodeMessage(widget.code.issuer)
: context.l10n.unpinnedCodeMessage(widget.code.issuer), : context.l10n.unfavoritedCodeMessage(widget.code.issuer),
), ),
), ),
); );

View File

@ -58,9 +58,9 @@ class _CodeSelectionActionsWidgetState
items.add( items.add(
SelectionActionButton( SelectionActionButton(
labelText: widget.code.isPinned labelText: widget.code.isPinned
? context.l10n.unpinText ? context.l10n.unfav
: context.l10n.pinText, : context.l10n.fav,
icon: widget.code.isPinned ? Icons.push_pin : Icons.push_pin_outlined, icon: widget.code.isPinned ? Icons.star_outline : Icons.star,
onTap: widget.onPin, onTap: widget.onPin,
), ),
); );