Skip to content

Commit d5d1218

Browse files
Committing the missing changes from internal popup.
1 parent 1cc61c8 commit d5d1218

File tree

4 files changed

+29
-69
lines changed

4 files changed

+29
-69
lines changed

maui/src/Popup/Helpers/PopupExtension/PopupExtension.Android.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ internal static int GetScreenWidth()
150150

151151
int leftInsets = 0;
152152
#if NET10_0
153-
// In .NET 10, the root view’s width in landscape includes the navigation bar, so subtract the left window inset from the root view width to get the usable content width.
153+
// In .NET 10, the root view’s width in landscape includes the navidation bar, so subtract the left window inset from the root view width to get the usable content width.
154154
leftInsets = PopupExtension.GetWindowInsets("Left");
155155
#endif
156156
return (int)Math.Round((platformRootView!.Width - leftInsets) / WindowOverlayHelper._density);
@@ -174,25 +174,30 @@ internal static int GetScreenHeight()
174174
}
175175
else if (platformRootView is not null)
176176
{
177-
int topInsets = 0;
178-
int bottomInsets = 0;
179177
#if NET10_0
178+
int topInsets = 0;
179+
int bottomInsets = 0;
180+
180181
// In .NET 10, the root view’s height includes the navigation bar, so subtract the bottom window inset from the root view height to get the usable content height.
181182
bottomInsets = PopupExtension.GetWindowInsets("Bottom");
182183
if (!WindowFlagHasFullScreen)
183184
{
184185
topInsets = PopupExtension.GetWindowInsets("Top");
185186
}
186-
#endif
187+
188+
// 994925: In resize mode, skip adding keyboard height in .NET 10 because the root view already includes it.
189+
platformRootViewHeight = platformRootView.Height - topInsets - bottomInsets;
190+
#else
187191

188192
if (IsResizeMode() && !WindowFlagHasNoLimits)
189193
{
190194
platformRootViewHeight = platformRootView.Height + (GetKeyboardHeight() * WindowOverlayHelper._density);
191195
}
192196
else
193197
{
194-
platformRootViewHeight = platformRootView.Height - topInsets - bottomInsets;
198+
platformRootViewHeight = platformRootView.Height;
195199
}
200+
#endif
196201

197202
return (int)Math.Round(platformRootViewHeight / WindowOverlayHelper._density);
198203
}
@@ -265,7 +270,7 @@ internal static int GetWindowInsets(string position)
265270
{
266271
#if NET10_0
267272
// In .NET 10 case, fall back to decorViewFrame when Top inset is 0.
268-
return insets.Top == 0 ? (int)Math.Round((WindowOverlayHelper._decorViewFrame?.Top ?? 0f) / WindowOverlayHelper._density) : insets.Top;
273+
return insets.Top == 0 ? (int)Math.Round(WindowOverlayHelper._decorViewFrame?.Top ?? 0f / WindowOverlayHelper._density) : insets.Top;
269274
#else
270275
return insets.Top;
271276
#endif
@@ -274,7 +279,7 @@ internal static int GetWindowInsets(string position)
274279
{
275280
#if NET10_0
276281
// In .NET 10 case, fall back to decorViewFrame when Left inset is 0.
277-
return insets.Left == 0 ? (int)Math.Round((WindowOverlayHelper._decorViewFrame?.Left ?? 0f) / WindowOverlayHelper._density) : insets.Left;
282+
return insets.Left == 0 ? (int)Math.Round(WindowOverlayHelper._decorViewFrame?.Left ?? 0f / WindowOverlayHelper._density) : insets.Left;
278283
#else
279284
return insets.Left;
280285
#endif

maui/src/Popup/PopupFooter.cs

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ internal void UpdateFooterAppearance()
128128
{
129129
// Accept and Decline button text in SfPopup is cropped initially when FooterFontSize is set.
130130
UpdateFooterStyle();
131-
UpdateFooterChildView();
131+
UpdateFooterChildProperties();
132132
}
133133

134134
/// <summary>
@@ -239,52 +239,6 @@ void AddChildViews()
239239
Children.Add(_footerView);
240240
}
241241

242-
/// <summary>
243-
/// Updates the width and height of the child views.
244-
/// </summary>
245-
void UpdateFooterChildView()
246-
{
247-
if (_popupView is not null && _popupView._popup is not null)
248-
{
249-
if (_popupView._popup.AppearanceMode == PopupButtonAppearanceMode.OneButton)
250-
{
251-
// Need to measure the button, only when the button is not visible(On Initial loading), remeasuring multiple times will cause the improper size for the button(Run time scenario).
252-
if (_acceptButton is not null && !_acceptButton.IsVisible)
253-
{
254-
_acceptButton.HorizontalOptions = LayoutOptions.End;
255-
_acceptButtonWidth = GetFooterButtonWidth(_acceptButton);
256-
_acceptButton.WidthRequest = Math.Max(0, _acceptButtonWidth);
257-
_acceptButton.HeightRequest = Math.Max(0, _footerButtonHeight);
258-
}
259-
}
260-
else if (_popupView._popup.AppearanceMode == PopupButtonAppearanceMode.TwoButton)
261-
{
262-
if (_acceptButton is not null && !_acceptButton.IsVisible)
263-
{
264-
_acceptButtonWidth = GetFooterButtonWidth(_acceptButton);
265-
_acceptButton.WidthRequest = Math.Max(0, _acceptButtonWidth);
266-
_acceptButton.HeightRequest = Math.Max(0, _footerButtonHeight);
267-
}
268-
269-
if (_declineButton is not null && !_declineButton.IsVisible)
270-
{
271-
_declineButtonWidth = GetFooterButtonWidth(_declineButton);
272-
_declineButton.WidthRequest = Math.Max(0, _declineButtonWidth);
273-
_declineButton.HeightRequest = Math.Max(0, _footerButtonHeight);
274-
}
275-
if (_declineButton is not null)
276-
{
277-
_declineButton.IsVisible = _popupView._popup.ShowFooter;
278-
}
279-
}
280-
if (_acceptButton is not null)
281-
{
282-
_acceptButton.IsVisible = _popupView._popup.ShowFooter;
283-
}
284-
}
285-
}
286-
287-
288242
/// <summary>
289243
/// Gets the footer button width based on text size.
290244
/// </summary>

maui/src/Popup/SfPopup/SfPopup.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,16 +1828,6 @@ internal bool DismissPopup()
18281828
_showYPosition = -1;
18291829
_keyboardHeight = 0;
18301830
SetPopupViewDefaultHeight();
1831-
1832-
if (_popupOverlayContainer is not null)
1833-
{
1834-
_popupOverlayContainer.Parent = null;
1835-
}
1836-
1837-
if (_popupView is not null)
1838-
{
1839-
_popupView.Parent = null;
1840-
}
18411831
}
18421832

18431833
if (_popupView is not null && _popupView._popup._taskCompletionSource is not null)
@@ -2105,7 +2095,7 @@ void DisplayPopup()
21052095
{
21062096
// 989436 : [Android] Popup is not shown when IsOpen is set in XAML or constructor at loading with a Shell page.
21072097
// In Android, the Shell page is not loaded initially, so the popup is displayed only after the Shell page has loaded.
2108-
if (_popupView == null || (PopupExtension.GetMainWindowPage() is Shell shellPage && !shellPage.IsLoaded))
2098+
if (_popupView == null || (PopupExtension.GetMainWindowPage() is Shell shellPage && shellPage.CurrentPage == null && !shellPage.IsLoaded))
21092099
{
21102100
_isOpenDeferred = true;
21112101
WireEvents();
@@ -3360,6 +3350,17 @@ void ProcessAnimationCompleted(View view)
33603350
{
33613351
ResetAnimatedProperties();
33623352
RemovePopupViewAndResetValues();
3353+
3354+
// 991903: Fixed issue where Popup closing animation was not working on iOS and macOS.
3355+
if (_popupOverlayContainer is not null)
3356+
{
3357+
_popupOverlayContainer.Parent = null;
3358+
}
3359+
3360+
if (_popupView is not null)
3361+
{
3362+
_popupView.Parent = null;
3363+
}
33633364
}
33643365

33653366
RaisePopupEvent();
@@ -3713,7 +3714,7 @@ static void OnIsFullScreenPropertyChanged(BindableObject bindable, object oldVal
37133714
static void OnAppearanceModePropertyChanged(BindableObject bindable, object oldValue, object newValue)
37143715
{
37153716
var popup = (SfPopup)bindable;
3716-
if (popup is not null && popup._popupView is not null && popup._popupView._footerView is not null && popup._popupView.IsViewLoaded)
3717+
if (popup is not null && popup._popupView is not null && popup._popupView._footerView is not null)
37173718
{
37183719
popup._popupView._footerView.UpdateFooterChild();
37193720
if (popup.IsOpen)

maui/src/Popup/SfPopup/SfPopup.iOS.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ internal void WirePlatformSpecificEvents()
5858
if (ModalPage is not null)
5959
{
6060
// Wired the size change event for the Modal page when a popup is opened from it.
61-
ModalPage.SizeChanged += this.OnMainPageSizeChanged;
61+
ModalPage.SizeChanged += OnMainPageSizeChanged;
6262
}
6363
else if (windowPage is Shell shellPage && shellPage.CurrentPage != null)
6464
{
6565
// Maui:990575-TODO : Shell page size changed event not triggered after .NET 10 update, so wire the size changed event for the current page of the Shell page.
66-
shellPage.CurrentPage.SizeChanged += this.OnMainPageSizeChanged;
66+
shellPage.CurrentPage.SizeChanged += OnMainPageSizeChanged;
6767
}
6868
else
6969
{
70-
windowPage.SizeChanged += this.OnMainPageSizeChanged;
70+
windowPage.SizeChanged += OnMainPageSizeChanged;
7171
}
7272
}
7373

0 commit comments

Comments
 (0)