namespace WorkTime.Mobile.Pages.Components; public partial class SettingComponent : ContentView { public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(SettingComponent), string.Empty); public static readonly BindableProperty UnitProperty = BindableProperty.Create(nameof(Unit), typeof(string), typeof(SettingComponent), string.Empty); public static readonly BindableProperty PlaceholderProperty = BindableProperty.Create(nameof(Placeholder), typeof(string), typeof(SettingComponent), string.Empty); public static readonly BindableProperty ValueProperty = BindableProperty.Create(nameof(Value), typeof(TimeSpan), typeof(SettingComponent), TimeSpan.Zero, BindingMode.TwoWay); public string Title { get => (string)GetValue(TitleProperty); set => SetValue(TitleProperty, value); } public string Unit { get => (string)GetValue(UnitProperty); set => SetValue(UnitProperty, value); } public string Placeholder { get => (string)GetValue(PlaceholderProperty); set => SetValue(PlaceholderProperty, value); } public TimeSpan Value { get => (TimeSpan)GetValue(ValueProperty); set => SetValue(ValueProperty, value); } public SettingComponent() { InitializeComponent(); } private void OnValueChanged(object? sender, TextChangedEventArgs e) { if (!int.TryParse(e.NewTextValue, out var number)) return; switch (Unit) { case "Stunden": case "Uhr": Value = TimeSpan.FromHours(number); break; case "Minuten": Value = TimeSpan.FromMinutes(number); break; } } public void ClearInput() { Content.FindByName(nameof(EntryField)).Text = string.Empty; } }