Merge branch 'LuckyDucko:master' into master
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
|
||||
<TargetFrameworks>net7.0;net7.0-ios;net7.0-maccatalyst;;net7.0-android33.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0;net8.0-maccatalyst;net8.0-ios;net8.0-android34.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
|
||||
|
||||
<!-- iOS, Android, MacCatalyst -->
|
||||
<UseMaui>true</UseMaui>
|
||||
@@ -27,12 +27,14 @@
|
||||
<Authors>Tyson Hooker,Maksym Koshovyi,Aswin P G, Kirill Lyubimov, Martijn Van Dijk, Shane Neuville</Authors>
|
||||
<Company>$(CompanyName)</Company>
|
||||
<PackageTags>Mopups;Popups;Maui;rg;Xamarin;ios;android;Windows;MacOS;Mopups;Dialogs;macos;windows</PackageTags>
|
||||
<Version>1.2.0</Version>
|
||||
<Version>1.3.0</Version>
|
||||
<Title>Mopups (Maui Popups)</Title>
|
||||
<PackageReleaseNotes>Finally did a release that should support Windows
|
||||
Added in previous work for awaitable popups directly into this repo under prebaked.</PackageReleaseNotes>
|
||||
<PackageReleaseNotes>Added in several fixes from the community (THANKYOU!)
|
||||
|
||||
Upgraded to .NET 8</PackageReleaseNotes>
|
||||
<IncludeSymbols>True</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<PublishAot>True</PublishAot>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-android|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -80,6 +82,23 @@ Added in previous work for awaitable popups directly into this repo under prebak
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
|
||||
<EnableSGenConc>True</EnableSGenConc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
|
||||
<EnableSGenConc>True</EnableSGenConc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android34.0|AnyCPU'">
|
||||
<AndroidLinkTool>r8</AndroidLinkTool>
|
||||
<RunAOTCompilation>True</RunAOTCompilation>
|
||||
<EnableLLVM>True</EnableLLVM>
|
||||
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android34.0|AnyCPU'">
|
||||
<RunAOTCompilation>True</RunAOTCompilation>
|
||||
<EnableLLVM>True</EnableLLVM>
|
||||
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncAwaitBestPractices" Version="6.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System.Windows.Input;
|
||||
|
||||
using AsyncAwaitBestPractices;
|
||||
|
||||
using AsyncAwaitBestPractices;
|
||||
using Mopups.Animations;
|
||||
using Mopups.Animations.Base;
|
||||
using Mopups.Enums;
|
||||
using Mopups.Services;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Mopups.Pages;
|
||||
|
||||
@@ -108,17 +106,17 @@ public partial class PopupPage : ContentPage
|
||||
set => SetValue(BackgroundClickedCommandParameterProperty, value);
|
||||
}
|
||||
|
||||
public static readonly BindableProperty AndroidTalkbackAccessibilityWorkaroundProperty = BindableProperty.Create(nameof(AndroidTalkbackAccessibilityWorkaround), typeof(bool), typeof(PopupPage), false);
|
||||
public static readonly BindableProperty DisableAndroidAccessibilityHandlingProperty = BindableProperty.Create(nameof(DisableAndroidAccessibilityHandling), typeof(bool), typeof(PopupPage), false);
|
||||
|
||||
public bool AndroidTalkbackAccessibilityWorkaround
|
||||
public bool DisableAndroidAccessibilityHandling
|
||||
{
|
||||
get => (bool)GetValue(AndroidTalkbackAccessibilityWorkaroundProperty);
|
||||
set => SetValue(AndroidTalkbackAccessibilityWorkaroundProperty, value);
|
||||
get => (bool)GetValue(DisableAndroidAccessibilityHandlingProperty);
|
||||
set => SetValue(DisableAndroidAccessibilityHandlingProperty, value);
|
||||
}
|
||||
|
||||
public PopupPage()
|
||||
{
|
||||
//BackgroundColor = Color.FromArgb("#80000000");
|
||||
BackgroundColor = Colors.Transparent;
|
||||
}
|
||||
|
||||
protected override bool OnBackButtonPressed()
|
||||
@@ -286,7 +284,7 @@ public partial class PopupPage : ContentPage
|
||||
return CloseWhenBackgroundIsClicked;
|
||||
}
|
||||
|
||||
internal void SendBackgroundClick()
|
||||
internal bool SendBackgroundClick()
|
||||
{
|
||||
BackgroundClicked?.Invoke(this, EventArgs.Empty);
|
||||
if (BackgroundClickedCommand?.CanExecute(BackgroundClickedCommandParameter) == true)
|
||||
@@ -296,6 +294,8 @@ public partial class PopupPage : ContentPage
|
||||
if (OnBackgroundClicked())
|
||||
{
|
||||
MopupService.Instance.RemovePageAsync(this).SafeFireAndForget();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,12 @@ public class PopupPageHandler : PageHandler
|
||||
|
||||
public PopupPageHandler()
|
||||
{
|
||||
this.SetMauiContext(MauiApplication.Current.Application.Windows[0].Handler.MauiContext);
|
||||
SetMauiContext(MauiApplication.Current.Application.Windows[0].Handler.MauiContext);
|
||||
}
|
||||
|
||||
public PopupPageHandler(IMauiContext context)
|
||||
{
|
||||
SetMauiContext(context);
|
||||
}
|
||||
|
||||
protected override void ConnectHandler(ContentViewGroup platformView)
|
||||
|
||||
@@ -115,13 +115,13 @@ public class PopupPageRenderer : ContentViewGroup
|
||||
systemPadding = new Thickness();
|
||||
}
|
||||
|
||||
(PopupHandler.VirtualView as PopupPage).SetValue(PopupPage.SystemPaddingProperty, systemPadding);
|
||||
(PopupHandler.VirtualView as PopupPage).SetValue(PopupPage.KeyboardOffsetProperty, keyboardOffset);
|
||||
(PopupHandler.VirtualView as PopupPage)?.SetValue(PopupPage.SystemPaddingProperty, systemPadding);
|
||||
(PopupHandler.VirtualView as PopupPage)?.SetValue(PopupPage.KeyboardOffsetProperty, keyboardOffset);
|
||||
|
||||
if (changed)
|
||||
(PopupHandler.VirtualView as PopupPage).Layout(new Rect(Context.FromPixels(left), Context.FromPixels(top), Context.FromPixels(right), Context.FromPixels(bottom)));
|
||||
(PopupHandler.VirtualView as PopupPage)?.Layout(new Rect(Context.FromPixels(left), Context.FromPixels(top), Context.FromPixels(right), Context.FromPixels(bottom)));
|
||||
else
|
||||
(PopupHandler.VirtualView as PopupPage).ForceLayout();
|
||||
(PopupHandler.VirtualView as PopupPage)?.ForceLayout();
|
||||
base.OnLayout(changed, left, top, right, bottom);
|
||||
//base.OnLayout(changed, 20, 500, 1080, 2000);
|
||||
//base.OnLayout(changed, visibleRect.Left, visibleRect.Top, visibleRect.Right, visibleRect.Bottom);
|
||||
|
||||
@@ -36,20 +36,19 @@ public class AndroidMopups : IPopupPlatform
|
||||
|
||||
public Task AddAsync(PopupPage page)
|
||||
{
|
||||
try
|
||||
{
|
||||
HandleAccessibility(true);
|
||||
HandleAccessibility(true, page.DisableAndroidAccessibilityHandling, page.Parent as Page);
|
||||
|
||||
page.Parent = MauiApplication.Current.Application.Windows[0].Content as Element;
|
||||
var AndroidNativeView = IPopupPlatform.GetOrCreateHandler<PopupPageHandler>(page).PlatformView as Android.Views.View;
|
||||
DecoreView?.AddView(AndroidNativeView);
|
||||
page.Parent = MauiApplication.Current.Application.Windows[0].Content as Element;
|
||||
page.Parent ??= MauiApplication.Current.Application.Windows[0].Content as Element;
|
||||
|
||||
return PostAsync(AndroidNativeView);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
var handler = page.Handler ??= new PopupPageHandler(page.Parent.Handler.MauiContext);
|
||||
|
||||
var androidNativeView = handler.PlatformView as Android.Views.View;
|
||||
var decoreView = Platform.CurrentActivity?.Window?.DecorView as FrameLayout;
|
||||
|
||||
decoreView?.AddView(androidNativeView);
|
||||
|
||||
return PostAsync(androidNativeView);
|
||||
}
|
||||
|
||||
public Task RemoveAsync(PopupPage page)
|
||||
@@ -58,7 +57,7 @@ public class AndroidMopups : IPopupPlatform
|
||||
|
||||
if (renderer != null)
|
||||
{
|
||||
HandleAccessibility(false);
|
||||
HandleAccessibility(false, page.DisableAndroidAccessibilityHandling, page.Parent as Page);
|
||||
|
||||
DecoreView?.RemoveView(renderer.PlatformView as Android.Views.View);
|
||||
renderer.DisconnectHandler(); //?? no clue if works
|
||||
@@ -70,35 +69,50 @@ public class AndroidMopups : IPopupPlatform
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static void HandleAccessibility(bool showPopup)
|
||||
//! important keeps reference to pages that accessibility has applied to. This is so accessibility can be removed properly when popup is removed. #https://github.com/LuckyDucko/Mopups/issues/93
|
||||
readonly List<Android.Views.View?> views = new();
|
||||
void HandleAccessibility(bool showPopup, bool disableAccessibilityHandling, Page? mainPage = null)
|
||||
{
|
||||
Page? mainPage = Application.Current?.MainPage;
|
||||
|
||||
if (mainPage is null)
|
||||
if (disableAccessibilityHandling)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int navCount = mainPage.Navigation.NavigationStack.Count;
|
||||
int modalCount = mainPage.Navigation.ModalStack.Count;
|
||||
|
||||
ProcessView(showPopup, mainPage.Handler?.PlatformView as Android.Views.View);
|
||||
|
||||
if (navCount > 0)
|
||||
if (showPopup)
|
||||
{
|
||||
ProcessView(showPopup, mainPage.Navigation?.NavigationStack[navCount - 1]?.Handler?.PlatformView as Android.Views.View);
|
||||
mainPage ??= Application.Current?.MainPage;
|
||||
|
||||
if (mainPage is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
views.Add(mainPage.Handler?.PlatformView as Android.Views.View);
|
||||
|
||||
int navCount = mainPage.Navigation.NavigationStack.Count;
|
||||
int modalCount = mainPage.Navigation.ModalStack.Count;
|
||||
|
||||
if (navCount > 0)
|
||||
{
|
||||
views.Add(mainPage.Navigation?.NavigationStack[navCount - 1]?.Handler?.PlatformView as Android.Views.View);
|
||||
}
|
||||
|
||||
if (modalCount > 0)
|
||||
{
|
||||
views.Add(mainPage.Navigation?.ModalStack[modalCount - 1]?.Handler?.PlatformView as Android.Views.View);
|
||||
}
|
||||
}
|
||||
|
||||
if (modalCount > 0)
|
||||
foreach (var view in views)
|
||||
{
|
||||
ProcessView(showPopup, mainPage.Navigation?.ModalStack[modalCount - 1]?.Handler?.PlatformView as Android.Views.View);
|
||||
ProcessView(showPopup, view);
|
||||
}
|
||||
|
||||
static void ProcessView(bool showPopup, Android.Views.View? view)
|
||||
{
|
||||
if (view is null)
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// Screen reader
|
||||
@@ -110,7 +124,7 @@ public class AndroidMopups : IPopupPlatform
|
||||
}
|
||||
}
|
||||
|
||||
Task<bool> PostAsync(Android.Views.View? nativeView)
|
||||
static Task<bool> PostAsync(Android.Views.View? nativeView)
|
||||
{
|
||||
if (nativeView == null)
|
||||
{
|
||||
|
||||
@@ -6,9 +6,13 @@ namespace Mopups.Platforms.iOS
|
||||
{
|
||||
public PopupPageHandler()
|
||||
{
|
||||
this.SetMauiContext(MauiUIApplicationDelegate.Current.Application.Windows[0].Handler.MauiContext); //Still a hack?
|
||||
SetMauiContext(MauiUIApplicationDelegate.Current.Application.Windows[0].Handler.MauiContext); //Still a hack?
|
||||
}
|
||||
|
||||
public PopupPageHandler(IMauiContext context)
|
||||
{
|
||||
SetMauiContext(context); //Still a hack?
|
||||
}
|
||||
protected override Microsoft.Maui.Platform.ContentView CreatePlatformView()
|
||||
{
|
||||
return base.CreatePlatformView();
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Mopups.Platforms.iOS
|
||||
{
|
||||
internal class PopupWindow : UIWindow
|
||||
{
|
||||
|
||||
private bool _stop = false;
|
||||
public PopupWindow(IntPtr handle) : base(handle)
|
||||
{
|
||||
}
|
||||
@@ -24,6 +26,12 @@ namespace Mopups.Platforms.iOS
|
||||
|
||||
public override UIView HitTest(CGPoint point, UIEvent? uievent)
|
||||
{
|
||||
|
||||
if (_stop)
|
||||
{
|
||||
return base.HitTest(point, uievent);
|
||||
}
|
||||
|
||||
var platformHandler = (PopupPageRenderer?)RootViewController;
|
||||
var renderer = platformHandler?.Handler;
|
||||
var hitTestResult = base.HitTest(point, uievent);
|
||||
@@ -36,6 +44,11 @@ namespace Mopups.Platforms.iOS
|
||||
|
||||
if ((formsElement.BackgroundInputTransparent || formsElement.CloseWhenBackgroundIsClicked ) && renderer?.PlatformView == hitTestResult)
|
||||
{
|
||||
if (formsElement.CloseWhenBackgroundIsClicked)
|
||||
{
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
formsElement.SendBackgroundClick();
|
||||
if (formsElement.BackgroundInputTransparent)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using CoreGraphics;
|
||||
|
||||
|
||||
using Mopups.Interfaces;
|
||||
using Mopups.Interfaces;
|
||||
using Mopups.Pages;
|
||||
using Mopups.Platforms.iOS;
|
||||
|
||||
using UIKit;
|
||||
using UIKit;
|
||||
namespace Mopups.iOS.Implementation;
|
||||
|
||||
internal class iOSMopups : IPopupPlatform
|
||||
@@ -13,15 +10,13 @@ internal class iOSMopups : IPopupPlatform
|
||||
// It's necessary because GC in Xamarin.iOS 13 removes all UIWindow if there are not any references to them. See #459
|
||||
private readonly List<UIWindow> _windows = new List<UIWindow>();
|
||||
|
||||
private static bool IsiOS9OrNewer => UIDevice.CurrentDevice.CheckSystemVersion(9, 0);
|
||||
|
||||
private static bool IsiOS13OrNewer => UIDevice.CurrentDevice.CheckSystemVersion(13, 0);
|
||||
|
||||
public bool IsSystemAnimationEnabled => true;
|
||||
|
||||
public Task AddAsync(PopupPage page)
|
||||
{
|
||||
page.Parent = Application.Current.MainPage;
|
||||
page.Parent ??= Application.Current?.MainPage;
|
||||
|
||||
page.DescendantRemoved += HandleChildRemoved;
|
||||
|
||||
@@ -29,7 +24,7 @@ internal class iOSMopups : IPopupPlatform
|
||||
if (keyWindow?.WindowLevel == UIWindowLevel.Normal)
|
||||
keyWindow.WindowLevel = -1;
|
||||
|
||||
var handler = (PopupPageHandler)IPopupPlatform.GetOrCreateHandler<PopupPageHandler>(page);
|
||||
var handler = (page.Handler ??= new PopupPageHandler(page.Parent.Handler.MauiContext)) as PopupPageHandler;
|
||||
|
||||
PopupWindow window;
|
||||
|
||||
@@ -57,7 +52,7 @@ internal class iOSMopups : IPopupPlatform
|
||||
|
||||
handler.ViewController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
|
||||
handler.ViewController.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
|
||||
|
||||
|
||||
|
||||
return window.RootViewController.PresentViewControllerAsync(handler.ViewController, false);
|
||||
|
||||
@@ -124,12 +119,15 @@ internal class iOSMopups : IPopupPlatform
|
||||
|
||||
private static void DisposeModelAndChildrenHandlers(VisualElement view)
|
||||
{
|
||||
foreach (Element child in view.GetVisualTreeDescendants())
|
||||
foreach (var descendant in view.GetVisualTreeDescendants())
|
||||
{
|
||||
IElementHandler handler = child.Handler;
|
||||
child?.Handler?.DisconnectHandler();
|
||||
(handler?.PlatformView as UIView)?.RemoveFromSuperview();
|
||||
(handler?.PlatformView as UIView)?.Dispose();
|
||||
if (descendant is IElement child)
|
||||
{
|
||||
IElementHandler handler = child.Handler;
|
||||
child?.Handler?.DisconnectHandler();
|
||||
(handler?.PlatformView as UIView)?.RemoveFromSuperview();
|
||||
(handler?.PlatformView as UIView)?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
view?.Handler?.DisconnectHandler();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
|
||||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true" android:theme="@style/AppTheme"></application>
|
||||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:theme="@style/AppTheme"></application>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
</manifest>
|
||||
@@ -2,8 +2,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
|
||||
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0-maccatalyst;net8.0-ios;net8.0-android</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
|
||||
|
||||
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
|
||||
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
|
||||
|
||||
Reference in New Issue
Block a user