Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 401
[Story of Your Layout] Interactive flex factor changer#1402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
albertusdev
merged 20 commits into
flutter:master
from
albertusdev:story-of-layout-flex-factor-changerNov 26, 2019
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9765325
attempt to remove flag
2f1b95e
group manager
80e2ec9
Merge branch 'master' of github.com:flutter/devtools into story-of-la…
29fd311
debug this
59cd30d
Remove StoryOfYourFlexWidget dependency to experimental flag
b1f1744
Remove unnecessary changes
965c3a0
Fix minor bugs and remove unnecessary functions
35efc51
Adjust TODOs
cc68a22
Merge branch 'master' into story-of-layout-avoid-flutter-framework-ch…
kenzieschmoll b21fd22
Fix minor bug and changes
e6433b1
Add flex factor changer and make InspectorScreenDetailsTab act only a…
3f7b586
Re-enable details tab test in InspectorScreen
c6c09bd
Add .flutter-plugins-dependencies to .gitignore
64816b1
Rename variables and remove print statement
c46fb95
Merge branch 'master' of github.com:flutter/devtools into story-of-la…
5c28248
Remove experimental flag from Flex feature, disable goldens, and code…
2703dfe
Add comment
7c96d61
Rename responsibleWidget to rootWidget
cd9b113
Remove unnecessary comment
58c8117
More clean ups
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
37 changes: 23 additions & 14 deletions
37 packages/devtools_app/lib/src/inspector/flutter/inspector_data_models.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 17 additions & 70 deletions
87 packages/devtools_app/lib/src/inspector/flutter/inspector_screen_details_tab.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,8 +8,6 @@ import 'package:flutter/widgets.dart'; | ||
| import '../diagnostics_node.dart'; | ||
| import '../inspector_controller.dart'; | ||
| import '../inspector_service.dart'; | ||
| import 'inspector_data_models.dart'; | ||
| import 'story_of_your_layout/flex.dart'; | ||
| class InspectorDetailsTabController extends StatelessWidget { | ||
| @@ -37,17 +35,15 @@ class InspectorDetailsTabController extends StatelessWidget { | ||
| Widget build(BuildContext context) { | ||
| final tabs = <Tab>[ | ||
| _buildTab('Details Tree'), | ||
| if (InspectorController.enableExperimentalStoryOfLayout) | ||
| _buildTab('Layout Details'), | ||
| _buildTab('Layout Details'), | ||
| ]; | ||
| final tabViews = <Widget>[ | ||
| detailsTree, | ||
| if (InspectorController.enableExperimentalStoryOfLayout) | ||
| Banner( | ||
| message: 'PROTOTYPE', | ||
| location: BannerLocation.topStart, | ||
| child: LayoutDetailsTab(controller: controller), | ||
| ), | ||
| Banner( | ||
| message: 'PROTOTYPE', | ||
| location: BannerLocation.topStart, | ||
| child: LayoutDetailsTab(controller: controller), | ||
| ), | ||
| ]; | ||
| final focusColor = Theme.of(context).focusColor; | ||
| return Container( | ||
| @@ -92,6 +88,7 @@ class InspectorDetailsTabController extends StatelessWidget { | ||
| } | ||
| } | ||
| /// Tab that acts as a proxy to decide which widget to be displayed | ||
| class LayoutDetailsTab extends StatefulWidget { | ||
| const LayoutDetailsTab({Key key, this.controller}) : super(key: key); | ||
| @@ -107,67 +104,27 @@ class _LayoutDetailsTabState extends State<LayoutDetailsTab> | ||
| RemoteDiagnosticsNode get selected => controller?.selectedNode?.diagnostic; | ||
| InspectorObjectGroupManager objectGroupManager; | ||
| RemoteDiagnosticsNode root; | ||
| RemoteDiagnosticsNode previousSelection; | ||
| RemoteDiagnosticsNode getRoot(RemoteDiagnosticsNode node) { | ||
| if (!StoryOfYourFlexWidget.shouldDisplay(node)) return null; | ||
| if (node.isFlex) return node; | ||
| return node.parent; | ||
| Widget rootWidget(RemoteDiagnosticsNode node) { | ||
| if (StoryOfYourFlexWidget.shouldDisplay(node)) | ||
| return StoryOfYourFlexWidget(controller); | ||
| return const SizedBox(); | ||
| } | ||
| void onSelectionChanged() async { | ||
| if (!StoryOfYourFlexWidget.shouldDisplay(selected)) { | ||
| setState(() => root = null); | ||
| return; | ||
| void onSelectionChanged() { | ||
| if (rootWidget(previousSelection).runtimeType != | ||
| rootWidget(selected).runtimeType) { | ||
| setState(() => previousSelection = selected); | ||
| } | ||
| final shouldFetch = | ||
| root?.dartDiagnosticRef?.id != getRoot(selected)?.dartDiagnosticRef?.id; | ||
| if (shouldFetch) { | ||
| objectGroupManager.cancelNext(); | ||
| // TODO(albertusangga) show loading animation when root is null? | ||
| setState(() { | ||
| root = null; | ||
| }); | ||
| final nextObjectGroup = objectGroupManager.next; | ||
| root = await nextObjectGroup.getDetailsSubtreeWithRenderObject( | ||
| selected.isFlex ? selected : selected.parent, | ||
| subtreeDepth: 1, | ||
| ); | ||
| if (!nextObjectGroup.disposed) { | ||
| assert(objectGroupManager.next == nextObjectGroup); | ||
| objectGroupManager.promoteNext(); | ||
| } | ||
| } | ||
| setState(() {}); | ||
| } | ||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| updateObjectGroupManager(); | ||
| controller.addSelectionListener(onSelectionChanged); | ||
| } | ||
| void updateObjectGroupManager() { | ||
| final service = controller.inspectorService; | ||
| if (service != objectGroupManager?.inspectorService) { | ||
| objectGroupManager = InspectorObjectGroupManager( | ||
| service, | ||
| 'flex-layout', | ||
| ); | ||
| } | ||
| onSelectionChanged(); | ||
| } | ||
| @override | ||
| void didUpdateWidget(Widget oldWidget) { | ||
| super.didUpdateWidget(oldWidget); | ||
| updateObjectGroupManager(); | ||
| } | ||
| @override | ||
| void dispose() { | ||
| controller.removeSelectionListener(onSelectionChanged); | ||
| @@ -177,17 +134,7 @@ class _LayoutDetailsTabState extends State<LayoutDetailsTab> | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| super.build(context); | ||
albertusdev marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // TODO(albertusangga): Visualize non-flex widget constraint model | ||
| if (root == null || !StoryOfYourFlexWidget.shouldDisplay(selected)) | ||
| return const SizedBox(); | ||
| final flexLayoutProperties = FlexLayoutProperties.fromDiagnostics(root); | ||
| final highlightChild = | ||
| selected.isFlex ? null : selected.parent.childrenNow.indexOf(selected); | ||
| return StoryOfYourFlexWidget( | ||
| flexLayoutProperties, | ||
| highlightChild: highlightChild, | ||
| inspectorController: controller, | ||
| ); | ||
| return rootWidget(selected); | ||
| } | ||
| @override | ||
16 changes: 16 additions & 0 deletions
16 packages/devtools_app/lib/src/inspector/flutter/inspector_service_flutter_extension.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this happen ever? Consider an assert: assert(node != null);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but just to be safe since we are getting the node by fetching from the framework side?