Skip to content
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

Change parts of Expander implementation to support animation #2522

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stephenquan
Copy link
Contributor

@stephenquan stephenquan commented Feb 14, 2025

Description of Change

Change the way how Expander implements expanding and collapsing from an Content.IsVisibile changed to a VerticalStackLayout.HeightRequest change so that animations can be applied to the HeightRequest property.

Updates where made to the sample to demonstrate how the animation may work.

No changes were made to the unit tests as it was felt that the core Expander component was kept at feature parity.

Documentation will be provided and the content will be similar to what's in this PR's xmldoc and samples.

Files changed

  • samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml
    • Added PropertyChanged event handlers to enable animation
  • samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
    • Enable animation by calling ContentHeightTo in reaction to IsExpanded property change
  • samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
    • Implement a C# only equivalent example
  • src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
    • Rewrite of various parts of the Expander implementation
      • Original implementation had Header and Content dynamically added and removed from the Grid new implementation has Header and Content applied two new ContentView instances (this change, I felt makes the implementation shorter and easier to read)
      • Added a VerticalStackLayout
      • Remove the IsVisible binding since we're not using it any more
      • Added mechanisms to control the VerticalStackLayout.HeightRequest property via
        • Expander.ContentHeight property
        • Expander.MinimumContentHeight property
        • Expander.MaximumContentHeight property
        • Expander.ContentTo method

Linked Issues

#2521

Linked Discussions

#1628

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

This PR was created to solicit suggestions from the team.

…t instead of Content.IsVisible so that the user can use animate expanding/collapsing modes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant