Merge pull request #102 from LuckyDucko/Net8Upgrade

Net8 upgrade
This commit is contained in:
Tyson Elliot Hooker
2024-01-14 17:05:30 +11:00
committed by GitHub
9 changed files with 70 additions and 24 deletions

View File

@@ -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>

View File

@@ -116,7 +116,7 @@ public partial class PopupPage : ContentPage
public PopupPage()
{
//BackgroundColor = Color.FromArgb("#80000000");
BackgroundColor = Colors.Transparent;
}
protected override bool OnBackButtonPressed()
@@ -284,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)
@@ -294,6 +294,8 @@ public partial class PopupPage : ContentPage
if (OnBackgroundClicked())
{
MopupService.Instance.RemovePageAsync(this).SafeFireAndForget();
return true;
}
return false;
}
}

View File

@@ -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)

View File

@@ -36,13 +36,19 @@ public class AndroidMopups : IPopupPlatform
public Task AddAsync(PopupPage page)
{
HandleAccessibility(true, page.DisableAndroidAccessibilityHandling);
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;
return PostAsync(AndroidNativeView);
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)
@@ -51,7 +57,7 @@ public class AndroidMopups : IPopupPlatform
if (renderer != null)
{
HandleAccessibility(false, page.DisableAndroidAccessibilityHandling);
HandleAccessibility(false, page.DisableAndroidAccessibilityHandling, page.Parent as Page);
DecoreView?.RemoveView(renderer.PlatformView as Android.Views.View);
renderer.DisconnectHandler(); //?? no clue if works
@@ -65,7 +71,7 @@ public class AndroidMopups : IPopupPlatform
//! 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)
void HandleAccessibility(bool showPopup, bool disableAccessibilityHandling, Page? mainPage = null)
{
if (disableAccessibilityHandling)
{
@@ -74,7 +80,7 @@ public class AndroidMopups : IPopupPlatform
if (showPopup)
{
Page? mainPage = Application.Current?.MainPage;
mainPage ??= Application.Current?.MainPage;
if (mainPage is null)
{

View File

@@ -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();

View File

@@ -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)
{

View File

@@ -10,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;
@@ -26,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;

View File

@@ -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>

View File

@@ -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> -->