void DisplayFadedContainer() { ViewExtensions.CancelAnimations(clickContainer); ViewExtensions.CancelAnimations(progressBar); ViewExtensions.CancelAnimations(playButton); ViewModel.UpdateButtonSource(); Device.BeginInvokeOnMainThread(async() => { { progressBar.Opacity = 1; playButton.Opacity = 1; if (CrossMediaManager.Current.VideoPlayer.Status != MediaPlayerStatus.Playing) { clickContainer.Opacity = 0; clickContainer.BackgroundColor = Color.Black; } await Task.WhenAll( playButton.FadeTo(1, fadeDuration), progressBar.FadeTo(1, fadeDuration), clickContainer.FadeTo(fadedOpacity, fadeDuration)); } }); }
public ClickableLayout() { TapGestureRecognizer tapGesture = new TapGestureRecognizer(); ContentView container = this; tapGesture.Command = new Command(async() => { await container.FadeTo(0, 100); ClickCommand.Execute(null); await container.FadeTo(1, 100); }); container.GestureRecognizers.Add(tapGesture); container.Content = new ContentPresenter(); }
public async static void FadeControl(ContentView control, bool toBecomeVisible) { if (toBecomeVisible) { control.IsVisible = true; control.Opacity = 0.0; var isCancelled = await control.FadeTo(1.0, AnimationHelper.ControlFadeInDurationInMs); } else { var isCancelled = await control.FadeTo(0.0, AnimationHelper.ControlFadeOutDurationInMs); control.IsVisible = false; } }
async Task PlayWinningAnimation() { try { var view = new ContentView { BackgroundColor = Color.FromHex("#7000"), VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; var animation = new AnimationView { Animation = "trophy.json", WidthRequest = 360, HeightRequest = 360, Loop = false, AutoPlay = false, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, }; view.Content = animation; view.Opacity = 0; var layout = Content as AbsoluteLayout; AbsoluteLayout.SetLayoutFlags(view, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(view, new Rectangle(0, 0, 1, 1)); layout.Children.Add(view); await view.FadeTo(1, 250); animation.Play(); await Task.Delay(3000); await view.FadeTo(0, 300); layout.Children.Remove(view); } catch (Exception e) { Log.Instance.LogException(e); } }
/// <summary> /// Notifica leggere con pannello con animazione fade in/out /// </summary> /// <param name="message">Messaggio della notifica</param> public void SendLightNotification(string message) { if (ContentViewLightNotification == null || MessageViewLightNotification == null) { Debug.WriteLine("Unable to show the ligth notification. Xamarin controls are not set"); return; } MessageViewLightNotification.Text = message; Device.BeginInvokeOnMainThread(async() => { ContentViewLightNotification.IsVisible = true; await ContentViewLightNotification.FadeTo(1.0, 500); await System.Threading.Tasks.Task.Delay(1000); await ContentViewLightNotification.FadeTo(0.0, 500); ContentViewLightNotification.IsVisible = false; }); }
public static void ShowMessage(ContentView notificationMessageView, string message = "") { Label notificationMessageLabel = notificationMessageView.Content as Label; notificationMessageLabel.Text = message; notificationMessageView.IsVisible = true; notificationMessageView.Opacity = 1; if (!string.IsNullOrEmpty(notificationMessageLabel.Text)) { notificationMessageView.FadeTo(0, 3000); } }
private async void PBreakdown_Clicked(object sender, EventArgs e) { var p = BindingContext as PredictionContainer; var name = p.Name; var parent = Parent.Parent.Parent as Grid; var oldview = BreakdownView; if (BreakdownView != null) { await BreakdownView.FadeTo(0); BreakdownView = null; } BreakdownView = new PredictionBreakdown(p.show, p.network) { Opacity = 0, BackgroundColor = Content.BackgroundColor }; parent.Children.Add(BreakdownView); BreakdownView.Padding = p.IsShowPage ? new Thickness(0, 50, 0, 0) : 0; if (isDesktop) { Grid.SetColumn(BreakdownView, 1); } PanelOpened?.Invoke(this, new EventArgs()); await BreakdownView.FadeTo(1); if (oldview != null) { parent.Children.Remove(oldview); } }
private async Task ShowPage(int Index) { if (_contentPage == null || _contentPage.Children.Count() == 0) { return; } //hiding all pages foreach (var p in _contentPage.Children) { if (p.IsVisible) { await p.FadeTo(0, 200); p.IsVisible = false; } } ContentView selectedPage = (ContentView)_contentPage.Children[Index]; selectedPage.IsVisible = true; await selectedPage.FadeTo(1, 200); }