Rg.Plugins.Popup icon indicating copy to clipboard operation
Rg.Plugins.Popup copied to clipboard

MAUI support timeline

Open jeremy-bridges opened this issue 2 years ago • 44 comments

💬 Questions and Help

I'm curious if contributors are going to move to support MAUI. Ideally, I'd love to test out this new platform while it is in beta. Ideally, pre-release packages of Rg.Plugins.Popup would facilitate this testing. Thanks for considering it.

jeremy-bridges avatar Jul 30 '21 16:07 jeremy-bridges

Hey @jeremy-bridges i have recently been thinking about this, and how to go about doing it.

I definitely plan on giving it an attempt, my concerns is our custom renderers we use on each platform, as apart from Android/iOS i am at a loss for other platforms.

LuckyDucko avatar Aug 01 '21 00:08 LuckyDucko

Would also love it if we get MAUI support. Rg is currently solving a pretty niche problem we have in our project and we are planning to move over to MAUI as soon as it drops.

stefandb1995 avatar Sep 03 '21 06:09 stefandb1995

+1 on this. I tried using pop-up from community toolkit, but it lacks animations and has some bugs. Would be great to see this NuGet migrated to MAUI. I only need Android implementation, so if you could do first pre release with just Android (or Android & iOS) that would be great.

maxkoshevoi avatar Sep 03 '21 08:09 maxkoshevoi

All custom renderers and other Xamarin.Forms stuff should still work in MAUI through some compatibility namespace. Similar to how they'd created Xamarin.CommunityToolkit.MauiCompat

https://devblogs.microsoft.com/xamarin/introducing-net-maui-compatibility-for-the-xamarin-community-toolkit/

maxkoshevoi avatar Sep 03 '21 08:09 maxkoshevoi

I recently started doing work on this on Windows Visual studio, using the compatibility tools and whatnot.

Almost got a working prototype for Android, however, I was having issues with deployment and just generally not understanding the windows version.

I will be able to complete this once they have a working version of MAUI for Mac VS, or at least something workable.

we definitely will try an Android/iOS version first, moving forward from there.

LuckyDucko avatar Sep 17 '21 01:09 LuckyDucko

Not sure if it's still gonna help, but I found an article detailing how to perform the migration: https://www.syncfusion.com/blogs/post/how-to-reuse-xamarin-forms-custom-renderers-in-net-maui.aspx

maxkoshevoi avatar Sep 17 '21 07:09 maxkoshevoi

@LuckyDucko let me know what we can do to help you out. [email protected] @redth

davidortinau avatar Sep 23 '21 18:09 davidortinau

@maxkoshevoi & others I've made my first prototype thrown up on the new Maui-Compatibility branch. I have not gone through what is mentioned on that sync fusion post exactly, just bashed around until popups started appearing. There still seems to be some weird issues which I'm sure are my own fault. Currently its only Android. Also, would love some help from people remaking the xaml pages to be 'maui compatible' so then we can determine what's actually wrong with my changes.

@davidortinau the shock/surprise of you dropping into this thread kicked me into gear, so thank you for that. I think the best help would be the ongoing changes to the what MAUI Xaml is, as right now it has me spinning (Why does everything suddenly need .Content? im sure there is a good reason.)

LuckyDucko avatar Sep 29 '21 09:09 LuckyDucko

  1. I think you should retarget package to net6.0;net6.0-ios;net6.0-android;net6.0-maccatalyst;net6.0-windows.
  2. You should remove all Xamarin.Forms packages (and packages that reference Xamarin.Forms), and add this to csproj
<UseMaui>true</UseMaui><!-- To add MAUI packages -->
<SingleProject>true</SingleProject><!-- To support using code for different platforms in Platforms folder -->
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling><!-- To use Windows code in single project (https://docs.microsoft.com/ru-ru/windows/apps/windows-app-sdk/single-project-msix) -->

Also add this to enable implicit usings: <ImplicitUsings>enable</ImplicitUsings>

  1. Related to 2. You need to update all usings from Xamarin.Forms.* to Microsoft.Maui.*. try-convert or upgrade-assistant tool might help with that, but I'm not sure.

maxkoshevoi avatar Sep 29 '21 15:09 maxkoshevoi

@maxkoshevoi I have only targeted net6.0-android on purpose, due to your comment

Would be great to see this NuGet migrated to MAUI. I only need Android implementation, so if you could do first pre release with just Android

The rest will also be done, but it seems a good move to focus on one platform at a time.

i have kept the MAUI work exclusively within https://github.com/rotorgames/Rg.Plugins.Popup/tree/Maui-Compatibility/Rg.Popup.Plugin.Maui

So people are able to compare old v new in this 'transition' period

There is also sampleMaui folder that will eventually replace Samples.

Within this Maui area,

  • i have removed Xamarin.Forms (it comes up as a build error otherwise i believe?)
  • I have enabled UseMaui
  • I have enabled Single project

ImplicitUsings i will add in. The Enable PreviewMSIXTooling i will leave until we start working on Windows implementations.

LuckyDucko avatar Sep 29 '21 22:09 LuckyDucko

i have kept the MAUI work exclusively within https://github.com/rotorgames/Rg.Plugins.Popup/tree/Maui-Compatibility/Rg.Popup.Plugin.Maui

My bad, I didn't notice Rg.Popup.Plugin.Maui folder, opened Rg.Plugins.Popup.sln, and wondered, why is project targeting .netstandard and referencing Xamarin.Forms 😄

I've looked at the Maui project, and cleaned it up a bit. Added .net6 target so that abstractions or non-platform-dependant classes from this NuGet could be used in platform-agnistic projects, and fixed some warnings (functionality is not changed).

Everything builds, but Sample crashes with Microsoft.Maui.Controls.Xaml.XamlParseException: 'Position 21:7. Type converter failed: UintTypeConverter cannot convert from System.String.' on LoginPopupPage

image

Do you also have this behavior? I'm using VS2022 Preview 4.1.

maxkoshevoi avatar Sep 30 '21 06:09 maxkoshevoi

Are you using Rider to auto suggest these fixes (concerning nullable and whatnot) Keep 'em coming, there is some cobwebs in this code (looking at you Task.SetResult) that need to be cleared out.

Hmm, i have not gotten that error yet, using VS2022 Preview as well. Let me download your branch and see whats up.

I just tested your code, and it deploys just fine on my Test Device (Samsung A20). Are you using emulators?

LuckyDucko avatar Sep 30 '21 06:09 LuckyDucko

Are you using Rider to auto suggest these fixes (concerning nullable and whatnot)

Nope, got all suggestions from the VS. There're around 100 warnings left by the way, but fixes would require changing the behavior, and I figured that they are not fixed on purpose (like adding ConfigureAwait and validating all external arguments). image

PS: Some analyzers only analyze open files. Do this force-analyze whole solution: image

I just tested your code, and it deploys just fine on my Test Device (Samsung A20). Are you using emulators?

Glad to hear, that I didn't break anything 😄. Yes, I'm using Android 11 emulator, but it shouldn't affect anything, right? Are you sure, you are using VS Preview 4.x with Maui RC1 (aka Preview 8)? image

maxkoshevoi avatar Sep 30 '21 06:09 maxkoshevoi

(like adding ConfigureAwait and validating all external arguments). I have made a project detailing things that we could add like this while the upgrade is being completed. If you can make a real simple note for it/issue, that would be good, and then i will add it in the project so we remember later

Hmmm, i am using that version of VS preview, and 1.1608 as far as i'm aware.

LuckyDucko avatar Sep 30 '21 07:09 LuckyDucko

Tried it on physical Pixel 4 (Android 12 Beta 5). Same crash. Maybe my VS is broken. PS: git clean -fdx -> Rebuild also didn't help

maxkoshevoi avatar Sep 30 '21 07:09 maxkoshevoi

Have you fixed the UintTypeConverter issue? I fixed it by changing implementation of UintTypeConverter to

public class UintTypeConverter : TypeConverter
{
    public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
    {
        try
        {
            return Convert.ToUInt32(value);
        }
        catch (Exception)
        {
            throw new InvalidOperationException($"Cannot convert {value} into {typeof(uint)}");
        }
    }
}

also, you have to change EasingTypeConverter too

public class EasingTypeConverter : TypeConverter
{
    public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
    {
        if (value != null)
        {
            var fieldInfo = typeof(Easing).GetRuntimeFields()?.FirstOrDefault(fi =>
            {
                if (fi.IsStatic)
                    return fi.Name == value.ToString();
                return false;
            });
            if (fieldInfo != null)
            {
                var fieldValue = fieldInfo.GetValue(null);
                if (fieldValue != null)
                    return (Easing)fieldValue;
            }
        }
        throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Easing)}");
    }
}

yunusefendi52 avatar Oct 01 '21 05:10 yunusefendi52

@yunusefendi52 Good catch! I thought it was a built-in converter. Updated convertors do work.

  • Why did you change this?
if (fieldInfo != null)
    return (Easing?)fieldInfo.GetValue(null);
  • Would you mind creating a PR with new converter implementations?

@LuckyDucko I was able to launch the Sample, thanks to new converters, and now there's another issue. Popups are not closing when I click outside of them. Back button also doesn't do anything. Only clicking on "Close" button on popup itself closes the popup.

maxkoshevoi avatar Oct 01 '21 07:10 maxkoshevoi

Sure @maxkoshevoi, don't know why I changed fieldValuethough but I will changed it back to the original code

yunusefendi52 avatar Oct 01 '21 07:10 yunusefendi52

Back button also doesn't do anything

I think you should set up that manually in MainActivity https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started#android-back-button

yunusefendi52 avatar Oct 01 '21 08:10 yunusefendi52

I think you should set up that manually

Thanks, forgot about that. Good thing is that there's now new "Maui way" of doing this via ConfigureLifecycleEvents. Created a PR.

@LuckyDucko Here's more detailed explanation of the current issue:

  1. If I click outside of the Popup - it doesn't close
  2. If I click outside of the Popup - click is passed to the page underneath (not the case in current stable version)
  3. Back button still doesn't work for LoginPopupPage popup (but works for others)

popup1

maxkoshevoi avatar Oct 01 '21 11:10 maxkoshevoi

@maxkoshevoi good call on the MAUI way idea, i originally had it set up manually in mainactivity, but if there is the MAUI way, we should implement that.

@yunusefendi52 thanks for fixing the converter issue. Its strange to me that i was able to compile and launch without it. But its sorted now. so thats good 👍🏻

The LoginPopupPage i also was having strange issues, i have definitely noticed the issue you mentioning. Once we figure out why click is passing underneath to underlying pages, would we want to keep that as a functionality that can be turned off/on. I can see uses for it.

LuckyDucko avatar Oct 04 '21 22:10 LuckyDucko

@maxkoshevoi

I fixed the situation concerning the LoginPopupPage, i believe it was relating to the use of MainThread. I was making adjustments and wasnt expecting it to work.

However, when i made the popuppage renderer available for Maui, it stopped appearing properly. So i commented that out for now, but would be a good next step

LuckyDucko avatar Oct 05 '21 06:10 LuckyDucko

@LuckyDucko Now all popups not close on back button 😄 You need to remove public override void OnBackPressed() from MainActivity to Maui lifecycle to work (calling base.OnBackPressed() also should work, but didn't test that).

But after fixing that, there're new issues.

  • LoginPopupPage is closing on back button, but cannot be opened again (also it's opening animation is strange. there's some disappearing shadow on the right, and popup is not centered)
  • Closing animation is gone for all popups if closed with back button

popup2

maxkoshevoi avatar Oct 05 '21 08:10 maxkoshevoi

@maxkoshevoi oh my bad, i thought i fully removed it! Fixed

The LoginPopupPage issue you mentioned is because it is a stored Popup Page i changed it to work like the other pages, and it works fine. I imagine most use cases are similar to that. I came across this issue as well, and thought i fixed it. Perhaps i didn't commit my latest changes, made a mistake while reverting other work.

The closing animation situation is new. I have messed around with other animation work, so i will look into that.

The shadow on the right is the scrollbar for a scrollview, it is badly centered. I think i'll leave these two until i get the proper popup renderer working. I think it might be best if i remake it using slim renderers, just so i get a handle on the new technology instead of relying on older compatibility.

(Also need to set up my gpg key for windows, i usually do my work on mac, need to stop added unverified commits)

LuckyDucko avatar Oct 05 '21 09:10 LuckyDucko

Quick update

I'm still working through this. I initially tried to convert our current renderer over to a MAUI handler version, but i ran into some struggles concerning how we use GetRenderer method and whatnot.

So, had to scrap all that work, however, still i struggled to get the actual renderer to work, once enabled it kept just not appearing, and i'm unsure if its a renderer issue, a change in how Maui works concerning our xaml pages, or a mix!

So, my latest idea, is i am recreating the pages in the new CSharp Markup, to take advantage of its autocomplete and also in the hope that this repo will be an example of the same thing made many different ways (XAML/CSharpMarkup/MVU/Blazor?) I plan on taking charge on atleast the beginnings of each of these remakes, which will either be in their own solutions, namespaces, or with extra names (LoginPageXaml/LoginPageCsharpMarkup/LoginPageMVU).

Also, the badly centered scrollbar was a Xaml issue i believe

once Android is at a minimal viable product, i can start organising the project in terms of what needs to be done, and we can continue to move from there

LuckyDucko avatar Oct 15 '21 01:10 LuckyDucko

@martijn00 Why is this closed? Latest NuGet release still doesn't support any of net6 TFMs, and not-yet-released MAUI project in this repository only supports Android. Is MAUI support dropped for this package?

maxkoshevoi avatar Feb 02 '22 11:02 maxkoshevoi

@maxkoshevoi i believe @martijn00 has made a mistake here

I apologise for the loooong hiatus concerning this, i want to get back onto it. The maui release will definitely have breaking changes

LuckyDucko avatar Feb 02 '22 22:02 LuckyDucko

Any updates? As Maui is going to be release soon enough?

scarrier92 avatar May 09 '22 13:05 scarrier92

@scarrier92 I am going to continue development on the Maui version of this release separately in a new repo, due to the breaking changes. I am having some issues however, I do hope to push through with them and have some form of a release

i had an android version working, however, it seems to have stopped, so guess ill be back on that now

LuckyDucko avatar May 10 '22 05:05 LuckyDucko

https://github.com/AswinPG/RGPopup I have a an android working version for maui here with animations and a few bugs :) Thanks to @LuckyDucko for Mopups. That repo helped me a lot while porting.

AswinPG avatar Jun 01 '22 09:06 AswinPG