2016-07-13 01:59:09 +03:00
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
|
|
|
|
public class StepperCell : ExtendedViewCell
|
|
|
|
|
{
|
|
|
|
|
public StepperCell(string labelText, double value, double min, double max, double increment)
|
|
|
|
|
{
|
|
|
|
|
Label = new Label
|
|
|
|
|
{
|
|
|
|
|
Text = labelText,
|
|
|
|
|
HorizontalOptions = LayoutOptions.Start,
|
2016-08-23 01:59:15 +03:00
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
|
|
|
|
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
|
2016-07-13 01:59:09 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
StepperValueLabel = new Label
|
|
|
|
|
{
|
|
|
|
|
HorizontalOptions = LayoutOptions.FillAndExpand,
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
|
|
|
|
HorizontalTextAlignment = TextAlignment.Start,
|
|
|
|
|
Text = value.ToString(),
|
2016-08-23 01:59:15 +03:00
|
|
|
|
Style = (Style)Application.Current.Resources["text-muted"],
|
|
|
|
|
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
|
2016-07-13 01:59:09 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Stepper = new Stepper
|
|
|
|
|
{
|
|
|
|
|
HorizontalOptions = LayoutOptions.End,
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
|
|
|
|
Minimum = min,
|
|
|
|
|
Maximum = max,
|
|
|
|
|
Increment = increment,
|
|
|
|
|
Value = value
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var stackLayout = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
Orientation = StackOrientation.Horizontal,
|
|
|
|
|
Children = { Label, StepperValueLabel, Stepper },
|
|
|
|
|
Spacing = 15,
|
2016-08-23 05:59:42 +03:00
|
|
|
|
Padding = Device.OnPlatform(
|
|
|
|
|
iOS: new Thickness(15, 8),
|
|
|
|
|
Android: new Thickness(15, 2),
|
|
|
|
|
WinPhone: new Thickness(15, 8))
|
2016-07-13 01:59:09 +03:00
|
|
|
|
};
|
|
|
|
|
|
2016-08-23 05:59:42 +03:00
|
|
|
|
if(Device.OS == TargetPlatform.Android)
|
|
|
|
|
{
|
|
|
|
|
Label.TextColor = Color.Black;
|
|
|
|
|
}
|
2016-08-26 04:43:47 +03:00
|
|
|
|
stackLayout.AdjustPaddingForDevice();
|
2016-08-23 05:59:42 +03:00
|
|
|
|
|
2016-07-13 01:59:09 +03:00
|
|
|
|
View = stackLayout;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 08:28:05 +03:00
|
|
|
|
public Label Label { get; private set; }
|
|
|
|
|
public Label StepperValueLabel { get; private set; }
|
|
|
|
|
public Stepper Stepper { get; private set; }
|
|
|
|
|
|
2016-07-13 01:59:09 +03:00
|
|
|
|
private void Stepper_ValueChanged(object sender, ValueChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
StepperValueLabel.Text = e.NewValue.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 08:28:05 +03:00
|
|
|
|
public void InitEvents()
|
|
|
|
|
{
|
|
|
|
|
Stepper.ValueChanged += Stepper_ValueChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Stepper.ValueChanged -= Stepper_ValueChanged;
|
|
|
|
|
}
|
2016-07-13 01:59:09 +03:00
|
|
|
|
}
|
|
|
|
|
}
|