From f6f864c88c002a49fc46942e34ec22ea073674d5 Mon Sep 17 00:00:00 2001 From: Zach Herman Date: Thu, 26 Sep 2019 11:38:40 -0700 Subject: [PATCH] Do not collapse Update Rates button in a transient state (#619) * Do not collapse Update Rates button in a transient state * Address PR feedback and add animation to everything affected by IsCurrencyLoadingVisible --- src/Calculator/Views/UnitConverter.xaml | 98 ++++++++++++++++----- src/Calculator/Views/UnitConverter.xaml.cpp | 18 ++-- 2 files changed, 90 insertions(+), 26 deletions(-) diff --git a/src/Calculator/Views/UnitConverter.xaml b/src/Calculator/Views/UnitConverter.xaml index ba533d3..b2d8d3d 100644 --- a/src/Calculator/Views/UnitConverter.xaml +++ b/src/Calculator/Views/UnitConverter.xaml @@ -260,14 +260,6 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Grid.ColumnSpan="4"> @@ -475,8 +538,7 @@ Grid.Row="1" Grid.Column="1" HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}" - Style="{ThemeResource ValueContainerStyle}" - Visibility="{x:Bind Model.IsCurrencyLoadingVisible, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}"> + Style="{ThemeResource ValueContainerStyle}"> @@ -520,15 +582,13 @@ ItemTemplate="{StaticResource UnitTemplate}" ItemsSource="{Binding Units, Converter={StaticResource AlwaysSelectedConverter}}" SelectedItem="{Binding Unit1, Mode=TwoWay, Converter={StaticResource ValidSelectedItemConverter}}" - TabIndex="2" - Visibility="{x:Bind Model.IsCurrencyLoadingVisible, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}"/> + TabIndex="2"/> + Style="{ThemeResource ValueContainerStyle}"> @@ -572,8 +632,7 @@ ItemTemplate="{StaticResource UnitTemplate}" ItemsSource="{Binding Units, Converter={StaticResource AlwaysSelectedConverter}}" SelectedItem="{Binding Unit2, Mode=TwoWay, Converter={StaticResource ValidSelectedItemConverter}}" - TabIndex="4" - Visibility="{x:Bind Model.IsCurrencyLoadingVisible, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}"/> + TabIndex="4"/> + SizeChanged="SupplementaryResultsPanelInGrid_SizeChanged"> NetworkBehavior == NetworkAccessBehavior::OptIn) + // If IsCurrencyLoadingVisible is true that means CurrencyRefreshButton_Click was recently called + // and is still executing. In this case there is no reason to process the click. + if (!Model->IsCurrencyLoadingVisible) { - m_meteredConnectionOverride = true; - } + if (Model->NetworkBehavior == NetworkAccessBehavior::OptIn) + { + m_meteredConnectionOverride = true; + } - Model->RefreshCurrencyRatios(); + Model->RefreshCurrencyRatios(); + } } void UnitConverter::OnDataContextChanged(_In_ FrameworkElement ^ sender, _In_ DataContextChangedEventArgs ^ args) @@ -320,15 +325,16 @@ void UnitConverter::OnIsDisplayVisibleChanged() { if (Model->IsCurrencyLoadingVisible) { + VisualStateManager::GoToState(this, L"CurrencyLoadingState", false); StartProgressRingWithDelay(); } else { HideProgressRing(); - if (m_isAnimationEnabled && Model->IsCurrencyCurrentCategory && !Model->CurrencyTimestamp->IsEmpty()) + if (Model->IsCurrencyCurrentCategory && !Model->CurrencyTimestamp->IsEmpty()) { - TimestampFadeInAnimation->Begin(); + VisualStateManager::GoToState(this, L"CurrencyLoadedState", m_isAnimationEnabled); } } }