Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 22, 2025

Introduces DisplayRotationStateTrigger, a new state trigger that provides granular control over device display rotation states. Unlike OrientationStateTrigger which only differentiates between portrait and landscape orientations, this trigger responds to specific rotation angles (0°, 90°, 180°, 270°).

Overview

This new trigger enables developers to create visual states that are triggered based on the device's exact display rotation, providing more precise control for applications that need to respond differently to specific rotation states.

Key Features

Granular Rotation Control:

  • Rotation0 (0°) - Device in natural position
  • Rotation90 (90°) - Device rotated 90 degrees
  • Rotation180 (180°) - Device upside down
  • Rotation270 (270°) - Device rotated 270 degrees
  • Unknown - Unknown rotation state

Responsive Design:

  • Automatically responds to device rotation changes via DeviceDisplay.MainDisplayInfoChanged
  • Proper lifecycle management with event subscription/unsubscription
  • Design-time support with DesignMode.IsDesignModeEnabled check

Developer Experience:

  • Complete inline XML documentation with comprehensive XAML examples
  • Full nullable reference type compliance
  • Comprehensive unit test coverage with 6 test methods
  • Working sample implementation in Controls.Sample

Use Cases

Perfect for applications requiring specific rotation-based layouts:

  • Games with different UI layouts for each rotation state
  • Apps needing to handle upside-down orientations differently from normal portrait
  • Complex responsive designs requiring granular rotation control
  • Applications with rotation-specific features or constraints

Sample Usage

<VisualState Name="UpsideDown">
    <VisualState.StateTriggers>
        <DisplayRotationStateTrigger Rotation="Rotation180" />
    </VisualState.StateTriggers>
    <VisualState.Setters>
        <Setter Property="BackgroundColor" Value="Red" />
    </VisualState.Setters>
</VisualState>

Implementation Details

  • Follows the same architectural patterns as existing state triggers (OrientationStateTrigger, DeviceStateTrigger)
  • Includes comprehensive unit tests covering all rotation combinations, property changes, device rotation changes, and lifecycle management
  • Integrated sample in StateTriggersPage.xaml demonstrates practical usage with different background colors for each rotation state
  • PublicAPI files updated for all target platforms

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Can you create a DisplayRotationStateTrigger that is basically the OrientationStateTrigger, but does not only return portrait or landscape. It can use the DisplayRotation enum. Make sure to also add tests. Copy all the tests for the OrientationStateT... Add DisplayRotationStateTrigger for granular device rotation control Aug 22, 2025
Copilot AI requested a review from mattleibow August 22, 2025 19:49
Copilot AI requested a review from mattleibow August 22, 2025 20:09
@mattleibow mattleibow changed the base branch from main to net10.0 August 22, 2025 20:55
@mattleibow mattleibow force-pushed the copilot/fix-1c0f6ffb-931c-49ad-bb8f-bf0f37f3071a branch from 4eb6936 to b2740b0 Compare August 22, 2025 21:39
@mattleibow
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow mattleibow added this to the .NET 10.0-rc2 milestone Aug 22, 2025
@mattleibow mattleibow moved this from Todo to Ready To Review in MAUI SDK Ongoing Aug 22, 2025
@mattleibow mattleibow marked this pull request as ready for review August 22, 2025 21:40
Copilot AI review requested due to automatic review settings August 22, 2025 21:40
@mattleibow mattleibow requested a review from a team as a code owner August 22, 2025 21:40
@mattleibow mattleibow requested a review from rmarinho August 22, 2025 21:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new DisplayRotationStateTrigger that provides granular control over device rotation states, complementing the existing OrientationStateTrigger which only differentiates between portrait and landscape orientations.

  • Adds DisplayRotationStateTrigger class for precise rotation detection (0°, 90°, 180°, 270°, Unknown)
  • Implements comprehensive test coverage with 19 unit tests for all rotation scenarios
  • Enhances MockDeviceDisplay with rotation testing capabilities

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Controls/src/Core/DisplayRotationStateTrigger.cs New state trigger class providing granular rotation-based visual state control
src/Controls/tests/Core.UnitTests/DisplayRotationStateTriggerTests.cs Comprehensive test suite covering all rotation scenarios and edge cases
src/Controls/tests/Core.UnitTests/OrientationStateTriggerTests.cs New test file for existing OrientationStateTrigger functionality
src/Controls/tests/Core.UnitTests/MockDeviceDisplay.cs Enhanced with constructor and SetMainDisplayRotation method for testing
Multiple PublicAPI.Unshipped.txt files API surface additions for the new DisplayRotationStateTrigger across all platforms

@mattleibow
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow
Copy link
Member

This will be nice with the new SafeArea features.

@mattleibow
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow mattleibow force-pushed the copilot/fix-1c0f6ffb-931c-49ad-bb8f-bf0f37f3071a branch from 706d08d to 19ba232 Compare September 9, 2025 17:34
@mattleibow mattleibow force-pushed the copilot/fix-1c0f6ffb-931c-49ad-bb8f-bf0f37f3071a branch from 69e61d9 to f026c25 Compare September 9, 2025 20:26
@mattleibow
Copy link
Member

@copilot please update the title and description. Something went wrong and it is all mixed up. Have a look at the code and write a fresh description. It is all out of date now.

@mattleibow
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor Author

Copilot AI commented Sep 9, 2025

@copilot please update the title and description. Something went wrong and it is all mixed up. Have a look at the code and write a fresh description. It is all out of date now.

Updated the PR title and description to accurately reflect this new feature implementation. The PR introduces DisplayRotationStateTrigger which provides granular control over device rotation states (0°, 90°, 180°, 270°) with comprehensive tests, sample integration, and full documentation. (f026c25)

@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Sep 11, 2025
@PureWeen PureWeen merged commit fd730f4 into net10.0 Sep 11, 2025
149 checks passed
@PureWeen PureWeen deleted the copilot/fix-1c0f6ffb-931c-49ad-bb8f-bf0f37f3071a branch September 11, 2025 17:25
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Sep 11, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

p/0 Current heighest priority issues that we are targeting for a release.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants