Skip to content

Commit

Permalink
[iOS] FlyoutPage Shadow works incorrectly on iOS - fix (#22351)
Browse files Browse the repository at this point in the history
* Fixed #22169

* Update PhoneFlyoutPageRenderer.cs

* Code refactor
  • Loading branch information
kubaflo committed May 13, 2024
1 parent 8b10f39 commit b2870c7
Showing 1 changed file with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.ComponentModel;
using System.Linq;
using CoreGraphics;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
Expand Down Expand Up @@ -663,11 +664,8 @@ bool shouldReceive(UIGestureRecognizer g, UITouch t)
targetFrame.X = (nfloat)Math.Min(_flyoutController.View.Frame.Width, Math.Max(0, motion));
targetFrame.X = targetFrame.X * directionModifier;
if (_applyShadow)
{
var openProgress = targetFrame.X / _flyoutController.View.Frame.Width;
ApplyDetailShadow((nfloat)openProgress);
}
ApplyShadow(targetFrame);
detailView.Frame = targetFrame;
}
Expand All @@ -692,11 +690,7 @@ bool shouldReceive(UIGestureRecognizer g, UITouch t)
targetFrame.X = (float)Element.Bounds.Width - (flyoutWidth + targetFrame.X);
}
if (_applyShadow)
{
var openProgress = targetFrame.X / flyoutWidth;
ApplyDetailShadow((nfloat)openProgress);
}
ApplyShadow(targetFrame);
flyoutView.Frame = targetFrame;
}
Expand Down Expand Up @@ -757,6 +751,30 @@ bool shouldReceive(UIGestureRecognizer g, UITouch t)
View.AddGestureRecognizer(_panGesture);
}

void ApplyShadow(CGRect targetFrame)
{
if (!_applyShadow)
return;

var flyoutWidth = _flyoutController.View.Frame.Width;
nfloat openProgress;

if (!FlyoutOverlapsDetailsInPopoverMode)
{
openProgress = !IsRTL
? targetFrame.X / flyoutWidth
: ((float)Element.Bounds.Width - targetFrame.Right) / flyoutWidth;
}
else
{
openProgress = !IsRTL
? (targetFrame.X + flyoutWidth) / flyoutWidth
: ((float)Element.Bounds.Width - targetFrame.X) / flyoutWidth;
}

ApplyDetailShadow(openProgress);
}

static bool IsSwipeView(UIView view)
{
if (view == null)
Expand Down

0 comments on commit b2870c7

Please sign in to comment.