Skip to content

Commit

Permalink
feat: add "show in main log" and "show in context" right-click actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatNerdSquared committed Jan 3, 2025
1 parent 4a97c0c commit 35fc595
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
15 changes: 14 additions & 1 deletion lib/context_menus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,29 @@ scm.Menu buildEntryCardContextMenu({
required bool isEncrypted,
required VoidCallback toggleEncryptCallback,
required Function(String) addAncestorCallback,
required VoidCallback showInContextCallback,
required VoidCallback showInMainLogCallback,
}) =>
scm.Menu(
children: [
scm.MenuAction(
title: 'Add as ancestor',
callback: () => addAncestorCallback(entryId),
),
scm.MenuSeparator(),
scm.MenuAction(
title: 'Show in Context',
callback: showInContextCallback,
),
scm.MenuAction(
title: 'Show in Main Log',
callback: showInMainLogCallback,
),
scm.MenuSeparator(),
scm.MenuAction(
title: 'Copy Entry URL',
callback: () => Clipboard.setData(ClipboardData(text: 'peregrine://peregrine/entry/$entryId')),
callback: () => Clipboard.setData(
ClipboardData(text: 'peregrine://peregrine/entry/$entryId')),
),
scm.MenuAction(
title: isEncrypted ? 'Decrypt Entry' : 'Encrypt Entry',
Expand Down
8 changes: 8 additions & 0 deletions lib/model/entry_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ class PeregrineEntryFilter extends StateNotifier<EntryFilter> {
name: state.name,
icon: state.icon);
}

void clearSearch() {
state = EntryFilter(
includes: {...state.includes, FilterType.search: ''},
excludes: state.excludes,
name: state.name,
icon: state.icon);
}
}

enum FilterType { search, tag, contact }
Expand Down
31 changes: 22 additions & 9 deletions lib/widgets/peregrine_entry_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,28 @@ class _PeregrineEntryCardState extends ConsumerState<PeregrineEntryCard> {
: Container(),
scm.ContextMenuWidget(
menuProvider: (_) => buildEntryCardContextMenu(
isEncrypted: entry.isEncrypted,
toggleEncryptCallback: () => ref
.read(entryListProvider.notifier)
.toggleEncrypt(widget.entryId),
entryId: widget.entryId,
addAncestorCallback: (_) => ref
.read(currentAncestorsProvider.notifier)
.addAncestor(widget.entryId),
),
isEncrypted: entry.isEncrypted,
toggleEncryptCallback: () => ref
.read(entryListProvider.notifier)
.toggleEncrypt(widget.entryId),
entryId: widget.entryId,
addAncestorCallback: (_) => ref
.read(currentAncestorsProvider.notifier)
.addAncestor(widget.entryId),
showInContextCallback: () {
ref.read(entryFilterProvider.notifier).clearSearch();
ref
.read(currentJumpIdProvider.notifier)
.update((_) => widget.entryId);
},
showInMainLogCallback: () {
ref
.read(entryFilterProvider.notifier)
.setAllEntriesFilter();
ref
.read(currentJumpIdProvider.notifier)
.update((_) => widget.entryId);
}),
child: PretCard(
padding: EdgeInsets.only(
top: PretConfig.thinElementSpacing,
Expand Down

0 comments on commit 35fc595

Please sign in to comment.