bitwarden-android/src/App/Controls/StepperCell.cs

58 lines
1.8 KiB
C#
Raw Normal View History

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,
VerticalOptions = LayoutOptions.CenterAndExpand
};
StepperValueLabel = new Label
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalTextAlignment = TextAlignment.Start,
Text = value.ToString(),
Style = (Style)Application.Current.Resources["text-muted"]
};
Stepper = new Stepper
{
HorizontalOptions = LayoutOptions.End,
VerticalOptions = LayoutOptions.CenterAndExpand,
Minimum = min,
Maximum = max,
Increment = increment,
Value = value
};
Stepper.ValueChanged += Stepper_ValueChanged;
var stackLayout = new StackLayout
{
Orientation = StackOrientation.Horizontal,
Children = { Label, StepperValueLabel, Stepper },
Spacing = 15,
Padding = new Thickness(15, 8)
};
View = stackLayout;
}
private void Stepper_ValueChanged(object sender, ValueChangedEventArgs e)
{
StepperValueLabel.Text = e.NewValue.ToString();
}
public Label Label { get; private set; }
public Label StepperValueLabel { get; private set; }
public Stepper Stepper { get; private set; }
}
}