Skip to content

Commit

Permalink
Fixed hang
Browse files Browse the repository at this point in the history
Was using TreeController.search !
TODO - fix TargetsWrapper misplacement of target covers and btns
  • Loading branch information
biancashouse committed Apr 18, 2024
1 parent e9f5ad5 commit d948fba
Show file tree
Hide file tree
Showing 40 changed files with 910 additions and 1,319 deletions.
46 changes: 23 additions & 23 deletions example/.firebase/hosting.YnVpbGRcd2Vi.cache
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
favicon.png,1708776909321,0cab6e3dd5a9f008afdd133e1e1207cf65f2f2a10eb6712e3c209d8a5f76425a
flutter.js,1712123089908,f5a14edb95c81962fa23eaaae56e126c490103fa2f18b3ad825460cbdc0f9e4e
index.html.jic,1712203008730,450d91343d6c4e4ebf643feca4fbd233cbf13f2fddb65dbad43f1408f0d32494
index.tmpl.html,1708776904218,db354b8f2b060e79f22237c8fa4a0a126f8476dd3a0145e032db1f94e12dc069
manifest.json,1708776904218,0bee7a1ad8c8853d3f1aa1a5c004c9b00e0e3915e451e5107e058dba069c93f4
assets/assets/images/bridging-the-gap-logo.jpeg,1709603134636,bc7eef7612f77cde161d7d53a5167d95e922c62e5e3728adbf5f088c45545fb6
Expand All @@ -23,31 +25,29 @@ assets/packages/flutter_content/lib/assets/images/google-icons/sheets.png,170877
assets/packages/flutter_content/lib/assets/images/google-icons/slides.png,1708776908129,436dd120a01caf9220cccf50e91b583df115c1d31ca22f935f999cb4793b8515
assets/startup-scripts/cats-config.json,1708776904214,8c5026aa006dd1496109e5f281e294a41549117c13984dd0072b6ec3e53a35c7
assets/startup-scripts/example-config.json,1708854933099,96f1f0e89604299954ebe5111c267ad7e2ab5e56fe4b1cb7bc09693cef0c1dcc
icons/Icon-192.png,1708776908536,eaf2464bfb1d192fdd192a616f7b858dee456d573c6ec619648a1dcf2bdddfa6
icons/Icon-512.png,1708776908252,9cf4cd298ae95acc1f25e97d88aa3f6bbfdf40867ea0f8a854c4393f49d56e64
icons/Icon-maskable-192.png,1708776908525,196ce9142a3442ab37ae90cd46c3389e4660400c859b81cbb0538a51b39752eb
icons/Icon-maskable-512.png,1708776907913,6833b7c449e0dd24d5e164a53cc4557e643893e675b476b05efcbb9a6aa05bf0
flutter.js,1712123089908,f5a14edb95c81962fa23eaaae56e126c490103fa2f18b3ad825460cbdc0f9e4e
index.html,1712235360526,2a22090e8bcb777a63d1e888f7c9d1c9ff328004211dc5b951516d076fc079ab
version.json,1712235358793,5681baaa8d2e258cbb0fd11e3aaa16eb218980d545af5756808375b7ecd21223
flutter_service_worker.js,1712235361120,97289c92f94e45df3dab4339ce1fd7f0b4aaffb9621951356e9e00b5ea2fb877
index.html.jic,1712203008730,450d91343d6c4e4ebf643feca4fbd233cbf13f2fddb65dbad43f1408f0d32494
assets/AssetManifest.bin,1712235358970,101f9f07c8e751f633efa97add0bfa613ae630b70ad9e37516359e239477d127
assets/AssetManifest.bin.json,1712235358970,eb37bcd3ca1b6e57b043db66299a15547884275782168e4aecc033a426fffabf
assets/AssetManifest.json,1712235358970,27719e640c59cfede9c314523fba5389928da66b3a6ff6dc760d70c884c932f3
assets/FontManifest.json,1712235358970,e38b95988f5d060cf9b7ce97cb5ac9236d6f4cc04a11d69567df97b2b4cbc5e5
assets/packages/cupertino_icons/assets/CupertinoIcons.ttf,1712235360501,f59150eed777f87591658721b2d83b7c24a09b2bd3195480a4bf864753afdec7
assets/fonts/MaterialIcons-Regular.otf,1712235360506,bf484ea31013eb523ec79e8714ebdfed95885f34175d58ffab39b67f0a8bafab
assets/shaders/ink_sparkle.frag,1712235359091,591c7517d5cb43eb91ea451e0d3f9f585cbf8298cf6c46a9144b77cb0775a406
canvaskit/skwasm.worker.js,1712123089906,3fd50075667dba6e3822f8300deafbd0236ef4ddaa09228f2d07fefdfc22c905
canvaskit/canvaskit.js,1712123089824,78fcd45d44f595265e49e58d7de7be7c0f272b8028a7f2fa7f885cdd55ddfa3e
canvaskit/skwasm.js,1712123089883,ea7b5728dd099712b1ee59c47cadffab7891c3612f4567edc838fdeceded3560
canvaskit/chromium/canvaskit.js,1712123089858,765f1da9cc7d4436b770238da368cde4175891ee3efe25b1d527f89085676c56
assets/NOTICES,1712235358971,3613e4947f596874592f90b0b07798b99e7c6cef14423479823ffaa5c3038d08
canvaskit/chromium/canvaskit.js.symbols,1712123089862,3d33b487a1e36b6145e0efe7a3f6f9826844301de61343a6761e22f3030ed3d9
canvaskit/canvaskit.js.symbols,1712123089828,128193b5dcf67bd21064f3a0e3144f40ca5d994a29f6548235ca5c14d3648a24
canvaskit/canvaskit.wasm,1712123089857,146684bc3d008b6447f94d6fccd220e7952e0d91f16db5665787739cf78e2788
canvaskit/skwasm.js,1712123089883,ea7b5728dd099712b1ee59c47cadffab7891c3612f4567edc838fdeceded3560
canvaskit/skwasm.js.symbols,1712123089887,f91e30b4c5f94a2c35f80b1c75d6db43d23602dbca69f243242b0b15d5b914d6
canvaskit/skwasm.wasm,1712123089905,d03ac87729205c75879766cbcd225e669a9766552d3b64a08b255116e23f4671
canvaskit/skwasm.worker.js,1712123089906,3fd50075667dba6e3822f8300deafbd0236ef4ddaa09228f2d07fefdfc22c905
canvaskit/chromium/canvaskit.js,1712123089858,765f1da9cc7d4436b770238da368cde4175891ee3efe25b1d527f89085676c56
canvaskit/chromium/canvaskit.js.symbols,1712123089862,3d33b487a1e36b6145e0efe7a3f6f9826844301de61343a6761e22f3030ed3d9
canvaskit/chromium/canvaskit.wasm,1712123089882,d39a626014748054f5ec9b684bfecf18dd19e640643e4ba5b98a21e62e4b61ab
main.dart.js,1712235006867,1859d5c5cf98a6f57b6d34d4ef2eae31efb24db5628c3389ef9ae3567e7317e1
canvaskit/canvaskit.wasm,1712123089857,146684bc3d008b6447f94d6fccd220e7952e0d91f16db5665787739cf78e2788
icons/Icon-192.png,1708776908536,eaf2464bfb1d192fdd192a616f7b858dee456d573c6ec619648a1dcf2bdddfa6
icons/Icon-512.png,1708776908252,9cf4cd298ae95acc1f25e97d88aa3f6bbfdf40867ea0f8a854c4393f49d56e64
icons/Icon-maskable-192.png,1708776908525,196ce9142a3442ab37ae90cd46c3389e4660400c859b81cbb0538a51b39752eb
icons/Icon-maskable-512.png,1708776907913,6833b7c449e0dd24d5e164a53cc4557e643893e675b476b05efcbb9a6aa05bf0
index.html,1712913513955,e6f4673e6d41947e0176dbfb7f6391e1705c518543c06775aaffc51e7243ef4e
version.json,1712913512006,6efb30111b65a2f22066243372af8bb04b0d78674339231ec3396704896cfeb3
flutter_service_worker.js,1712913514574,b730fc789066c27499da61fe37382f50cb30e8a00a7295e25d8b2707f045189a
assets/AssetManifest.json,1712913512235,27719e640c59cfede9c314523fba5389928da66b3a6ff6dc760d70c884c932f3
assets/AssetManifest.bin,1712913512235,101f9f07c8e751f633efa97add0bfa613ae630b70ad9e37516359e239477d127
assets/AssetManifest.bin.json,1712913512236,eb37bcd3ca1b6e57b043db66299a15547884275782168e4aecc033a426fffabf
assets/FontManifest.json,1712913512236,e38b95988f5d060cf9b7ce97cb5ac9236d6f4cc04a11d69567df97b2b4cbc5e5
assets/packages/cupertino_icons/assets/CupertinoIcons.ttf,1712913513933,f59150eed777f87591658721b2d83b7c24a09b2bd3195480a4bf864753afdec7
assets/fonts/MaterialIcons-Regular.otf,1712913513934,bf484ea31013eb523ec79e8714ebdfed95885f34175d58ffab39b67f0a8bafab
assets/shaders/ink_sparkle.frag,1712913512371,591c7517d5cb43eb91ea451e0d3f9f585cbf8298cf6c46a9144b77cb0775a406
assets/NOTICES,1712913512236,7f0ca623fc52a4001d2b45470963eac5dac71299ded3c35ac5f23f349b13fb4a
main.dart.js,1712913511301,80045edcd904773be66b54bbbac2de08ad0dfd8245a60485cf6ef6f51fcb4130
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Future<void> main() async {
initialValueJsonAssetPath: "startup-scripts/example-config.json",
webHome: const FlutterContentPage(
panelName: 'home',
snippetName: 'example-home',
snippetName: 'example-home-4',
fromTemplate: SnippetTemplate.empty_snippet,
),
// webHome: const ZoomerSamplePage(),
Expand Down
3 changes: 2 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: example
description: "Example website project to demo the flutter_content pkg."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 0.9.0+18
version: 0.9.1+18

environment:
sdk: '>=3.2.3 <4.0.0'
Expand All @@ -29,3 +29,4 @@ flutter:
assets:
- assets/images/
- startup-scripts/

40 changes: 21 additions & 19 deletions lib/flutter_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ typedef EncodedSnippetJson = String;
typedef JsonMap = Map<String, dynamic>;
typedef SizeFunc = Size Function();
typedef PosFunc = Offset Function();
typedef TargetsWrapperName = String;

typedef DoubleFunc = double Function();

Expand Down Expand Up @@ -338,15 +337,17 @@ class FC {
void addToSnippetCache({
required SnippetName snippetName,
required SnippetRootNode rootNode,
required VersionId initialVersionId,
required bool editing,
required VersionId versionId,
// required bool editing,
}) {
debugPrint('addToSnippetCache($snippetName)');
snippetCache.addAll({
snippetName: {initialVersionId: rootNode}
});
updateEditingVersionId(
snippetName: snippetName, newVersionId: initialVersionId);
if (snippetCache.containsKey(snippetName)) {
snippetCache[snippetName]![versionId] = rootNode;
} else {
snippetCache.addAll({
snippetName: {versionId: rootNode}
});
}
}

void updateEditingVersionId({
Expand Down Expand Up @@ -390,7 +391,6 @@ class FC {
/// Docs about CFBundleVersion: https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion
late CAPIBloC capiBloc;
Map<TargetsWrapperName, GlobalKey> targetsWrappers = {};
late bool
_skipAssetPkgName; // when using assets from within the flutter_content pkg itself
late List<String> _googleFontNames;
Expand All @@ -403,12 +403,12 @@ class FC {

final inEditMode = ValueNotifier<bool>(false);

bool get canEditContent =>
HydratedBloc.storage.read("canEditContent") ?? false;
bool get canEditContent => true;
// HydratedBloc.storage.read("canEditContent") ?? false;

void setCanEdit(bool b) => HydratedBloc.storage.write("canEditContent", b);

Offset calloutConfigToolbarPos(context) =>
Offset calloutConfigToolbarPos() =>
_calloutConfigToolbarPos ??
Offset(
Useful.scrW / 2 - 350,
Expand All @@ -432,8 +432,7 @@ class FC {
_handlers[name];

// each snippet panel has a gk, a last selected node, and a ur
final Map<GlobalKey, STreeNode> gkSTreeNodeMap =
{}; // every node's toWidget() creates a GK
final Map<GlobalKey, STreeNode> gkSTreeNodeMap = {}; // every node's toWidget() creates a GK
final Map<PanelName, SnippetName> snippetPlacementMap = {};
final Map<PanelName, GlobalKey> panelGkMap = {};
final List<ScrollController> registeredScrollControllers = [];
Expand All @@ -454,13 +453,16 @@ class FC {
// Snippet Stack
final Queue<SnippetBloC> _snippetsBeingEdited = Queue<SnippetBloC>();

SnippetBloC? get snippetBeingEdited =>
areAnySnippetsBeingEdited ? _snippetsBeingEdited.first : null;
SnippetBloC? get snippetBeingEdited {
return _snippetsBeingEdited.isNotEmpty ? _snippetsBeingEdited.first : null;
}

bool get areAnySnippetsBeingEdited => _snippetsBeingEdited.isNotEmpty;

void pushSnippet(SnippetBloC snippetBloc) {
_snippetsBeingEdited.addFirst(snippetBloc);
debugPrint("snippetBeingEdited is $snippetBeingEdited");
return;
}

SnippetBloC? popSnippet() =>
Expand Down Expand Up @@ -493,8 +495,8 @@ class FC {
return gk;
}

TargetsWrapperState? parentTW(String twName) =>
FC().targetsWrappers[twName]?.currentState as TargetsWrapperState?;
// TargetsWrapperState? parentTW(String twName) =>
// FC().targetsWrappers[twName]?.currentState as TargetsWrapperState?;

// final FeatureList _singleTargetBtnFeatures = [];

Expand All @@ -504,7 +506,7 @@ class FC {

STreeNode? get selectedNode => snippetBeingEdited?.state.selectedNode;

STreeNode? get highlightedNode => snippetBeingEdited?.state.highlightedNode;
// STreeNode? get highlightedNode => snippetBeingEdited?.state.highlightedNode;

SnippetTreeController? get currentTreeC => snippetBeingEdited?.state.treeC;

Expand Down
18 changes: 16 additions & 2 deletions lib/src/api/snippet_panel/callout_snippet_tree_and_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_content/flutter_content.dart';
import 'package:flutter_content/src/api/snippet_panel/callout_snippet_tree_and_properties_content.dart';
import 'package:flutter_content/src/bloc/snippet_event.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';

// void removeSnippetTreeCallout(String snippetName) => Callout.removeOverlay(snippetName);
Expand All @@ -14,8 +15,8 @@ import 'package:hydrated_bloc/hydrated_bloc.dart';
//
// void refreshSnippetTreeCallout(String snippetName) => Callout.refreshOverlay(snippetName);

CalloutConfig
snippetTreeCalloutConfig(SnippetBloC snippetBloc, VoidCallback onDismissedF) {
CalloutConfig snippetTreeCalloutConfig(
SnippetBloC snippetBloc, VoidCallback onDismissedF) {
double width() {
double? w = HydratedBloc.storage.read("snippet-tree-callout-width");
if (w != null) return w.abs();
Expand Down Expand Up @@ -96,6 +97,9 @@ void showSnippetTreeAndPropertiesCallout({
ScrollController? ancestorHScrollController,
ScrollController? ancestorVScrollController,
required VoidCallback onDismissedF,
required STreeNode startingAtNode,
required STreeNode? selectedNode,
required STreeNode tappedNode,
bool allowButtonCallouts = false,
}) async {
STreeNode rootNode = snippetBloc.state.rootNode;
Expand Down Expand Up @@ -123,6 +127,16 @@ void showSnippetTreeAndPropertiesCallout({
},
targetGkF: targetGKF,
);
// imm select a node
STreeNode sel = selectedNode ?? startingAtNode;
snippetBloc.add(SnippetEvent.selectNode(
node: sel,
selectedTreeNodeGK: GlobalKey(debugLabel: 'selectedTreeNodeGK'),
// imageTC: tc,
));
Useful.afterNextBuildDo(() {
tappedNode.showNodeWidgetOverlay();
});
}

// void _clearSelection() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ class SnippetTreeAndPropertiesCalloutContents extends HookWidget {
// some properties cannot be deleted!snippetBloc.state.selectedNode.canBeDeleted()
// some properties cannot be deleted
if (!snippetBloc.state.selectedNode.canBeDeleted()) return;
bool wasShowingAsRoot = snippetBloc.state.selectedNode == snippetBloc.treeC.roots.first;
STreeNode? parentNode = snippetBloc.state.selectedNode.parent as STreeNode?;
Callout.dismiss(SELECTED_NODE_BORDER_CALLOUT);
snippetBloc.add(const SnippetEvent.deleteNodeTapped());
Useful.afterNextBuildDo(() async {
Expand All @@ -368,6 +370,13 @@ class SnippetTreeAndPropertiesCalloutContents extends HookWidget {
// if was tab or tabview, reset the tab Q and controller
SnippetPanelState? spState = SnippetPanel.of(context);
spState?.resetTabQandC;
// redraw tree if deleted node was root
if (wasShowingAsRoot && parentNode != null) {
snippetBloc.add(SnippetEvent.selectNode(
node: parentNode,
selectedTreeNodeGK: GlobalKey(debugLabel: 'selectedTreeNodeGK'),
));
}
});
});
Callout.dismiss("TreeNodeMenu");
Expand Down Expand Up @@ -407,38 +416,38 @@ class SnippetTreeAndPropertiesCalloutContents extends HookWidget {
),
tooltip: 'Save a a new Snippet...',
),
IconButton(
hoverColor: Colors.white30,
onPressed: () async {
// some properties cannot be deleted!snippetBloc.state.selectedNode.canBeDeleted()
// some properties cannot be deleted
if (!snippetBloc.state.selectedNode.canBeDeleted()) return;
Callout.dismiss(SELECTED_NODE_BORDER_CALLOUT);
snippetBloc.add(const SnippetEvent.deleteNodeTapped());
Useful.afterNextBuildDo(() async {
await Future.delayed(const Duration(milliseconds: 1000));
snippetBloc.add(const SnippetEvent.completeDeletion());
Useful.afterNextBuildDo(() {
// if was tab or tabview, reset the tab Q and controller
SnippetPanelState? spState = SnippetPanel.of(context);
spState?.resetTabQandC;
});
});
Callout.dismiss("TreeNodeMenu");
},
icon: Icon(Icons.delete,
color: Colors.red.withOpacity(
!snippetBloc.state.aNodeIsSelected ||
snippetBloc.state.selectedNode
is SnippetRefNode ||
(gc is GenericSingleChildNode? &&
gc?.parent is StepNode &&
(gc?.propertyName == 'title' ||
gc?.propertyName == 'content'))
? .5
: 1.0)),
tooltip: 'Remove',
),
// IconButton(
// hoverColor: Colors.white30,
// onPressed: () async {
// // some properties cannot be deleted!snippetBloc.state.selectedNode.canBeDeleted()
// // some properties cannot be deleted
// if (!snippetBloc.state.selectedNode.canBeDeleted()) return;
// Callout.dismiss(SELECTED_NODE_BORDER_CALLOUT);
// snippetBloc.add(const SnippetEvent.deleteNodeTapped());
// Useful.afterNextBuildDo(() async {
// await Future.delayed(const Duration(milliseconds: 1000));
// snippetBloc.add(const SnippetEvent.completeDeletion());
// Useful.afterNextBuildDo(() {
// // if was tab or tabview, reset the tab Q and controller
// SnippetPanelState? spState = SnippetPanel.of(context);
// spState?.resetTabQandC;
// });
// });
// Callout.dismiss("TreeNodeMenu");
// },
// icon: Icon(Icons.delete,
// color: Colors.red.withOpacity(
// !snippetBloc.state.aNodeIsSelected ||
// snippetBloc.state.selectedNode
// is SnippetRefNode ||
// (gc is GenericSingleChildNode? &&
// gc?.parent is StepNode &&
// (gc?.propertyName == 'title' ||
// gc?.propertyName == 'content'))
// ? .5
// : 1.0)),
// tooltip: 'Remove',
// ),
],
),
// tree structure icon buttons
Expand Down Expand Up @@ -646,7 +655,8 @@ class SnippetTreePane extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
navigateUpTreeButton(context),
if (snippetBloc.treeC.roots.first.parent is! SnippetRootNode)
navigateUpTreeButton(context),
Expanded(
child: SnippetTreeView(snippetBloc: snippetBloc)),
],
Expand Down Expand Up @@ -675,7 +685,7 @@ class SnippetTreePane extends StatelessWidget {
snippetBloc.add(SnippetEvent.selectNode(
node: parent!,
// imageTC: tc,
selectedWidgetGK: GlobalKey(debugLabel: 'selectedWidgetGK'),
// selectedWidgetGK: GlobalKey(debugLabel: 'selectedWidgetGK'),
selectedTreeNodeGK: GlobalKey(debugLabel: 'selectedTreeNodeGK'),
));
Useful.afterNextBuildDo(() {
Expand Down
Loading

0 comments on commit d948fba

Please sign in to comment.