Finished Settings page

This commit is contained in:
2025-11-12 17:06:14 +01:00
parent a608f98497
commit e0bf95060a
38 changed files with 675 additions and 34 deletions

View File

@@ -0,0 +1,59 @@
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<Entry>(nameof(EntryField)).Text = string.Empty;
}
}