question

JassimAlRahma-9056 avatar image
0 Votes"
JassimAlRahma-9056 asked LeonLu-MSFT commented

Show Lottie Animation during a process


Hi,

I am trying below code and need to show Lottie Animation white muy code is running but the problem is it just hangs and the Lottie animation will only be show once the whole code is completed.

Here is my code;


 async void ButtonPayNow_Clicked(System.Object sender, System.EventArgs e)
 {
     ButtonPayNow.IsVisible = false;
     ScrollViewPay.IsVisible = false;
    
     LottiePay.PlayAnimation();
     LottiePay.IsVisible = true;
    
     HttpClient comes here....
 }



Kindly help...


Thanks,
Jassim


dotnet-csharpdotnet-xamarinforms
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I am not stopping the animation not setting isVisible of Lottie to false

0 Votes 0 ·

This is my full code:

 async void ButtonPayNow_Clicked(System.Object sender, System.EventArgs e)
 {
     ButtonPayNow.IsVisible = false;
     ScrollViewPay.IsVisible = false;
    
     LottiePay.PlayAnimation();
     LottiePay.IsVisible = true;
    
     --Run Stripe Payment code First
     --Run Stripe Payment code First
     --Run Stripe Payment code First
    
     if (charge.Status == "succeeded")
     {
         var client = new HttpClient();
    
         client.Timeout = TimeSpan.FromSeconds(App.HttpClient_TimeOut);
         client.BaseAddress = new Uri("https://www.domain.com/update.php");
    
         var content = new FormUrlEncodedContent(new[]
         {
             new KeyValuePair<string, string>("amount", "1.00"),
             new KeyValuePair<string, string>("description", "description"),
             new KeyValuePair<string, string>("user", "user")
         });
    
         var response = await client.PostAsync("https://www.domain.com/update.php", content);
    
         var result = await response.Content.ReadAsStringAsync();
    
         await DisplayAlert("succeeded", "Thank you", "Ok");
         await Navigation.PopModalAsync();
     }
     else
     {
         LottiePay.IsVisible = false;
         ScrollViewPay.IsVisible = true;
         ButtonPayNow.IsVisible = true;
     }
 }


0 Votes 0 ·
LeonLu-MSFT avatar image LeonLu-MSFT JassimAlRahma-9056 ·

Do you want to achieve the progressbar when you load the data? I test with my layout, I do not have Run Stripe Payment code First, So I add a task delay to test it

<ScrollView x:Name="ScrollViewPay">
            <StackLayout>
                <forms:AnimationView
                        x:Name="animationView"
                        Animation="LottieLogo1.json"
                        AnimationSource="AssetOrBundle"
                        WidthRequest="100"
                        HeightRequest="100"
                        RepeatCount="30"
                        RepeatMode="Restart"
                        AutoPlay="False"
                        IsVisible="False"
                        HorizontalOptions="Center"
                        VerticalOptions="Center"
                />
           
            </StackLayout>
        </ScrollView>

        <Button Text="ss" Clicked="Button_Clicked"></Button>
0 Votes 0 ·

Here is my background code. But the Lottie Animation worked as normal. when I click the ss button

public bool isStart = true;
        private async void Button_Clicked(object sender, EventArgs e)
        {
            animationView.PlayAnimation();
            animationView.IsVisible = true;
            await Task.Delay(2000);

            if (isStart)
            {
                
                await DisplayAlert("succeeded", "Thank you", "Ok");
                isStart = false;
               
            }
            else
            {
                
              //  animationView.PlayAnimation();

                animationView.IsVisible = false;
                isStart = true;
            }
             
          //  animationView.IsVisible = true;
        }
0 Votes 0 ·
LeonLu-MSFT avatar image LeonLu-MSFT JassimAlRahma-9056 ·

Could you share a demo about this issue? That I can reproduce it.

0 Votes 0 ·

0 Answers