Modal Loading with Xamarin?

Asked

Viewed 157 times

0

I am creating an application with Xamarin and I want to create a Modal of Loading while doing a search in Webservice. I researched some examples that use Page Modal and others with Popup. Now I’m trying to create with the plugin Rg.Plugins.Popup but I’m not succeeding, Popup does not open.

What’s the best way to do it ?

Popup Page

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage 
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
    xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
    x:Class="CooperativaApp.View.PopUpLoading"
    CloseWhenBackgroundIsClicked="False">
    <!--You can set an animation in the xaml file or in the csharp code behind-->
    <pages:PopupPage.Animation>
        <animations:ScaleAnimation 
            PositionIn="Center"
            PositionOut="Center"
            ScaleIn="1.2"
            ScaleOut="0.8"
            DurationIn="400"
            DurationOut="300"
            EasingIn="SinOut"
            EasingOut="SinIn"
            HasBackgroundAnimation="True"
            />
    </pages:PopupPage.Animation>
    <!--You can use any elements here which are extended from Xamarin.Forms.View-->
    <StackLayout 
        VerticalOptions="Center" 
        HorizontalOptions="Center" 
        Padding="20, 20, 20, 20">
        <ActivityIndicator             
            IsRunning="True"
            IsVisible="True"
            Color="Green"/>
    </StackLayout>
</pages:PopupPage>

Login screen

private void OnClickAcessar(object sender, EventArgs args){     
            //abre o popup loading
            PopupNavigation.Instance.PushAsync(new PopUpLoading());

            //objeto usuario
            Usuario usuario = new Usuario();
            usuario.login = "admin";
            usuario.pswd = "admin";

            //consulta login webservice
            UsuarioService service = new UsuarioService();
            service.doLogin(usuario);

            //fecha o popup loading
            PopupNavigation.Instance.PopAsync();
        }
  • Hello Hoping, you need to inform more details about your application, because looking at your implementation is correct. Have you made the required plugin settings? https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started

  • @Viniciusdutra the problem was that had to put the method as async and use await in the popup call. I did this and it worked !

  • Great @Fernando, you can close the question so if your problem has been solved

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.