Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rg.Plugins.Popup.Exceptions.RGInitialisationException: 'You MUST call Rg.Plugins.Popup.Popup.Init(); prior to using it. #763

Open
Tchicken95 opened this issue Nov 13, 2023 · 0 comments

Comments

@Tchicken95
Copy link

Tchicken95 commented Nov 13, 2023

🐛 Bug Report

Projet Xamarin android and ios

My MainPAge.xaml.cs :

using System.ComponentModel;
using Xamarin.Forms;
using GenTurfEvo.ViewModel;
using System.Threading.Tasks;
using System;
using Rg.Plugins.Popup.Pages;
using Rg.Plugins.Popup.Services;

namespace GenTurfEvo.Views
{
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        private readonly MainPageViewModel _viewModel;
        public MainPage()
        {
            InitializeComponent();
            BindingContext = _viewModel = new MainPageViewModel();
        }
        private async void OnFrameTapped(object sender, EventArgs e)
        {
            // Afficher la popup avec le DatePicker
            await DisplayDatePickerPopup(this);
        }

        private async void OnCancelButtonClicked(object sender, EventArgs e)
        {
            await PopupNavigation.Instance.PopAsync();
        }

        private async void OnConfirmButtonClicked(object sender, EventArgs e)
        {
            // Traiter la date sélectionnée
            await PopupNavigation.Instance.PopAsync();
        }

        private async Task DisplayDatePickerPopup(MainPage mainPage)
        {
            var customDatePickerPopup = new CustomDatePickerPopup(mainPage);
            await PopupNavigation.Instance.PushAsync(customDatePickerPopup);
        }

        private class CustomDatePickerPopup : PopupPage
        {
            private readonly MainPage _mainPage;

            public CustomDatePickerPopup(MainPage mainPage)
            {
                _mainPage = mainPage;

                var datePicker = new DatePicker
                {
                    Format = "dd/MM/yyyy",
                    MaximumDate = DateTime.Now
                };

                var cancelButton = new Button { Text = "Annuler" };
                var confirmButton = new Button { Text = "Valider" };

                cancelButton.Clicked += _mainPage.OnCancelButtonClicked;
                confirmButton.Clicked += _mainPage.OnConfirmButtonClicked;

                Content = new StackLayout
                {
                    Children = { datePicker, cancelButton, confirmButton },
                    Padding = new Thickness(20)
                };
            }
        }
    }
}

My call on MainPage.xaml :

                        <!-- Date des courses -->
                        <Frame Grid.Row="0" Grid.Column="1" Margin="1,1,1,0" Padding="5,0" BackgroundColor="Green" BorderColor="Orange">
                                <Frame.GestureRecognizers>
                                    <TapGestureRecognizer Tapped="OnFrameTapped" />
                                </Frame.GestureRecognizers>
                            <Label FontSize="18" FontFamily="NunitoSemiBold" FontAttributes="Bold" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="Sélectionner une date" TextColor="{StaticResource colorWhite}" />
                        </Frame>


```### Expected behavior
Detail of error after call OnFrameTapped :
Rg.Plugins.Popup.Exceptions.RGInitialisationException
  Message=You MUST call Rg.Plugins.Popup.Popup.Init(); prior to using it.
See more info: https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started#initialization
  Source=mscorlib
  Arborescence des appels de procédure :
  at Rg.Plugins.Popup.Services.PopupNavigationImpl.get_PopupPlatform () [0x0001d] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigationImpl.cs:35 
  at Rg.Plugins.Popup.Services.PopupNavigationImpl..ctor () [0x0001c] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigationImpl.cs:45 
  at Rg.Plugins.Popup.Services.PopupNavigation.get_Instance () [0x00014] in Z:\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Services\PopupNavigation.cs:30 
  at GenTurfEvo.Views.MainPage.DisplayDatePickerPopup (GenTurfEvo.Views.MainPage mainPage) [0x00020] in C:\NewTurf\GenTurfEvo\GenTurfEvo\Views\MainPage.xaml.cs:42 
  at GenTurfEvo.Views.MainPage.OnFrameTapped (System.Object sender, System.EventArgs e) [0x00026] in C:\NewTurf\GenTurfEvo\GenTurfEvo\Views\MainPage.xaml.cs:25 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Java.Lang.IRunnable.cs:84 
  at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00005] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22 
  at (wrapper native-to-managed) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(intptr,intptr)

### Reproduction steps

### Configuration
Visual studio 2022 last version
Last version on all nugets packages
Rg.Plugins.Popup Version : 2.1

**Platform:** 
- [ ] :robot: Android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant