Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #409 and #59 - UI issues with UnitConverter in RtL #410

Merged
merged 4 commits into from
Apr 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Calculator/Views/UnitConverter.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,8 @@
<Grid x:Name="Value1Container"
Grid.Row="1"
Grid.Column="1"
HorizontalAlignment="Left"
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
Style="{ThemeResource ValueContainerStyle}"
FlowDirection="{x:Bind LayoutDirection}"
Visibility="{x:Bind Model.IsCurrencyLoadingVisible, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand Down Expand Up @@ -511,6 +510,7 @@
<ComboBox x:Name="Units1"
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
Style="{ThemeResource ComboStyle}"
AutomationProperties.AutomationId="Units1"
AutomationProperties.Name="{x:Bind Model.Unit1AutomationName, Mode=OneWay}"
Expand All @@ -528,9 +528,8 @@
<Grid x:Name="Value2Container"
Grid.Row="3"
Grid.Column="1"
HorizontalAlignment="Left"
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
Style="{ThemeResource ValueContainerStyle}"
FlowDirection="{x:Bind LayoutDirection}"
Visibility="{x:Bind Model.IsCurrencyLoadingVisible, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand Down Expand Up @@ -564,6 +563,7 @@
<ComboBox x:Name="Units2"
Grid.Row="4"
Grid.Column="1"
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
Style="{ThemeResource ComboStyle}"
AutomationProperties.AutomationId="Units2"
AutomationProperties.Name="{x:Bind Model.Unit2AutomationName, Mode=OneWay}"
Expand All @@ -581,8 +581,8 @@
Grid.Row="5"
Grid.Column="1"
MinHeight="48"
Margin="12,0,6,0"
HorizontalAlignment="Left"
Padding="12,0,6,0"
HorizontalAlignment="{x:Bind FlowDirectionHorizontalAlignment}"
VerticalAlignment="Top"
FlowDirection="{x:Bind LayoutDirection}"
SizeChanged="SupplementaryResultsPanelInGrid_SizeChanged"
Expand Down
11 changes: 3 additions & 8 deletions src/Calculator/Views/UnitConverter.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,17 @@ using namespace Windows::UI::ViewManagement;
static const long long DURATION_500_MS = 10000 * 500;

UnitConverter::UnitConverter() :
m_layoutDirection(::FlowDirection::LeftToRight),
m_meteredConnectionOverride(false),
m_isAnimationEnabled(false)
{
m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection();
m_FlowDirectionHorizontalAlignment = m_layoutDirection == ::FlowDirection::RightToLeft ? ::HorizontalAlignment::Right : ::HorizontalAlignment::Left;

InitializeComponent();

// adding ESC key shortcut binding to clear button
ClearEntryButtonPos0->SetValue(Common::KeyboardShortcutManager::VirtualKeyProperty, Common::MyVirtualKey::Escape);

m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection();
if (m_layoutDirection == ::FlowDirection::RightToLeft)
{
Units1->HorizontalContentAlignment = ::HorizontalAlignment::Right;
Units2->HorizontalContentAlignment = ::HorizontalAlignment::Right;
}

// Is currency symbol preference set to right side
bool preferRight = LocalizationSettings::GetInstance().GetCurrencySymbolPrecedence() == 0;
VisualStateManager::GoToState(this, preferRight ? "CurrencySymbolRightState" : "CurrencySymbolLeftState", false);
Expand Down
3 changes: 2 additions & 1 deletion src/Calculator/Views/UnitConverter.xaml.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// UnitConverter.xaml.h
Expand All @@ -22,6 +22,7 @@ namespace CalculatorApp
public:
UnitConverter();
DEPENDENCY_PROPERTY_OWNER(UnitConverter);
PROPERTY_R(Windows::UI::Xaml::HorizontalAlignment, FlowDirectionHorizontalAlignment);

void AnimateConverter();

Expand Down