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

Added ButtonIconFontSize and ButtonIconFontSizeAuto to ActionButton, Fixed WizardPageXaml #44

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
87 changes: 82 additions & 5 deletions NControl.Controls/NControl.Controls/ActionButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ public Color ButtonColor
});

/// <summary>
/// Gets or sets the color of the buton.
/// Gets or sets the button font family.
/// </summary>
/// <value>The color of the buton.</value>
/// <value>The button font family.</value>
public string ButtonFontFamily
{
get { return (string)GetValue (ButtonFontFamilyProperty);}
Expand Down Expand Up @@ -249,9 +249,58 @@ public string ButtonIcon
}

/// <summary>
/// The button icon property.
/// The button icon font size property.
/// </summary>
public static BindableProperty ButtonIconFontSizeProperty =
BindableProperty.Create(nameof(ButtonIconFontSize), typeof(double), typeof(ActionButton), (double)14,
BindingMode.TwoWay, null, (bindable, oldValue, newValue) =>
{
var ctrl = (ActionButton)bindable;
ctrl.ButtonIconFontSize = (double)newValue;
});

/// <summary>
/// Gets or sets the size of the button icon font.
/// </summary>
/// <value>The size of the button icon font.</value>
public double ButtonIconFontSize
{
get { return (double)GetValue(ButtonIconFontSizeProperty); }
set
{
SetValue(ButtonIconFontSizeProperty, value);
ButtonIconLabel.FontSize = (double)value;
}
}

/// <summary>
/// The button icon font size auto property.
/// </summary>
public static BindableProperty ButtonIconFontSizeAutoProperty =
BindableProperty.Create(nameof(ButtonIconFontSizeAuto), typeof(bool), typeof(ActionButton), (bool)false,
BindingMode.TwoWay, null, (bindable, oldValue, newValue) =>
{
var ctrl = (ActionButton)bindable;
ctrl.ButtonIconFontSizeAuto = (bool)newValue;
});

/// <summary>
/// Gets or sets the automatic sizing of the button icon font size.
/// </summary>
/// <value>The size of the button icon auto font.</value>
public bool ButtonIconFontSizeAuto
{
get { return (bool)GetValue(ButtonIconFontSizeAutoProperty); }
set
{
SetValue(ButtonIconFontSizeAutoProperty, value);
}
}

/// <summary>
/// The has shadow property.
/// </summary>
public static BindableProperty HasShadowProperty =
public static BindableProperty HasShadowProperty =
BindableProperty.Create(nameof(HasShadow), typeof(bool), typeof(ActionButton), true,
BindingMode.TwoWay, null, (bindable, oldValue, newValue) => {
var ctrl = (ActionButton)bindable;
Expand Down Expand Up @@ -391,7 +440,35 @@ public override bool TouchesEnded (System.Collections.Generic.IEnumerable<NGraph

#endregion

/// <summary>
/// <summary>
/// Lays out the children.
/// </summary>
/// <returns>The children.</returns>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <param name="width">Width.</param>
/// <param name="height">Height.</param>
protected override void LayoutChildren(double x, double y, double width, double height)
{
base.LayoutChildren(x, y, width, height);

if (ButtonIconFontSizeAuto)
{
//TODO: Improve the calculations for Auto FontSizing ratios
if (width > 0 && width < 32)
ButtonIconFontSize = width / 4;
if (width >= 32 && width < 64)
ButtonIconFontSize = width / 3.5;
if (width > 64 && width < 96)
ButtonIconFontSize = width / 3;
if (width >= 96 && width < 128)
ButtonIconFontSize = width / 2.5;
if (width >= 128)
ButtonIconFontSize = width / 2;
}
}

/// <summary>
/// On Measure
/// </summary>
/// <param name="widthConstraint"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ protected override void OnAppearing ()
var ab = new ActionButton {
ButtonColor = Color.FromHex("#E91E63"),
ButtonIcon = FontAwesomeLabel.FAThumbsUp,
ButtonIconFontSize = 18,
};
layout.Children.Add(ab, () => new Rectangle((layout.Width/4)-(56/2), (layout.Height/2)-(56/2), 56, 56));

var abtgl = new ToggleActionButton {
ButtonColor = Color.FromHex("#FF5722"),
ButtonIcon = FontAwesomeLabel.FAPlus,
ButtonIconFontSizeAuto = true,
};
abtgl.SetBinding (IsToggledProperty, "IsToggled");
layout.Children.Add(abtgl, () => new Rectangle((layout.Width/2)-(56/2), (layout.Height/2)-(56/2), 56, 56));
layout.Children.Add(abtgl, () => new Rectangle((layout.Width / 2) - (56 / 2), (layout.Height / 2) - (56 / 2), 84, 84));

_command = new Command ((obj) => {}, (obj) => abtgl.IsToggled);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ protected override void OnAppearing ()
Pages = {
new Button {
Command = new Command((obj)=>wizard.Page++),
Text = "Page 2",
Text = "Page 1",
},

new Button {
Command = new Command((obj)=>wizard.Page++),
Text = "Page 3",
Text = "Page 2",
},

new Button {
Command = new Command((obj)=>wizard.Page++),
Text = "Page 4",
Text = "Page 3",
},

new Button {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ncontrols="clr-namespace:NControl.Controls;assembly=NControl.Controls"
x:Class="NControl.Controls.Demo.FormsApp.WizardPageXaml">
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ncontrols="clr-namespace:NControl.Controls;assembly=NControl.Controls" x:Class="NControl.Controls.Demo.FormsApp.WizardPageXaml">
<ContentPage.Content>
<ncontrols:WizardLayout>
<ncontrols:WizardLayout x:Name="wizard">
<ncontrols:WizardLayout.Pages>
<ContentView><Label Text="Page 1"/></ContentView>
<ContentView><Label Text="Page 1"/></ContentView>
<ContentView><Button Text="Page 1" Clicked="Handle_Clicked" /></ContentView>
<ContentView><Button Text="Page 2" Clicked="Handle_Clicked" /></ContentView>
<ContentView><Button Text="Page 3" Clicked="Handle_Clicked" /></ContentView>
<ContentView><Button Text="Done" /></ContentView>
</ncontrols:WizardLayout.Pages>
</ncontrols:WizardLayout>
</ContentPage.Content>
</ContentPage>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ public WizardPageXaml()
InitializeComponent();
Title = "WizardLayout XAML";
}

void Handle_Clicked(object sender, System.EventArgs e)
{
this.wizard.Page++;
}
}
}