48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace WorkTime.Mobile.Pages.Components;
|
|
|
|
public partial class DateSelector : ContentView {
|
|
|
|
public static readonly BindableProperty CurrentDateProperty = BindableProperty.Create(
|
|
nameof(CurrentDate),
|
|
typeof(DateTime),
|
|
typeof(DateSelector),
|
|
DateTime.Now);
|
|
|
|
public static readonly BindableProperty MaxDateProperty = BindableProperty.Create(
|
|
nameof(MaxDate),
|
|
typeof(DateTime),
|
|
typeof(DateSelector),
|
|
DateTime.Now);
|
|
|
|
public static readonly BindableProperty CommandProperty = BindableProperty.Create(
|
|
nameof(Command),
|
|
typeof(IRelayCommand<DateOnly>),
|
|
typeof(DateSelector));
|
|
|
|
public DateTime CurrentDate {
|
|
get => (DateTime)GetValue(CurrentDateProperty);
|
|
set => SetValue(CurrentDateProperty, value);
|
|
}
|
|
|
|
public DateTime MaxDate {
|
|
get => (DateTime)GetValue(MaxDateProperty);
|
|
set => SetValue(MaxDateProperty, value);
|
|
}
|
|
|
|
public IRelayCommand<DateOnly>? Command {
|
|
get => (IRelayCommand<DateOnly>)GetValue(CommandProperty);
|
|
set => SetValue(CommandProperty, value);
|
|
}
|
|
|
|
public DateSelector() {
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void OnDateSelected(object? sender, DateChangedEventArgs e) {
|
|
var date = DateOnly.FromDateTime(CurrentDate);
|
|
Command?.Execute(date);
|
|
}
|
|
|
|
} |