First convert
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst;</TargetFrameworks>
|
||||
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst;</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<!-- iOS, Android, MacCatalyst -->
|
||||
<UseMaui>true</UseMaui>
|
||||
<UseMauiEssentials>true</UseMauiEssentials>
|
||||
@@ -12,10 +13,11 @@
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
|
||||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-android|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
@@ -32,20 +34,17 @@
|
||||
<Title>Mopups (Maui Popups)</Title>
|
||||
<PackageReleaseNotes>Fixed OnAppearing/OnDisappearing Event not firing</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-android|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0|AnyCPU'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0|AnyCPU'">
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0|AnyCPU'">
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncAwaitBestPractices" Version="6.0.4" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Platforms\MacCatalyst\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Maui.Handlers;
|
||||
using Microsoft.Maui.Platform;
|
||||
|
||||
namespace Mopups.Platforms.Windows
|
||||
{
|
||||
public class PopupPageHandler : PageHandler
|
||||
{
|
||||
public PopupPageHandler()
|
||||
{
|
||||
}
|
||||
|
||||
protected override ContentPanel CreatePlatformView()
|
||||
{
|
||||
return new PopupPageRenderer(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
using Microsoft.Maui.Platform;
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.ViewManagement;
|
||||
using Rect = Windows.Foundation.Rect;
|
||||
using Size = Windows.Foundation.Size;
|
||||
using Mopups.Pages;
|
||||
using WinPopup = global::Microsoft.UI.Xaml.Controls.Primitives.Popup;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Mopups.Platforms.Windows
|
||||
{
|
||||
public class PopupPageRenderer : ContentPanel
|
||||
{
|
||||
private Rect _keyboardBounds;
|
||||
private readonly PopupPageHandler handler;
|
||||
|
||||
internal WinPopup? Container { get; private set; }
|
||||
|
||||
private PopupPage CurrentElement => (PopupPage)handler.VirtualView;
|
||||
|
||||
public PopupPageRenderer(PopupPageHandler handler)
|
||||
{
|
||||
this.handler = handler;
|
||||
this.Loaded += OnLoaded;
|
||||
this.Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
private void OnKeyboardHiding(InputPane sender, InputPaneVisibilityEventArgs args)
|
||||
{
|
||||
_keyboardBounds = Rect.Empty;
|
||||
UpdateElementSize();
|
||||
}
|
||||
|
||||
private void OnKeyboardShowing(InputPane sender, InputPaneVisibilityEventArgs args)
|
||||
{
|
||||
_keyboardBounds = sender.OccludedRect;
|
||||
UpdateElementSize();
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
UpdateElementSize();
|
||||
|
||||
return base.ArrangeOverride(finalSize);
|
||||
}
|
||||
|
||||
internal void Prepare(WinPopup container)
|
||||
{
|
||||
Container = container;
|
||||
|
||||
// Not sure off hand the replacement on these
|
||||
//var inputPane = InputPane.GetForCurrentView();
|
||||
//inputPane.Showing += OnKeyboardShowing;
|
||||
//inputPane.Hiding += OnKeyboardHiding;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void OnUnloaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
DeviceDisplay.Current.MainDisplayInfoChanged -= OnDisplayInfoChanged;
|
||||
PointerPressed -= OnBackgroundClick;
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
DeviceDisplay.Current.MainDisplayInfoChanged += OnDisplayInfoChanged;
|
||||
PointerPressed += OnBackgroundClick;
|
||||
}
|
||||
|
||||
private void OnDisplayInfoChanged(object? sender, DisplayInfoChangedEventArgs e)
|
||||
{
|
||||
//Handled size and orientation changes here
|
||||
}
|
||||
|
||||
internal void Destroy()
|
||||
{
|
||||
Container = null;
|
||||
|
||||
DeviceDisplay.Current.MainDisplayInfoChanged -= OnDisplayInfoChanged;
|
||||
PointerPressed -= OnBackgroundClick;
|
||||
|
||||
// Not sure off hand the replacement on these
|
||||
//var inputPane = InputPane.GetForCurrentView();
|
||||
//inputPane.Showing -= OnKeyboardShowing;
|
||||
//inputPane.Hiding -= OnKeyboardHiding;
|
||||
|
||||
PointerPressed -= OnBackgroundClick;
|
||||
}
|
||||
|
||||
private void OnOrientationChanged(DisplayInformation sender, object args)
|
||||
{
|
||||
UpdateElementSize();
|
||||
}
|
||||
|
||||
private void OnSizeChanged(object sender, WindowSizeChangedEventArgs e)
|
||||
{
|
||||
UpdateElementSize();
|
||||
}
|
||||
|
||||
private void OnBackgroundClick(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if ((e.OriginalSource as PopupPageRenderer) == this)
|
||||
{
|
||||
CurrentElement.SendBackgroundClick();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateElementSize()
|
||||
{
|
||||
if (CurrentElement != null)
|
||||
{
|
||||
var capturedElement = CurrentElement;
|
||||
|
||||
//Window.Current.Bounds replacement
|
||||
var platformWindow = handler.MauiContext.Services.GetService<Microsoft.UI.Xaml.Window>();
|
||||
var windowBound = platformWindow.Bounds;
|
||||
|
||||
|
||||
//var visibleBounds = ApplicationView.GetForCurrentView().VisibleBounds;
|
||||
// Need to locate the replacement for VisibleBounds
|
||||
var visibleBounds = windowBound;
|
||||
|
||||
var keyboardHeight = _keyboardBounds != Rect.Empty ? _keyboardBounds.Height : 0;
|
||||
|
||||
var top = Math.Max(0, visibleBounds.Top - windowBound.Top);
|
||||
var bottom = Math.Max(0, windowBound.Bottom - visibleBounds.Bottom);
|
||||
var left = Math.Max(0, visibleBounds.Left - windowBound.Left);
|
||||
var right = Math.Max(0, windowBound.Right - visibleBounds.Right);
|
||||
|
||||
var systemPadding = new Thickness(left, top, right, bottom);
|
||||
|
||||
capturedElement.SetValue(PopupPage.SystemPaddingProperty, systemPadding);
|
||||
capturedElement.SetValue(PopupPage.KeyboardOffsetProperty, keyboardHeight);
|
||||
//if its not invoked on MainThread when the popup is showed it will be blank until the user manually resizes of owner window
|
||||
this.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
capturedElement.Layout(new Microsoft.Maui.Graphics.Rect(windowBound.X, windowBound.Y, windowBound.Width, windowBound.Height));
|
||||
capturedElement.ForceLayout();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
SampleMaui/Platforms/Windows/App.xaml
Normal file
8
SampleMaui/Platforms/Windows/App.xaml
Normal file
@@ -0,0 +1,8 @@
|
||||
<maui:MauiWinUIApplication
|
||||
x:Class="SampleMaui.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:maui="using:Microsoft.Maui"
|
||||
xmlns:local="using:SampleMaui.WinUI">
|
||||
|
||||
</maui:MauiWinUIApplication>
|
||||
24
SampleMaui/Platforms/Windows/App.xaml.cs
Normal file
24
SampleMaui/Platforms/Windows/App.xaml.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace SampleMaui.WinUI;
|
||||
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
public partial class App : MauiWinUIApplication
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
|
||||
}
|
||||
|
||||
46
SampleMaui/Platforms/Windows/Package.appxmanifest
Normal file
46
SampleMaui/Platforms/Windows/Package.appxmanifest
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="F225AABE-A6FB-4C70-A52B-06DC16DFDA4E" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>$placeholder$</DisplayName>
|
||||
<PublisherDisplayName>User Name</PublisherDisplayName>
|
||||
<Logo>$placeholder$.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="$placeholder$"
|
||||
Description="$placeholder$"
|
||||
Square150x150Logo="$placeholder$.png"
|
||||
Square44x44Logo="$placeholder$.png"
|
||||
BackgroundColor="transparent">
|
||||
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />
|
||||
<uap:SplashScreen Image="$placeholder$.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
|
||||
</Package>
|
||||
15
SampleMaui/Platforms/Windows/app.manifest
Normal file
15
SampleMaui/Platforms/Windows/app.manifest
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="SampleMaui.app"/>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<!-- The combination of below two tags have the following effect:
|
||||
1) Per-Monitor for >= Windows 10 Anniversary Update
|
||||
2) System < Windows 10 Anniversary Update
|
||||
-->
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
||||
@@ -3,6 +3,10 @@
|
||||
"SampleMopups": {
|
||||
"commandName": "Project",
|
||||
"hotReloadEnabled": true
|
||||
},
|
||||
"Windows Machine": {
|
||||
"commandName": "MsixPackage",
|
||||
"nativeDebugging": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
|
||||
<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks> -->
|
||||
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.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);net6.0-tizen</TargetFrameworks> -->
|
||||
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>SampleMaui</RootNamespace>
|
||||
<UseMaui>true</UseMaui>
|
||||
@@ -21,9 +21,10 @@
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
|
||||
<!-- <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
|
||||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>-->
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
|
||||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
|
||||
|
||||
<!--<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>-->
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- App Icon -->
|
||||
|
||||
Reference in New Issue
Block a user