feat: add demo, fix clear button of TimeRangePicker.

This commit is contained in:
Dong Bin
2025-02-19 22:09:27 +08:00
parent 6461490c34
commit fa5c9d1125
15 changed files with 180 additions and 67 deletions

View File

@@ -7,22 +7,9 @@ namespace Ursa.Demo.ViewModels;
public partial class DatePickerDemoViewModel: ObservableObject
{
[ObservableProperty] private DateTime? _selectedDate;
[ObservableProperty] private DateTime? _startDate;
[ObservableProperty] private DateTime? _endDate;
public DatePickerDemoViewModel()
{
SelectedDate = DateTime.Today;
StartDate = DateTime.Today;
EndDate = DateTime.Today.AddDays(7);
}
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.PropertyName == nameof(SelectedDate))
{
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using CommunityToolkit.Mvvm.ComponentModel;
namespace Ursa.Demo.ViewModels;
public partial class DateRangePickerDemoViewModel: ObservableObject
{
[ObservableProperty] private DateTime? _startDate;
[ObservableProperty] private DateTime? _endDate;
public DateRangePickerDemoViewModel()
{
StartDate = DateTime.Today;
EndDate = DateTime.Today.AddDays(7);
}
}

View File

@@ -41,6 +41,7 @@ public partial class MainViewViewModel : ViewModelBase
MenuKeys.MenuKeyClassInput => new ClassInputDemoViewModel(),
MenuKeys.MenuKeyClock => new ClockDemoViewModel(),
MenuKeys.MenuKeyDatePicker => new DatePickerDemoViewModel(),
MenuKeys.MenuKeyDateRangePicker => new DateRangePickerDemoViewModel(),
MenuKeys.MenuKeyDateTimePicker => new DateTimePickerDemoViewModel(),
MenuKeys.MenuKeyDialog => new DialogDemoViewModel(),
MenuKeys.MenuKeyDisableContainer => new DisableContainerDemoViewModel(),
@@ -75,6 +76,7 @@ public partial class MainViewViewModel : ViewModelBase
MenuKeys.MenuKeyTimeBox => new TimeBoxDemoViewModel(),
MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(),
MenuKeys.MenuKeyTimePicker => new TimePickerDemoViewModel(),
MenuKeys.MenuKeyTimeRangePicker => new TimeRangePickerDemoViewModel(),
MenuKeys.MenuKeyToast => new ToastDemoViewModel(),
MenuKeys.MenuKeyToolBar => new ToolBarDemoViewModel(),
MenuKeys.MenuKeyTreeComboBox => new TreeComboBoxDemoViewModel(),

View File

@@ -53,9 +53,11 @@ public class MenuViewModel : ViewModelBase
MenuHeader = "Date & Time", Children = new ObservableCollection<MenuItemViewModel>
{
new() { MenuHeader = "Date Picker", Key = MenuKeys.MenuKeyDatePicker },
new() { MenuHeader = "Date Range Picker", Key = MenuKeys.MenuKeyDateRangePicker },
new() { MenuHeader = "Date Time Picker", Key = MenuKeys.MenuKeyDateTimePicker },
new() { MenuHeader = "Time Box", Key = MenuKeys.MenuKeyTimeBox },
new() { MenuHeader = "TimePicker", Key = MenuKeys.MenuKeyTimePicker },
new() { MenuHeader = "Time Picker", Key = MenuKeys.MenuKeyTimePicker },
new() { MenuHeader = "Time Range Picker", Key = MenuKeys.MenuKeyTimeRangePicker },
new() { MenuHeader = "Clock", Key = MenuKeys.MenuKeyClock }
}
},
@@ -108,6 +110,7 @@ public static class MenuKeys
public const string MenuKeyClassInput = "Class Input";
public const string MenuKeyClock = "Clock";
public const string MenuKeyDatePicker = "DatePicker";
public const string MenuKeyDateRangePicker = "DateRangePicker";
public const string MenuKeyDateTimePicker = "DateTimePicker";
public const string MenuKeyDialog = "Dialog";
public const string MenuKeyDisableContainer = "DisableContainer";
@@ -142,6 +145,7 @@ public static class MenuKeys
public const string MenuKeyTimeBox = "TimeBox";
public const string MenuKeyTimeline = "Timeline";
public const string MenuKeyTimePicker = "TimePicker";
public const string MenuKeyTimeRangePicker = "TimeRangePicker";
public const string MenuKeyToast = "Toast";
public const string MenuKeyToolBar = "ToolBar";
public const string MenuKeyTreeComboBox = "TreeComboBox";

View File

@@ -6,13 +6,9 @@ namespace Ursa.Demo.ViewModels;
public partial class TimePickerDemoViewModel: ObservableObject
{
[ObservableProperty] private TimeSpan? _time;
[ObservableProperty] private TimeSpan? _startTime;
[ObservableProperty] private TimeSpan? _endTime;
public TimePickerDemoViewModel()
{
Time = new TimeSpan(12, 20, 0);
StartTime = new TimeSpan(8, 21, 0);
EndTime = new TimeSpan(18, 22, 0);
}
}

View File

@@ -0,0 +1,16 @@
using System;
using CommunityToolkit.Mvvm.ComponentModel;
namespace Ursa.Demo.ViewModels;
public partial class TimeRangePickerDemoViewModel: ObservableObject
{
[ObservableProperty] private TimeSpan? _startTime;
[ObservableProperty] private TimeSpan? _endTime;
public TimeRangePickerDemoViewModel()
{
StartTime = new TimeSpan(8, 21, 0);
EndTime = new TimeSpan(18, 22, 0);
}
}