Skip to content

Add iPhone Duo support to Controls.Foldable - #38915

Merged
kubaflo merged 17 commits into
net11.0from
jfversluis-iphone-duo-foldable-support
Oct 22, 2026
Merged

kubaflo merged 17 commits into
net11.0from
jfversluis-iphone-duo-foldable-support

Conversation

@jfversluis

@jfversluis jfversluis commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Adds first-class iPhone Duo support to Microsoft.Maui.Controls.Foldable so TwoPaneView can automatically split around an active iOS division reserved region. Queries and coordinate conversion are scoped to the observed native view and window, preserving correct behavior across windows and scenes instead of relying on global screen geometry.

The implementation was originally staged behind a capability switch while the bindings from dotnet/macios#26705 were unreleased. Official Xcode 27.1 support is now available through workload set 10.0.402.1, including Microsoft.iOS.Sdk.net10.0_27.1 27.1.10018. The native path now enables automatically when the iOS target platform version is 27.1 or later; IosDuoBindingsAvailable remains available as an explicit build-graph override.

Customer behavior

  • Active division reserved regions drive TwoPaneView pane geometry.
  • Inactive division regions and occlusion regions do not force a split.
  • UIHingeInteraction supplies hinge state and angle for interaction/effects only; angle is never used to guess layout geometry.
  • The existing Controls.Sample Foldable page displays mode, physical division status, visible panes, and live hinge angle.

Implementation

  • Registers a scoped iOS IFoldableService and tracks the relevant view/window/scene.
  • Uses UIView.GetReservedRegions(UIViewReservedRegionKind.CreateDivision()) after the iOS 27.1 runtime guard.
  • Converts UIKit hinge radians to the existing degree-based MAUI API.
  • Waits for UIKit's first hinge update for GetHingeAngleAsync() and refreshes state through the documented interaction enable cycle.
  • Attaches interactions to the window-controller root view and removes/disposes them on unload, handler replacement, or service disposal.
  • Makes internal foldable queries view-aware while retaining the existing public API surface.
  • Binds DualScreenInfo.Current to the last activated MAUI iOS scene/window, analogous to Android's resumed-activity behavior.
  • Makes WindowSpanModeStateTrigger follow its attached visual element/window.
  • Re-queries layout geometry after UIKit finishes settling reserved regions following a hinge callback. The delayed refresh is coalesced, skips unloaded elements, and runs through the shared layout-guide path so TwoPaneView, element-scoped DualScreenInfo, DualScreenInfo.Current, and property-only state-trigger consumers remain synchronized.

Compatibility

  • Android behavior and public API semantics remain unchanged.
  • iOS versions before 27.1 and non-foldable devices retain the existing configurable responsive split behavior.
  • Mac Catalyst remains unchanged; the Duo APIs compile only for iOS.
  • No reflection, selector strings, private APIs, public API additions, or new CI lane are introduced.

Validation

Official workload installation was isolated under session storage rather than changing the machine-global workload graph:

.NET SDK: 10.0.402
Workload set: 10.0.402.1
Microsoft.iOS SDK/ref/runtime: 27.1.10018
Xcode: 27.1 (27A9275)

Build and test results:

  • Controls.Foldable net10.0-ios27.1 with the official bindings: succeeded, 0 errors. The newer SDK reports existing MAUI-wide nullability/obsoletion warnings outside this change.
  • Controls.Foldable net10.0-ios26.0: succeeded, 0 warnings, 0 errors.
  • Controls.Foldable net10.0-maccatalyst26.0: succeeded, 0 warnings, 0 errors.
  • Controls.Foldable net10.0-android36.0: succeeded, 0 warnings, 0 errors.
  • Controls.Sample net10.0-ios27.1 / iossimulator-arm64: succeeded. The official SDK requires an invocation-only minimum deployment target override of iOS 15.0 on this branch.
  • dotnet test src/Controls/Foldable/test/Controls.Foldable.UnitTests.csproj --no-restore --nologo --verbosity minimal: 32 passed, 0 failed.
  • git diff --check: passed.

Runtime validation used DevFlow from dotnet/maui-labs, temporarily enabled only in the local Debug sample and removed before commit. The audit ran on an iOS 27.1 iPhone Duo simulator with the official stable workload:

  • Closed: division inactive, hinge 0°, responsive layout retained.
  • Partially Open: division active, hinge approximately 128°, Mode: Wide, with two exact 455.5-point panes separated by the 40-point division region.
  • Open: division inactive, hinge 180°, responsive layout restored.
  • Live Open → Partially Open → Open transitions completed without navigation or restart.
  • Active physical division geometry ignored responsive threshold and pane-length slider values; exact reserved-region pane bounds remained authoritative.
  • All four sliders were exercised, including threshold transitions and 0/1, 1/0, and 0.25/0.75 pane-length ratios.
  • Pane priority, all Tall/Wide configurations (including reversed and SinglePane modes), ModeChanged status, and both Reset buttons were exercised successfully.
  • The audit identified a stale element-scoped DualScreenInfo division after Partially Open → Open. The shared delayed region refresh in this PR fixes the issue; the final build reported Division region: inactive and 180° live without restart.
  • An independent code review confirmed the refresh covers property-only consumers and DualScreenInfo.Current, is coalesced, avoids unloaded elements, and leaves Android/Mac Catalyst behavior unchanged.

Issues Fixed

N/A — implements iPhone Duo support enabled by dotnet/macios#26705.

Use iOS 27.1 division reserved regions for per-view TwoPaneView layout and UIHingeInteraction for hinge angle updates. Keep the implementation compile-gated until the corresponding dotnet/macios bindings flow into MAUI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38915

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38915"

@azure-pipelines

This comment has been minimized.

@jfversluis

Copy link
Copy Markdown
Member Author

@PureWeen could you please review this staged iPhone Duo support, particularly the per-view/window service lifecycle and the compile gate for the pending iOS 27.1 bindings from dotnet/macios#26705?

I also verified that Microsoft.Maui.Controls.Foldable is still actively distributed as a separate NuGet package: version 10.0.110 is currently published with iOS, Android, Mac Catalyst, Windows, and base net10.0 assets, and the MAUI official-release pipeline explicitly includes the package.

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 26, 2026
@azure-pipelines

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Note

🔍 /review started

AzDO build 15477226 is running for ios.

The s/agent-review-in-progress label stays on this PR while the run is active. The final recommendation and outcome labels are posted only after Gate, expert review, and Deep UI tests finish.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 3 findings

See inline comments for details.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Sep 26, 2026
jfversluis and others added 2 commits September 27, 2026 12:34
Use element-scoped DualScreenInfo and platform-neutral UI so the existing TwoPaneView gallery page demonstrates iPhone Duo division regions and hinge updates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Create element-scoped foldable state when the page appears and report layout state from TwoPaneView so the gallery reflects the active iPhone Duo division immediately.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jfversluis

Copy link
Copy Markdown
Member Author

iPhone Duo gallery validation

Book posture — active division region

iPhone Duo Book posture

Open posture

iPhone Duo Open posture

Captured from the updated Controls.Sample gallery on the iOS 27.1 iPhone Duo simulator using local-only bindings matching dotnet/macios#26705. The Book posture reports Mode: Wide, an active division region, and two visible panes.

Attach UIHingeInteraction to the window controller root view following UIKit guidance and retain its escaping update handler for the monitor lifetime. Add focused coverage for all TwoPaneView controls exposed by the foldable gallery.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jfversluis

Copy link
Copy Markdown
Member Author

Foldable gallery functionality audit

  • ✅ Active division layout: verified on the iPhone Duo 27.1 simulator; TwoPaneView enters Wide mode and aligns both panes around the 40-point division region.
  • ✅ Responsive thresholds: verified by tests; they control fallback responsive layout when there is no active division.
  • ✅ Pane lengths: verified by tests; applied in responsive mode and intentionally ignored while a physical division dictates exact pane bounds.
  • ✅ Pane priority / SinglePane configuration: verified by tests.
  • ✅ Wide/Tall configurations and ordering: verified by tests, including horizontal-division BottomTop ordering.
  • ✅ Reset: restores the page defaults through the same tested bindable properties.
  • ✅ Inactive and occlusion behavior: inactive division regions do not force a split; occlusion regions are not queried as hinges.
  • ⚠️ Hinge angle: a minimal Swift probe using only public UIHingeInteraction reports the initial FullyOpen state and π correctly on this simulator. The temporary pre-flow .NET binding shim does not deliver its managed block callback, so it cannot validate the final binding path. The library now follows Apple’s documented root-view attachment pattern and retains the escaping handler for the monitor lifetime. Final managed callback verification remains dependent on the official [xcode27.1] Update to Xcode 27.1 Beta 1 based on release/10.0.1xx macios#26705 bindings flowing into MAUI.

Focused tests now cover 22 scenarios and pass. The clean Controls.Sample iOS build and Foldable build matrix also pass.

Reconnect monitoring after a view enters a window, centralize service subscription cleanup, and avoid retaining DualScreenInfo through a direct HandlerChanged subscription. Add lifecycle regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 21, 2026
@kubaflo

kubaflo commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Merge-safety review

Recommendation: hold merge pending validation, not because of a confirmed new code defect.

Reviewed commit 69c6b3e, including an independent GPT-5.3 Codex code review, GPT-6.1 Sol evidence analysis, prior review reconciliation, actual CI results, and screenshot comparisons.

No confirmed introduced source defect surfaced, and all 39 platform-neutral Foldable unit tests passed locally. Earlier findings around subscription balancing, handler/service rebinding, trigger cleanup, geometry refresh, and retained-window cleanup are addressed in the current code. In particular, FoldableService.Dispose() now clears _window, so that earlier inline concern is resolved despite having no thread reply.

Pipeline Current-head result Assessment
maui-pr Passed No current build failure
maui-pr-devicetests Failed Android image assertion also occurs on main; MacCatalyst Core Tests has no final test results
maui-pr-uitests Failed Mixed provisioning failures, failures also seen on main, and unresolved visual/runtime evidence

The remaining concerns are validation gaps, not proven regressions:

  • MacCatalyst Core Tests did not finish with usable results. XHarness reports TEST_RESULTS_MISSING, launcher exit 137, and no test-end signal. This cannot be counted as either a clean run or a confirmed PR-caused failure.
  • Two Mac Entry visual failures remain unexplained: placeholder and read-only clear button. I inspected the actual images, checked-in baselines, and diffs. Clear buttons appear where the baselines have none; image dimensions match. No causal connection to Foldable was established, but these should not be dismissed without attribution or a rerun.
  • The new native iOS 27.1 path was not independently executed in this review. The available host has Xcode 26.6 and iOS runtimes through 26.5. Passing net10.0 tests does not execute UIKit monitoring or the iOS-only delayed reserved-region refresh. The published foldable screenshots predate the final fixes and cannot establish current-head live hinge/lifecycle correctness.

Several red results should not be reported as new regressions: the Android image-background assertion, Mac WebView timeout, and Mac translation/layout assertion have matching failures on main. Eight UI jobs fail during unchanged Android SDK provisioning. The Android Controls XML and final console summary also agree on a completed 1,023-test run with one assertion failure; exit 1 alone is not proof of a crash.

Before merge: obtain current-head iOS 27.1 evidence for live fold/unfold transitions, resizing and element/ancestor movement, trigger detach/reattach, shared monitor consumers, and window/scene teardown. Rerun or conclusively attribute the remaining failures and restore required CI coverage. No replacement implementation is recommended without a verified defect.

kubaflo
kubaflo previously approved these changes Oct 22, 2026
@kubaflo
kubaflo changed the base branch from main to net11.0 October 22, 2026 17:48
@kubaflo
kubaflo dismissed their stale review October 22, 2026 17:48

The base branch was changed.

Keep the Foldable test project mapping while preserving removal of obsolete Compatibility mappings. Select the two-argument MainThread test hook explicitly after net11 added an overload.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 17:54
@kubaflo

kubaflo commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Resolved and pushed the conflicts with net11.0 in ordinary merge commit ae35d534b1, on the original PR branch.

The two conflicts were in test-runner/project maps. Kept this PR's Controls.Foldable.UnitTests mapping and Foldable test detection while retaining net11's removal of obsolete Compatibility mappings. The Foldable production implementation is unchanged from the PR head.

Validation also caught an integration issue: net11 added a second MainThread.SetCustomImplementation overload, so the test helper's name-only reflection lookup became ambiguous. Updated it to select the existing two-argument overload explicitly; all 39 Foldable unit tests now pass.

PowerShell syntax parsing passed for both resolved scripts and the automatically merged detection-test file. Direct invocation of Detect-TestsInDiff.ps1 -ChangedFiles src/Controls/Foldable/test/FoldableRegionHelperTests.cs selected the correct unit-test project and runner. git diff --check passed for the resolved scripts and test-helper change. No new pipeline tests were written, and no native UI/device tests or XCTest were run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Default packaging omits native iOS support, and unresolved geometry and window-trigger defects can produce incorrect layouts or state.

4 open issues

Review effort: Balanced

Comment on lines +22 to +24
<IosDuoBindingsAvailable Condition="'$(IosDuoBindingsAvailable)' == '' and '$(TargetPlatformVersion)' != ''">$([MSBuild]::VersionGreaterThanOrEquals('$(TargetPlatformVersion)', '27.1'))</IosDuoBindingsAvailable>
<IosDuoBindingsAvailable Condition="'$(IosDuoBindingsAvailable)' == ''">false</IosDuoBindingsAvailable>
<DefineConstants Condition="'$(IosDuoBindingsAvailable)' == 'true'">$(DefineConstants);IOS_DUO_BINDINGS</DefineConstants>
Comment on lines +523 to 525
bool IsInMultipleRegions(Rect layoutBounds, Rect hinge)
{
bool isInMultipleRegions = false;
_info?.PropertyChanged -= OnDualScreenInfoPropertyChanged;

_visualElement = visualElement;
_info = new DualScreenInfo(visualElement);
Comment on lines +97 to +101
var windowRegion = platformView.ConvertRectToView(
new CoreGraphics.CGRect(localRegion.X, localRegion.Y, localRegion.Width, localRegion.Height),
platformView.Window);

return new Rect(windowRegion.X, windowRegion.Y, windowRegion.Width, windowRegion.Height);
@kubaflo
kubaflo disabled auto-merge October 22, 2026 22:11
@kubaflo
kubaflo merged commit a561eae into net11.0 Oct 22, 2026
36 of 39 checks passed
@kubaflo
kubaflo deleted the jfversluis-iphone-duo-foldable-support branch October 22, 2026 22:12
@github-actions github-actions Bot added this to the .NET 11.0-rc2 milestone Oct 22, 2026
@beeradmoore

Copy link
Copy Markdown
Contributor

@kubaflo , is this getting back ported to .NET 10 MAUI as well?

@kubaflo

kubaflo commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@beeradmoore, sorry but it won't

@kubaflo

kubaflo commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@beeradmoore actually, let me discuss with the team

@beeradmoore

Copy link
Copy Markdown
Contributor

Not critical if they are not, at least for us we plan to move to .NET 11 when we can. MAUI/iOS always gets caught up in a weird iOS release thing.

New iOS comes out (iOS 27.0)
The current .NET adds partial for new Xcode (usually build tools, but not SDK) (Xcode 27.0, Xcode 27.1)
The next .NET is a month or two away (.NET 11)
Fixes and new features get merged into new .NET branch (.NET 11)
Old .NET uses new tooling but not new features (Xcode 27.1 on .NET 10)

kubaflo added a commit that referenced this pull request Oct 23, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Backports [#38915](#38915), "Add
iPhone Duo support to Controls.Foldable", from squash commit
`a561eaec4aacbe962416c64491aa5ffbc6bde9ae` to **`inflight/current`**, as
explicitly requested.

Preserves the source implementation: view/window-scoped reserved-region
geometry, hinge monitoring and lifecycle cleanup, scene activation
support, shared layout refresh, state triggers, sample updates, and
Foldable unit tests. Original author and source coauthors are preserved.

The only cherry-pick conflicts were in `.github/scripts/RunTests.ps1`
and `.github/scripts/shared/Detect-TestsInDiff.ps1`. Resolution retains
this branch's Compatibility test entries and adds the source Foldable
mappings. Formatting is scoped to changed C# files; the formatter's
unrelated Android null-conditional event rewrite was not retained.

**SDK limitation:** the source's native Duo path is enabled only for iOS
target platform version 27.1+ (or an explicit `IosDuoBindingsAvailable`
override with compatible bindings). This target branch currently
defaults to iOS 26.0, so its default build retains fallback behavior
rather than enabling Duo APIs. This PR does not upgrade the branch-wide
SDK/workload or remove capability/runtime guards. Publishing actual
Duo-enabled artifacts requires a compatible iOS 27.1 SDK build
configuration.

**Validation run in this backport worktree** using .NET SDK
`11.0.100-preview.6.26359.118`, targeting this branch's `net10.0` TFMs,
and Xcode 26.6:

| Command | Result |
| --- | --- |
| `dotnet test
src/Controls/Foldable/test/Controls.Foldable.UnitTests.csproj --nologo
--verbosity minimal` | Passed: 39, failed: 0, skipped: 0; rerun after
formatting and normal restore. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios26.0 --nologo --verbosity minimal` | Passed: 0 warnings, 0
errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-maccatalyst26.0 --no-restore --nologo --verbosity minimal` |
Passed: 0 warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-android36.0 --no-restore --nologo --verbosity minimal` | Passed:
3 Gradle Java 8 obsolescence warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios27.1 -p:TargetFrameworks=net10.0-ios27.1 --nologo --verbosity
minimal` | Blocked: NETSDK1140, local SDK supports iOS 26.0/26.5, not
27.1. |
| `git diff --cached --check` | Passed. |
| `git diff --check` | Passed. |

Formatting command (passed; `changed_files` contains staged changed
`.cs` paths):

```bash
changed_files=()
while IFS= read -r file; do changed_files+=("$file"); done < <(git diff --cached --name-only -- '*.cs')
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include "${changed_files[@]}" --verbosity quiet
```

PowerShell syntax check (passed for all three source script files):

```powershell
$files=@(".github/scripts/RunTests.ps1", ".github/scripts/shared/Detect-TestsInDiff.ps1", ".github/scripts/shared/Detect-TestsInDiff.Tests.ps1")
foreach ($file in $files) {
    $tokens=$null; $errors=$null
    [System.Management.Automation.Language.Parser]::ParseFile((Join-Path $PWD $file), [ref]$tokens, [ref]$errors) > $null
    if ($errors.Count) { $errors | Write-Error; exit 1 }
    Write-Output "Parsed $file"
}
```

Build/test/format subprocesses ran with `GH_TOKEN`, `GITHUB_TOKEN`, and
`COPILOT_GITHUB_TOKEN` removed from their environments. A `--no-restore`
test attempt after the explicit 27.1 restore probe encountered changed
assets; normal restore and the full 39-test rerun above succeeded.

**Not run:** native iOS 27.1/Duo compilation or simulator/device runtime
validation, sample app build/runtime validation, Windows validation, or
pipeline Pester tests. No XCTest or host UI automation was used. Source
PR validation is not claimed as a result of this backport.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Backport of [#38915](#38915); no
separate issue.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 741e14bf-fe5c-4150-857c-40b354de3403
kubaflo added a commit that referenced this pull request Oct 25, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Backports [#38915](#38915), "Add
iPhone Duo support to Controls.Foldable", from squash commit
`a561eaec4aacbe962416c64491aa5ffbc6bde9ae` to **`inflight/current`**, as
explicitly requested.

Preserves the source implementation: view/window-scoped reserved-region
geometry, hinge monitoring and lifecycle cleanup, scene activation
support, shared layout refresh, state triggers, sample updates, and
Foldable unit tests. Original author and source coauthors are preserved.

The only cherry-pick conflicts were in `.github/scripts/RunTests.ps1`
and `.github/scripts/shared/Detect-TestsInDiff.ps1`. Resolution retains
this branch's Compatibility test entries and adds the source Foldable
mappings. Formatting is scoped to changed C# files; the formatter's
unrelated Android null-conditional event rewrite was not retained.

**SDK limitation:** the source's native Duo path is enabled only for iOS
target platform version 27.1+ (or an explicit `IosDuoBindingsAvailable`
override with compatible bindings). This target branch currently
defaults to iOS 26.0, so its default build retains fallback behavior
rather than enabling Duo APIs. This PR does not upgrade the branch-wide
SDK/workload or remove capability/runtime guards. Publishing actual
Duo-enabled artifacts requires a compatible iOS 27.1 SDK build
configuration.

**Validation run in this backport worktree** using .NET SDK
`11.0.100-preview.6.26359.118`, targeting this branch's `net10.0` TFMs,
and Xcode 26.6:

| Command | Result |
| --- | --- |
| `dotnet test
src/Controls/Foldable/test/Controls.Foldable.UnitTests.csproj --nologo
--verbosity minimal` | Passed: 39, failed: 0, skipped: 0; rerun after
formatting and normal restore. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios26.0 --nologo --verbosity minimal` | Passed: 0 warnings, 0
errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-maccatalyst26.0 --no-restore --nologo --verbosity minimal` |
Passed: 0 warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-android36.0 --no-restore --nologo --verbosity minimal` | Passed:
3 Gradle Java 8 obsolescence warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios27.1 -p:TargetFrameworks=net10.0-ios27.1 --nologo --verbosity
minimal` | Blocked: NETSDK1140, local SDK supports iOS 26.0/26.5, not
27.1. |
| `git diff --cached --check` | Passed. |
| `git diff --check` | Passed. |

Formatting command (passed; `changed_files` contains staged changed
`.cs` paths):

```bash
changed_files=()
while IFS= read -r file; do changed_files+=("$file"); done < <(git diff --cached --name-only -- '*.cs')
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include "${changed_files[@]}" --verbosity quiet
```

PowerShell syntax check (passed for all three source script files):

```powershell
$files=@(".github/scripts/RunTests.ps1", ".github/scripts/shared/Detect-TestsInDiff.ps1", ".github/scripts/shared/Detect-TestsInDiff.Tests.ps1")
foreach ($file in $files) {
    $tokens=$null; $errors=$null
    [System.Management.Automation.Language.Parser]::ParseFile((Join-Path $PWD $file), [ref]$tokens, [ref]$errors) > $null
    if ($errors.Count) { $errors | Write-Error; exit 1 }
    Write-Output "Parsed $file"
}
```

Build/test/format subprocesses ran with `GH_TOKEN`, `GITHUB_TOKEN`, and
`COPILOT_GITHUB_TOKEN` removed from their environments. A `--no-restore`
test attempt after the explicit 27.1 restore probe encountered changed
assets; normal restore and the full 39-test rerun above succeeded.

**Not run:** native iOS 27.1/Duo compilation or simulator/device runtime
validation, sample app build/runtime validation, Windows validation, or
pipeline Pester tests. No XCTest or host UI automation was used. Source
PR validation is not claimed as a result of this backport.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Backport of [#38915](#38915); no
separate issue.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 741e14bf-fe5c-4150-857c-40b354de3403
kubaflo added a commit that referenced this pull request Oct 26, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Backports [#38915](#38915), "Add
iPhone Duo support to Controls.Foldable", from squash commit
`a561eaec4aacbe962416c64491aa5ffbc6bde9ae` to **`inflight/current`**, as
explicitly requested.

Preserves the source implementation: view/window-scoped reserved-region
geometry, hinge monitoring and lifecycle cleanup, scene activation
support, shared layout refresh, state triggers, sample updates, and
Foldable unit tests. Original author and source coauthors are preserved.

The only cherry-pick conflicts were in `.github/scripts/RunTests.ps1`
and `.github/scripts/shared/Detect-TestsInDiff.ps1`. Resolution retains
this branch's Compatibility test entries and adds the source Foldable
mappings. Formatting is scoped to changed C# files; the formatter's
unrelated Android null-conditional event rewrite was not retained.

**SDK limitation:** the source's native Duo path is enabled only for iOS
target platform version 27.1+ (or an explicit `IosDuoBindingsAvailable`
override with compatible bindings). This target branch currently
defaults to iOS 26.0, so its default build retains fallback behavior
rather than enabling Duo APIs. This PR does not upgrade the branch-wide
SDK/workload or remove capability/runtime guards. Publishing actual
Duo-enabled artifacts requires a compatible iOS 27.1 SDK build
configuration.

**Validation run in this backport worktree** using .NET SDK
`11.0.100-preview.6.26359.118`, targeting this branch's `net10.0` TFMs,
and Xcode 26.6:

| Command | Result |
| --- | --- |
| `dotnet test
src/Controls/Foldable/test/Controls.Foldable.UnitTests.csproj --nologo
--verbosity minimal` | Passed: 39, failed: 0, skipped: 0; rerun after
formatting and normal restore. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios26.0 --nologo --verbosity minimal` | Passed: 0 warnings, 0
errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-maccatalyst26.0 --no-restore --nologo --verbosity minimal` |
Passed: 0 warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-android36.0 --no-restore --nologo --verbosity minimal` | Passed:
3 Gradle Java 8 obsolescence warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios27.1 -p:TargetFrameworks=net10.0-ios27.1 --nologo --verbosity
minimal` | Blocked: NETSDK1140, local SDK supports iOS 26.0/26.5, not
27.1. |
| `git diff --cached --check` | Passed. |
| `git diff --check` | Passed. |

Formatting command (passed; `changed_files` contains staged changed
`.cs` paths):

```bash
changed_files=()
while IFS= read -r file; do changed_files+=("$file"); done < <(git diff --cached --name-only -- '*.cs')
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include "${changed_files[@]}" --verbosity quiet
```

PowerShell syntax check (passed for all three source script files):

```powershell
$files=@(".github/scripts/RunTests.ps1", ".github/scripts/shared/Detect-TestsInDiff.ps1", ".github/scripts/shared/Detect-TestsInDiff.Tests.ps1")
foreach ($file in $files) {
    $tokens=$null; $errors=$null
    [System.Management.Automation.Language.Parser]::ParseFile((Join-Path $PWD $file), [ref]$tokens, [ref]$errors) > $null
    if ($errors.Count) { $errors | Write-Error; exit 1 }
    Write-Output "Parsed $file"
}
```

Build/test/format subprocesses ran with `GH_TOKEN`, `GITHUB_TOKEN`, and
`COPILOT_GITHUB_TOKEN` removed from their environments. A `--no-restore`
test attempt after the explicit 27.1 restore probe encountered changed
assets; normal restore and the full 39-test rerun above succeeded.

**Not run:** native iOS 27.1/Duo compilation or simulator/device runtime
validation, sample app build/runtime validation, Windows validation, or
pipeline Pester tests. No XCTest or host UI automation was used. Source
PR validation is not claimed as a result of this backport.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Backport of [#38915](#38915); no
separate issue.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 741e14bf-fe5c-4150-857c-40b354de3403
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Backports [#38915](#38915), "Add
iPhone Duo support to Controls.Foldable", from squash commit
`a561eaec4aacbe962416c64491aa5ffbc6bde9ae` to **`inflight/current`**, as
explicitly requested.

Preserves the source implementation: view/window-scoped reserved-region
geometry, hinge monitoring and lifecycle cleanup, scene activation
support, shared layout refresh, state triggers, sample updates, and
Foldable unit tests. Original author and source coauthors are preserved.

The only cherry-pick conflicts were in `.github/scripts/RunTests.ps1`
and `.github/scripts/shared/Detect-TestsInDiff.ps1`. Resolution retains
this branch's Compatibility test entries and adds the source Foldable
mappings. Formatting is scoped to changed C# files; the formatter's
unrelated Android null-conditional event rewrite was not retained.

**SDK limitation:** the source's native Duo path is enabled only for iOS
target platform version 27.1+ (or an explicit `IosDuoBindingsAvailable`
override with compatible bindings). This target branch currently
defaults to iOS 26.0, so its default build retains fallback behavior
rather than enabling Duo APIs. This PR does not upgrade the branch-wide
SDK/workload or remove capability/runtime guards. Publishing actual
Duo-enabled artifacts requires a compatible iOS 27.1 SDK build
configuration.

**Validation run in this backport worktree** using .NET SDK
`11.0.100-preview.6.26359.118`, targeting this branch's `net10.0` TFMs,
and Xcode 26.6:

| Command | Result |
| --- | --- |
| `dotnet test
src/Controls/Foldable/test/Controls.Foldable.UnitTests.csproj --nologo
--verbosity minimal` | Passed: 39, failed: 0, skipped: 0; rerun after
formatting and normal restore. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios26.0 --nologo --verbosity minimal` | Passed: 0 warnings, 0
errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-maccatalyst26.0 --no-restore --nologo --verbosity minimal` |
Passed: 0 warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-android36.0 --no-restore --nologo --verbosity minimal` | Passed:
3 Gradle Java 8 obsolescence warnings, 0 errors. |
| `dotnet build src/Controls/Foldable/src/Controls.Foldable.csproj -f
net10.0-ios27.1 -p:TargetFrameworks=net10.0-ios27.1 --nologo --verbosity
minimal` | Blocked: NETSDK1140, local SDK supports iOS 26.0/26.5, not
27.1. |
| `git diff --cached --check` | Passed. |
| `git diff --check` | Passed. |

Formatting command (passed; `changed_files` contains staged changed
`.cs` paths):

```bash
changed_files=()
while IFS= read -r file; do changed_files+=("$file"); done < <(git diff --cached --name-only -- '*.cs')
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include "${changed_files[@]}" --verbosity quiet
```

PowerShell syntax check (passed for all three source script files):

```powershell
$files=@(".github/scripts/RunTests.ps1", ".github/scripts/shared/Detect-TestsInDiff.ps1", ".github/scripts/shared/Detect-TestsInDiff.Tests.ps1")
foreach ($file in $files) {
    $tokens=$null; $errors=$null
    [System.Management.Automation.Language.Parser]::ParseFile((Join-Path $PWD $file), [ref]$tokens, [ref]$errors) > $null
    if ($errors.Count) { $errors | Write-Error; exit 1 }
    Write-Output "Parsed $file"
}
```

Build/test/format subprocesses ran with `GH_TOKEN`, `GITHUB_TOKEN`, and
`COPILOT_GITHUB_TOKEN` removed from their environments. A `--no-restore`
test attempt after the explicit 27.1 restore probe encountered changed
assets; normal restore and the full 39-test rerun above succeeded.

**Not run:** native iOS 27.1/Duo compilation or simulator/device runtime
validation, sample app build/runtime validation, Windows validation, or
pipeline Pester tests. No XCTest or host UI automation was used. Source
PR validation is not claimed as a result of this backport.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Backport of [#38915](#38915); no
separate issue.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 741e14bf-fe5c-4150-857c-40b354de3403
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-review-in-progress AI review is currently running for this PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants