rotorgames / Rg.Plugins.Popup

Xamarin Forms popup plugin
MIT License
1.15k stars 337 forks source link

MAUI support timeline #684

Open jeremy-bridges opened 3 years ago

jeremy-bridges commented 3 years ago

💬 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.

LuckyDucko commented 3 years ago

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.

stefandb1995 commented 3 years ago

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.

maxkoshevoi commented 3 years ago

+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 commented 3 years ago

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/

LuckyDucko commented 3 years ago

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.

maxkoshevoi commented 3 years ago

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

davidortinau commented 3 years ago

@LuckyDucko let me know what we can do to help you out. david.ortinau@microsoft.com @redth

LuckyDucko commented 3 years ago

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

maxkoshevoi commented 3 years ago

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>

3) 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.

LuckyDucko commented 3 years ago

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

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

maxkoshevoi commented 3 years ago

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.

LuckyDucko commented 3 years ago

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?

maxkoshevoi commented 3 years ago

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

LuckyDucko commented 3 years ago

(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.

maxkoshevoi commented 3 years ago

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

yunusefendi52 commented 3 years ago

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)}");
    }
}
maxkoshevoi commented 3 years ago

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

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

yunusefendi52 commented 3 years ago

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

yunusefendi52 commented 3 years ago

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

maxkoshevoi commented 3 years ago

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](https://user-images.githubusercontent.com/6609929/135610968-cb8643f3-5b63-46ea-8cb0-60c1c5f43478.gif)
LuckyDucko commented 3 years ago

@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 commented 3 years ago

@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

maxkoshevoi commented 3 years ago

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

![popup2](https://user-images.githubusercontent.com/6609929/135984908-9ad5bf8d-9f5f-4506-84d9-c70b0ae38be8.gif)
LuckyDucko commented 3 years ago

@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 commented 3 years ago

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

maxkoshevoi commented 2 years ago

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

LuckyDucko commented 2 years ago

@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

scarrier92 commented 2 years ago

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

LuckyDucko commented 2 years ago

@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

AswinPG commented 2 years ago

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.

LuckyDucko commented 2 years ago

@AswinPG absolute legend! I was stuck on something going pear shaped with Android, i am going to look at the changes you have made and see it work back to my own, as i'm trying to upgrade the codebase as i'm going, which i'm pretty sure is where i've come unstuck.

LuckyDucko commented 2 years ago

And we are off (Android only, and its pre-release so make sure you set that for your searching in Nuget)

Went through Aswin's code and figured out the changes that needed to be made, iOS is next on the list, but let me know what Android issues you have.

I plan on integrating awaitable tasks baked in to popups (not in the way awaitablepopups does it however, as that requires alot of extra that I dont think people want)

https://github.com/LuckyDucko/Mopups https://www.nuget.org/packages/Mopups/1.0.0-preview.14.1

LuckyDucko commented 2 years ago

We now have iOS working and available, Next on the list is UWP , since I know that many Rg users use UWP. Lets hope I can sift through it ;)

tranb3r commented 2 years ago

Is there a nuget that works on ios and android ?

TamerIrdais commented 2 years ago

What's the time estimate for this to be fully supported for Windows and macOS as well?

TamerIrdais commented 2 years ago

@LuckyDucko Can you please provide us with timeframe when this is going to be available for WinUI and macOS? Rg.Plugin.Popup is used all over our code for Xamarin and we are moving to MAUI and this is critical to our work, so I would really appreciate a feedback on my question please.

LuckyDucko commented 2 years ago

@TamerIrdais

In the Mopups Repo, we have a PR for basic MacOS availability.

I cannot provide timeframes as i am only 1 person (with the help of some dedicated individuals), and i have been getting the grips on .Net Web Development.

The next goals however are MacOS and Windows. Thats for sure. I'll give it a dedicated try over this weekend, and see if i can get Windows working. Disclaimer i have never once built/used a Windows Application so its going to be another learning experience

TamerIrdais commented 2 years ago

@LuckyDucko Thank you very much for the feedback and for your hard work working on this project, looking forward for it to complete and supports Windows and MacCatalyst.

davidbuckleyni commented 2 years ago

Any more word on this at all would be nice to have it soon rc1 is in a few weeks.

Phenek commented 2 years ago

Hello guys,

For people who just need simple popup without animation etc.. Do you know the Modal stack on MAUI?

You can push ContentPage with "transparent" background.

BackgroundColor = Color.FromArgb("#01010101");

Push like this

await Application.Current.MainPage.Navigation.PushModalAsync(page);

Pop like this (unfortunatly you can not remove a specific page, only the last one)

await Application.Current.MainPage.Navigation.PopModalAsync();

Okay It lacks of many things, but it's a workaround for thoose really stuck and need just basics. Combined with the logique of the community toolkit you can await for a task completion etc...

but it's a simple modal page with a transparent background, you can do whatever layout on it

(Center the content on the middle of the modal page, or animate the content your self when OnAppearing, easy).

It works on Mac, iOS, Android, Windows, without handlers or renderers. It was enough for me.

LuckyDucko commented 2 years ago

To be clear to everyone, MAUI development is done on the Mopups Repo, not on this repo. We currently have iOS and Android support.

Mopups is Rg.popups, with some changes and new direction

https://github.com/LuckyDucko/Mopups

TamerIrdais commented 2 years ago

@LuckyDucko Did you have the chance last weekend to check the support for Windows for the project?

LuckyDucko commented 2 years ago

I did, and i am sorry to say that unless someone else is able to make some strides in it, i don't think i am going to make much headway.

I was having difficulty even at the get go trying to set it up with WinUI. If someone is able to create a project in MAUI with all the environment setup, i might be able to port it over.

Phenek commented 1 year ago

The only issue with my workaround is that we can not remove a specific page. So a popup can not close it self, only the last one...

I open an issue on MAUI repo below. #11271 [Enhancement] Remove a specific Modal Page

Yeah we need to get rid of it!