async void Achivements(object sender, EventArgs e) { BoxView button = AchievementsButton; Image image = AchievementsImage; ButtonLock(); AnimateButton(null, image, null); AnimateButton(null, null, button); await button.FadeTo(0.5f, 100); await button.FadeTo(1f, 100); var Test = App.database.GetUserStats(1); if (Test != null) { App.Online = true; } var Stats = App.database.GetUserStats(App.LoggedinUser.ID).First(); if (Stats != null && App.Online) { await Navigation.PushAsync(new AchivementsPage(Stats)); } else { await DisplayAlert("Article Load Failure", "Troferna misslyckades att laddas in, vänligen försök igen.", "OK"); } ButtonLock(); }
private async void Close() { await _fader.FadeTo(0, AnimationSpeed, Easing.SinInOut); _fader.IsVisible = false; await _flyout.TranslateTo(0, _pageHeight, AnimationSpeed, Easing.SinInOut); IsVisible = false; }
/// <summary> /// Raises the appearing event. /// </summary> protected override void OnAppearing() { base.OnAppearing(); if (_platformHelper.ControlAnimatesItself) { _overlay.FadeTo(0.2F); _contentView.TranslateTo(0.0, 0.0, 250, Easing.CubicInOut); } }
public async void ShowPopup(View popupView, Constraint xConstraint, Constraint yConstraint, Constraint widthConstraint = null, Constraint heightConstraint = null) { DismissPopup(); this.popup = popupView; this.layout.InputTransparent = true; this.content.InputTransparent = true; this.layout.Children.Add(this.mask, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height); })); this.layout.Children.Add(this.popup, xConstraint, yConstraint, widthConstraint, heightConstraint); this.layout.ForceLayout(); await System.Threading.Tasks.Task.WhenAll(mask.FadeTo(1), popup.FadeTo(1)); }
async void BoxFade(BoxView box, double val, uint time, bool first) { if (first) { await box.FadeTo(1, time, Easing.Linear); } bool isComplate = await box.FadeTo(0.1, 5000, Easing.Linear); if (!isComplate) { await box.FadeTo(1, 1, Easing.Linear); } BoxFade(box, 1, 1, false); }
public async Task FadeTo() { var view = new BoxView(); await view.FadeTo(0); Assert.AreEqual(0, view.Opacity); }
async void SideMenu(object sender, EventArgs e) { BoxView button = ProfileSettingsButton; Image image = ProfileSettingsImage; ButtonLock(); AnimateButton(null, image, null); AnimateButton(null, null, button); await button.FadeTo(0.5f, 100); await button.FadeTo(1f, 100); App.Startpage.IsPresented = true; ButtonLock(); }
async void History(object sender, EventArgs e) { BoxView button = HistoryButton; Image image = HistoryImage; ButtonLock(); AnimateButton(null, image, null); AnimateButton(null, null, button); await button.FadeTo(0.5f, 100); await button.FadeTo(1f, 100); await Navigation.PushAsync(new NewsGridPage(2)); ButtonLock(); }
async void Favorites(object sender, EventArgs e) { BoxView button = FavoritesButton; Image image = FavoritesImage; ButtonLock(); AnimateButton(null, image, null); AnimateButton(null, null, button); await button.FadeTo(0.5f, 100); await button.FadeTo(1f, 100); await Navigation.PushAsync(new NewsGridPage(3)); ButtonLock(); }
async void StylePage(object sender, EventArgs e) { BoxView button = StyleButton; Image image = StyleImage; ButtonLock(); AnimateButton(null, image, null); AnimateButton(null, null, button); await button.FadeTo(0.5f, 100); await button.FadeTo(1f, 100); await Navigation.PushAsync(new StylePage()); ButtonLock(); }
private async void AnimatePopupOff(BoxView backgroundBox) { ToggleAddToQuotePopupVisibilities(backgroundBox); await Task.WhenAll( gridEditQuotePopup.ScaleTo(1, 250, Easing.Linear), gridEditQuotePopup.FadeTo(1, 250, Easing.Linear), this.ScaleTo(1, 250, Easing.Linear), this.FadeTo(1, 250, Easing.Linear), backgroundBox.FadeTo(0.5, 250, Easing.Linear) ); }
public async Task AnimateSky() { await Task.Delay(750); //delays before second text var nightTask = _bgNight.FadeTo(1d, 1000, Easing.Linear); var moonTask = AnimateMoon(); await Task.Delay(750); //delays before second text var label2 = _label2.FadeTo(1d, 250, Easing.Linear); await Task.WhenAll(nightTask, moonTask, label2); }
public async Task ParallelFadeTo() { var a = new BoxView(); var b = new BoxView(); var list = new List <Task> { a.FadeTo(0), b.FadeTo(0) }; await Task.WhenAll(list); Assert.AreEqual(0, a.Opacity); Assert.AreEqual(0, b.Opacity); }
public void DisplayView() { Device.BeginInvokeOnMainThread(async() => { var animationList = new List <Task> { _backgroundOverlayBoxView.FadeTo(1, AnimationConstants.WelcomeViewAnimationTime), _textAndButtonStack.ScaleTo(AnimationConstants.WelcomeViewMaxSize, AnimationConstants.WelcomeViewAnimationTime), _overlayFrame.ScaleTo(AnimationConstants.WelcomeViewMaxSize, AnimationConstants.WelcomeViewAnimationTime) }; await Task.WhenAll(animationList); animationList = new List <Task> { _textAndButtonStack.ScaleTo(AnimationConstants.WelcomeViewNormalSize, AnimationConstants.WelcomeViewAnimationTime), _overlayFrame.ScaleTo(AnimationConstants.WelcomeViewNormalSize, AnimationConstants.WelcomeViewAnimationTime) }; await Task.WhenAll(animationList); }); }
async void InitBoxFade(BoxView box, double val) { await box.FadeTo(val, 4, Easing.Linear); }
private async Task TabAnimation(TabItemPage page) { if (HasUnderline) { var prevunderline = this.Children.FirstOrDefault(x => x.AutomationId == "underlineitem"); //Adding underline on item BoxView underline = new BoxView() { AutomationId = "underlineitem", HeightRequest = 1, StyleId = page.Index.ToString(), Color = TitleActiveTextColor, WidthRequest = 70, Opacity = 0, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.EndAndExpand }; //remove previous underline and animate it async Task <bool> AnimatePrev() { if (prevunderline != null) { int spaces = (int.Parse(underline.StyleId) - int.Parse(prevunderline.StyleId)) * 100; await prevunderline.TranslateTo(spaces, 0, 200, Easing.SinOut); return(this.Children.Remove(prevunderline)); } else { return(await Task.FromResult(true)); } }; //add a new underline and animate it async Task <bool> AnimateAddUnderline() { this.Children.Add(underline, page.Index, 1); return(await underline.FadeTo(100, 1000, Easing.SinIn)); }; //runs the two actions at the same time await Task.WhenAny <bool> ( AnimatePrev(), AnimateAddUnderline() ); } //highligth tab button title var tabs = this.Children.Where(tb => tb.StyleId != null && tb.StyleId.Contains("tabbutton")).ToList(); //foreach (StackLayout tb in tabs) foreach (CustomFrame tb in tabs) { var buttonarea = tb.Content as StackLayout; var title = buttonarea.Children.FirstOrDefault(lbl => lbl is Label) as Label; if (tb.StyleId == $"tabbutton{page.Index}") { title.TextColor = TitleActiveTextColor; if (page.IconActiveName.Contains("svg")) { var icon = buttonarea.Children.FirstOrDefault(ico => ico is SvgCachedImage) as SvgCachedImage; var xfSource = _imageSourceConverter.ConvertFromInvariantString(page.IconActiveName) as ImageSource; icon.Source = new SvgImageSource(xfSource, 0, 0, true); } else { var icon = buttonarea.Children.FirstOrDefault(ico => ico is CachedImage) as CachedImage; icon.Source = ImageSource.FromFile(page.IconActiveName); } tb.StartColor = StartActiveBackgroundColor; tb.EndColor = EndActiveBackgroundColor; } else { title.TextColor = TitleTextColor; var iconnormal = Pages.FirstOrDefault(ico => ico.Index == int.Parse(tb.StyleId.Replace("tabbutton", string.Empty))); if (iconnormal.IconName.Contains("svg")) { var icon = buttonarea.Children.FirstOrDefault(ico => ico is SvgCachedImage) as SvgCachedImage; var xfSource = _imageSourceConverter.ConvertFromInvariantString(iconnormal.IconName) as ImageSource; icon.Source = new SvgImageSource(xfSource, 0, 0, true); } else { var icon = buttonarea.Children.FirstOrDefault(ico => ico is CachedImage) as CachedImage; icon.Source = ImageSource.FromFile(iconnormal.IconName); } tb.StartColor = StartBackgroundColor; tb.EndColor = EndBackgroundColor; } } }
private void BuildAndroid() { var ellipseRadius = 60; var translationXEllipse = _likeContainerPosition.X - ellipseRadius + 10; var heartEllipse = new Ellipse { Scale = 0, Opacity = 0, WidthRequest = 100, HeightRequest = 100, Fill = new SolidColorBrush(Color.FromHex("F4570B")), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, TranslationX = translationXEllipse, TranslationY = _likeContainerPosition.Y + GetTopHeightSpacing() - ellipseRadius }; var pulseEllipse = new Ellipse { IsVisible = false, Scale = 1, Opacity = 1, WidthRequest = 100, HeightRequest = 100, Fill = new SolidColorBrush(Color.FromHex("F4570B")), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, TranslationX = translationXEllipse, TranslationY = _likeContainerPosition.Y + GetTopHeightSpacing() - ellipseRadius }; var ellipseBackgroundWidth = Width; var ellipseBackground = new Ellipse { Scale = 0, Opacity = 0, WidthRequest = ellipseBackgroundWidth, HeightRequest = ellipseBackgroundWidth, Fill = new SolidColorBrush((Color)App.Current.Resources["ContentItemBackground"]), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, TranslationX = (Width / 2) - (ellipseBackgroundWidth / 2) + 20, TranslationY = (Height / 2) - (ellipseBackgroundWidth / 2) + 40 }; var mainLayer = new BoxView { WidthRequest = Width, Opacity = 0, HeightRequest = Height, BackgroundColor = Color.Black }; var stackLayoutDescription = new StackLayout { Opacity = 0, VerticalOptions = LayoutOptions.Start, Margin = new Thickness(60, 0), TranslationY = (Height / 2), Children = { new Label { Text = "Like this playlist?", TextColor = (Color)App.Current.Resources["TextPrimaryColor"], FontSize = Device.GetNamedSize(NamedSize.Title, typeof(Label)) }, new Label { Text = "Tap the heart to save it to your library.", TextColor = (Color)App.Current.Resources["TextSecondaryColor"], FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) } } }; var playlistLikeControl = new PlaylistLikeControl { Total = _totalLikes, TextColor = (Color)App.Current.Resources["PlaylistControlTextColor"], Source = (FileImageSource)App.Current.Resources["playlist_control_source"], Opacity = 0, TranslationX = heartEllipse.TranslationX, TranslationY = heartEllipse.TranslationY, HorizontalOptions = heartEllipse.HorizontalOptions, VerticalOptions = heartEllipse.VerticalOptions, WidthRequest = heartEllipse.WidthRequest, HeightRequest = heartEllipse.HeightRequest }; var grid = new Grid { Children = { mainLayer, ellipseBackground, stackLayoutDescription, heartEllipse, pulseEllipse, playlistLikeControl, new BoxView { BackgroundColor = Color.Transparent } } }; var tap = new TapGestureRecognizer(); tap.Tapped += async(object sender, System.EventArgs e) => { this.AbortAnimation(ParentAnimationName); pulseEllipse.IsVisible = false; heartEllipse.Scale = 1; heartEllipse.Opacity = 1; await Task.WhenAll( ellipseBackground.ScaleTo(0, 300), ellipseBackground.FadeTo(0, 300), stackLayoutDescription.FadeTo(0, 300, Easing.CubicOut), heartEllipse.ScaleTo(0, 300), heartEllipse.FadeTo(0, 300), playlistLikeControl.FadeTo(0, 300) ); await mainLayer.FadeTo(0, 100, easing : Easing.CubicInOut); await Navigation.PopModalAsync(false); }; grid.GestureRecognizers.Add(tap); Content = grid; Task.WhenAny( StartAndroidAnimationAsync( mainLayer, ellipseBackground, heartEllipse, pulseEllipse, stackLayoutDescription, playlistLikeControl ) ).SafeFireAndForget(AnimationException); }
public static Page GetMainPage() { var contentPage = new ContentPage(); contentPage.Title = "Fun animations!"; var button = new Button { Text = "Animate" }; var box = new BoxView { WidthRequest = 100, HeightRequest = 100, Color = Color.Red, HorizontalOptions = LayoutOptions.Center }; var stack = new StackLayout { Padding = 10, Spacing = 10, VerticalOptions = LayoutOptions.FillAndExpand, Children = { button, box } }; button.Clicked += async(sender, args) => { button.IsEnabled = false; box.Color = Color.Green; var originalPosition = box.Bounds; var newPosition = box.Bounds; newPosition.Y = contentPage.Height - box.Height; await box.LayoutTo(newPosition, 2000, Easing.BounceOut); box.FadeTo(0, 2000); box.Color = Color.Yellow; await box.ScaleTo(2, 2000); box.FadeTo(1, 2000); await box.ScaleTo(1, 2000); box.Color = Color.Green; await box.LayoutTo(originalPosition, 2000, Easing.Linear); box.Color = Color.Red; button.IsEnabled = true; }; contentPage.Content = stack; return(new NavigationPage(contentPage)); }
private async void AnimateBackgroundToVisible() { boxViewBackground.IsVisible = true; await boxViewBackground.FadeTo(0.5, 250, Easing.Linear); }
public async void animateOpening() { //wait for page height to be set wait: try { while (Application.Current.MainPage.Height <= 0) { ; } } catch (Exception ex) { goto wait; } //set utilities padding size based on device switch (Device.RuntimePlatform) { case Device.iOS: Debug.WriteLine("Device: " + Application.Current.MainPage.Height); switch (Application.Current.MainPage.Height) { case 568: //iPhone 5s, SE GlobalVariables.dateFontSize = 10; GlobalVariables.countdownFontSize = 19; GlobalVariables.eventFontSize = 11; unitLabel.Text = String.Format("{0,7}{1,8}{2,7}{3,6}", "Days", "Hrs", "Mins", "Secs"); utilPaddingHeight = 20; break; case 812: //iPhone X unitLabel.Text = String.Format("{0,8}{1,11}{2,10}{3,8}", "Days", "Hrs", "Mins", "Secs"); utilPaddingHeight = 40; break; default: //667 iPhone 6, 6s, 7, 8 //736 iPhone 6, 6s, 7, 8 Plus //1024 iPad 3 unitLabel.Text = String.Format("{0,8}{1,11}{2,10}{3,8}", "Days", "Hrs", "Mins", "Secs"); utilPaddingHeight = 20; break; } break; default: unitLabel.Text = String.Format("{0,8}{1,11}{2,10}{3,10}", "Days", "Hrs", "Mins", "Secs"); utilPaddingHeight = 0; break; } utilitiesPadding.HeightRequest = utilPaddingHeight; //fade out blue boxview Device.BeginInvokeOnMainThread(async() => { await animationStack.FadeTo(1.0, 1); }); //create single cell grid and add background logo Grid logoGrid = new Grid { HorizontalOptions = LayoutOptions.FillAndExpand }; Device.BeginInvokeOnMainThread(() => { this.BackgroundColor = Color.Black; animationStack.Children.Add(logoGrid); }); double imageHeight = (405.0 / 3524.0) * (Bounds.Width); BoxView logoBackground = new BoxView() { BackgroundColor = Color.FromRgb(0.0, 0.0, 220.0 / 255.0), Opacity = 0.0, HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = imageHeight }; Device.BeginInvokeOnMainThread(() => { logoGrid.Children.Add(logoBackground, 0, 2, 0, 1); }); //add logo image to grid and fade in LogoWithName.Opacity = 0.0; Device.BeginInvokeOnMainThread(() => { logoGrid.Children.Add(LogoWithName, 0, 2, 0, 1); }); while (Bounds == null || Bounds.Height <= 0) { ; } double logoGridTranslateLen = Bounds.Height / 2.16; Device.BeginInvokeOnMainThread(() => { logoGrid.TranslateTo(0.0, logoGridTranslateLen, 1); Device.BeginInvokeOnMainThread(async() => { await LogoWithName.FadeTo(0.0, 800); await LogoWithName.FadeTo(0.99, 600); await LogoWithName.FadeTo(1.0, 500); }); }); //move logo and background to top together and briefly pause await Task.Run(() => { double len = 30.0; //segments in transition to top while (LogoWithName.Opacity != 1) { ; } Device.BeginInvokeOnMainThread(async() => { int i = 1; while (i <= len) { await logoBackground.FadeTo(i / len, 1); Device.BeginInvokeOnMainThread(async() => { if (i <= len) { await logoGrid.TranslateTo(0.0, ((len - i) / len) * logoGridTranslateLen + (i / len) * (utilPaddingHeight) + (i / len) * 5, 1); Device.BeginInvokeOnMainThread(() => { i++; }); } }); } }); while (logoBackground.Opacity != 1) { ; } displayActivityIndicator(); //Thread.Sleep(100); animating = false; }); }