Skip to content

Commit

Permalink
feat: wrap ancestors + preview via tooltip, switch to super_context_menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatNerdSquared committed May 26, 2024
1 parent 54fe38d commit 6c98aa1
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 58 deletions.
54 changes: 27 additions & 27 deletions lib/context_menus.dart
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import 'package:pret_a_porter/pret_a_porter.dart';
import 'package:super_context_menu/super_context_menu.dart' as scm;

import 'export_utils.dart';
import 'model/entry_data.dart';
import 'model/tag_data.dart';

Menu buildTagButtonContextMenu(
scm.Menu buildTagButtonContextMenu(
String tagName,
PeregrineTag tagInfo,
Function(String) autoEncryptToggleCallback,
List<PeregrineEntry> entries,
) =>
Menu(
items: [
MenuItem.checkbox(
label: 'Auto Encrypt',
checked: tagInfo.autoEncrypt,
onClick: (_) => autoEncryptToggleCallback(tagName),
scm.Menu(
children: [
scm.MenuAction(
title: 'Auto Encrypt',
state: tagInfo.autoEncrypt
? scm.MenuActionState.checkOn
: scm.MenuActionState.checkOff,
callback: () => autoEncryptToggleCallback(tagName),
),
MenuItem.submenu(
label: 'Export as...',
submenu: Menu(
items: [
MenuItem(
label: 'Markdown',
onClick: (_) => exportMarkdown(
entries: entries,
logName: tagName,
),
scm.Menu(
title: 'Export as...',
children: [
scm.MenuAction(
title: 'Markdown',
callback: () => exportMarkdown(
entries: entries,
logName: tagName,
),
],
),
)
),
],
),
],
);

Menu buildEntryCardContextMenu({
scm.Menu buildEntryCardContextMenu({
required String entryId,
required Function(String) addAncestorCallback,
}) =>
Menu(
items: [
MenuItem(
label: 'Add as ancestor',
onClick: (_) => addAncestorCallback(entryId),
scm.Menu(
children: [
scm.MenuAction(
title: 'Add as ancestor',
callback: () => addAncestorCallback(entryId),
)
],
);
44 changes: 32 additions & 12 deletions lib/widgets/entry_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:pret_a_porter/pret_a_porter.dart';
import 'package:super_context_menu/super_context_menu.dart' as scm;
import 'package:super_sliver_list/super_sliver_list.dart';

import '../config.dart';
Expand Down Expand Up @@ -55,18 +56,37 @@ class EntryListViewState extends ConsumerState<EntryListView> {
? CupertinoScrollbar(
controller: _scrollController, child: listView)
: listView),
Wrap(
Row(
children: ref
.watch(currentAncestorsProvider)
.map((id) => ContextMenuRegion(
contextMenu: Menu(items: [
MenuItem(
label: 'Remove as ancestor',
onClick: (_) => ref
.read(currentAncestorsProvider.notifier)
.removeAncestor(id))
]),
child: PretCard(child: Text(id))))
.map((id) => Flexible(
child: Tooltip(
richMessage: WidgetSpan(
child: PeregrineEntryCard(
entryId: id,
isTopLevel: false,
),
),
decoration: const BoxDecoration(
color: Colors.transparent,
),
child: scm.ContextMenuWidget(
menuProvider: (_) => scm.Menu(children: [
scm.MenuAction(
title: 'Remove as ancestor',
callback: () => ref
.read(currentAncestorsProvider
.notifier)
.removeAncestor(id))
]),
child: PretCard(
child: Text(
id,
overflow: TextOverflow.ellipsis,
),
)),
),
))
.toList(),
),
Padding(
Expand Down Expand Up @@ -95,8 +115,8 @@ class EntryListViewState extends ConsumerState<EntryListView> {
itemCount: entries.length,
itemBuilder: (context, index) {
var entryId = entries[index];
return ContextMenuRegion(
contextMenu: buildEntryCardContextMenu(
return scm.ContextMenuWidget(
menuProvider: (_) => buildEntryCardContextMenu(
entryId: entryId,
addAncestorCallback: (_) => ref
.read(currentAncestorsProvider.notifier)
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:pret_a_porter/pret_a_porter.dart';
import 'package:super_context_menu/super_context_menu.dart';

import '../context_menus.dart';
import '../main.dart';
Expand Down Expand Up @@ -74,8 +75,8 @@ class Sidebar extends ConsumerWidget {
padding: const EdgeInsets.only(
left: PretConfig.defaultElementSpacing,
right: PretConfig.defaultElementSpacing),
child: ContextMenuRegion(
contextMenu: buildTagButtonContextMenu(
child: ContextMenuWidget(
menuProvider: (_) => buildTagButtonContextMenu(
tagName,
tags[tagName]!,
(name) =>
Expand Down
8 changes: 8 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
#include "generated_plugin_registrant.h"

#include <contextual_menu/contextual_menu_plugin.h>
#include <irondash_engine_context/irondash_engine_context_plugin.h>
#include <super_native_extensions/super_native_extensions_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) contextual_menu_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ContextualMenuPlugin");
contextual_menu_plugin_register_with_registrar(contextual_menu_registrar);
g_autoptr(FlPluginRegistrar) irondash_engine_context_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "IrondashEngineContextPlugin");
irondash_engine_context_plugin_register_with_registrar(irondash_engine_context_registrar);
g_autoptr(FlPluginRegistrar) super_native_extensions_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SuperNativeExtensionsPlugin");
super_native_extensions_plugin_register_with_registrar(super_native_extensions_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
2 changes: 2 additions & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

list(APPEND FLUTTER_PLUGIN_LIST
contextual_menu
irondash_engine_context
super_native_extensions
url_launcher_linux
)

Expand Down
6 changes: 6 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import FlutterMacOS
import Foundation

import contextual_menu
import device_info_plus
import irondash_engine_context
import path_provider_foundation
import super_native_extensions
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ContextualMenuPlugin.register(with: registry.registrar(forPlugin: "ContextualMenuPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SuperNativeExtensionsPlugin.register(with: registry.registrar(forPlugin: "SuperNativeExtensionsPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
20 changes: 19 additions & 1 deletion macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
PODS:
- contextual_menu (0.0.1):
- FlutterMacOS
- device_info_plus (0.0.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- irondash_engine_context (0.0.1):
- FlutterMacOS
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- super_native_extensions (0.0.1):
- FlutterMacOS
- url_launcher_macos (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- contextual_menu (from `Flutter/ephemeral/.symlinks/plugins/contextual_menu/macos`)
- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- irondash_engine_context (from `Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- super_native_extensions (from `Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)

EXTERNAL SOURCES:
contextual_menu:
:path: Flutter/ephemeral/.symlinks/plugins/contextual_menu/macos
device_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos
FlutterMacOS:
:path: Flutter/ephemeral
irondash_engine_context:
:path: Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
super_native_extensions:
:path: Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos

SPEC CHECKSUMS:
contextual_menu: 6d35fb15942c0d8769f5eae8d3bda653994a6f5a
device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95

PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading

0 comments on commit 6c98aa1

Please sign in to comment.