Maui icon indicating copy to clipboard operation
Maui copied to clipboard

Readonly Struct Record instead of ValueTuples

Open ne0rrmatrix opened this issue 8 months ago • 0 comments

  • Bug fix

Description of Change

This commit introduces significant improvements to the MauiMediaElement class for Android, focusing on the management of the current activity and its window. A new record struct, CurrentPlatformActivity, has been added to encapsulate the current Activity and its Window, streamlining the handling process and enhancing code readability and maintainability. Changes include:

  • The constructor of MauiMediaElement now checks for null Platform.CurrentActivity or window, throwing an InvalidOperationException if either is null, ensuring the element's proper context for operation.
  • The CurrentPlatformActivity record struct replaces the need for the previously used static method VerifyAndRetrieveCurrentWindowResources, removing redundancy.
  • Full-screen functionality and system bars visibility adjustments now directly utilize the currentPlatformActivity instance for accessing the current window, simplifying the implementation and improving code clarity.

These modifications collectively enhance the clarity, efficiency, and error handling of the MauiMediaElement class on Android.

Linked Issues

  • Fixes #1971

PR Checklist

  • [x] 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)
  • [x] Rebased on top of main at time of PR
  • [x] Changes adhere to coding standard
  • [ ] Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

@pictos requested replacing ValueTuples with readonly struct record

ne0rrmatrix avatar Jun 21 '24 22:06 ne0rrmatrix