Started working on main page
This commit is contained in:
48
src/WorkTime.Mobile/Pages/Components/DateSelector.xaml.cs
Normal file
48
src/WorkTime.Mobile/Pages/Components/DateSelector.xaml.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user