Skip to content

Conversation

@ValentinVignal
Copy link
Contributor

Fixes #134654

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Sep 13, 2023
@ValentinVignal
Copy link
Contributor Author

I'm not too proud of the test. Do you have any idea how I could improve it?

@ValentinVignal
Copy link
Contributor Author

@Renzo-Olivares is there something I should do for this PR?

Copy link
Contributor

@Renzo-Olivares Renzo-Olivares left a comment

Choose a reason for hiding this comment

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

Hi @ValentinVignal thanks for the contribution! This looks awesome, I just had a few comments and suggestions for the test.

expect(actualPositionedBox.widthFactor, 2.0);
});


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this extra line is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

///
/// If the value of [crossAxisSizeFactor] is less than one, the child will be
/// clipped in the appropriate axis.
final double? crossAxisSizeFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment describing the default behavior when this is not defined. (The cross axis size is as large as the parent).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment in chore: Add assert and comment. Is that good enough?

///
/// If the value of [crossAxisSizeFactor] is less than one, the child will be
/// clipped in the appropriate axis.
final double? crossAxisSizeFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this should have a different name since it is not directly the counter of sizeFactor since it is not an animation.

Copy link
Contributor Author

@ValentinVignal ValentinVignal Sep 26, 2023

Choose a reason for hiding this comment

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

Sure! I'm all in for a different name, I wasn't really happy with this one. Would you have a suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe staticCrossAxisSizeFactor or fixedCrossAxisSizeFactor? I think its important to make it clear that the widget does not listen to this value and animate on it unlike sizeFactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to go with fixedCrossAxisSizeFactor and I renamed it in refactor: Rename parameter to fixedCrossAxisSizeFactor

textDirection: TextDirection.ltr,
child: SizeTransition(
sizeFactor: animation,
crossAxisSizeFactor: 2.0,
Copy link
Contributor

Choose a reason for hiding this comment

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

This test works to verify that the crossAxisSizeFactor is actually being passed but we should also add a test that verifies the intended behavior. Maybe that test could verify the size of the parent before/after the transition when crossAxisSizeFactor is set to 1.0. Before the size would be equal to the size of the child, and after it would be 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Nice idea! I added the test in test: Test the size transition cross axis size

this.axis = Axis.vertical,
required Animation<double> sizeFactor,
this.axisAlignment = 0.0,
this.crossAxisSizeFactor,
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably assert this value is non-negative since Align cannot take a non-negative size factor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the Align's assert in chore: Add assert and comment

expect(actualPositionedBox.heightFactor, 1.0);
});

testWidgetsWithLeakTracking('SizeTransition with crossAxisSizeFactor should size its cross axi from its children - vertical axis', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

axi -> axis. Same for horizontal test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops sorry about that. I fixed it in doc: Fix typo in test description

Copy link
Contributor

@Renzo-Olivares Renzo-Olivares left a comment

Choose a reason for hiding this comment

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

Left some comments. Thanks for making the changes!

await tester.pump();
expect(actualPositionedBox.heightFactor, 0.0);
expect(actualPositionedBox.widthFactor, 1.0);
expect(tester.getSize(find.byKey(key)), const Size(100, 0));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is an extra space in Size(100, 0).

await tester.pump();
expect(actualPositionedBox.heightFactor, 0.0);
expect(actualPositionedBox.widthFactor, 1.0);
expect(tester.getSize(find.byKey(key)), const Size(100, 0));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should remove this extra space here (100, 0).

await tester.pump();
expect(actualPositionedBox.heightFactor, 1.0);
expect(actualPositionedBox.widthFactor, 0.0);
expect(tester.getSize(find.byKey(key)), const Size(0, 100));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove extra space.

expect(tester.getSize(find.byKey(key)), const Size(100, 0));
});

testWidgetsWithLeakTracking('SizeTransition with crossAxisSizeFactor should size its cross axis from its children - horizontal axis', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: update name of crossAxisSizeFactor in tests.

@ValentinVignal
Copy link
Contributor Author

Oops sorry for those mistakes @Renzo-Olivares . I have fixed them in test: Better format the code and rename test description with fixedCr…

Copy link
Contributor

@Renzo-Olivares Renzo-Olivares left a comment

Choose a reason for hiding this comment

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

LGTM thank you for the contribution!

@Renzo-Olivares Renzo-Olivares changed the title Add SizeTransition.crossAxisSizeFactor Add SizeTransition.fixedCrossAxisSizeFactor Sep 27, 2023
@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 2, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 2, 2023
@auto-submit auto-submit bot merged commit b989428 into flutter:master Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a new parameter to SizeTransition to control the cross axis size factor

3 participants