Skip to content

Commit

Permalink
Merge pull request #76 from ludocornut/master
Browse files Browse the repository at this point in the history
Update FlexButton.xaml.cs
  • Loading branch information
robinmanuelthiel authored Jul 17, 2019
2 parents 1a0f33c + dbe3292 commit 072e371
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions Flex.Demo/FlexDemoPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
ClickedCommand="{Binding ButtonClickedCommand}"
IconOrientation="Right"
HorizontalOptions="Center"
Padding="0"
WidthRequest="300"
HeightRequest="76"
HasShadow="false"
Expand Down
13 changes: 12 additions & 1 deletion Flex.Demo/FlexDemoPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ void ToggleIsEnabled_Clicked(object sender, EventArgs e)

void ToggleIconOrientation_Clicked(object sender, EventArgs e)
{
WideButton.IconOrientation = WideButton.IconOrientation == IconOrientation.Left ? IconOrientation.Right : IconOrientation.Left;
switch (WideButton.IconOrientation)
{
case IconOrientation.Left:
WideButton.IconOrientation = IconOrientation.Right;
break;
case IconOrientation.Right:
WideButton.IconOrientation = IconOrientation.Top;
break;
case IconOrientation.Top:
WideButton.IconOrientation = IconOrientation.Left;
break;
}
}

public void ToggleHasShadow_Clicked(object sender, EventArgs e)
Expand Down
11 changes: 10 additions & 1 deletion Flex/Controls/FlexButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ void SetButtonMode()
// Configure Container
switch (IconOrientation)
{
case IconOrientation.Top:
ContainerContent.Direction = FlexDirection.Column;
break;

case IconOrientation.Left:
ContainerContent.Direction = FlexDirection.Row;
break;
Expand All @@ -383,7 +387,12 @@ void SetButtonMode()
}
if (!userChangedIconPadding)
{
IconPadding = IconOrientation == IconOrientation.Left ? new Thickness(0, 0, 6, 0) : new Thickness(6, 0, 0, 0);
switch (IconOrientation)
{
case IconOrientation.Top: IconPadding = new Thickness(0, 0, 0, 6); break;
case IconOrientation.Left: IconPadding = new Thickness(0, 0, 6, 0); break;
case IconOrientation.Right: IconPadding = new Thickness(6, 0, 0, 0); break;
}
userChangedIconPadding = false; // Set this back to false, as the above line triggers OnPropertyChanged
}

Expand Down
3 changes: 2 additions & 1 deletion Flex/Extensions/IconOrientation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum IconOrientation
{
Left,
Right
Right,
Top
}
}

0 comments on commit 072e371

Please sign in to comment.