Fixed the display date of the calendar items. Created test project for core library, included tests for recurring calendar events.
This commit is contained in:
@@ -293,6 +293,30 @@ public partial class CalendarAppShellViewModel : CalendarBaseViewModel,
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void RegisterRecipients()
|
||||
{
|
||||
base.RegisterRecipients();
|
||||
|
||||
UnregisterRecipients();
|
||||
|
||||
Messenger.Register<VisibleDateRangeChangedMessage>(this);
|
||||
Messenger.Register<CalendarEnableStatusChangedMessage>(this);
|
||||
Messenger.Register<NavigateManageAccountsRequested>(this);
|
||||
Messenger.Register<CalendarDisplayTypeChangedMessage>(this);
|
||||
Messenger.Register<DetailsPageStateChangedMessage>(this);
|
||||
}
|
||||
|
||||
protected override void UnregisterRecipients()
|
||||
{
|
||||
base.UnregisterRecipients();
|
||||
|
||||
Messenger.Unregister<VisibleDateRangeChangedMessage>(this);
|
||||
Messenger.Unregister<CalendarEnableStatusChangedMessage>(this);
|
||||
Messenger.Unregister<NavigateManageAccountsRequested>(this);
|
||||
Messenger.Unregister<CalendarDisplayTypeChangedMessage>(this);
|
||||
Messenger.Unregister<DetailsPageStateChangedMessage>(this);
|
||||
}
|
||||
|
||||
public void Receive(VisibleDateRangeChangedMessage message) => HighlightedDateRange = message.DateRange;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -658,7 +658,7 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
|
||||
// Check all the events for the given date range and calendar.
|
||||
// Then find the day representation for all the events returned, and add to the collection.
|
||||
|
||||
var events = await _calendarService.GetCalendarEventsAsync(calendarViewModel, dayRangeRenderModel).ConfigureAwait(false);
|
||||
var events = await _calendarService.GetCalendarEventsAsync(calendarViewModel, dayRangeRenderModel.Period).ConfigureAwait(false);
|
||||
|
||||
foreach (var @event in events)
|
||||
{
|
||||
|
||||
@@ -17,13 +17,71 @@ public partial class CalendarItemViewModel : ObservableObject, ICalendarItem, IC
|
||||
|
||||
public IAccountCalendar AssignedCalendar => CalendarItem.AssignedCalendar;
|
||||
|
||||
public DateTime StartDate { get => CalendarItem.StartDate; set => CalendarItem.StartDate = value; }
|
||||
/// <summary>
|
||||
/// Gets or sets the start date in local time based on the event's timezone.
|
||||
/// The underlying CalendarItem stores dates in UTC.
|
||||
/// </summary>
|
||||
public DateTime StartDate
|
||||
{
|
||||
get
|
||||
{
|
||||
// Convert from UTC stored in database to local time using the event's timezone
|
||||
var startDateTimeOffset = CalendarItem.StartDateTimeOffset;
|
||||
return startDateTimeOffset.LocalDateTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
// When setting, convert from local time to UTC for storage
|
||||
// Preserve the timezone information
|
||||
if (!string.IsNullOrEmpty(CalendarItem.StartTimeZone))
|
||||
{
|
||||
try
|
||||
{
|
||||
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(CalendarItem.StartTimeZone);
|
||||
var utcDateTime = TimeZoneInfo.ConvertTimeToUtc(value, timeZoneInfo);
|
||||
CalendarItem.StartDate = utcDateTime;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If timezone lookup fails, assume value is already in UTC
|
||||
CalendarItem.StartDate = value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No timezone info, assume UTC
|
||||
CalendarItem.StartDate = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime EndDate => CalendarItem.EndDate;
|
||||
/// <summary>
|
||||
/// Gets the end date in local time based on the event's timezone.
|
||||
/// The underlying CalendarItem stores dates in UTC.
|
||||
/// </summary>
|
||||
public DateTime EndDate
|
||||
{
|
||||
get
|
||||
{
|
||||
// Convert from UTC stored in database to local time using the event's timezone
|
||||
var endDateTimeOffset = CalendarItem.EndDateTimeOffset;
|
||||
return endDateTimeOffset.LocalDateTime;
|
||||
}
|
||||
}
|
||||
|
||||
public double DurationInSeconds { get => CalendarItem.DurationInSeconds; set => CalendarItem.DurationInSeconds = value; }
|
||||
|
||||
public ITimePeriod Period => CalendarItem.Period;
|
||||
/// <summary>
|
||||
/// Gets the time period in local time.
|
||||
/// </summary>
|
||||
public ITimePeriod Period
|
||||
{
|
||||
get
|
||||
{
|
||||
// Return a period using local times for UI display
|
||||
return new TimeRange(StartDate, EndDate);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAllDayEvent => CalendarItem.IsAllDayEvent;
|
||||
public bool IsMultiDayEvent => CalendarItem.IsMultiDayEvent;
|
||||
@@ -32,7 +90,7 @@ public partial class CalendarItemViewModel : ObservableObject, ICalendarItem, IC
|
||||
public bool IsRecurringParent => CalendarItem.IsRecurringParent;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isSelected;
|
||||
public partial bool IsSelected { get; set; }
|
||||
|
||||
public ObservableCollection<CalendarEventAttendee> Attendees { get; } = new ObservableCollection<CalendarEventAttendee>();
|
||||
|
||||
@@ -42,4 +100,4 @@ public partial class CalendarItemViewModel : ObservableObject, ICalendarItem, IC
|
||||
}
|
||||
|
||||
public override string ToString() => CalendarItem.Title;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Wino.Calendar.ViewModels.Data;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
|
||||
namespace Wino.Calendar.ViewModels.Interfaces;
|
||||
|
||||
@@ -26,5 +24,5 @@ public interface IAccountCalendarStateService : INotifyPropertyChanged
|
||||
/// Enumeration of currently selected calendars.
|
||||
/// </summary>
|
||||
IEnumerable<AccountCalendarViewModel> ActiveCalendars { get; }
|
||||
IEnumerable<IGrouping<MailAccount, AccountCalendarViewModel>> GroupedAccountCalendarsEnumerable { get; }
|
||||
// IEnumerable<IGrouping<MailAccount, AccountCalendarViewModel>> GroupedAccountCalendarsEnumerable { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user