Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 401
Animate changes to flexlayouts#1404
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
8aa64e4dbe7c617b06a0df557052244c0c829d73b6fee3ca663c4ff523f8f8fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -105,11 +105,34 @@ class LayoutProperties { | ||
| LayoutProperties(child, copyLevel: copyLevel - 1)) | ||
| ?.toList(growable: false); | ||
| LayoutProperties.values({ | ||
| @required this.node, | ||
| @required this.children, | ||
| @required this.constraints, | ||
| @required this.description, | ||
| @required this.flexFactor, | ||
| @required this.isFlex, | ||
| @required this.size, | ||
| }); | ||
| factory LayoutProperties.lerp( | ||
| LayoutProperties begin, LayoutProperties end, double t) { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: trailing comma? | ||
| return LayoutProperties.values( | ||
| node: end.node, | ||
| children: end.children, | ||
| constraints: BoxConstraints.lerp(begin.constraints, end.constraints, t), | ||
| description: end.description, | ||
| flexFactor: begin.flexFactor + (begin.flexFactor - end.flexFactor) * t, | ||
| isFlex: begin.isFlex && end.isFlex, | ||
| size: Size.lerp(begin.size, end.size, t), | ||
| ); | ||
| } | ||
| final RemoteDiagnosticsNode node; | ||
| final List<LayoutProperties> children; | ||
| final BoxConstraints constraints; | ||
| final String description; | ||
| final int flexFactor; | ||
| final num flexFactor; | ||
albertusdev marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| final bool isFlex; | ||
| final Size size; | ||
| @@ -172,13 +195,57 @@ class LayoutProperties { | ||
| double.parse(json['height']), | ||
| ); | ||
| } | ||
| LayoutProperties copyWith({ | ||
| List<LayoutProperties> children, | ||
| BoxConstraints constraints, | ||
| String description, | ||
| int flexFactor, | ||
| bool isFlex, | ||
| Size size, | ||
| }) { | ||
| return LayoutProperties.values( | ||
| node: node, | ||
| children: children ?? this.children, | ||
| constraints: constraints ?? this.constraints, | ||
| description: description ?? this.description, | ||
| flexFactor: flexFactor ?? this.flexFactor, | ||
| isFlex: isFlex ?? this.isFlex, | ||
| size: size ?? this.size, | ||
| ); | ||
| } | ||
| } | ||
| final Expando<FlexLayoutProperties> _flexLayoutExpando = Expando(); | ||
| /// TODO(albertusangga): Move this to [RemoteDiagnosticsNode] once dart:html app is removed | ||
| class FlexLayoutProperties extends LayoutProperties { | ||
| FlexLayoutProperties._( | ||
| FlexLayoutProperties({ | ||
| Size size, | ||
| List<LayoutProperties> children, | ||
| RemoteDiagnosticsNode node, | ||
| BoxConstraints constraints, | ||
| bool isFlex, | ||
| String description, | ||
| num flexFactor, | ||
| this.direction, | ||
| this.mainAxisAlignment, | ||
| this.crossAxisAlignment, | ||
| this.mainAxisSize, | ||
| this.textDirection, | ||
| this.verticalDirection, | ||
| this.textBaseline, | ||
| }) : super.values( | ||
| size: size, | ||
| children: children, | ||
| node: node, | ||
| constraints: constraints, | ||
| isFlex: isFlex, | ||
| description: description, | ||
| flexFactor: flexFactor, | ||
| ); | ||
| FlexLayoutProperties._fromNode( | ||
| RemoteDiagnosticsNode node, { | ||
| this.direction, | ||
| this.mainAxisAlignment, | ||
| @@ -197,6 +264,40 @@ class FlexLayoutProperties extends LayoutProperties { | ||
| return _flexLayoutExpando[node] ??= _buildNode(node); | ||
| } | ||
| @override | ||
| FlexLayoutProperties copyWith({ | ||
| Size size, | ||
| List<LayoutProperties> children, | ||
| BoxConstraints constraints, | ||
| bool isFlex, | ||
| String description, | ||
| num flexFactor, | ||
| Axis direction, | ||
| MainAxisAlignment mainAxisAlignment, | ||
| MainAxisSize mainAxisSize, | ||
| CrossAxisAlignment crossAxisAlignment, | ||
| TextDirection textDirection, | ||
| VerticalDirection verticalDirection, | ||
| TextBaseline textBaseline, | ||
| }) { | ||
| return FlexLayoutProperties( | ||
| size: size ?? this.size, | ||
| children: children ?? this.children, | ||
| node: node, | ||
| constraints: constraints ?? this.constraints, | ||
| isFlex: isFlex ?? this.isFlex, | ||
| description: description ?? this.description, | ||
| flexFactor: flexFactor ?? this.flexFactor, | ||
| direction: direction ?? this.direction, | ||
| mainAxisAlignment: mainAxisAlignment ?? this.mainAxisAlignment, | ||
| mainAxisSize: mainAxisSize ?? this.mainAxisSize, | ||
| crossAxisAlignment: crossAxisAlignment ?? this.crossAxisAlignment, | ||
| textDirection: textDirection ?? this.textDirection, | ||
| verticalDirection: verticalDirection ?? this.verticalDirection, | ||
| textBaseline: textBaseline ?? this.textBaseline, | ||
| ); | ||
| } | ||
| static FlexLayoutProperties _buildNode(RemoteDiagnosticsNode node) { | ||
| final Map<String, Object> renderObjectJson = node?.renderObject; | ||
| if (renderObjectJson == null) return null; | ||
| @@ -206,7 +307,7 @@ class FlexLayoutProperties extends LayoutProperties { | ||
| key: (property) => property['name'], | ||
| value: (property) => property['description'], | ||
| ); | ||
| return FlexLayoutProperties._( | ||
| return FlexLayoutProperties._fromNode( | ||
| node, | ||
| direction: _directionUtils.enumEntry(data['direction']), | ||
| mainAxisAlignment: | ||
| @@ -222,8 +323,8 @@ class FlexLayoutProperties extends LayoutProperties { | ||
| } | ||
| final Axis direction; | ||
| MainAxisAlignment mainAxisAlignment; | ||
| CrossAxisAlignment crossAxisAlignment; | ||
| final MainAxisAlignment mainAxisAlignment; | ||
| final CrossAxisAlignment crossAxisAlignment; | ||
| final MainAxisSize mainAxisSize; | ||
| final TextDirection textDirection; | ||
| final VerticalDirection verticalDirection; | ||
| @@ -245,11 +346,12 @@ class FlexLayoutProperties extends LayoutProperties { | ||
| String get type => direction == Axis.horizontal ? 'Row' : 'Column'; | ||
| int get totalFlex { | ||
| num get totalFlex { | ||
| if (children?.isEmpty ?? true) return 0; | ||
| _totalFlex ??= children | ||
| .map((child) => child.flexFactor ?? 0) | ||
| .reduce((value, element) => value + element); | ||
| .reduce((value, element) => value + element) | ||
| .toInt(); | ||
| return _totalFlex; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
nit: add extra line before the factory constructor?