From 5561721675480e73ce8d827b724ebcb65fec8b69 Mon Sep 17 00:00:00 2001 From: "Dr.Rx" Date: Fri, 24 May 2019 17:00:14 -0400 Subject: [PATCH] Enable keypads entrance animations --- src/Calculator.Shared/Views/Calculator.xaml | 10 ++-- .../Views/Calculator.xaml.cs | 57 +++++++++++++++---- src/Calculator.Shared/Views/MainPage.xaml.cs | 3 +- .../Views/UnitConverter.xaml | 12 ++-- .../Views/UnitConverter.xaml.cs | 50 ++++++++++++++++ 5 files changed, 111 insertions(+), 21 deletions(-) diff --git a/src/Calculator.Shared/Views/Calculator.xaml b/src/Calculator.Shared/Views/Calculator.xaml index 43fd6291..decad7bc 100644 --- a/src/Calculator.Shared/Views/Calculator.xaml +++ b/src/Calculator.Shared/Views/Calculator.xaml @@ -497,7 +497,7 @@ - + - - + + @@ -535,7 +536,8 @@ - + diff --git a/src/Calculator.Shared/Views/Calculator.xaml.cs b/src/Calculator.Shared/Views/Calculator.xaml.cs index a73fc6b1..bddf99f0 100644 --- a/src/Calculator.Shared/Views/Calculator.xaml.cs +++ b/src/Calculator.Shared/Views/Calculator.xaml.cs @@ -362,7 +362,51 @@ namespace CalculatorApp } // TODO UNO - private Storyboard Animate => (Storyboard)Resources[nameof(Animate)]; + private Storyboard _animate; + private Storyboard Animate + { + get + { + if (_animate == null) + { +#if NETFX_CORE + _animate = (Storyboard)Resources[nameof(Animate)]; +#else + _animate = StaticResources.Animate; +#endif + + foreach (var animation in _animate.Children) + { + Storyboard.SetTarget(animation, NumpadPanel); + } + } + + return _animate; + } + } + // TODO UNO + private Storyboard _animateWithoutResult; + private Storyboard AnimateWithoutResult + { + get + { + if (_animateWithoutResult == null) + { +#if NETFX_CORE + _animateWithoutResult = (Storyboard)Resources[nameof(AnimateWithoutResult)]; +#else + _animateWithoutResult = StaticResources.AnimateWithoutResult; +#endif + + foreach (var animation in _animateWithoutResult.Children) + { + Storyboard.SetTarget(animation, NumpadPanel); + } + } + + return _animateWithoutResult; + } + } // Once the storyboard that rearranges the buttons completed, // We do the animation based on the Mode or Orientation change. @@ -377,18 +421,11 @@ namespace CalculatorApp { m_resultAnimate = false; - // TODO UNO - foreach (var animation in Animate.Children) - { - Storyboard.SetTarget(animation, NumpadPanel); - } - - Animate.Begin(); + Animate.Begin(); } else { - /* UNO TODO */ - AnimateWithoutResult?.Begin(); + AnimateWithoutResult.Begin(); } } } diff --git a/src/Calculator.Shared/Views/MainPage.xaml.cs b/src/Calculator.Shared/Views/MainPage.xaml.cs index dc6f2482..9977fbc4 100644 --- a/src/Calculator.Shared/Views/MainPage.xaml.cs +++ b/src/Calculator.Shared/Views/MainPage.xaml.cs @@ -181,8 +181,7 @@ namespace CalculatorApp EnsureConverter(); if (!NavCategory.IsConverterViewMode(previousMode)) { - // UNO TODO - // m_converter.AnimateConverter(); + m_converter.AnimateConverter(); } } diff --git a/src/Calculator.Shared/Views/UnitConverter.xaml b/src/Calculator.Shared/Views/UnitConverter.xaml index 0e5dae72..1cc9f170 100644 --- a/src/Calculator.Shared/Views/UnitConverter.xaml +++ b/src/Calculator.Shared/Views/UnitConverter.xaml @@ -233,8 +233,9 @@ - - + + + @@ -246,7 +247,8 @@ - + + @@ -260,10 +262,10 @@ - + + diff --git a/src/Calculator.Shared/Views/UnitConverter.xaml.cs b/src/Calculator.Shared/Views/UnitConverter.xaml.cs index 4d016c60..98a5f0dd 100644 --- a/src/Calculator.Shared/Views/UnitConverter.xaml.cs +++ b/src/Calculator.Shared/Views/UnitConverter.xaml.cs @@ -19,6 +19,7 @@ using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Media.Animation; using Windows.UI.Xaml.Navigation; using Calculator; using CalculatorApp.Common; @@ -273,6 +274,30 @@ namespace CalculatorApp Model.OnPaste(pastedString, Model.Mode); } + private Storyboard _animationStory; + private Storyboard AnimationStory + { + get + { + if (_animationStory == null) + { +#if NETFX_CORE + _animationStory = (Storyboard)Resources[nameof(AnimationStory)]; +#else + _animationStory = StaticResources.AnimationStory; +#endif + + + foreach (var animation in _animationStory.Children) + { + Storyboard.SetTarget(animation, ConverterNumPad); + } + } + + return _animationStory; + } + } + public void AnimateConverter() { if (App.IsAnimationEnabled()) @@ -339,6 +364,31 @@ namespace CalculatorApp } } + // TODO UNO + private Storyboard _timestampFadeInAnimation; + private Storyboard TimestampFadeInAnimation + { + get + { + if (_timestampFadeInAnimation == null) + { +#if NETFX_CORE + _timestampFadeInAnimation = (Storyboard)Resources[nameof(TimestampFadeInAnimation)]; +#else + _timestampFadeInAnimation = StaticResources.TimestampFadeInAnimation; +#endif + + + foreach (var animation in _timestampFadeInAnimation.Children) + { + Storyboard.SetTarget(animation, CurrencyTimestampTextBlock); + } + } + + return _timestampFadeInAnimation; + } + } + void OnIsDisplayVisibleChanged() { if (Model.IsCurrencyLoadingVisible)