Event details page navigation, handling of attendees in Outlook synchronizer, navigation changes for calendar.

This commit is contained in:
Burak Kaan Köse
2025-01-16 22:00:05 +01:00
parent 56d6c22d53
commit 7cfa5a57f5
21 changed files with 374 additions and 99 deletions

View File

@@ -194,7 +194,6 @@ namespace Wino.Calendar.ViewModels
public override void OnNavigatedFrom(NavigationMode mode, object parameters)
{
;
// Do not call base method because that will unregister messenger recipient.
// This is a singleton view model and should not be unregistered.
}
@@ -214,6 +213,9 @@ namespace Wino.Calendar.ViewModels
[RelayCommand]
private void NavigateSeries()
{
if (DisplayDetailsCalendarItemViewModel == null) return;
NavigateEvent(DisplayDetailsCalendarItemViewModel, CalendarEventTargetType.Series);
}
[RelayCommand]
@@ -221,14 +223,13 @@ namespace Wino.Calendar.ViewModels
{
if (DisplayDetailsCalendarItemViewModel == null) return;
NavigateEvent(DisplayDetailsCalendarItemViewModel);
NavigateEvent(DisplayDetailsCalendarItemViewModel, CalendarEventTargetType.Single);
}
[RelayCommand]
private void NavigateEvent(CalendarItemViewModel calendarItemViewModel)
private void NavigateEvent(CalendarItemViewModel calendarItemViewModel, CalendarEventTargetType calendarEventTargetType)
{
// Double tap or clicked 'view details' of the event detail popup.
_navigationService.Navigate(WinoPage.EventDetailsPage, calendarItemViewModel);
var target = new CalendarItemTarget(calendarItemViewModel.CalendarItem, calendarEventTargetType);
_navigationService.Navigate(WinoPage.EventDetailsPage, target);
}
[RelayCommand(AllowConcurrentExecutions = false, CanExecute = nameof(CanSaveQuickEvent))]
@@ -799,7 +800,7 @@ namespace Wino.Calendar.ViewModels
// Recurring events must be selected as a single instance.
// We need to find the day that the event is in, and then select the event.
if (calendarItemViewModel.IsSingleExceptionalInstance)
if (!calendarItemViewModel.IsRecurringEvent)
{
return [calendarItemViewModel];
}
@@ -845,7 +846,7 @@ namespace Wino.Calendar.ViewModels
DisplayDetailsCalendarItemViewModel = message.CalendarItemViewModel;
}
public void Receive(CalendarItemDoubleTappedMessage message) => NavigateEvent(message.CalendarItemViewModel);
public void Receive(CalendarItemDoubleTappedMessage message) => NavigateEvent(message.CalendarItemViewModel, CalendarEventTargetType.Single);
public void Receive(CalendarItemRightTappedMessage message)
{

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Itenso.TimePeriod;
using Wino.Core.Domain.Entities.Calendar;
@@ -25,16 +26,16 @@ namespace Wino.Calendar.ViewModels.Data
public ITimePeriod Period => CalendarItem.Period;
public bool IsAllDayEvent => CalendarItem.IsAllDayEvent;
public bool IsMultiDayEvent => CalendarItem.IsMultiDayEvent;
public bool IsRecurringEvent => CalendarItem.IsRecurringEvent;
public bool IsSingleExceptionalInstance => CalendarItem.IsSingleExceptionalInstance;
public bool IsRecurringChild => CalendarItem.IsRecurringChild;
public bool IsRecurringParent => CalendarItem.IsRecurringParent;
[ObservableProperty]
private bool _isSelected;
public ObservableCollection<CalendarEventAttendee> Attendees { get; } = new ObservableCollection<CalendarEventAttendee>();
public CalendarItemViewModel(CalendarItem calendarItem)
{
CalendarItem = calendarItem;

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@@ -27,7 +28,10 @@ namespace Wino.Calendar.ViewModels
[NotifyPropertyChangedFor(nameof(CanViewSeries))]
private CalendarItemViewModel _currentEvent;
public bool CanViewSeries => CurrentEvent?.CalendarItem.RecurringCalendarItemId != null;
[ObservableProperty]
private CalendarItemViewModel _seriesParent;
public bool CanViewSeries => CurrentEvent?.IsRecurringChild ?? false;
#endregion
@@ -40,16 +44,40 @@ namespace Wino.Calendar.ViewModels
CurrentSettings = _preferencesService.GetCurrentCalendarSettings();
}
public override void OnNavigatedTo(NavigationMode mode, object parameters)
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
{
base.OnNavigatedTo(mode, parameters);
Messenger.Send(new DetailsPageStateChangedMessage(true));
if (parameters == null || parameters is not CalendarItemViewModel passedCalendarItem)
if (parameters == null || parameters is not CalendarItemTarget args)
return;
CurrentEvent = passedCalendarItem;
await LoadCalendarItemTargetAsync(args);
}
private async Task LoadCalendarItemTargetAsync(CalendarItemTarget target)
{
try
{
var currentEventItem = await _calendarService.GetCalendarItemTargetAsync(target);
if (currentEventItem == null)
return;
CurrentEvent = new CalendarItemViewModel(currentEventItem);
var attendees = await _calendarService.GetAttendeesAsync(currentEventItem.EventTrackingId);
foreach (var item in attendees)
{
CurrentEvent.Attendees.Add(item);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
public override void OnNavigatedFrom(NavigationMode mode, object parameters)