Skip to content

122 UniformItemsLayout#216

Merged
TheCodeTraveler merged 13 commits intomainfrom
122-uniform-grid
Feb 15, 2022
Merged

122 UniformItemsLayout#216
TheCodeTraveler merged 13 commits intomainfrom
122-uniform-grid

Conversation

@VladislavAntonyuk
Copy link
Copy Markdown
Contributor

Fixes

#122

Description

Migrate UniformGrid to MCT
image

@VladislavAntonyuk VladislavAntonyuk force-pushed the 122-uniform-grid branch 2 times, most recently from 5b79950 to 44f78fa Compare December 10, 2021 21:44
@pictos pictos added the do not merge Do not merge this PR label Dec 11, 2021
@pictos
Copy link
Copy Markdown
Member

pictos commented Dec 11, 2021

Adding the do-not-merge because the #214 has priority

@TheCodeTraveler TheCodeTraveler removed the do not merge Do not merge this PR label Dec 14, 2021
Copy link
Copy Markdown
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

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

Hey Vlad!

Let's Update 2 Things:

  • Move UniformGrid from the Views folder/namespace to Layouts folder + namespace
    • Technically, UniformGrid is a View, but since it contains List<IView> Children, it is more accurate to define it as a Layout
  • Rearchitect UniformGrid
    • Let's have UniformGrid inherit from Layout instead Grid, e.g. public class UniformGrid : Layout
    • (More thoughts below)

Rearchitecting UniformGrid

I think we need to rethink how UniformGrid is architected.

A lot of Grid properties are not being used (like RowDefinitions and ColumnDefinitions) because ILayoutManager is essentially re-drawing the UI on the screen to imitate a Grid.

Perhaps we don't inherit from Grid, and instead Layout instead.

👇 Check out this example I added to the sample where I add an IView to the UniformGrid using uniformGrid.Children.Add().

The child is added to the Grid, but it is always added to the same column + row.

Once the row becomes wider than the screen, it wraps around creating what looks like a new column.

And if I specify a Row/Column for the child, it is ignored; the child is always added to the same row/column:

var boxView = new BoxView
{
	HeightRequest = widthRequest,
	WidthRequest = heightRequest,
	Color = randomColor
};
Grid.SetRow(boxView, 1);
Grid.SetColumn(boxView, 1);
uniformGrid.Children.Add(boxView);
ScreenFlow.mp4

Comment thread src/CommunityToolkit.Maui.UnitTests/Views/UniformGrid_Tests.cs Outdated
Comment thread src/CommunityToolkit.Maui.UnitTests/Views/UniformGrid_Tests.cs Outdated
@VladislavAntonyuk
Copy link
Copy Markdown
Contributor Author

Hey Brandon, maybe rename the control to UniformLayout?

@TheCodeTraveler
Copy link
Copy Markdown
Collaborator

Yea! Naming is tough, but I like where you're going with it!

Along with Uniform to let users know everything will be spaced evenly, maybe we also add something that lets users know we'll be putting their controls into rows + columns?

Here's a couple more ideas:

  • UniformRowsColumnsLayout
  • EvenlySpacedGridLayout
  • AutoSpacedLayout
  • EvenlySpacedRowsColumnsLayout
  • AutoSpacedRowsColumnsLayout

I'm not sold on any of these, but sometimes it helps to throw a bunch of names out there 😃

@bijington
Copy link
Copy Markdown
Contributor

Yea! Naming is tough, but I like where you're going with it!

You are telling me! Child 1 and Child 2 would definitely agree with you 😆

Along with Uniform to let users know everything will be spaced evenly, maybe we also add something that lets users know we'll be putting their controls into rows + columns?

Here's a couple more ideas:

  • UniformRowsColumnsLayout
  • EvenlySpacedGridLayout
  • AutoSpacedLayout
  • EvenlySpacedRowsColumnsLayout
  • AutoSpacedRowsColumnsLayout

I'm not sold on any of these, but sometimes it helps to throw a bunch of names out there 😃

I still quite like UniformGrid as the grid suffix implies the rows/columns part. Some other possible names could be:

  • UniformItemsLayout
  • that's all I've got

@VladislavAntonyuk VladislavAntonyuk marked this pull request as draft January 6, 2022 22:48
@VladislavAntonyuk VladislavAntonyuk force-pushed the 122-uniform-grid branch 3 times, most recently from 83be63e to 101d826 Compare February 14, 2022 17:17
* 122 UniformGrid

* Fix for rc2. remove compatibility usage

* Add comments, add tests

* Fix uniform tests

* MaxRows, MaxColumns

* Add samples

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

Update Syntax

Update Formatting

Update Descriptions

UniformGridTestPage

Update UniformGridTestPage.xaml.cs
@VladislavAntonyuk VladislavAntonyuk marked this pull request as ready for review February 14, 2022 22:46
Copy link
Copy Markdown
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

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

Thanks Vlad! I love the new name, love the new IUniformItemsLayout interface, and am impressed at the elegance of the implementation of UniformItemsLayout 💯 👏

@TheCodeTraveler

This comment was marked as resolved.

@TheCodeTraveler

This comment was marked as resolved.

Copy link
Copy Markdown
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

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

Approving again now that we've updated the CI Pipeline for .NET MAUI Preview 13

@TheCodeTraveler TheCodeTraveler enabled auto-merge (squash) February 15, 2022 22:21
@TheCodeTraveler TheCodeTraveler merged commit 0c93535 into main Feb 15, 2022
@delete-merged-branch delete-merged-branch bot deleted the 122-uniform-grid branch February 15, 2022 22:37
@TheCodeTraveler TheCodeTraveler changed the title 122 uniform grid 122 UniformItemsLayout Feb 15, 2022
@TheCodeTraveler TheCodeTraveler linked an issue Feb 15, 2022 that may be closed by this pull request
10 tasks
marsscotia pushed a commit to marsscotia/Maui that referenced this pull request Feb 21, 2022
* 122 UniformGrid (CommunityToolkit#139)

* 122 UniformGrid

* Fix for rc2. remove compatibility usage

* Add comments, add tests

* Fix uniform tests

* MaxRows, MaxColumns

* Add samples

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

Update Syntax

Update Formatting

Update Descriptions

UniformGridTestPage

Update UniformGridTestPage.xaml.cs

* Make it more MAUI style

* Remove NSubstitute

* Rename folder from `Views` to `Layouts`

* Create `UniformItemsLayoutViewModel.cs` and `UniformItemsLayoutTestViewModel`

* Update Formatting

* Remove whitespace

* Update UniformItemsLayoutTestPage.xaml

* Update `UniformItemsLayoutTestPage`

* Remove test page

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2024
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.

[Proposal] UniformItemsLayout

4 participants