Skip to content

[Personal WIP] Story of Layout feature #1

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

Closed
wants to merge 35 commits into from
Closed

Conversation

albertusdev
Copy link
Owner

@albertusdev albertusdev commented Oct 23, 2019

A PR to show my progress on working on this feature.

Dependency:

@albertusdev
Copy link
Owner Author

albertusdev commented Oct 23, 2019

Check-in 1:

  • Show BoxConstraints next to the summary tree
  • Highlight constraints of widget that unconstrained it's child

image

@albertusdev
Copy link
Owner Author

albertusdev commented Oct 24, 2019

Check-in 2:

  • Rename Show Constraints button to Layout button (change term of showConstraints to debugLayoutModeEnabled)
  • Change color from red to yellow (Dangerous to Warning, since we are unsure whether it's really an error)
  • Highlight children that got unconstrained by its parents (highlight the contraints text)
  • Highlight the parent widget name that unconstrained its child
  • Show fade-in/fade-out animation when Debug Layout mode

Concerns:

  • performance on Flutter web since I'm using ValueNotifier & ValueListenableBuilder for all of the inspector row nodes

image

@albertusdev
Copy link
Owner Author

albertusdev commented Oct 24, 2019

Check-in 3:

  • Made very early prototype on explaining Flex layouting (the feature for now will be temporarily called 'Story of Your Flex Widget')
  • Visualizing Flex and able to detect the Flex type (Row/Column)
  • Displaying correct amount of children and all of the children's widget name
  • All children are still equally weighted for this check in

image
image

@@ -4,6 +4,7 @@

import 'dart:math';

import 'package:devtools_app/src/ui/fake_flutter/_real_flutter.dart';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto imports are doing the wrong thing. just go ahead and import
'package:flutter/material.dart'

final Map<String, Object> flexDetails = node.diagnostic?.json['flex'];
final int numOfChildren = node.diagnostic.childrenNow.length;
final List<Widget> children = node.diagnostic.childrenNow.map((RemoteDiagnosticsNode child) => Expanded(
flex: 1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can now use List comprehensions for this sort of case in dart. so
[for (var child in node.diagnostic.childrenNow)
Container(something something)
];

children: [
Container(
margin: const EdgeInsets.only(bottom: 4.0),
child: const Text('Story of Your Flex Widget', style: TextStyle(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the name of the widget class. So:
'Story of the flex layout of your ${diagnostic.description} widget'
so
Story of the flex layout of your Column widget
or
Story of the flex layout of your Row widget.

@override
Widget build(BuildContext context) {
final Map<String, Object> flexDetails = node.diagnostic?.json['flex'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting to see this!
Go ahead and add getters for the extra json fields you add to RemoteDiagnosticsNode.

),
Expanded(
child: Container(
color: Colors.blue,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to use colors from the Theme whenever possible. That will make the ui work in dark and light theme.
See calls to Theme.of in the code for examples.

@albertusdev
Copy link
Owner Author

albertusdev commented Oct 24, 2019

Check in 4:

  • Avoid using hardcoded color and instead use Color from Theme (to support Light/Dark theme)
  • Remove hack in InspectorTree node
  • Remove wrong import
  • Rename 'Story of your Flex widget' to 'Story of the layout of your Row/Column widget'

TODOs for tomorrow:

  • Choose more contrasts and sutiable colors
  • Display Flex widget size, constraints, main axis and cross axis
  • Properly size Flex children

Screenshots:
image

@albertusdev
Copy link
Owner Author

Check in 5:

Changelist:

  • Create proper deserializer method for flex properties from DiagnosticsNode
  • Create new flag (isExperimentalStoryOfLayoutEnabled) in InspectorTreeFlutterController to prevent showing all this features changes until my PR (github.com/Story of layout PR flutter#2) is landed to Flutter main repository
  • Inspector details tree now live inside of Tabs! User can focus on layout details instead if they want to.
  • Removed animation from DianogsticsNodeDescriptions for now (due to minor performance concerns and adding new flag, might add it later!)
  • Changed hardcoded constants for Buttons in InspectorScreen to prevent button groups expanding to two lines

Screenshots:

  • Inspector screen have tabs now!
    image

TODOs:

  • Remove // constraints word from ConstraintsDescriptor
  • Highlight only unconstrained word in the ConstraintsDescriptor
  • Move StoryOfYourFlexWidget from Dialog to Tab

Albertus Angga Raharja added 8 commits October 24, 2019 20:30
…rent widget that did the unconstraining, and add animation
…pport Light/Dark theme)

- Remove hack in InspectorTree node
- Remove wrong import
- Rename 'Story of your Flex widget' to 'Story of the layout of your Row/Column widget'
… for details tree, and several minor changes.

- Create proper deserializer method for flex properties from DiagnosticsNode
- Create new flag (`isExperimentalStoryOfLayoutEnabled`) in `InspectorTreeFlutterController` to prevent showing all this features changes until my PR (github.com/albertusdev/flutter/pull/2) is landed to Flutter main repository
- Inspector details tree now live inside of Tabs! User can focus on layout details instead if they want to.
- Removed animation from DianogsticsNodeDescriptions for now (due to minor performance concerns and adding new flag, might add it later!)
- Changed hardcoded constants for Buttons in InspectorScreen to prevent button groups expanding to two lines
Repository owner locked as off-topic and limited conversation to collaborators Oct 28, 2019
@albertusdev albertusdev changed the title [WIP] Story of Layout feature [Personal WIP] Story of Layout feature Oct 28, 2019
@albertusdev albertusdev force-pushed the story-of-layout branch 2 times, most recently from 69e4ce0 to fb9c121 Compare October 29, 2019 02:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants